Level 04

 Publ .

 Mins 2 (241 words).

 Edit .

Level 04

On the home directory, is available a hidden folder with another setuid binary.

$ ls -la .trash/
total 24
dr-xr-x--- 2 root       leviathan4  4096 Jan 11 19:18 .
drwxr-xr-x 3 root       root        4096 Jan 11 19:18 ..
-r-sr-x--- 1 leviathan5 leviathan4 14928 Jan 11 19:18 bin
$ ./.trash/bin
01000101 01001011 01001011 01101100 01010100 01000110 00110001 01011000 01110001 01110011 00001010

Execution of this file displays what appears to be a string that encodes some binary data. There are in total 11 numbers, and they might represent each one character.

There are a bunch of online sites to decode this binary representation. The shell might as well be used to do it:

$ for a in $(  ./.trash/bin ); do printf "%x"  $((2#$a)); done | xxd -r -p
EKKlTF1Xqs

The command above means:

  • $ ( ./.trash/bin ) expands to the list of binary numbers.

  • for a in $( ... ); sets the variable a to store the value of each binary number for each iteration of the for loop.

  • printf "%x" $((2#$a)) is a function call executed in each loop iteration. It has two arguments.

    • $((2#$a)) expands to the decimal representation of the binary number represented by the string stored in the variable $a.
    • "%x" is a format specifier indicating that the number printf outputs is going to be displayed as a hexadecimal value.
  • xxd -r -p receives in the pipe the hexadecimal value and reverses it to a plain text ASCII character.