Created
October 28, 2015 22:39
-
-
Save adamhrv/3c7a1fc2fedbb42a807c to your computer and use it in GitHub Desktop.
Key Logger Key Counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Keylogger analysis tool: output key counts to CSV | |
* ITP Stratosphere of Surveillance | |
* Built: Processing 2.2.1 | |
*/ | |
import java.util.Map; | |
HashMap<String, Keystroke> keystrokes; | |
String inputFile = "keystroke.log", outputFile = "keystroke.csv"; | |
void setup() { | |
size(800, 600); | |
keystrokes = new HashMap<String, Keystroke>(); | |
// 1445981506,485565000,[cmd] | |
String[] logfile = loadStrings(inputFile); // your input file in /data folder | |
for (int i = 0; i < logfile.length; i++) { | |
String[] pieces = split(logfile[i], ","); | |
String keyChar = pieces[2]; | |
if ( keyChar.equals(" "))keyChar = "[space]"; // replacement | |
long t = Long.parseLong(pieces[0]) + Long.parseLong(pieces[1]); | |
if ( keystrokes.containsKey(keyChar)) { | |
keystrokes.get(keyChar).addKeystroke(t); | |
} else { | |
keystrokes.put( keyChar, new Keystroke(keyChar, t)); | |
} | |
} | |
// Output to csv | |
PrintWriter pw = createWriter("data/" + outputFile); // | |
for (Map.Entry mk : keystrokes.entrySet ()) { | |
Keystroke k = (Keystroke) mk.getValue(); | |
println( k.times.size() + "," + k.keyChar); | |
pw.println(k.keyChar + ","+k.times.size()); | |
} | |
pw.flush(); | |
pw.close(); | |
exit(); | |
} | |
void draw() { | |
// empty | |
} | |
public class Keystroke { | |
String keyChar; | |
ArrayList<Long> times; | |
Keystroke(String keyChar, long t) { | |
this.keyChar = keyChar; | |
times = new ArrayList<Long>(); | |
times.add(t); | |
} | |
public void addKeystroke(long t) { | |
times.add(t); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment