• We just launched and are currently in beta. Join us as we build and grow the community.

Insanity: 1 Vulnhub Walkthrough

SrJavaEdit

Rogue Agent
S Rep
0
0
0
Rep
0
S Vouches
0
0
0
Vouches
0
Posts
136
Likes
148
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 500 XP
Today we are going to solve another boot2root challenge called “Insanity: 1“. It’s available at VulnHub for penetration testing and you can download it from here.

The merit of making this lab is due to Thomas Williams. Let’s start and learn how to break it down successfully.

Level: Hard

Penetration Testing Methodology

Reconnaissance

  • Netdiscover
  • Nmap

Enumeration

  • Dirsearch
  • Wireshark

Exploiting

  • SQL Injection through e-mails
  • Password theft in database
  • Weak hash cracking

Privilege Escalation

  • Cracking to passwords stored in Firefox
  • Capture the flag

Walkthrough

Reconnaissance

We are looking for the machine with netdiscover

Code:
netdiscover -i ethX

1.png


So, we put the IP address in our “/etc/hosts” file and start by running the map of all the ports with operating system detection, software versions, scripts and traceroute.

Code:
nmap -A –p- insanity.vh

2.png


Enumeration

The recognition and enumeration of vulnerable services have been the hardest part of this machine. Since it had many services to which they managed to entangle you, turning out to be all of them (except one) rabbit holes.

Some evidence of these services (rabbit hole):

FTP:

3.png


Bludit (From here we will list the user “Otis”.):

4.png


phpMyAdmin:

5.png


Having seen the above, we will go directly to the correct and vulnerable services.We start with the organization’s web service, a hosting service.

6.png


We puzzled with dirsearch and found several directories, but we will focus only on two “/monitoring/” and “/webmail/“.

7.png


Well, we used the user “otis” and the password “123456” (I took it out with guessing).

8.png


We will enter a panel are monitoring the internal server, we see that we can add new servers.

9.png


We insert our IP (it can be another one that is operative) and we see that it marks us “Status: UP“. What does this tell us? Well, the application below is running a ping to our machine to check if it is on.

10.png


We use dirsearch again, this time we will fuze the content of “/monitoring/”.

We go through the directories obtained until we reach the directory “/monitoring/class/“.

11.png


We access the directory and we find what we already imagined, a “ping.php” file.

12.png


We open Wireshark and see that the machine does indeed execute a ping. Do you think the same as me? Of course, we do! A command injection!

13.png


Let’s do as usual, a proof of concept.

14.png


We wait for it to run, but we see that it does not work (Status: DOWN). We contrast this information with Wireshark and see that it does not move either, so we are in another “rabbit hole“.

15.png


Well, nothing, we continue with the other service. Now we have a “SquirrelMail” in version 1.4.22, if you look for exploit you will find that it is vulnerable to remote code execution (RCE), but I already advance you that it will not work either xD.

16.png


We use the same credentials, access the “Inbox” and see that emails with errors are arriving.
Attention! These emails only appear if the server is “DOWN”
.

17.png


We read one of them, if we look at it, it is structured in 4 columns… This is something that called my attention a lot, since it seems to be loading this information through a database.

18.png


Seeing this, I lost my mind and came up with the crazy idea of launching a payload list of SQL Injection (/usr/share/wfuzz/wordlist/vulns/sql_inj.txt).

Configuration Attack:

19.png


Executed attack:

20.png


We are checking all the emails that we receive, we find this one that shows “Localhost“, therefore, the site is vulnerable to SQL Injection.

21.png


We do another test, this time we list the hostname and version of MariaDB.

22.png


Exploiting

We continue to exploit the vulnerability, although this would be faster by posting only 3 photos, I think it is worth seeing all these images, which will help us learn how to exploit SQL injection without any tools.

Obtain user and database:

23.png


Obtain all databases:

24.png


Obtain all tables:

25.png


Obtain all the columns in a table:

26.png


Dump users, passwords and emails:

27.png


After trying to crack the hashes of the two (hidden) users, it is not possible to obtain it even with JTR, Hascat or other online tools. Everything looks like another “rabbit hole“.

We continue to list and find these two hashes in the “mysql” database.

28.png


The 2nd hash does not correspond to that of a MySQL, we use the online tool “hashes.com” and obtain the password in plain text.

29.png


We logged in through SSH and great! We are in!

30.png


Privilege Escalation (root)

We do an “ls -lna” and see that we have a “Mozilla Firefox” folder, very very rare.

Whenever you see software folders, check it out, because it’s not normal.

31.png


We check if the browser has been storing user passwords. How to check this? As simple as listing these 4 files.

32.png


If these files exist, it means that they contain passwords and we can use a tool “Firefox_Decrypt” to obtain the passwords in plain.

We download the tool, choose the 2nd option and we will NOT give you a password when you ask for the “Master Password”.

We will get some credentials in the “root” user plane.

33.png


We try to authenticate with the user “root” and the password obtained and…. Yes! we are root!

We read the flag and have a good coffee.

34.png


Author: David UtĂłn is Penetration Tester and security auditor for Web applications, perimeter networks, internal and industrial corporate infrastructures, and wireless networks. Contacted on LinkedInand Twitter.
 

452,292

323,526

323,535

Top