-
Notifications
You must be signed in to change notification settings - Fork 0
/
cc6_decimal2binary.py
46 lines (40 loc) · 1.33 KB
/
cc6_decimal2binary.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
import requests
cc_number = 6
url_input = 'https://cc.the-morpheus.de/challenges/' + str(cc_number) + '/'
url_output = 'https://cc.the-morpheus.de/solutions/' + str(cc_number) + '/'
def recursive_decimal2binary(decimal, binaries=None):
if binaries is None:
binaries = []
binary = int(decimal % 2)
if binary is 1:
decimal = decimal - 1
binaries.append(binary)
if decimal == 0:
binaries.reverse()
solution = ''.join(str(e) for e in binaries)
return solution
return recursive_decimal2binary(decimal // 2, binaries)
response = int(requests.get(url_input).text)
print('------------ Response of Server --------')
print(response)
print('----------------------------------------')
result = recursive_decimal2binary(response)
print(result)
response2 = requests.post(url_output, json={'token': result})
print('------------Response 2 of Server -------')
print(response2.text)
print('----------------------------------------')
# Success: TMT{O6gjviTFP0f1Uv25chkI}
"""
import time
start = time.time()
for i in range(100):
pass
print((time.time() - start)/100)
result = ''
response2 = requests.post(url_output, json={'token': result})
print('------------Response 2 of Server -------')
print(response2.text)
print('----------------------------------------')
# Success: TMT{WBVjoml6PjsOu3yzFvr3}
"""