-
Notifications
You must be signed in to change notification settings - Fork 15
/
http_shell_script.py
94 lines (71 loc) · 2.61 KB
/
http_shell_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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# !usr/bin/python
import sys
import os
import json
def print_method(method):
if method == 'GET':
print(" _____ ______ _______")
print(" / ____| | ____| |__ __|")
print(" | | __ | |__ | | ")
print(" | | |_ | | __| | | ")
print(" | |__| | | |____ | | ")
print(" \_____| |______| |_| ")
elif method == 'POST':
print(" _____ ____ _____ _______")
print(" | __ \ / __ \ / ____| |__ __|")
print(" | |__) | | | | | | (___ | | ")
print(" | ___/ | | | | \___ \ | | ")
print(" | | | |__| | ____) | | | ")
print(" |_| \____/ |_____/ |_| ")
def print_success_request():
print()
print("############################################")
print("########### SUCCESS SEND REQUEST ###########")
print("############################################")
def print_request_message(url):
print()
print("############# REQUEST MESSAGE ##############")
print(url)
print("############################################")
print("############################################")
print("############ HTTP SHELL SCRIPT #############")
print("############################################")
METHOD = sys.argv[1]
if METHOD == 'GET':
print_method(METHOD)
URL = "http GET http://127.0.0.1:8000/post/"
print_request_message(URL)
print_success_request()
result = os.popen(URL).read()
print()
print("############### RESPONSE ##################")
print(
json.dumps(
json.loads(result),
indent=4,
sort_keys=True)
)
print("############### RESPONSE ##################")
else:
start, end = int(sys.argv[2]), int(sys.argv[3]) + 1
print_method(METHOD)
for i in range(start, end):
PREFIX = "http --form POST http://127.0.0.1:8000/post/ "
DATA = 'title="Post Test Title{}" body="Post Test Body{}"'
URL = PREFIX + DATA.format(i, i)
print_request_message(URL)
print_success_request()
result = os.popen(URL).read()
print()
print("############### RESPONSE ##################")
print(
json.dumps(
json.loads(result),
indent=4,
sort_keys=True)
)
print("############### RESPONSE ##################")
print()
print("############################################")
print("############### END SCRIPT ################")
print("############################################")