Trailing Bits (Bitshifting)
{"author" : ["ret2basic"]}

Challenge

The text that includes the flag is transmitted while unfortunately both of its head and tail bits are lost 😟
Attachment:

Solution

For the challenge description, we know that some bits are removed from both head and tail of this binary data. The idea is to keep performing bitwise left shift until we have readable text.

Implementation

1
#!/usr/bin/env python3
2
from Crypto.Util.number import long_to_bytes
3
​
4
with open("output.txt", "r") as f:
5
binary_text = f.read().strip()
6
​
7
counter = 0
8
while True:
9
# Bitwise left shift
10
plaintext = long_to_bytes(int(binary_text, 2) << counter)
11
​
12
if b"CCTF" in plaintext:
13
print(f"{plaintext = }")
14
exit()
15
​
16
counter += 1
Copied!
Last modified 2mo ago