This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxpl.py
53 lines (44 loc) · 1.37 KB
/
xpl.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
import re
import sys
main_cmp = open('main_compare.txt','r').read()
# Regex for array_get to retrieve array index
array_get_str = r'array_get\((\d+),'
# Regex for array_get to retrieve byte comparison
cmp_str = r'!= (\d+)'
# Array buffer
cmp_arr = [-1 for _ in range(32)]
# Retrieve byte comparisons and store in buffer using array index
for each in main_cmp.split('\n'):
if re.findall(array_get_str, each):
index = int(re.findall(array_get_str, each)[0])
cmp_int = int(re.findall(cmp_str, each)[0]) if re.findall(cmp_str, each) else 0
cmp_arr[index] = cmp_int
print(f'In main__compare: {bytearray(cmp_arr)}')
# Reversed byte array manipulations
for i in range(len(cmp_arr) - 1, -1, -1):
if i > 0:
cmp_arr[i] ^= cmp_arr[i - 1]
cmp_arr[i] ^= (i + 1)
cmp_arr[i] -= 5
cmp_arr[i] = chr(cmp_arr[i])
cmp_arr = ''.join(cmp_arr)
print(f'Before main__compare: {cmp_arr}')
import sys
import requests
from urllib.parse import quote
if len(sys.argv) < 2:
print(f'Usage: {sys.argv[0]} <uuid>')
sys.exit()
UUID = sys.argv[1]
# Retrieve URL from arguments
HOST = 'http://localhost'
PORT = 8888
if len(sys.argv) >= 3:
HOST = sys.argv[2]
if len(sys.argv) == 4:
PORT = sys.argv[3]
# POST request with reversed byte string
url = f'{HOST}:{PORT}/' + quote(cmp_arr)
print(f'Posting {url}')
x = requests.post(url, cookies={'id': UUID})
print(x.text)