Full Cycle
Full Cycle
Platform: hackerlab | Category: Misc | Type: Challenge | Difficulty: Easy | OS: Linux | Author: XESXOR | Date: 2025-12-23 | Status: Solved Techniques: Byte reversal / file reconstruction, File header analysis (magic bytes), JPEG structure understanding (FF D8 start, FF D9 end markers)
Summary
Task: Recover a broken JPEG image from full_cycle.zip. Solution: Reverse all bytes in the file - the JPEG was stored with bytes in reverse order (end marker at beginning, start marker at end).
Full Cycle — hackerlab.pro
Description
"Сэр, он снова прислал нерабочую картинку..." (Sir, he sent a broken image again...)
File: full_cycle.zip contains fullCycle.jpg
Analysis
1. Initial file check
bash read-only • copy allowed$ unzip full_cycle.zip $ file fullCycle.jpg fullCycle.jpg: data
The file is not recognized as an image — the file command shows just "data".
2. Hex dump analysis
bash read-only • copy allowed$ xxd fullCycle.jpg | head 00000000: d9ff 0a21 6f72 6220 ...
File beginning: D9 FF — this is the JPEG end marker FF D9, but the bytes are swapped!
bash read-only • copy allowed$ xxd fullCycle.jpg | tail ... d8ff
File end: D8 FF — this is the JPEG start marker FF D8, also in reverse order!
3. Hypothesis
The entire file is reversed — bytes are in reverse order. The name "Full Cycle" hints at this.
Normal JPEG structure:
- Beginning:
FF D8(SOI — Start Of Image) - End:
FF D9(EOI — End Of Image)
Our file:
- Beginning:
D9 FF(reversed EOI) - End:
D8 FF(reversed SOI)
Solution
python read-only • copy allowed#!/usr/bin/env python3 """ Full Cycle - Byte Reversal Restoring a reversed JPEG file """ with open('fullCycle.jpg', 'rb') as f: data = f.read() # Reverse all bytes reversed_data = data[::-1] with open('fixed.jpg', 'wb') as f: f.write(reversed_data) print(f"Original size: {len(data)} bytes") print(f"Fixed file saved as: fixed.jpg")
Verifying the result
bash read-only • copy allowed$ python3 solve.py Original size: 12345 bytes Fixed file saved as: fixed.jpg $ file fixed.jpg fixed.jpg: JPEG image data, JFIF standard 1.01
The file is now recognized as JPEG!
Viewing the image
After opening fixed.jpg, the flag is visible on the image.
Reference: JPEG Magic Bytes
| Marker | Hex | Description |
|---|---|---|
| SOI | FF D8 | Start Of Image (file beginning) |
| EOI | FF D9 | End Of Image (file end) |
| APP0 | FF E0 | JFIF marker |
| APP1 | FF E1 | EXIF marker |
Alternative Solution (bash)
bash read-only • copy allowed# Using xxd and tac for reversal xxd -p fullCycle.jpg | tr -d '\n' | fold -w2 | tac | tr -d '\n' | xxd -r -p > fixed.jpg
Or using a Python one-liner:
bash read-only • copy allowedpython3 -c "open('fixed.jpg','wb').write(open('fullCycle.jpg','rb').read()[::-1])"