Skip to content

Commit dab98f1

Browse files
committed
aded old bandit writeups and goatcounter
1 parent 5418451 commit dab98f1

26 files changed

+1239
-3
lines changed

_config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ analytics:
6161
google:
6262
id: # fill in your Google Analytics ID
6363
goatcounter:
64-
id: # fill in your GoatCounter ID
64+
id: slavetomints
6565
umami:
6666
id: # fill in your Umami ID
6767
domain: # fill in your Umami domain
@@ -75,7 +75,7 @@ analytics:
7575

7676
# Page views settings
7777
pageviews:
78-
provider: # now only supports 'goatcounter'
78+
provider: goatcounter # now only supports 'goatcounter'
7979

8080
# Prefer color scheme setting.
8181
#
@@ -88,7 +88,7 @@ pageviews:
8888
# light — Use the light color scheme
8989
# dark — Use the dark color scheme
9090
#
91-
theme_mode: dark # [light | dark]
91+
theme_mode: # [light | dark]
9292

9393
# The CDN endpoint for media resources.
9494
# Notice that once it is assigned, the CDN url
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- GoatCounter -->
2+
<script
3+
async
4+
src="https://gc.zgo.at/count.js"
5+
data-goatcounter="https://{{ site.analytics.goatcounter.id }}.goatcounter.com/count"
6+
></script>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- Display GoatCounter pageviews -->
2+
<script>
3+
document.addEventListener('DOMContentLoaded', () => {
4+
const pv = document.getElementById('pageviews');
5+
6+
if (pv !== null) {
7+
const uri = location.pathname.replace(/\/$/, '');
8+
const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${encodeURIComponent(uri)}.json`;
9+
10+
fetch(url)
11+
.then((response) => response.json())
12+
.then((data) => {
13+
const count = data.count.replace(/\s/g, '');
14+
pv.innerText = new Intl.NumberFormat().format(count);
15+
})
16+
.catch((error) => {
17+
pv.innerText = '1';
18+
});
19+
}
20+
});
21+
</script>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Bandit Level 0 → Level 1
3+
date: 2025-01-16 14:00:00 +/-0600
4+
category: [OverTheWire, Bandit]
5+
tags: [overthewire, bandit, writeups, training]
6+
description: OverTheWire Bandit Level 0 → Level 1
7+
---
8+
> ssh bandit0@bandit.labs.overthewire.org -p 2220
9+
>
10+
> password: bandit0
11+
{: prompt-info }
12+
13+
## Intro to Bandit
14+
15+
Welcome to Bandit! This is OverTheWire's beginner wargame and is meant to be an introduction to how the other wargames work. This makes it a wonderful place to get acquainted with UNIX systems.
16+
17+
bandit0 is extremely easy by design, its whole purpose is to get you familiar with the syntax for `ssh` since it is what you will be using to connect to the challenge server for each level.
18+
19+
### SSH basics
20+
21+
The syntax for `ssh` is `ssh user@host -p port`. When it asks to continue connecting because it doesn't know the fingerprint, it means that it's never connected to this host before, and want you to confirm that this is the right host. It then asks us for the password, which we are provided in the challenge description.
22+
23+
```terminal
24+
25+
┌─[slavetomints@parrot]─[~]
26+
└──╼ $ssh bandit0@bandit.labs.overthewire.org -p 2220
27+
_ _ _ _
28+
| |__ __ _ _ __ __| (_) |_
29+
| '_ \ / _` | '_ \ / _` | | __|
30+
| |_) | (_| | | | | (_| | | |_
31+
|_.__/ \__,_|_| |_|\__,_|_|\__|
32+
33+
34+
This is an OverTheWire game server.
35+
More information on http://www.overthewire.org/wargames
36+
37+
bandit0@bandit.labs.overthewire.org's password:
38+
```
39+
40+
Great! Welcome to the server! Let's take a look around and see what we can find here.
41+
42+
```terminal
43+
44+
bandit0@bandit:~$ ls
45+
readme
46+
```
47+
48+
### The Command Prompt
49+
Now before we check out that file, if you've never wondered what the `bandit0@bandit:~$` means on the command line, let's quickly look at that.
50+
51+
The first part is the username for the active user, who in this case is `bandit0`. If you want to find out for yourself who the active user is, run the command `whoami` in the command line.
52+
53+
The next part, the `bandit` is the hostname of the machine. You can also find this out by running the aptly named command `hostname`.
54+
55+
```terminal
56+
57+
bandit0@bandit:~$ whoami
58+
bandit0
59+
bandit0@bandit:~$ hostname
60+
bandit
61+
```
62+
63+
The "~", called a tilde, is your current location on the file system. The tilde means the user's home directory. If you go to another user's home directory, you'll see the full path to it, but you only see the tilde if it is your own home directory.
64+
65+
```terminal
66+
67+
bandit0@bandit:~$ cd /home/bandit1
68+
bandit0@bandit:/home/bandit1$ cd /home/bandit0
69+
bandit0@bandit:~$
70+
```
71+
72+
Now, what does the `$` mean? It means that you are a user with normal user privileges. if you were the root user, you'd likely see a `#` instead, indicating that you have elevated admin privileges.
73+
74+
Okay! So now let's look at the file we found earlier!
75+
76+
### bandit0
77+
```terminal
78+
79+
bandit0@bandit:~$ cat readme
80+
Congratulations on your first steps into the bandit game!!
81+
Please make sure you have read the rules at https://overthewire.org/rules/
82+
If you are following a course, workshop, walkthrough or other educational activity,
83+
please inform the instructor about the rules as well and encourage them to
84+
contribute to the OverTheWire community so we can keep these games free!
85+
86+
The password you are looking for is: {hidden in accordance with game rules}
87+
```
88+
89+
Remember to save that password, as we'll use it to log into the next level.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Bandit Level 1 → Level 2
3+
date: 2025-01-16 14:00:00 +/-0600
4+
category: [OverTheWire, Bandit]
5+
tags: [overthewire, bandit, writeups, training]
6+
description: OverTheWire Bandit Level 1 → Level 2
7+
---
8+
9+
> ssh bandit1@bandit.labs.overthewire.org -p 2220
10+
>
11+
> The password for the next level is stored in a file called **-** located in the home directory
12+
{: .prompt-info }
13+
14+
## The Solution
15+
16+
Using the password we got from the last challenge, lets ssh into the game server as `bandit1`
17+
18+
```terminal
19+
20+
┌─[slavetomints@parrot]─[~]
21+
└──╼ $ssh bandit1@bandit.labs.overthewire.org -p 2220
22+
_ _ _ _
23+
| |__ __ _ _ __ __| (_) |_
24+
| '_ \ / _` | '_ \ / _` | | __|
25+
| |_) | (_| | | | | (_| | | |_
26+
|_.__/ \__,_|_| |_|\__,_|_|\__|
27+
28+
29+
This is an OverTheWire game server.
30+
More information on http://www.overthewire.org/wargames
31+
32+
bandit1@bandit.labs.overthewire.org's password:
33+
```
34+
35+
Now, this one seems simple enough, actually it should be just as easy as the last challenge, just `cat` the file and get a move on. So let's try that.
36+
37+
```terminal
38+
39+
bandit1@bandit:~$ cat -
40+
41+
```
42+
Huh, that's odd. What happened is that `-` is used for a few different things in UNIX/UNIX-like systems, most commonly to specify flags for a command such as `ls -sa`. Now what's happening is the terminal is waiting for the "rest" of the command, as it doesn't think that we are quite done yet.
43+
44+
The way around it is to specify exactly what we want to `cat`. See the following
45+
46+
```terminal
47+
48+
bandit1@bandit:~$ cat ./-
49+
{hidden in accordance with game rules}
50+
```
51+
52+
What this does is it uses `.` to specify the current directory, and then the file named `-` in it. And that how we can get the password for the next level.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Bandit Level 2 → Level 3
3+
date: 2025-01-16 14:00:00 +/-0600
4+
category: [OverTheWire, Bandit]
5+
tags: [overthewire, bandit, writeups, training]
6+
description: OverTheWire Bandit Level 2 → Level 3
7+
---
8+
9+
> ssh bandit2@bandit.labs.overthewire.org -p 2220
10+
>
11+
> The password for the next level is stored in a file called **spaces in this filename** located in the home directory
12+
{: .prompt-info }
13+
14+
Alrighty, the challenge this time is to `cat` the contents of a file whose name has spaces in it. What happens if we just try to use the file as it?
15+
16+
```terminal
17+
bandit2@bandit:~$ ls
18+
spaces in this filename
19+
bandit2@bandit:~$ cat spaces in this filename
20+
cat: spaces: No such file or directory
21+
cat: in: No such file or directory
22+
cat: this: No such file or directory
23+
cat: filename: No such file or directory
24+
```
25+
26+
Why does this happen? It's because with the spaces they're interpreted as sperate files/directories, and since they dont exist, it cant output their content.
27+
28+
So there are two ways we can do this, the first way is arguably easier and it's through simply putting the filename in quotes. The other way involves using the escape character `\` in front of each space to signal that it is part of the string and not part of the command `.\`
29+
30+
```terminal
31+
bandit2@bandit:~$ cat 'spaces in this filename'
32+
{hidden in accordance with game rules}
33+
bandit2@bandit:~$ cat spaces\ in\ this\ filename
34+
{hidden in accordance with game rules}
35+
```
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: Bandit Level 3 → Level 4
3+
date: 2025-01-16 14:00:00 +/-0600
4+
category: [OverTheWire, Bandit]
5+
tags: [overthewire, bandit, writeups, training]
6+
description: OverTheWire Bandit Level 3 → Level 4
7+
---
8+
9+
> ssh bandit3@bandit.labs.overthewire.org -p 2220
10+
>
11+
> The password for the next level is stored in a hidden file in the **inhere** directory.
12+
{: .prompt-info }
13+
14+
After `ssh`ing into the server, let's check out that directory.
15+
16+
```terminal
17+
18+
bandit3@bandit:~$ ls
19+
inhere
20+
bandit3@bandit:~$ cd inhere
21+
bandit3@bandit:~/inhere$ ls
22+
bandit3@bandit:~/inhere$
23+
```
24+
25+
Hm, nothing, let's talk a little bit about `ls`.
26+
27+
## ls
28+
`ls` is short for the word `list`, and it does just that. it lists all the files and directories in the specified directory. If no directory is given, then it uses the current one. By default, hidden files and directories (those with a period in front of them), do not show up as they are considered "hidden". The man page shows this for the `-a` flag
29+
30+
```
31+
-a, --all do not ignore entries starting with .
32+
```
33+
34+
## The Solution
35+
So, rerunning the earlier command with that flag we get.
36+
37+
```terminal
38+
39+
bandit3@bandit:~/inhere$ ls -a
40+
. .. ...Hiding-From-You
41+
```
42+
43+
The `.` and `..` are the current directory and the directory one level higher up respectively, like how they would be used with `cd`. Wwhy is `.` the current directory, and why is `..` the directory one level up? It's from very early Unix, and exemplified in [this 1974 paper by Dennis Ritchie and Ken Thompson](https://people.eecs.berkeley.edu/~brewer/cs262/unix.pdf).
44+
45+
Now that we know what the name of the file is, lets use cat to figure it out.
46+
47+
```terminal
48+
49+
bandit3@bandit:~/inhere$ cat ...Hiding-From-You
50+
{hidden in accordance with game rules}
51+
```
52+
53+
## Behind The Scenes
54+
### Why `.` and `..` Are Hidden Using `ls` By Deafult
55+
56+
Rob Pike, a Canadian programmer that worked on Unix in the early years, had [this to say on the topic on his blog](https://web.archive.org/web/20141205101508/https://plus.google.com/+RobPikeTheHuman/posts/R58WgWwN9jp):
57+
> A lesson in shortcuts.
58+
>
59+
> Long ago, as the design of the Unix file system was being worked out, the entries . and .. appeared, to make navigation easier. I'm not sure but I believe .. went in during the Version 2 rewrite, when the file system became hierarchical (it had a very different structure early on). When one typed ls, however, these files appeared, so either Ken or Dennis added a simple test to the program. It was in assembler then, but the code in question was equivalent to something like this:
60+
>
61+
> `if (name[0] == '.') continue;`
62+
>
63+
> This statement was a little shorter than what it should have been, which is
64+
>
65+
> `if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) continue;
66+
>
67+
> but hey, it was easy.
68+
>
69+
> Two things resulted.
70+
>
71+
> First, a bad precedent was set. A lot of other lazy programmers introduced bugs by making the same simplification. Actual files beginning with periods are often skipped when they should be counted.
72+
>
73+
> Second, and much worse, the idea of a "hidden" or "dot" file was created. As a consequence, more lazy programmers started dropping files into everyone's home directory. I don't have all that much stuff installed on the machine I'm using to type this, but my home directory has about a hundred dot files and I don't even know what most of them are or whether they're still needed. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge.
74+
>
75+
> I'm pretty sure the concept of a hidden file was an unintended consequence. It was certainly a mistake.
76+
>
77+
> How many bugs and wasted CPU cycles and instances of human frustration (not to mention bad design) have resulted from that one small shortcut about 40 years ago?
78+
>
79+
> Keep that in mind next time you want to cut a corner in your code.
80+
>
81+
> (For those who object that dot files serve a purpose, I don't dispute that but counter that it's the files that serve the purpose, not the convention for their names. They could just as easily be in $HOME/cfg or $HOME/lib, which is what we did in Plan 9, which had no dot files. Lessons can be learned.)
82+
>
83+
> Aug 2, 2012
84+
85+
The more you know!
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Bandit Level 4 → Level 5
3+
date: 2025-01-16 14:00:00 +/-0600
4+
category: [OverTheWire, Bandit]
5+
tags: [overthewire, bandit, writeups, training]
6+
description: OverTheWire Bandit Level 4 → Level 5
7+
---
8+
9+
> ssh bandit4@bandit.labs.overthewire.org -p 2220
10+
>
11+
> The password for the next level is stored in the only human-readable file in the **inhere** directory. Tip: if your terminal is messed up, try the “reset” command.
12+
{: .prompt-info }
13+
14+
## Poking Around
15+
Let's take a look at the server now.
16+
17+
```terminal
18+
19+
bandit4@bandit:~$ ls
20+
inhere
21+
bandit4@bandit:~$ cd inhere
22+
bandit4@bandit:~/inhere$ ls
23+
-file00 -file01 -file02 -file03 -file04 -file05 -file06 -file07 -file08 -file09
24+
```
25+
26+
Now, we're looking for the only human-readable file. While we could `cat` every single file, we run the risk of breaking our terminal if we output binary data. So, let's use the `file` command to figure out the file type!
27+
28+
Now, remembering the lessons we learned earlier, if the file starts with '-' it is going to be interpreted as a flag, so instead lets prepend `./` to the file names.
29+
30+
Also, instead of just looking at each file one after another, let's use the wildcard `*` to designate that I want to use every single file in the directory.
31+
32+
```terminal
33+
34+
bandit4@bandit:~/inhere$ file ./*
35+
./-file00: data
36+
./-file01: data
37+
./-file02: data
38+
./-file03: data
39+
./-file04: data
40+
./-file05: data
41+
./-file06: data
42+
./-file07: ASCII text
43+
./-file08: data
44+
./-file09: data
45+
```
46+
47+
Looks like `-file07` is the one we want.
48+
49+
### The Solution
50+
```terminal
51+
52+
bandit4@bandit:~/inhere$ cat ./-file07
53+
{hidden in accordance with game rules}
54+
```

0 commit comments

Comments
 (0)