-
Guessed integrity check :
user : hash : b64_encoded_info
in cookieuser
-
info in YAML format
-
Some YAML parsers allow to redefine the same key, that replaces the old value
-
We have a hint : /src-code/ contains a swp file, original file was removed. It's easy to extract from it the src code of the web app. Of course it's a double-key permissive YAML parser
-
A bad salt algorithm is used :
sha256(passkey + salt + info)
-
Salt length :
passkey.len
== 20 andsalt.len
== 10, we could consider a single salt of30 bytes
and extend the hash -
Pwned :>
Last active
November 5, 2018 23:34
-
-
Save LoadLow/e9b807b36ecbde7f75f5b4a432691fae to your computer and use it in GitHub Desktop.
INS'HACK CTF 2018 - Web Crypt0r part 2 - Extend the hash - RushB%
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
import base64 | |
import subprocess | |
import sys | |
cookie = sys.argv[1].split(':') | |
user = cookie[0] | |
base_sign = cookie[1] | |
info = base64.decodestring(cookie[2]) | |
to_append = "\ninsa_coins: 600\n" | |
file = open('base_info.txt', 'w') | |
file.write(info) | |
file.close() | |
result = subprocess.check_output([ | |
'./hash_extender', | |
'--file=base_info.txt', | |
'-s', base_sign, '-f', 'sha256', '-l', '30', | |
'-a', to_append, | |
'--out-data-format', 'raw', | |
'--out-signature-format', 'hex', | |
'-q' | |
]) | |
new_hash = result[:64] | |
new_user_infos = result[64:] | |
new_cookie = user + ':' + new_hash + ':' + base64.b64encode(new_user_infos) | |
print("New cookie is : " + new_cookie) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment