Awkward file names
User rung1
ssh -p 2222 rung1@play.ctf.wail.ly
Goal
The password for the next level is in the only file of your home directory. Its name starts with dashes and contains spaces.
Commands that may help
lscat
Reading
man bash, section QUOTING: how quotes keep a name with spaces in one piece. Inside amanpage, type/QUOTINGand press Enter to jump to that section, andqto leave.man bash, start of the section SHELL BUILTIN COMMANDS: a--marks the end of the options. Most commands,catincluded, follow the same rule.
Prerequisite: not tied to a lecture chapter.
Hints
Hint 1
List your home directory with
ls; it may show the name between quotes, which are not part of the name. Then try cat followed by the name. Two things can go wrong: the shell cuts the name at every space, and cat takes anything that starts with - for an option. Fix one problem at a time.Hint 2
Quotes keep a name in one piece: the shell hands everything between
" and " to the command as a single word, spaces included.Hint 3
You need three pieces, in this order, separated by spaces: the command
cat; then -- on its own, which tells cat that every word after it is a file name and not an option; then the full file name, dashes and spaces included, between double quotes so the shell keeps its spaces. Putting ./ in front of the name, inside the quotes, also works instead of --, because the name then starts with a dot.