Skip to content

Commit 57b33ef

Browse files
authored
Add files via upload
1 parent f2b2e4f commit 57b33ef

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: "OverTheWire Bandit: Level 9 to Level 10"
3+
date: 2026-06-26 19:40:00 +0500
4+
categories: [CTF, Bandit]
5+
tags: [linux, strings, grep, binary, piping, overthewire, beginner]
6+
---
7+
8+
## The Goal
9+
10+
Find the password in `data.txt` — stored in one of the few human-readable strings, preceded by several `=` characters.
11+
12+
## What I Did
13+
14+
The level mentioned "human-readable strings" which immediately suggested the file wasn't plain text. I checked the `strings` man page first, then ran it on the file:
15+
16+
```bash
17+
bandit9@bandit:~$ strings data.txt
18+
```
19+
20+
That printed a wall of readable text extracted from what was otherwise a binary file. Too much to read through manually. Since the level said the password was preceded by `=` signs, I piped the output into `grep`:
21+
22+
```bash
23+
bandit9@bandit:~$ strings data.txt | grep "="
24+
```
25+
26+
That filtered the output down to only lines containing `=`, one of which had several `=` signs followed by the password.
27+
28+
## What Was Actually Happening
29+
30+
**`data.txt` is a binary file** — not plain text. Running `cat` on it would flood the terminal with garbage characters. The file contains mostly non-printable binary data with a few human-readable strings embedded inside it.
31+
32+
**`strings`** scans a file and extracts sequences of printable characters above a minimum length (4 by default). It ignores everything else — all the binary noise — and outputs only the readable parts. This is how you pull text out of executables, compressed files, or any binary format.
33+
34+
**`grep "="`** then filtered that output for lines containing `=`. Since the password was described as being preceded by multiple `=` characters, this narrowed the results immediately to the relevant line.
35+
36+
The pipe connects both — `strings` output flows directly into `grep` without touching disk.
37+
38+
## Other Ways I Could Have Done It
39+
40+
**`strings` with minimum length filter:**
41+
```bash
42+
strings -n 10 data.txt | grep "="
43+
```
44+
`-n 10` only extracts strings of 10 characters or longer, cutting out short fragments that add noise.
45+
46+
**`grep -a` directly on the binary:**
47+
```bash
48+
grep -a "===" data.txt
49+
```
50+
The `-a` flag forces `grep` to treat a binary file as text. Works but produces messier output with binary characters mixed in.
51+
52+
**`xxd` for inspection:**
53+
```bash
54+
xxd data.txt | grep "==="
55+
```
56+
`xxd` shows a hex dump with ASCII characters on the side. Useful for low-level inspection of binary content but much harder to read than `strings`.
57+
58+
`strings | grep` is the cleanest approach for this type of problem.
59+
60+
## What I Learned
61+
62+
**`strings` extracts readable text from binary files.** Any time a file isn't plain text — executables, compressed archives, unknown formats — `strings` is the first tool to reach for when you want to see what readable content is inside.
63+
64+
**Binary files will break `cat`.** Your terminal fills with garbage characters and sometimes gets into a broken state. Always check what type of file you're dealing with using `file` before reading it.
65+
66+
**Piping filters progressively.** `strings` does the broad extraction, `grep` does the precise filtering. Each command does one thing. The pipe connects them.
67+
68+
## Commands Used
69+
70+
| Command | What it did |
71+
|---|---|
72+
| `man strings` | Checked what strings does before using it |
73+
| `strings data.txt` | Extracted all human-readable text from the binary file |
74+
| `strings data.txt \| grep "="` | Filtered output to lines containing `=` signs |

0 commit comments

Comments
 (0)