-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_ammo.py
59 lines (45 loc) · 1.35 KB
/
make_ammo.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
def make_ammo(method, url, headers, case, body):
""" makes phantom ammo """
# http request w/o entity body template
req_template = (
"%s %s HTTP/1.1\r\n"
"%s\r\n"
"\r\n"
)
# http request with entity body template
req_template_w_entity_body = (
"%s %s HTTP/1.1\r\n"
"%s\r\n"
"Content-Length: %d\r\n"
"\r\n"
"%s\r\n"
)
if not body:
req = req_template % (method, url, headers)
else:
req = req_template_w_entity_body % (method, url, headers, len(body), body)
# phantom ammo template
ammo_template = (
"%d %s\n"
"%s"
)
return ammo_template % (len(req), case, req)
def main():
for stdin_line in sys.stdin:
try:
method, url, case, body = stdin_line.split("||")
body = body.strip()
except ValueError:
method, url, case = stdin_line.split("||")
body = None
method, url, case = method.strip(), url.strip(), case.strip()
headers = "Host: hostname.com\r\n" + \
"User-Agent: tank\r\n" + \
"Accept: */*\r\n" + \
"Connection: Close"
sys.stdout.write(make_ammo(method, url, headers, case, body))
if __name__ == "__main__":
main()