Keystroke Logging

Install a keystroke logging program.

This would be a  simple program to write yourself but for security reasons it is not permitted to trap keystrokes in the background in java (processing).  First find keylogging software that writes a file full of all your keystrokes. I did not write these and so am a little distrustful of them but they did work for me and my bank account is still there.

  • Mac http://code.google.com/p/logkext/  logKext runs in back ground or http://www.macshadows.com/OLD/files/keyloggers/
  • PC http://www.spyarsenal.com/familykeylogger/  “Family” Keylogger

Analalyze the Resulting File

Then write a program to count your words, then find a way to pick out the most interesting words.  Finding the file that you keylogger is making can be difficult.  Sometimes you talk to your keylogger and tell it to print out the file by using your terminal and then after logging in typing something like “open”.  Check the instructions.

TreeMap wordCounts = new TreeMap();

void setup(){

String [] myLines = loadStrings(“/Users/Dan/Library/Preferences/User Preferences”);

String allText = join(myLines,”");

allText = allText.replaceAll(“\\[SHFT\\]“,”");

allText = allText.replaceAll(“\\[CMD\\]“,”");

allText = allText.replaceAll(“\\[DEL\\]“,”");

String[] words = allText.split(” “);

for (int i = 0; i < words.length; i++){

Integer thisWordCount = (Integer) wordCounts.get(words[i]);

if (thisWordCount == null){

wordCounts.put(words[i], new Integer(1));

}else{

println(“exists” + words[i]);

thisWordCount = new Integer(thisWordCount.intValue() + 1);

wordCounts.put(words[i], thisWordCount);

}

}

Object[] keys = wordCounts.keySet().toArray();

for(int i = 0; i < keys.length; i++){

Integer count = (Integer) wordCounts.get(keys[i]);

if (count.intValue() > 1){

println(keys[i] + ” ” + count.intValue());

}

}

}

void draw(){

}

One Response to “Keystroke Logging”

  1. [...] high for the month and below average for the year.  This code is a little further along than the word counting code because it uses a Word Objects instead of a simple Hashtable, and it introduces a way to sort those [...]