Hackvent_2018/Day 2/decode.py

35 lines
906 B
Python
Raw Permalink Normal View History

2018-12-04 12:54:01 +01:00
#!/usr/bin/python
import urllib.request
import urllib.parse
import base64
with open("input.txt", "r") as content_file:
content = content_file.read().replace("\n", "")
data = content.split(" ")
# Octal Bytes -> Decimal
data_oct = [int(c,8) for c in data]
# Decimal -> Ascii
string = ''.join(chr(i) for i in data_oct)
# Ascii -> Base32
string = base64.b32decode(string, casefold=False).decode("utf-8")
# Base32 -> 14-Segment-Code
url = "https://kryptografie.de/cgi-bin/MysteryMaster.exe"
params = {
"app": "Kryptografie.de",
"user": "",
"pass": "",
"chiffre": "14-Segment",
"opnum": 2,
"key": "",
"code": string
}
response = urllib.request.urlopen(url, urllib.parse.urlencode(params, True).encode('utf-8'))
result = response.read().decode('utf-8').replace("%0D%0A", "")
print(result)