Final Engagement
Attack, Defense & Analysis of a Vulnerable Network
Team Gamma:
Katie Donovan, Spencer Enriquez, Jack Cote, Ramzi Nasnas
1
Table of Contents - Red Team
This document contains the following resources:
Network Topology & Critical Vulnerabilities
Exploits Used
Avoiding Detection
Maintaining Access
2
Network Topology
& Critical Vulnerabilities
3
Network Topology
Network
Add Range:192.168.1.0/24
Netmask:.0.0.0.255
Gateway:192.168.1.1�
Virtual Machines:
IPv4:196.168.1.90
OS:Linux
Hostname: Kali
IPv4:192.168.1.100
OS: Linux
Hostname: ELK
IPv4:192,168.1.105
OS: Linux
Hostname: Capstone
IPv4: 192.168.1.110
OS: linux 3.2 - 4.9
Hostname: Target1
IPv4: 192.168.1.115
OS Linux 3.2 -4.9
Hostname: Target2
Critical Vulnerabilities: Target 1
Our assessment uncovered the following critical vulnerabilities in Target 1.
5
Vulnerability | Description | Impact |
Allows enumeration of user names. | medium | |
Weak Password | User michael’s password was also michael | High |
MySQL root password in wp-config.php file in plaintext | allowed easy extraction and unhashing of steven’s password. | High |
Improper sudo setting for python user �CVE-2006-0151 | steven can execute python scripts as root which allows for privilege escalation to root using similar to: python -c 'import pty;pty.spawn("/bin/bash")' | Critical |
wordpress xmlrpc �CVE-2020-28036 and others https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=xml-rpc | Allows privilege escalation XML-RPC to comment on a post. | High |
wordpress wp-cron.php�CVE-2013-6991 | Cross-site scripting (XSS) vulnerability allows remote attackers to inject arbitrary web script | Medium |
Target 1
Critical Vulnerabilities: Target 2
Our assessment uncovered the following critical vulnerabilities in Target 2.
6
Vulnerability | Description | Impact |
PHPMailer (versions 5.2.18 or earlier) remote code execution vulnerability | The ‘mailSend’ function can allow attackers to execute code in the parameters of the mail command. This can be used to upload “backdoor” malware and obtain a reverse shell as www-data. | High |
MySql root password in wp-config.php file, and this file is readable | Once in the system, this allows the attacker to obtain the mysql login | High |
Older versions of mySQL have poor protection against UDFs (user-defined functions). This enables the attacker to cause mySQL to run shell commands. | High | |
Poor permissions configuration on services | mySQL runs as root. Combined with the above vulnerability, this means the attacker can execute commands as root. | Critical |
Target 2
Vulnerabilities Details
Backup
7
Scannning Target 1 - nmap & wpscan details
8
user names scan
vulnerabilities scan
Target 1
nmap ports and services scan
Scanning Target 2
9
brute forcing usernames scan
ports and services scan
Vulnerabilities scan
Target 2
Exploits Used
10
Exploitation Target 1: Weak Password
Summarize the following:
11
Target 1
Exploitation Target 1: MySQL username and pwd in the clear
12
weak password / first point of entry
Target 1
MySQL root password in the clear in php file
which allowed extraction of passwd hashes
un-hash steven’s password with john-the-ripper
With both steven’s and michael’s passwords we were able to extract the first three flags using find commands and other search techniques.
Exploitation Target 1: - python root privilege CVE-2006-0151
13
Target 1
steven can execute python code at root level which allows easy escalation to root privilege
Exploitation Target 2: CVE-2016-10033 (Slide 1)
Also known as: “PHPMailer (5.2.18) remote code execution vulnerability”
14
2. Navigate to the backdoor in a web browser and run a simple command to verify it is working as intended:
Target 2
Exploitation Target 2: CVE-2016-10033 (Slide 2)
Also known as: “PHPMailer (5.2.18) remote code execution vulnerability”
15
3. Start a listener on Kali (192.168.1.90), port 4444
4. Return to the backdoor and run the command to grant a reverse shell:
Target 2
Exploitation Target 2: CVE-2016-10033 (Slide 3)
Also known as: “PHPMailer (5.2.18) remote code execution vulnerability”
16
5. Return to Kali (Metasploit). I now have a reverse shell as www-data:
6. Upgrade the reverse shell to Meterpreter by running:
ctrl + Z
Yes
sessions -u 1
sessions -i 2
Target 2
Exploitation Target 2: CVE-2016-10033 (Flags 1-3)
Also known as: “PHPMailer (5.2.18) remote code execution vulnerability”
17
Target 2
Capture flags!
Exploitation Target 2: CVE-2016-10033 (Post Exploitation)
Also known as: “PHPMailer (5.2.18) remote code execution vulnerability”
18
6. After gaining the shell as www-data, I looked for ways to escalate to root. I found a script to search for ways to escalate privileges called linuxprivchecker.py. I used Meterpreter to upload this script to the web server, and then executed it within it.
Target 2
Exploitation Target 2: MySQL UDF vulnerability (Slide 1)
Full name: MySQL 4.x/5.0 (Linux) - User-Defined Function (UDF) Dynamic Library (2)
19
In Kali machine:
In web server as www-data:
Target 2
Exploitation Target 2: MySQL UDF vulnerability (Slide 2)
Full name: MySQL 4.x/5.0 (Linux) - User-Defined Function (UDF) Dynamic Library (2)
20
In MySQL database:
Target 2
Exploitation Target 2: Improper permissions
Details: mySQL runs as root
21
In MySQL database:
Target 2
Exploitation Target 2: Improper permissions - Flag 4
Details: mySQL runs as root
22
In web server as www-data
Target 2
Avoiding Detection
23
Stealth Exploitation of Target 1 nmap scan detection 1
Monitoring Overview
Mitigating Detection
24
Target 1
Stealth Exploitation of Target 1 nmap url enum detection
Monitoring Overview
Mitigating Detection
25
Target 1
Running a nmap scan to enumerate the URLs on wordpress on target1 using command nmap -script http-enum.nse 192.168.1.110 was detected:
** Jack’s suggestion.
Stealth Exploitation of Target 1 nmap url enum detection
Monitoring Overview
Mitigating Detection
26
Target 1
Running a nmap scan to enumerate the URLs on wordpress on target1 using command nmap -script http-enum.nse 192.168.1.110 was detected:
** Jack’s suggestion.
Stealth Exploitation of Target 1 hydra scan detection
Monitoring Overview
Mitigating Detection
27
Target 1
Running a hydra scan to brute force the password on the wordpress login using command below was detected:
Stealth Exploitation of Target 1 hydra scan detection
Monitoring Overview
Mitigating Detection
28
Target 1
Running a hydra scan to brute force the password on the wordpress login using command below was detected:
8086728:
Stealth Exploitation of Target 1 hydra scan detection
Monitoring Overview
Mitigating Detection
29
Target 1
Running a hydra scan to brute force the password on the wordpress login using command below was detected:
Stealth Exploitation of Target 1 - other vulnerabilities
Monitoring Overview
30
Target 1
Stealth Exploitation of Target 2: (PHP mailer vulnerability)
Monitoring Overview
Mitigating Detection
31
Target 2
* source: https://sysdig.com/blog/reverse-shell-falco-sysdig-secure/
Stealth Exploitation of Target 2: mySQL UDF vulnerability
Monitoring Overview
Mitigating Detection
32
Target 2
Maintaining Access
33
Backdooring the Target
Backdoor Overview
34
Target 2
Alerts Implemented
35
HTTP Request Size Monitor
36
Excessive HTTP Errors
37
CPU Usage Monitor
38
Port scan alert
39
Hardening
40
Hardening Against Broken Authentication on Target 1
Many of the exploits performed on target one were the results of poor credential strength or storage.
Credential and credential storage strengthening solves the issue
41
Target 1
Hardening Against Wordpress Enumeration on Target 1
When logging in to a Wordpress website before version 2.8.1 with an incorrect password but correct username a unique error message is displayed. This allows attackers to brute force the username field to enumerate usernames.
Updating Wordpress to a version 2.8.1 or later solves the issue
42
Target 1
Hardening Against sudo Access Control on Target 1
steven’s user account on the web server host possessed sudo rights to the scripting language python. Python is able to perform essentially any task with the right script, making python sudo rights the equivalent to root access.
Proper sudo access controls solves the issue
43
Target 1
Hardening Against PHPMailer vulnerability on Target 2
Target 2 has one major vulnerability with its installation of PHPMailer:
CVE-2016-10033 - PHPMailer remote code execution vulnerability
To patch this vulnerability, PHPMailer should be updated to a version more recent than 5.2.18.
44
Target 2
Hardening Against mySQL vulnerabilities on Target 2
As has been explained, Target 2 has three vulnerabilities with mysql. Here is how to fix them:
45
Target 2
Traffic Profile
46
Traffic Profile
Our analysis identified the following characteristics of the traffic on the network:
47
Feature | Value | Description |
Top Talkers (IP Addresses) | 172.16.4.205 (45 MB) 185.243.115.84 (26 MB) 10.0.0.201 (12 MB) 166.62.111.64 (16 MB) | Machines that sent the most traffic. |
Most Common Protocols | TCP UDP TLS | Three most common protocols on the network. |
# of Unique IP Addresses | 808 | Count of observed IP addresses. |
Subnets | 10.6.12.0/24 172.16.4.0/24 10.0.0.0/24 | Observed subnet ranges. |
# of Malware Species | 1 | Number of malware binaries identified in traffic. |
Behavioral Analysis
Purpose of Traffic on the Network
Users were observed engaging in the following kinds of activity.
�“Normal” Activity
Suspicious Activity
48
Normal Activity
49
Video Streaming (Youtube)
50
News Browsing
Summarize the following:
51
Malicious Activity
52
Suspicious Endpoint Connections
Time Thieves
53
Suspicious Endpoint Connections (Continued)
Summarize the following:
54
Illegal Bitorrent Downloads
Summarize the following:
55
The End
56
Stealth Exploitation of Target 1 hydra scan detection
http.request.method : "POST" and http.response.status_code >= 400 and source.ip: 192.168.1.90
57
Target 1
Running a hydra scan to brute force the password on the wordpress login using command below was detected: