Sunday, December 7, 2014

Bandit Level 10 to Level 11

View base64 encoded data.

Host name is bandit.labs.overthewire.org 
User: bandit10
password: truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk


Commands used for this level:
ls - List information about the FILE's (the current directory by default).
cat - used to view contents of a file.
base64 - encode/decode data and print to standard output (use with -d to decode)

Step 1.
After logging in type ls
You will see a file data.txt

Step 2.
In that data.txt file we need read some base64 encoded data.
Type cat data.txt
We see what looks like our password but is much longer than our password really is. We need to decode the text to get our password. 
To decode the data we need to learn about base64 encoded data.
http://en.wikipedia.org/wiki/Base64
We learn that base64 is a binary to text encoding scheme. What base64 does is it encodes and decodes data into its base64 value.
The steps base64 encode takes are:
1. Each letter of text in a string of characters (a word) is converted to its ASCII decimal value. We will use the word "The" as our example. Looking up the ASCII chart we see the decimal values for T = 84, h = 104, e = 101.
2. Each decimal value is then converted to binary. To convert to binary from decimal you just divide the number by 2 repeatedly until you reach a value of 0. If your division has a remainder then your bit gets set to 1.
2/84 = 42 remainder 0
2/42 = 21 remainder 0
2/21 = 10 remainder 1
2/10 =   5 remainder 0
2/5   =   2 remainder 1
2/2   =   1 remainder 0
2/1   =   0 remainder 1
binary value for T is 01010100
binary value for h is 01101000
binary value for e is 01100101
3. The binary values for each word is then combined into a string of binary 010101000110100001100101 and broken up into strings of 6 bits 010101,000110,100001,100101
4. Each 6 bit string is then converted back to decimal value.
010101 = 21
000110 =   6
100001 = 33
100101 = 37
5. Finally those decimal values are matched to the base64 index values.
21 = V
 6  = G
33 = h
37 = l

Step 3.
It just so happens that Linux has a base64 tool. Lets read the man page by typing man base64. We see that this command when used with a -d will decode base64 data.
Type base64 -d data.txt and our decoded base64 data is display: The password is IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR


No comments:

Post a Comment