HackMyVM | Alzheimer

In this walkthrough, I demonstrate how I obtained complete ownership of Alzheimer from HackMyVM
In: HackMyVM, Attack, CTF, Home Lab, Linux, Easy Challenge
ℹ️
I keep all of my distrusted hosts from platforms like HackMyVM on a segmented VLAN -- 10.9.9.0/24 -- that has no internet access

Nmap Results

# Nmap 7.94SVN scan initiated Mon Nov 25 15:06:49 2024 as: /usr/lib/nmap/nmap -Pn -p- --min-rate 2000 -sC -sV -oN nmap-scan.txt 10.9.9.14
Nmap scan report for 10.9.9.14
Host is up (0.00043s latency).
Not shown: 65532 closed tcp ports (reset)
PORT   STATE    SERVICE VERSION
21/tcp open     ftp     vsftpd 3.0.3
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:10.6.6.9
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 5
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
22/tcp filtered ssh
80/tcp filtered http
Service Info: OS: Unix

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Mon Nov 25 15:06:51 2024 -- 1 IP address (1 host up) scanned in 1.82 seconds





Service Enumeration

TCP/21

We have anonymous access to the FTP server and .secretnote.txt which looks like it has a port knock sequence
🛑
If you're using Proxmox as your hypervisor, as I am, I had to boot into single user mode and correct the interface name from enp0s3 to ens18 due to the driver change on the NIC when importing the VM.

However, enp0s3 is also hard-coded in /etc/knockd.conf, so you'll need to boot back into single user mode and change it there as well.

Port Knocking

for port in {1000,2000,3000}; do sudo hping3 10.9.9.14 -n -c 1 -i 1 -S -p "$port"; done

Use the port knocking sequence described in .secretnote.txt

Both of the filtered ports are now open



TCP/80

Possible username: medusa
Looks like morse code
Not sure what to make of it just yet, but I'll make a note of it



Gobuster Enumeration

Directories and Files

gobuster dir -u http://10.9.9.14/ -x txt -w /usr/share/seclists/Discovery/Web-Content/big.txt -t 100 -r -o alzheimer.txt
/admin                (Status: 403) [Size: 169]
/home                 (Status: 200) [Size: 34]
/secret               (Status: 200) [Size: 44]
💡
Combing through both folders, /home is a dead end. /secret has a /secret/home sub-directory, but is also a dead end. We know the password is supposed to be in a .txt file.

The only other logical place to check for files would be FTP, in case issuing the port knock sequence did anything special there.





Exploit

Port Knock to SSH

Rechecking FTP

No new files, but we can see that is has been updated by looking at its timestamp, whereas it was Oct 03 2020 before
Indeed, it looks like the port knocking sequence causes this string to be appended to the file, which is probably the password





Post-Exploit Enumeration

Operating Environment

OS & Kernel

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Linux alzheimer 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux    

Current User

uid=1000(medusa) gid=1000(medusa) groups=1000(medusa),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev)

Matching Defaults entries for medusa on alzheimer:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User medusa may run the following commands on alzheimer:
    (ALL) NOPASSWD: /bin/id    



Users and Groups

Local Users

medusa:x:1000:1000:medusa,,,:/home/medusa:/bin/bash    

Local Groups

cdrom:x:24:medusa
floppy:x:25:medusa
audio:x:29:medusa
dip:x:30:medusa
video:x:44:medusa
plugdev:x:46:medusa
netdev:x:109:medusa
medusa:x:1000:    



Network Configurations

Network Interfaces

ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether bc:24:11:12:2a:d1 brd ff:ff:ff:ff:ff:ff
    inet 10.9.9.14/24 brd 10.9.9.255 scope global dynamic ens18
       valid_lft 5755sec preferred_lft 5755sec
    inet6 fe80::be24:11ff:fe12:2ad1/64 scope link 
       valid_lft forever preferred_lft forever    



Interesting Files

/usr/sbin/capsh

-rwsr-sr-x 1 root root 26776 Feb  6  2019 /usr/sbin/capsh    





Privilege Escalation

SUID Abuse

capsh | GTFOBins



Flags

User

HMVrespectmemories    

Root

HMVlovememories    
Comments
More from 0xBEN
Table of Contents
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to 0xBEN.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.