Reverse Polarity
1 minute to read
We are given this stream of bits from a hard drive:
10000110101010001000110011011000110010101100001011100100110111001111011010000100110100101110100010111110100011001101100011010010111000001110000011010010110111001111101
We need to represent it in readable characters. First, we can use Python to express the binary stream as a hexadecimal number:
$ python3 -q
>>> hex(0b10000110101010001000110011011000110010101100001011100100110111001111011010000100110100101110100010111110100011001101100011010010111000001110000011010010110111001111101)
'0x4354466c6561726e7b4269745f466c697070696e7d'
Notice that we must add 0b to tell Python that the number is in binary format.
From the hexadecimal digits, we can foresee that these are ASCII characters (i.e. 0x43 is C, 0x54 is T and 0x46 is F).
To decode these bytes from hexadecimal numbers, we can use binascii.unhexlify (without the 0x preffix):
>>> bytes.fromhex('4354466c6561726e7b4269745f466c697070696e7d')
b'CTFlearn{Bit_Flippin}'