Capstone Engagement
Assessment, Analysis, �and Hardening of a Vulnerable System
Prepared By: Sooji Lee, Aug 12, 2021
Table of Contents
This document contains the following sections:
01
02
03
04
Network Topology
Red Team: Security Assessment
Blue Team: Log Analysis and Attack Characterization
Hardening: Proposed Alarms and Mitigation Strategies
Network Topology
3
Network Topology
Network
Address Range: 192.168.1.0/24
Netmask: 255.255.255.0
Gateway: 192.168.1.1
Machines
IPv4: 192.168.1.1
OS: Windows
Hostname: (Red vs Blue) ML-REFVM-684427
IPv4: 192.168.1.105
OS: Linux
Hostname: Capstone
IPv4: 192.168.1.100
OS: Linux
Hostname: ELK
IPv4: 192.168.1.90
OS: Linux
Hostname: Kali
[Insert Here]
Use draw.io to create a diagram of the network.
Add your diagram to this slide and fill out the data in the sidebar.
Red Team
Security Assessment
5
Recon: Describing the Target
Nmap identified the following hosts on the network:
Hostname | IP Address | Role on Network |
(Red vs Blue) ML-REFVM-684427 | 192.168.1.1 | Virtual Host Machine that acts as a gateway to all the other VM and Servers via Hyper-V manager tool. Also connected ELK server via Kibana web interface |
Kali | 192.168.1.90 | Red Team Acts as the attacker’s machine |
ELK | 192.168.1.100 | Centralized logging server that would manage the logs of Capstone web server with ELK (filebeat, metricbeat, packetbeat). |
Capstone | 192.168.1.105 | Blue Team Acts as a vulnerable target Web server |
Vulnerability Assessment
The assessment uncovered the following critical vulnerabilities in the target:
Vulnerability | Description | Impact |
Open Port 22 (SSH) & 80 (HTTP) | Unnecessary open ports can allow attackers to access private information and increase vulnerability risks. Also, Port 80 is not recommended for web, as it’s not secure enough. | For Port 22, this allows attackers possible gain of control over the system through SSH. For Port 80, it’s not recommended to use if the web server contains any sensitive data |
CWE-23: Relative Path Traversal Common Weakness Enumeration (2021, July 20) CWE-23: Relative Path Traversal https://cwe.mitre.org/data/definitions/23.html | The software uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. | This allows attackers to gain knowledge of the hidden directories on the system |
Vulnerability Assessment
The assessment uncovered the following critical vulnerabilities in the target:
Vulnerability | Description | Impact |
CWE-307: Improper Restriction of Excessive Authentication Attempts Common Weakness Enumeration (2021, July 20) CWE-307: Improper Restriction of Excessive Authentication Attempts http://cwe.mitre.org/data/definitions/307.html | The software does not implement sufficient measures to prevent multiple failed authentication attempts within in a short time frame, making it more susceptible to brute force attacks. | This allows attacker to use brute force attack without any limitations to obtain credentials. |
CWE-434: Unrestricted Upload of File with Dangerous Type Common Weakness Enumeration (2021, July 20) CWE-434: Unrestricted Upload of File with Dangerous Type https://cwe.mitre.org/data/definitions/434.html | The software allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment. This can also be seen as LFI (Local File Inclusion) vulnerability. | This allows attacker to upload any malicious files on to the system that can increase the exploitation risk to the server. |
Vulnerability Assessment
The assessment uncovered the following critical vulnerabilities in the target:
Vulnerability | Description | Impact |
CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program (‘PHP Remote File Inclusion’) Common Weakness Enumeration (2021, July 20) CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program (‘PHP Remote File Inclusion’) http://cwe.mitre.org/data/definitions/98.html | The PHP application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in "require," "include," or similar functions. | This allows the attacker to use remote file inclusion to be able to run code on a server |
Exploitation: [Open Port 22 (SSH) & 80 (HTTP)]
Tools & Processes
I used nmap to scan for the open ports and services in the network.
Command used:
Nmap –sS 192.168.1.105
01
02
Achievements
Found that this IP address had open port 22 & 80.
Exploitation: [CWE-23: Relative Path Traversal]
Tools & Processes
I used dirb command to launch an attack against the web server. DIRB command is used to find existing and/or hidden web directories.
Command used:
Dirb http://192.168.1.105
01
02
Achievements
This command gave 2 hidden directories within the server.
Exploitation: [CWE-307: Improper Restriction of Excessive Authentication Attempts]
Tools & Processes
I used hydra command to run a brute force attack on secret_folder directories that was discovered when clicking through the website
Command used:
hydra -l ashton -P /usr/share/wordlists/rockyou.txt -s 80 -vV 192.168.1.105 http-get /company_folders/secret_folder
01
02
Achievements
With this command, it revealed the credentials
To the secret_folder directory
Exploitation: [CWE-434: Unrestricted Upload of File with Dangerous Type]
Tools & Processes
With the secret_folder directory exposed, I was able to move into the actual web server directory where I could have access to the server.
01
02
Achievements
I was able to drag and drop the malicious php shell script to the web server
Screenshot on the next slide
Exploitation: [CWE-434: Unrestricted Upload of File with Dangerous Type]
Exploitation: [CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program (‘PHP Remote File Inclusion’)]
Tools & Processes
Able to upload a reverse shell code without the server restricting the input before its usage.
01
02
Achievements
Once the code was executed, it granted access to the target server using a reverse shell.
Blue Team
Log Analysis and �Attack Characterization
16
Analysis: Identifying the Port Scan
Analysis: Identifying the Port Scan
Analysis: Finding the Request for the Hidden Directory
Analysis: Finding the Request for the Hidden Directory
Analysis: Finding the Request for the Hidden Directory
Analysis: Finding the Request for the Hidden Directory
Analysis: Uncovering the Brute Force Attack
Analysis: Uncovering the Brute Force Attack
Analysis: Finding the WebDAV Connection
Blue Team
Proposed Alarms and �Mitigation Strategies
26
Mitigation: Blocking the Port Scan
We can setup an alarm when detecting more than 10 port scans in a minute and also when there is 100 consecutive ICMP requests from a single source of IP.
Most of today’s firewalls and IDS/IPS systems can detect these types of port scanning and drop the packets in real-time. (and/or take an action of what is configured to do so.)
To mitigate port scans, we can set a firewall and/or IDS/IPS in our network, which can automatically take action when it detects port scanning.
Also, we can configure whitelisted IPs so that only whom are authorized can have access to the specific ports, and deny all the other traffics that are not configured.
System Hardening
Alarm
Mitigation: Finding the Request for the Hidden Directory
We can setup an alarm when detecting any machine that tries to request for an access to a specific directory or file.
The threshold for this should be 1 or more attempt for these kinds of hidden directories or files
The best practice to harden the system with these types of attack, is to just remove high risk directories and files from the web server, where these are not accessible from the public network.
You can use:
rm –r ../company_files command to remove an item or
mv –r ../company_files other_location to move an item to different location.
System Hardening
Alarm
Mitigation: Preventing Brute Force Attacks
Alert can be set when it detects 5 attempts of log-in within an 10 minutes of time period.
Another way of creating an alarm is when there is a Status code of 401 detected as the response from our server where threshold is 20 attempts in an hour.
Also, we can have alert where ‘User_agent.original’ value includes ‘hydra’
To block brute force attacks, we can configure our firewall or IDS/IPS systems to limit failed login attempts, and also limit the logins to the whitelisted IP addresses.
When the threshold has been reached, we can have the web server display a warning or a lockout message and have all the source IP from that specific IP to be blocked off from our network for a certain period of time.
System Hardening
Alarm
Mitigation: Detecting the WebDAV Connection
We can have alarm set when this directory is being accessed by an IP source that should not have access to this directory.
(As a good practice, all the external source IP should be blacklisted for this directory)
Alarm should go off when there is threshold of 1. Any attempt should trigger the alarm.
This directory should not be accessible from the web server or the web interface.
We can block all the traffic for this directory and only set designated whitelisted IPs to have access to this directory.
Firewalls and IDS/IPS can restrict the traffic and drop the packets in real-time.
System Hardening
Alarm
Mitigation: Identifying Reverse Shell Uploads
We can set the alarm for any ‘.php’ file that is uploaded to the server.
The alarm should trigger when there is any attempt to upload ‘.php’ file.
To harden the system, remove ability to upload files to this directory over the web.
Also, have only Admin of the local web server have authority to upload the file. (require of authentication)
System Hardening
Alarm
32