Created
April 8, 2018 19:57
-
-
Save MariaRigaki/75fb23a36295ea24aa04dd2a2e5f400a to your computer and use it in GitHub Desktop.
The last step from Avast's reversing challenge in security session 2018
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The message I got from the previous step was the following: | |
# The last step: 4e 3f 4a 5f 3g 5f 3d 3b 4c 5f 2c 46 1e 43 2f 4h 34 1e 2c 6c 32 5b 32 57 31 30 32 2h | |
# From that and the hint that "16 is not enough" we had to figure out that it was base18 encoded | |
# Decoder function from https://github.com/gg/integer_encoding | |
def decoder(alphabet): | |
""" | |
Returns a decoder that decodes a base-`len(alphabet)` encoded sequence of | |
alphabet elements into a positive integer. | |
`alphabet`: a list of hashable elements used to encode an integer; i.e. | |
`'0123456789'` is an alphabet consisting of digit characters. | |
""" | |
base = len(alphabet) | |
index = dict((v, k) for k, v in enumerate(alphabet)) | |
def decode(xs): | |
try: | |
result = 0 | |
for i, x in enumerate(xs[::-1]): | |
result += (base ** i) * index[x] | |
return result | |
except KeyError: | |
raise ValueError("%r is not in the alphabet %r" % (x, alphabet)) | |
return decode | |
hex_string = "4e 3f 4a 5f 3g 5f 3d 3b 4c 5f 2c 46 1e 43 2f 4h 34 1e 2c 6c 32 5b 32 57 31 30 32 2h".split(' ') | |
alphabet = '0123456789abcdefgh' | |
decode = decoder(alphabet) | |
final = [] | |
for i in hex_string: | |
final.append(chr(decode(i))) | |
print(''.join(final)) # VERiFiCATi0N K3Y: 0x8e8a7685 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment