Bandit - Level 2
Setup / Resources
man cdman lsman catman bash
Expand for walkthrough steps
Step 0
ssh bandit.labs.overthewire.org -p 2220 -l bandit1
Password from Level 1
Step 1
Faiure is always a good start
ls
ls -al
cat -
# termainal is hung
# ctrl + c
Why didn't that work?
What does
man catsay about standard input in theDESCRIPTIONsection
Step 2
Read The Scroll of Truth
man bash
# search by typing /
# search for "Redirecting Input"
And Stack Overflow
From: https://unix.stackexchange.com/a/16364
Using - as a filename to mean stdin/stdout is a convention that a lot of programs use. It is not a special property of the filename. The kernel does not recognise - as special so any system calls referring to - as a filename will use - literally as the filename.
With bash redirection, - is not recognised as a special filename¹, so bash will use that as the literal filename.
When cat sees the string - as a filename, it treats it as a synonym for stdin. To get around this, you need to alter the string that cat sees in such a way that it still refers to a file called -. The usual way of doing this is to prefix the filename with a path - ./-, or /home/Tim/-. This technique is also used to get around similar issues where command line options clash with filenames, so a file referred to as ./-e does not appear as the -e command line option to a program, for example.
Step 3
cat ./-
or
cat < -
Use the contents of this file as the password for the next level.