DEV Community

Krishna
Krishna

Posted on

2 1

OverTheWire Bandit Level 1 Level 2 walk-through

Challenge page => https://overthewire.org/wargames/bandit/bandit2.html

This challenge also involves reading a file to get the password, but it has a tricky file name.


Hint 1: Your cat command did not work, did it? :D It's ok. That's what this challenge is about.

Technically the cat command is working fine. As for why it did not read the file "-", once again the hints have been provided by the designers in the form of links for further reading.

Google Search for “dashed filename”
Advanced Bash-scripting Guide - Chapter 3 - Special Characters


Hint 2: The first result of the Google search, which leads to a Unix Stack Exchange post explains the problem and gives you the answer as well.


Solution

No more hints as you already have the answer :)

By now you've figured out that cat is treating "-" as a synonym for stdin.

As for what exactly cat is doing, go to the second link, and Ctrl+F for "redirection from/to stdin or stdout [dash]". It will lead you to a section that explains cat's behaviour, and other scenarios where the "-" is used by other commands

I would also recommend browsing the same article for info on the other special characters mentioned there.

As was shown in the Unix Stack Exchange post, the solution is to simply use the full path to the file like below, which ensures cat does not treat it as stdin

bandit3

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay