#               Overwrite Bandit level 12

![](https://cdn.hashnode.com/uploads/covers/6676c539ed293927a99fb0a5/99d06de4-612f-4ff6-86fc-aa3f332c3753.png align="center")

## **Bandit level 12**

Connect to the server:

```plaintext
ssh -p 2220 bandit12@bandit.labs.overthewire.org
```

using secure shell to connect to [**bandit.labs.overthewire.org**](http://bandit.labs.overthewire.org) through port 2220 with the username : bandit12

```plaintext
cd /tmp
mkdir example
cd
cp data.txt /tmp/example
```

Here we're moving to the /tmp directory and creating a sub-directory called example, then copying the file to /tmp/example.

```plaintext
file data.txt
```

file => checking what kind of file data.txt is

```plaintext
xxd -r data.txt > data
```

xxd -r => reversing the hex data back to the binary form

The `>` operator => redirects the data output to a new file

xxd -r data.txt > data => reversing the hex data back to the binary form and put the binary form to a new file called data.

```plaintext
file data
```

When we're checking the file data again, we're gonna find out that the data was a gzip compressed data. So for the next step we gonna change the name to data.gz so that we can decode the data using gzip.

```plaintext
mv data data.gz
```

mv => move (rename) files

mv data data.gz => we're changing the files name from data to data.gz

```plaintext
gzip -d data.gz
```

gzip -d = decode the gzip's data.

```plaintext
file data
```

when we check the file type again we'll find out that it was a bzip2 data. Now, we just need to rename the file again to [data.bz](http://data.bz) - in order to use bzip2 to decode the data.

```plaintext
mv data data.bz
bzip2 -d data.bz
```

we're changing the data's name and using bzip2 -d to decode the data

### So, u'll notice that if we use the [file](http://file.data) data again, it will says that its a gzip compressed data again. So because i think i already show you how to decode it, you can just do it all over again.

when you use file data again and you reached the data : POSIX tar achive (GNU), you can decode it using this command. Dont forget to change the file to tar datatype

```plaintext
mv data data.tar
tar xf data.tar
```

Basically, we're extracting the contents of the `data.tar` archive.

`tar` => The command used to manage archive files.

`x` => Extracts the contents of the archive.

`f` => Tells `tar` that the next argument specifies the archive filename.

`data.tar` => The archive file we want to extract.

### At the end, after reaching the climax of this repetitive task. When you use file data, its gonna shows you that the data : ASCII text. That's when we finally finished our job and can just use cat command to display the password.

![](https://cdn.hashnode.com/uploads/covers/6676c539ed293927a99fb0a5/7a112cec-b820-43d8-8086-3c74d426fedf.png align="center")

![](https://cdn.hashnode.com/uploads/covers/6676c539ed293927a99fb0a5/1ff84a54-c33d-4177-a7f1-4e1aaafcb1b4.png align="center")

![](https://cdn.hashnode.com/uploads/covers/6676c539ed293927a99fb0a5/22d75aa4-af56-49ba-9efd-f29bb3f1f068.png align="center")

> **“The Moment You Think of Giving Up, Think of the Reason Why You Held on So Long.” ~ Natsu Dragneel, *Fairy Tail***
