473,506 Members | 17,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Key logger

2 New Member
Hello,

I was wondering if it is possible to create a key logger program that utilize the javascript programming language. Well, the entire program itself wouldn't be coded in javascript, only the client-side of the program. So on the client, is it possible to use javascript to invisibly record what a user inputs in the address field, and other website forms, then that data would be sent to the server to be stored in a text file?


p.s. I'm trying to create this security system, that has the capacity to build psychological profiles of users based on the websites they go, and the key logger component would provide the system access to the user's data, to be used for processing.
Jan 13 '10 #1
5 3945
gits
5,390 Recognized Expert Moderator Expert
of course .... it is possible ... but you would only be able to record the keypresses that are done while the webpage has focus ...

kind regards
Jan 13 '10 #2
harrierdh
16 New Member
Here are two ways. The first code captures everything the user types. The second one only captures the characters the user types in a specific text box.
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. var keystrokes = "";
  3. if (navigator.appName == 'Netscape') {
  4.     window.captureEvents(Event.KEYPRESS);
  5.     document.onkeypress = netscapeKeyPress;
  6. }
  7. function netscapeKeyPress(e) {
  8.     keyCode=e.which;
  9.     handleEvent(keyCode);
  10. }
  11. function microsoftKeyPress() {
  12.     keyCode = window.event.keyCode;
  13.     handleEvent(keyCode);
  14. }
  15. function handleEvent(keyCode) {
  16.     keystrokes += String.fromCharCode(keyCode);
  17. }
  18. </script>
  19. <body onKeyPress="microsoftKeyPress();">
  20.  
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. var keystrokes = "";
  3. function captureKey(e) {
  4.     var key = window.event ? e.keyCode : e.which;
  5.     var keychar = String.fromCharCode(key);
  6.     keystrokes += keychar;
  7. }
  8. </script>
  9.  
  10. <input type="text" onkeypress="captureKey(event);" />
  11.  
Jan 13 '10 #3
gits
5,390 Recognized Expert Moderator Expert
the second script would even capture all keystrokes when you would add the listener to the document like this:
Expand|Select|Wrap|Line Numbers
  1. var keystrokes = "";
  2.  
  3. function captureKey(e) {
  4.     var key = window.event ? e.keyCode : e.which;
  5.     var keychar = String.fromCharCode(key);
  6.     keystrokes += keychar;
  7. }
  8.  
  9. document.onkeypress = captureKey;
and it should be preferred to use addEventListener() / attachEvent() to add the listerens ... like here for FF for example:
Expand|Select|Wrap|Line Numbers
  1. document.addEventListener('keypress', captureKey, true);
kind regards
Jan 14 '10 #4
acoder
16,027 Recognized Expert Moderator MVP
Also note that the first script is badly out of date to the point of almost being useless.
Jan 15 '10 #5
meng91
2 New Member
Thanks so much for the insight. More questions coming soon!!

best regards,
Jan 15 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2784
by: Nermin Brgulja | last post by:
Hi, I am using jdk1.4 Logger with a FileHandler for logging in a web application, and have two questions regarding logging: The first question is: I've created an Logger and mapped it to an...
0
1943
by: Laszlo | last post by:
Hi I need a GL::Logger wich implements Class::Singleton to be a singleton and Log::Log4perl to can log amy message into a file. Here is the module source:...
2
2461
by: Robert | last post by:
Hi all I have been trying to set up a framework with logging implemented using the built in Python logging module. For better or worse, I have decided to base the logger names on the module...
1
1568
by: rodsatt | last post by:
Hi, This is my first post, and I got questions about logging. When something happen within an object, and if I would like to log the event, what would be a good way to do it? 1. I make the...
10
8060
by: Gary Jefferson | last post by:
Suppose I have 3 modules that belong to a project, 'A', 'A.a' and 'B', and each module has its own logger, created with: module1logger = logging.getLogger('project.A') and module2logger =...
5
2105
by: CedricCicada | last post by:
Greetings! I want to write messages into the Windows event log. I found sevicemanager, but the source is always "Python Service", and I'd like to be a bit more descriptive. Poking around on...
4
1700
by: garyjefferson123 | last post by:
Suppose I have some sort of context variable that I want to appear in log messages. E.g.: logger = logging.getLogger("somelogger") class SomeOp: def __init__(self, ctx): self.ctx = ctx def...
2
3286
by: DwBear75 | last post by:
I am hoping to find some simple examples of how to create a logger instance using smtphandler. I don't want to create a separate ini file. I just want to sent the smtphost, from, to right in the...
1
1801
by: nagk9 | last post by:
Hi , I am using log4j in my application. I have the problem with log4j.properties file . It will automatically appends another logger file from the current logger which i am using for the...
1
2843
by: Matimus | last post by:
Yes but in the other hand :http://docs.python.org/library/logging.html#logger-objects That is part of the power of the logging module. If you ask for a logger of the same name in two different...
0
7220
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.