(Guide) Configure A Vulnerable Environment
(Guide) Configure A Vulnerable Environment
Environment
Table of Contents
Table of Contents .......................................................................................................... 2
Prerequisites ................................................................................................................ 3
Network Topology ......................................................................................................... 3
Vulnerable Environment ................................................................................................ 3
Overview................................................................................................................... 3
Open SSH on [project-x-email-svr] .............................................................................. 4
Detection Integration .............................................................................................. 5
Open SSH on [project-x-linux-client] ........................................................................... 5
Detection Integration .............................................................................................. 7
Create Detection Alert ............................................................................................ 8
Configure Email Connection from [project-x-email-svr] to [project-x-linux-client] ......... 12
Detection Integration ............................................................................................ 15
Enable WinRM on [project-x-win-client]..................................................................... 15
Detection Integration ............................................................................................ 15
Create Detection Alert .......................................................................................... 16
Enable RDP on [project-x-dc] .................................................................................... 20
Detection Integration ............................................................................................ 21
Setup “Sensitive File” [project-x-dc] .......................................................................... 22
Detection Integration ............................................................................................ 22
Create Detection Alert .......................................................................................... 25
Exfiltration to [project-x-attacker].............................................................................. 29
Detection Integration ............................................................................................ 29
Prerequisites
1. Baseline project-x network has been provisioned and configured.
o Guides 1 – 9 have been completed.
Network Topology
Vulnerable Environment
Overview
In this guide, we are going to perform configuration changes to make our environment
‘vulnerable’.
Depending on the size, scale, and complexity of a business network, attackers will often
leverage insecure and default configurations to their advantage. Even though these
configurations appear to be obviously insecure, you will still see some of these in
production environments. Often times, this is due to legacy systems, forgotten
infrastructure, urgency, or laziness (that one would be me).
� These configurations are intended for homelab use only and should not be applied in
production environments. Projectsecurity.io assumes no responsibility for any
communication or actions taken based on this material.
� Please make sure the Setup Wazuh Section has been completed in addition to all
other guides outlined in the Prerequisites.
Permit root login. Navigate to the #PermitRootLogin block. Uncomment and delete
prohibit-password, change to yes.
Detection Integration
[project-x-email-svr] does not have the Wazuh agent installed. This is intentional to
demonstrate how the absence of detection controls can create a gap in identifying
potentially malicious activity.
Permit root login. Navigate to the #PermitRootLogin block. Uncomment and delete
prohibit-password, change to yes.
Navigate to “Server management” “Rules”. And look up “5760” to view more detail about
this rule.
Here is a sample snapshot of a log generated when the SSH attempt fails.
Go to “Explore” “Alerting”.
Title the Monitor “3 Failed SSH Attempts”. Leave everything else default.
Scroll down to “Data source”. Add the following for the Index, hit the Enter key after typing:
wazuh-alerts-4.x-*
@timestamp
Next, we can add a query to select what logs and log fields we would like to monitor.
Based on a sample log of a failed ssh attempt, we can construct a query to monitor specific
field / value key-pairs.
� Where would you get sample logs?: We can populate sample logs by emulating the
behavior (failing SSH attempts) and having our Wazuh agent send the logs. We can also
use open-source rules / log samples to generate logs.
Based on the above sample log, let’s craft a query to select based on the “sshd” process
name and the “authentication_failed” rule group.
Your “Data filter” tab should now look something like this.
Add the following conditions to the Trigger. We set the “Severity level” to 3 (Medium) and
the “Trigger condition” above 2.
� So what we are doing here… Once we get more than 2 logs that have met the following
query conditions from above, an alert will be generated.
There’s also an “Actions” option. Here we could create an Email, Slack, or Microsoft Teams
notification of the alert. We could also launch a playbook that would follow a specific
instruction set to analyze, investigate, or isolate a host. We are not going to configure this
section. (We will in future modules!)
Let’s setup and configure postfix on [project-x-linux-client] so we can send emails to the
email server, leveraging Postfix again.
Install postfix and the mailutils utility to interact with your email inbox.
Choose “Internet Site” Leave the “System mail name:” the default linux-client.
Navigate to the /postfix/main.cf configuration file:
my_domain = corp.project-x-dc.com
home_mailbox = Maildir/
virtual_alias_maps=hash:/etc/postfix/virtual
[email protected] janed
� Here we are routing any email that comes from the email-svr address to janed.
mkdir -p ~/Maildir/{cur,new,tmp}
To interact with mail being delivered, we will use the mail package. mail will look for a
variable called MAIL to find mail for your user. Let’s ensure the MAIL variable is set
regardless of how the account is accessed:
source /etc/profile.d/mail.sh
Restart Postfix:
Detection Integration
[project-x-email-svr] does not have the Wazuh agent installed. This is intentional to
demonstrate how the absence of detection controls can create a gap in identifying
potentially malicious activity.
Enable-PSRemoting -force
Set-Item wsman:\localhost\client\trustedhosts *
Restart-Service WinRM
Detection Integration
An Event ID does not exist for Enabling Win-RM as a service. However, we can detect Win-
RM logins through the Event ID 4624 with a “logonProcessName” of Kerberos as WinRM
uses Kerberos.
Once we have enabled Security Windows logs (this should have been done in the Setup
Wazuh section), we should automatically get Windows Event Logs.
Wazuh has a built-in rule detection to detect successful and unsuccessful authentication
attempts into a Windows machine. The Windows Security Event IDs are 4624 (for
successful) and 4624 (for unsuccessful).
Here is a sample snapshot of a log generated when the WinRM attempt was successful.
data.win.eventdata.logonProcessName: Kerberos
Here we can see the logonProcessName, the computer that was logged into, the EventID
and the system message from a successful WinRM logon.
Go to “Explore” “Alerting”.
Select the “Monitors” tab on the top left.
Scroll down to “Data source”. Add the following for the Index, hit the Enter key after typing:
wazuh-alerts-4.x-*
Next, we can add a query to select what logs and log fields we would like to monitor.
Based on a sample log of a WinRM attempt, we can construct a query to monitor specific
field / value key-pairs.
Your “Data filter” tab should now look something like this.
Detection Integration
Wazuh has a built-in rule detection to detect successful and unsuccessful authentication
attempts into a Windows machine. The Windows Security Event IDs are 4624 (for
successful) and 4624 (for unsuccessful).
Navigate to “Server management” “Rules”. And look up “92653” to view more detail
about this rule.
Here is a sample snapshot of a log generated when the RDP attempt was successful.
Here we can see in the rule.description, that a successful logon attempt has been
made.
Navigate inside the folder Right-click “New” “Text File” Name the file “secrets”.
Add whatever content you would like. For this example, I added Deeboodah!.
Detection Integration
Navigate to “Server management” “Endpoint Groups” Select the “Windows” Agent
Group.
Select the “Files” tab agent.conf Select the Pencil Icon to edit the file.
<syscheck>
<frequency>60</frequency>
</syscheck>
Under Inventory there should be a new file path populated. Make sure the [project-x-dc
agent] is selected on the right.
Navigating to the Events tab, if we were to change the content inside the secrets.txt file, we
would have an event populate showcasing that the file has been modified.
Create Detection Alert
Let’s create an alert for accessing the secrets.txt file. This time, we are going to use the
local_rules.xml file to define a custom rule to monitor for changes occurring.
<group name="syscheck">
<field name="file">secrets.txt</field>
<match>modified</match>
</rule>
</group>
Go to “Explore” “Alerting”.
Scroll down to “Data source”. Add the following for the Index, hit the Enter key after typing:
wazuh-alerts-4.x-*
@timestamp
Next, we can add a query to select what logs and log fields we would like to monitor.
Based on a sample log of a modified file attempt, we can construct a query to monitor
specific field / value key-pairs.
Your “Data filter” tab should now look something like this.
Add the following conditions to the Trigger. We set the “Severity level” to 2 (High) and the
“Trigger condition” above 1.
Scroll to the bottom and Select “Create”.
Exfiltration to [project-x-attacker]
The scp (Secure Copy) command-line utility allows you to copy files and directories
between two systems over the SSH protocol. This tool will be used to exfiltrate the
secrets.txt file to our [project-x-attacker] machine.
Create a new file under the Kali Machine, this is where we will copy our secrets.txt file to:
touch /home/attacker/my_exfil.txt
Detection Integration
The above detection will be relied upon to detect changes to the secrets.txt file.
Go back to Powershell:
Set-ItemProperty -Path
"HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parame
ters" -Name AllowInsecureGuestAuth -Value 1 -Force