Skip to main content
Challenges Length-extension attack
Cryptography Expert Length-extension attack Solves: 7

Length-extension attack

Author: CyberSamSU
Points
160

SHA-256 (as well as MD5, SHA-1) is based on the Merkle-Damgård construction: the message is divided into blocks, the internal state passes from block to block, and the final state becomes the hash itself. The vulnerability of this construction is the length-extension attack.

Assumption: the server checks message authenticity using a naive MAC: MAC = sha256(secret || message), where secret is an unknown key. You know message and its MAC, as well as the length of the key. Since the hash is the final internal state, you can continue from this state and generate a valid MAC for secret || message || padding || append without knowing the key.

Given values (also available in the berilgan.txt file):

message = user=guest&role=user&expiry=2026
orig_mac = 21d7b4c85c7b11d997dc97546046c3cbdadf9326c5ce2ee80620f34b69977700
secret_length = 28 bayt
qo'shmoqchi (append) = &role=admin&grant=all

Task: using length-extension, calculate a valid MAC (forged MAC) for a new message with appended append.

Answer: the hex representation of the hash value (lowercase, no spaces).

Padding is the standard SHA-256 padding: 0x80, then zeros, then the message length in bits (64-bit, big-endian). The length is calculated based on the number of secret || message bytes.

Attached files
berilgan.txt Log in to download
soxta_xabar.hex Log in to download
SHA-256 checksums
berilgan.txt: 6951e14b12114050dafe52de5115a0f8a317a026823f04b079c4b741a98d1ad5
soxta_xabar.hex: a0f9057c0a84822c102ec1ef588a1846eb4c638eefb0208fa88ea674c6c93ecd
Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −16 pts Log in
Hint 2 −32 pts Log in
Hint 3 −48 pts Log in
To submit a flag, log in.

First solvers

1. Абдул 15.09.2026
2. Лазиз 04.10.2026
3. testrejim 09.10.2026
4. Raumdeuter 09.10.2026
5. 11111tttt 09.10.2026
6. Mirjaxon Qaxxarov 26.10.2026
7. Odam 04.11.2026