Last active
May 30, 2026 22:54
-
-
Save obormot/c997257d2cbf150fc0e598e1e97da7b4 to your computer and use it in GitHub Desktop.
cryptohack.org/challenges
This file contains hidden or 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
| # py2 | |
| import base64, codecs, json, socket | |
| conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| conn.connect(('socket.cryptohack.org', 13377)) | |
| for i in range(101): | |
| data = json.loads(conn.recv(1024)) | |
| print i, data, | |
| if 'flag' in data: | |
| print '***', data['flag'], '***' | |
| break | |
| enc, word = data['type'], data['encoded'] | |
| if enc == "base64": | |
| decoded = base64.b64decode(word) | |
| elif enc == "hex": | |
| decoded = word.decode('hex') | |
| elif enc == "rot13": | |
| decoded = codecs.decode(word, 'rot_13') | |
| elif enc == "bigint": | |
| decoded = word[2:].decode('hex') | |
| elif enc == "utf-8": | |
| decoded = ''.join(chr(b) for b in word) | |
| print decoded | |
| conn.send(json.dumps({'decoded': decoded}) + '\n') | |
| conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment