linuxSnookums

Enumeration:

Port Scanning:

┌──(kali㉿kali)-[~/…/Machines/OffsecPG/Practice/Snookums]
└─$ sudo nmap -sCV -p- --min-rate 4000 -oA nmap/services -vv 192.168.115.58
Starting Nmap 7.95 ( https://nmap.org ) at 2025-10-04 06:43 +03
Nmap scan report for 192.168.115.58                                                                                                                       07:04:50 [41/188]
Host is up, received echo-reply ttl 61 (0.17s latency).                              
Scanned at 2025-10-04 06:43:25 +03 for 242s                                          
Not shown: 65527 filtered tcp ports (no-response)                                    
PORT      STATE SERVICE     REASON         VERSION                                                                                                                         
21/tcp    open  ftp         syn-ack ttl 61 vsftpd 3.0.2                                                                                                                    
| ftp-anon: Anonymous FTP login allowed (FTP code 230)                               
|_Can't get directory listing: TIMEOUT                                               
| ftp-syst:                                                                                                                                                                
|   STAT:                                                                            
| FTP server status:                                                                 
|      Connected to ::ffff:192.168.45.235                                            
|      Logged in as ftp                                                                                                                                                    
|      TYPE: ASCII                                                                                                                                                         
|      No session bandwidth limit                                                                                                                                          
|      Session timeout in seconds is 300                                                                                                                                   
|      Control connection is plain text                                                                                                                                    
|      Data connections will be plain text                                                                                                                                 
|      At session startup, client count was 3                                        
|      vsFTPd 3.0.2 - secure, fast, stable                                           
|_End of status                                                                                                                                                            
22/tcp    open  ssh         syn-ack ttl 61 OpenSSH 7.4 (protocol 2.0)                                                                                                      
| ssh-hostkey:                                                                       
|   2048 4a:79:67:12:c7:ec:13:3a:96:bd:d3:b4:7c:f3:95:15 (RSA)                       
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtUk/m8ssh+nfn52VkolWbpJihGyH2vdELXJv/X0HIj5hbkXnM1QgSSKltTq+cev1QtkrwtUTV3j2AD5Ftxz7ivrm0PvsGNI6QGnIxdAwCvt1OjDHoz6IGDS4kz5IcW3Q3S
mwceCwDKPA55mupKhKlKjkZyLn4+d9An50AV1Hyj+E8APALHQBQFVp7cdJe9lqj7K8dxNVo1XExUDgU3trRSGDO5bZN7C57VsHXN6MIITU9RtyMhLbxYwA6KTU8RluW1/5v7T4EnHlRZcdmbneVcefK+EK69Mgdn5L+ww/5YrWi
YbXDOUTEymWfeyoOl2LoFBD/nmSb9hayKirR4guf                                                                                                                                   
|   256 a8:a3:a7:88:cf:37:27:b5:4d:45:13:79:db:d2:ba:cb (ECDSA)                      
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOk5HGeIHhlXkWc9v507Ap0zc5wnKxhGa7WG9fWJhL/yr9bveHEBZllHErnP6vaWM4WRudCxA6z6rqnhep9wNW8=
|   256 f2:07:13:19:1f:29:de:19:48:7c:db:45:99:f9:cd:3e (ED25519)                                                                                                          
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvde70kt/TjqXRmChJ0XvKYTpljMNu6TKlAtF/S4IHL   
80/tcp    open  http        syn-ack ttl 61 Apache httpd 2.4.6 ((CentOS) PHP/5.4.16)  
|_http-title: Simple PHP Photo Gallery                                               
| http-methods:                                                                                                                                                            
|_  Supported Methods: GET HEAD POST OPTIONS                                                                                                                               
|_http-server-header: Apache/2.4.6 (CentOS) PHP/5.4.16                                                                                                                     
111/tcp   open  rpcbind     syn-ack ttl 61 2-4 (RPC #100000)                                                                                                               
|_vulners: ERROR: Script execution failed (use -d to debug)                                                                                                                
| rpcinfo:                                                                                                                                                                 
|   program version    port/proto  service                                                                                                                                 
|   100000  2,3,4        111/tcp   rpcbind                                           
|   100000  2,3,4        111/udp   rpcbind                                                                                                                                 
|   100000  3,4          111/tcp6  rpcbind
|_  100000  3,4          111/udp6  rpcbind 
139/tcp   open  netbios-ssn syn-ack ttl 61 Samba smbd 3.X - 4.X (workgroup: SAMBA)
445/tcp   open  netbios-ssn syn-ack ttl 61 Samba smbd 4.10.4 (workgroup: SAMBA)
3306/tcp  open  mysql       syn-ack ttl 61 MySQL (unauthorized)
33060/tcp open  mysqlx      syn-ack ttl 61 MySQL X protocol listener
Service Info: Host: SNOOKUMS; OS: Unix

FTP (21):

Anonymous login is present, but I could not do anything or find any useful thing.

HTTP (80):

Run directory fuzzing:

Lets explore the website:

Simple php photo gallery running on port 80, and it exposes its current version 0.8, we can search for any public exploits:

We can test if this vulnerability still exists or get fixed:

This exploit states that the application was vulnerable to LFI and if allow_url_fopen was enabled to RFI as well.

Also the vulnable endpoint is /image.php?img=.

We can test this out:

The vulnearbility still exists.

Try RFI:

Go back to our web server:

It tried to load to get test.php but did not find it.

Exploitation:

Shell as apache:

We can now pull php reverse shell from the webshells, and change the IP, and the port to get a reverse shell:

We have to put our port to something the target machine can reach out to, because sometimes if firewall is running it will block all ports except configured ones in services like http or mysql, etc.

As shown in the nmap scan that port 3306 is open, we will start our webserver to listen on that port and host our php reverse shell:

And start our listener:

Now try with shell.php instead of test.php:

We can see it will hang, because we got a shell:

Stabilize our shell:

Now we have full interactive shell.

When we read the /etc/passwd file, we will find michael presents there, but ls the home folder:

Lateral Movement to michael:

As we have seen in the gobuster that we have db.php, lets read it to maybe find any credentials, so we can resuse the password, or access the mysql database:

Try it with mysql:

We successfully authenticated to mysql as root with that password.

Lets do some enumeration:

We will find SimplePHPGal which is not a default database:

We have users tables that contains two columns.

The passwords seemes to be base64 encoded, lets decode them, and try them one by one:

Lets try this password for michael:

We are michael.

Privilege Escalation:

I will upload linpeas to perform a quick automated scan for us:

Run it:

We can make sure that this is the case:

We will find the passwd file is writable, which could help us by adding a new user as root.

First we need to generate a hashes password using openssl or any other tool:

Echo this hash to the end of the passwd file with the Caesar3 user:

We assigned the user id and group id to 0 which is the same as root.

Check if our command worked:

We will see that our newly created user at the bottom of the file.

Now swithc user to Caesar3:

We successfully rooted the box.

Read the flags:

Last updated