1 of 32

Capstone Engagement

Assessment, Analysis, �and Hardening of a Vulnerable System

Prepared By: Sooji Lee, Aug 12, 2021

2 of 32

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

3 of 32

Network Topology

3

4 of 32

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.

​

​

5 of 32

Red Team

Security Assessment

​

5

6 of 32

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

7 of 32

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

8 of 32

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.

9 of 32

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

10 of 32

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.

11 of 32

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.

  • server-status
  • webdav directories

12 of 32

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

  • Login: ashton
  • Password: leopoldo

To the secret_folder directory

13 of 32

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

14 of 32

Exploitation: [CWE-434: Unrestricted Upload of File with Dangerous Type]

15 of 32

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.

16 of 32

Blue Team

Log Analysis and �Attack Characterization

16

17 of 32

Analysis: Identifying the Port Scan

  • The port scan occurred around 3:00PM.
  • Total of 20,008 packets were sent from the IP address 192.168.1.90.
  • This indicated that it was port scan when I’ve looked at the destination.port. There were thousands of requests for all different port numbers (screenshot on the next slide)

18 of 32

Analysis: Identifying the Port Scan

19 of 32

Analysis: Finding the Request for the Hidden Directory

  • 38,200 requests were made at around 3:30pm.
  • Status code 404: Page / File not found

20 of 32

Analysis: Finding the Request for the Hidden Directory

  • Seems like some kind of wordlist was used to find the existing/hidden directory from the existing web server, as ‘uri.path’ indicates many different directories were tried – and got the http status code of 404 (as it these directories does not exist).

21 of 32

Analysis: Finding the Request for the Hidden Directory

  • Also, there were 4 hits at around 4PM, specific to the secret_folder directory

22 of 32

Analysis: Finding the Request for the Hidden Directory

  • And it seems like the file name that was requested and got in was “Connect_to_corp_server” from the secret_folder. As the name of the file states, this file might be highly risky to be exposed to the attacker as it might have the list of steps of how to get into the corporation server.

23 of 32

Analysis: Uncovering the Brute Force Attack

  • There were 16,221 hits during the Brute Force Attack.
  • (you can use both filters and it gives you the same result of 16,221 hits)
  • Status code 401: Unauthorized client error

24 of 32

Analysis: Uncovering the Brute Force Attack

  • 16219 hits were made before the attacker discovered the correct password.

25 of 32

Analysis: Finding the WebDAV Connection

  • Total of 12 hits were requested to made to the webdav directory.
  • Looks like shell.php file was requested several times.

26 of 32

Blue Team

Proposed Alarms and �Mitigation Strategies

26

27 of 32

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

28 of 32

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

29 of 32

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

30 of 32

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

31 of 32

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 of 32

32