• Post Reply Bookmark Topic Watch Topic
  • New Topic

Keystroke logger  RSS feed

 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create a keylogger software as a jar file. I have looked up some solutions but they all have posted solutions for only certain keys. I have to program in such a way that my program should recognize the keystroke whatever the key may be and write it to a background file as notepad or MSword. Please help me asap.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
Partheban Udayakuma3 wrote:Please help me asap.

No such thing as ASAP here at the Ranch.

So you found some ready made code which shows you how to recognize "certain key strokes". But you want to capture all key strokes.
So which area are you having a problem
1) Understanding the ready made code
2) Expanding on the ready made code to suit your requirement
3) Anything else
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the welcome. I am sorry for the asap word

I need a program which captures all the keystrokes and writes it to a file. I found only codes that deal with special keys as Ctrl,Alt or win key etc. My program has to detect every single key pressed and write it in a background file and then I have to convert the program into a jar.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are just repeating what you said initially. You can help us help you by answering the questions I asked.
Also take a look at https://www.coderanch.com/how-to/java/NotACodeMill
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Here's the deal. I need a keylogger software as a jar file. I know that we can implement Keylistener interface to get the key typed. Now I am in a dilemma how to continuously get the keys typed and get them written in a file.
 
Paul Clapham
Sheriff
Posts: 22505
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which part of that, exactly, are you confused about? Getting the keys typed, or writing them to a file?

By the way I hope you realize that the KeyListener will only get the keys typed when your application is on top. If you were hoping to intercept keystrokes which were meant for other applications running, it won't do that.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I am confused on both parts. How to continuously monitor the keys typed as well as how to write them in a file. If keylistener doesnt work on background files what should I use to get the desired output.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to use the native API of whatever OS you intend this software to run. Given that this code will do little else (except write the key strokes to a file), Java would be a bad choice of implementation language.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a fresher looking for java developer job. I was asked by a company to write a code for keylogger in java. That is why I am writing this code in java.

I have written the following code but the problem is it doesnt give any output. It just runs.

import java.awt.BorderLayout;
import java.awt.event.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.*;

/**
* This Class opens a simple text area using JFrame and prints the typed key in a log file.
*
*/
public class KeyEventDemo
implements KeyListener
{
/**
* @param args defaultargs
*/
public static void main(String[] args) {
JTextField typingArea;
JFrame fr=new JFrame();
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
typingArea = new JTextField(20);
typingArea.addKeyListener(new KeyEventDemo());
fr.getContentPane().add(typingArea, BorderLayout.PAGE_START);
fr.pack();
fr.setVisible(true);
}

/** Triggers on the key pressed event and displays the typed key in the log */
public void keyTyped(KeyEvent e) {
try {
String keyString;
keyString = "key character = '" + e.getKeyChar() + "'";
//For system print console
System.out.println(keyString);
//For output to file
File a =new File("E:\\projects\\KeyLog.log");
if (!a.exists()) {
a.createNewFile();
}
FileWriter fw = new FileWriter(a.getAbsoluteFile(),true);
BufferedWriter bw = new BufferedWriter(fw);
bw.append(keyString);
bw.newLine();
bw.close();
} catch (Exception e1) {
e1.printStackTrace();
}
}

/** Triggers on the key pressed event */
public void keyPressed(KeyEvent e) {

}

/** Triggers on the key released event */
public void keyReleased(KeyEvent e) {

}
}
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Partheban Udayakumar wrote:I am a fresher looking for java developer job. I was asked by a company to write a code for keylogger in java. That is why I am writing this code in java.

I have written the following code but the problem is it doesnt give any output. It just runs.




Works for me. It wrote this...

key character = 'h'
key character = 'e'
key character = 'n'
key character = 'r'
key character = 'y'


to standard output and to the log file.

Henry
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya but the problem with this code is you have to type it in the small text box which appears to you in the corner. The company I have applied for is asking me to design a software which captures the keystrokes as the user types in his browser or any other application.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!