eCIR Labs
eCIR Labs
Scenario
The organization you work for (Wayne Enterprises) is using
Splunk as a SIEM solution to enhance its intrusion detection
capabilities. The SOC manager informed you that the
organization has been hit by an APT group. He tasked you with
responding to this incident by heavily utilizing Splunk and
all the data that it ingested.
Learning Objectives
The learning objective of this lab is to not only get
familiar with Splunk's architecture and detection
capabilities but also to learn effective Splunk search
writing.
Introduction To Splunk
Splunk's creators describe it as a solution to aggregate,
analyze and get answers from machine data. Splunk can be used
for Application Management, Operations Management, Security &
Compliance, etc.
Splunk can literally ingest almost any data from almost any
source, through both an agent-less and a forwarder approach.
Splunk Architecture Overview:
● Forwarder component
● Indexer component
● user: This role can create and edit its own saved
searches, run searches, edit its own preferences, create
and edit event types, and other similar tasks.
You will spend most of your time inside Splunk's Search &
Reporting.
Data Summary can provide you with hosts, sources or
sourcetypes on separate tabs.
Finally, this is how Events will look like.
As you write searches, you will notice that some parts of the
search string are automatically colored. The color is based
on the search syntax. Example:
Something else to consider while submitting searches is
Splunk's search modes.
https://docs.splunk.com/Documentation/Splunk/7.2.4/Search/Get
startedwithSearch
Recommended tools
● Splunk
Recommended tools
● Splunk
Tasks
Task 1: Identify any reconnaissance
activities against your network through
Splunk searches
Using Splunk's capabilities, try to identify any
reconnaissance activities performed by the APT group. Your
organization's website is imreallynotbatman.com.
Hints:
Hints:
Hints:
Hints:
Hints:
SOLUTIONS
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy, which
may be different from the one explained in the following lab.
Kali Machine
index="botsv1" earliest=0
index=botsv1 imreallynotbatman.com
The URLs being requested can be found inside the uri field.
index=botsv1 sourcetype=iis
Below are our findings so far.
https://www.threatcrowd.org/email.php?email=LILLIAN.ROSE@PO1S
0N1VY.COM
index=botsv1 sourcetype=stream:http
form_data=*username*passwd* dest_ip=192.168.250.70 | rex
field=form_data "passwd=(?<userpassword>\w+)" | stats count
by userpassword | sort - count
The search above extracts every user password and counts the
times it has been seen/used. If a password is seen more than
one time, this probably means that attackers got a hit and
used the password again to log in. This is why we are sorting
on count.
index=botsv1 sourcetype=stream:http
form_data=*username*passwd* dest_ip=192.168.250.70
src_ip=40.80.148.42 | rex field=form_data
"passwd=(?<userpassword>\w+)"| search userpassword=* | table
_time uri userpassword
The source from where the file was uploaded can easily be
identified, as follows.
index=botsv1 3791.exe
index=botsv1 3791.exe
sourcetype=XmlWinEventLog:Microsoft-Windows-Sysmon/Operationa
l
The important fields, in this case, are Hashes, CommandLine
and ParentCommandLine. You will have to add the last two
ones since they are not visible by default.
index=botsv1 3791.exe
sourcetype=XmlWinEventLog:Microsoft-Windows-Sysmon/Operationa
l EventCode=1
References:
1. https://www.slideshare.net/Splunk/splunk-data-onboarding
-overview-splunk-data-collection-architecture
2. https://www.splunk.com/en_us/training.html
Learning Objectives
The learning objective of this lab, is to learn effective
Splunk search writing and how to translate attacker TTPs into
Splunk searches.
Recommended tools
● Splunk
● Use a Chrome or Firefox browser to connect to Splunk's
web interface (http://demo.ine.local:8000)
Tasks
Task 1: Try to identify a successful
exploitation attempt without consulting with
the provided TTPs
As already mentioned the red team provided you with technical
details about some of their exploitation activities. Your SOC
manager tasked with first trying to identify a successful
exploitation attempt on your own leveraging Splunk.
Hints:
1. Malicious USB
4. Mature Ransomware
5. Code Obfuscation
Hints:
2. https://www.splunk.com/blog/2017/11/03/you-can-t-hyde-fr
om-dr-levenshtein-when-you-use-url-toolbox.html
SOLUTIONS
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy (which
may be different from the one explained in the following lab.
Kali Machine
Task 1: Try to identify a successful
exploitation attempt without consulting with
the provided TTPs
Once you are logged into Splunk's web management interface,
click the Search & Reporting application that resides on the
Apps column on your left. You should see something similar to
the below.
Before starting your investigation change the time range
picker to All time.
index=botsv1 sourcetype=stream:dns
query{}=cerberhhyed5frqa.xmfir0.win | table _time src_ip
dest_ip query{}
Based on the time included in the results above, you can give
192.168.250.100 a look as follows.
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
SourceIp="192.168.250.100"
You should see something similar to the below.
Those two spikes are certainly suspicious.
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
SourceIp="192.168.250.100" | stats count by app
osk.exe definitely looks suspicious. So, give it a closer
look by simply clicking on it.
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
app="C:\\Users\\bob.smith.WAYNECORPINC*"
Inspect the app field once again. You should see the
following.
Notice the existence of another curious looking application
C:\Users\bob.smith.WAYNECORPINC\AppData\Roaming\121214.tmp.
Give it a look by clicking on it. You should see the
following.
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
app="C:\\Users\\bob.smith.WAYNECORPINC*"
app="C:\\Users\\bob.smith.WAYNECORPINC\\AppData\\Roaming\\121
214.tmp"
Nothing curious-looking in the results, but there are
important fields that could be added to assist your
investigation, such as the CommandLine or the
ParentCommandLine one.
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
"121214.tmp" AND (ParentCommandLine=* OR CommandLine=*) |
table _time process process_id ParentProcessId ParentImage
CommandLine ParentCommandLine
You should see the following.
The earliest events are at the bottom of the table. If you
start from the first (earliest) event you will see that
wscript.exe (parent) called cmd.exe (child). In addition to
that, you can see from ParentCommandLine that wscript.exe
executed 20429.vbs.
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
"20429.vbs" AND (ParentCommandLine=* OR CommandLine=*) |
table _time process process_id ParentProcessId ParentImage
CommandLine ParentCommandLine
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
"121214.tmp"
You will come across the following.
If you submit the EE0828A4E4C195D97313BFC7D4B531F1 hash on a
search engine, you will identify that you are dealing with
Cerber ransomware.
index=botsv1
source="WinEventLog:Microsoft-Windows-Sysmon/Operational"
"*.vbs" AND (ParentCommandLine=* OR CommandLine=*) | table
_time process process_id Parent rocessId ParentImage
CommandLine ParentCommandLine
1. Identify mature ransomware activity
index="botsv1"
source="wineventlog:microsoft-windows-sysmon/operational"
EventCode=1 process=*\\vssadmin.exe | search
CommandLine="*vssadmin*" CommandLine="*Delete *"
CommandLine="*Shadows*"
1. Identify code obfuscation
index="botsv1"
source="wineventlog:microsoft-windows-sysmon/operational" |
eval len=len(CommandLine) | table User, len, CommandLine |
sort - len
Effectively Using the ELK Stack
Scenario
The organization you work for is evaluating a customized ELK
stack as a SIEM solution to enhance its intrusion detection
capabilities. The SOC manager tasked you with getting
familiar with the ELK stack and its detection capabilities.
He also tasked you with translating common attacker behavior
into ELK searches.
Learning Objectives
The learning objective of this lab, is to get familiar with
ELK stack's architecture and detection capabilities.
Introduction To ELK
Elastic's ELK is an open source stack that consists of three
applications (Elasticsearch, Logstash and Kibana) working in
synergy to provide users with end-to-end search and
visualization capabilities to analyze and investigate log
file sources in real time.
ELK's Search:
Recommended tools
● ELK
SOLUTIONS
Kali Machine
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy (which
may be different from the one explained in the following lab.
event_data.User:*
These results above do not contain all users, but only five
of them. Why so? This is because of the default Size of the
aggregation we created being five. To see all users we can
specify a larger size like fifty (50) and then press the play
button once again.
( event_data.Image:("*\\rundll32.exe" "*\\svchost.exe"
"*\\wmiprvse.exe" "*\\wmiadap.exe" "*\\smss.exe"
"*\\wininit.exe" "*\\taskhost.exe" "*\\lsass.exe"
"*\\winlogon.exe" "*\\csrss.exe" "*\\services.exe"
"*\\svchost.exe" "*\\lsm.exe" "*\\conhost.exe"
"*\\dllhost.exe" "*\\dwm.exe" "*\\spoolsv.exe"
"*\\wuauclt.exe" "*\\taskhost.exe" "*\\taskhostw.exe"
"*\\fontdrvhost.exe" "*\\searchindexer.exe"
"*\\searchprotocolhost.exe" "*\\searchfilterhost.exe"
"*\\sihost.exe") AND -event_data.Image:("*\\system32\\*"
"*\\syswow64\\*" "*\\winsxs\\*") ) OR (
event_data.TargetFilename:("*\\rundll32.exe" "*\\svchost.exe"
"*\\wmiprvse.exe" "*\\wmiadap.exe" "*\\smss.exe"
"*\\wininit.exe" "*\\taskhost.exe" "*\\lsass.exe"
"*\\winlogon.exe" "*\\csrss.exe" "*\\services.exe"
"*\\svchost.exe" "*\\lsm.exe" "*\\conhost.exe"
"*\\dllhost.exe" "*\\dwm.exe" "*\\spoolsv.exe"
"*\\wuauclt.exe" "*\\taskhost.exe" "*\\taskhostw.exe"
"*\\fontdrvhost.exe" "*\\searchindexer.exe"
"*\\searchprotocolhost.exe" "*\\searchfilterhost.exe"
"*\\sihost.exe") AND
-event_data.TargetFilename:("*\\system32\\*" "*\\syswow64\\*"
"*\\winsxs\\*") )
event_data.Image:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
event_data.TargetFilename:
C:\Users\PhisedUser\AppData\Local\Temp\65536.exe
event_data.Image:"*\\sc.exe" AND
(event_data.CommandLine:(*start* *sdshow*) OR
(event_data.CommandLine:*config* AND
event_data.CommandLine:*binPath*)) AND
event_data.IntegrityLevel:Medium
event_data.IntegrityLevel:Medium ensures that we don't get
results from privileged users (such as admins) performing
legitimate service tasks.
event_data.Image:"*\\whoami.exe" AND
(event_data.LogonId:0x3e7 OR event_data.SubjectLogonId:0x3e7
OR event_data.User:"NT AUTHORITY\\SYSTEM")
The LogonIds used in this and the previous tasks are usually
met when SYSTEM-level access is involved.
Additional Resources:
1. https://speakerdeck.com/felipead/elasticsearch-workshop
2. https://drive.google.com/file/d/0B2S_IOa0MiOHWndxWFRiUHN
oNW8/view
Suricata Fundamentals
LAB 4
Scenario
The organization you work for is considering to deploy
Suricata to enhance its traffic inspection capabilities. The
IT Security manager tasked you with thoroughly analyzing
Suricata's capabilities.
Learning Objectives
The learning objective of this lab is to get familiar with
the detection capabilities and features of Suricata.
Introduction To Suricata
Suricata is a high-performance Network IDS, IPS, and Network
Security Monitoring engine. It is open source and owned (as
well as developed) by a community-run non-profit foundation,
the Open Information Security Foundation (OISF).
● Intrusion Detection
● Intrusion Prevention
● Anomaly Detection
● GeoIP
● Multitenancy
● Multi-threading
Suricata Inputs
3. Live Input
NFQ is an inline IPS mode for Linux that works with IPTables
to send packets from kernel space into Suricata for
inspection. It is often used inline, and it requires the use
of IPTables to redirect packets to the NFQUEUE target which
allows Suricata to inspect the traffic. Drop rules will be
required in order for Suricata to drop packets.
Suricata Outputs
Notes:
● You may come across a Unified2 Suricata output. Unified2
is a Snort binary alert format. As you can imagine, this
output is used for integrating with other software that
uses Unified2. Any Unified2 output can be read using
Snort's u2spewfoo tool.
Recommended tools
● Suricata
● Wireshark
● EveBox
● jq
Tasks
Task 1: Get familiar with Suricata
configuration and configure custom rules
After Suricata is deployed, certain default configurations,
rules, and logs are applied. As an incident responder, you
should know how to apply your own Suricata configurations,
rules, and log locations, in order to make the best out of
it.
It is time to exercise.
SOLUTIONS
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy (which
may be different from the one explained in the following lab.
ls -lah /etc/suricata/rules/
more /etc/suricata/rules/emerging-trojan.rules
You should see something similar to the following.
Press the Space key multiple times, and you will be presented
with something similar to the below.
The first rule above is commented out; this means that it
won't be loaded. This could happen if a new version of this
rule has surfaced or if the threat related to this rule has
become obsolete etc.
more /etc/suricata/suricata.yaml
vim /etc/suricata/suricata.yaml
Enter /rule-path and press the Enter key
Press Shift + i
Change default-rule-path: from /etc/suricata/rules to
/root/Desktop
Change rule-files: from - emerging-malware.rules to -
customsig.rules
Press the Esc key
Enter :wq and then, press the Enter key
ifconfig
suricata -i ens5 -vv
Try it; scroll down and you will see the following.
suricata -q 0
suricata -i ens5
suricata -af-packet=ens5
2. fast.log
4. eve.json
Inside the /var/log/suricata directory, you will find a file
named eve.json.
cd /var/log/suricata
less eve.json
or
cd /var/log/suricata
less eve.json.1
Notes:
flow_id can help you correlate one event with other events
that happened on the same flow. pcap_cnt indicates the number
of the packet that triggered the alert (so you can inspect it
further with a tool like Wireshark).
vim /etc/suricata/suricata.yaml
Enter /http-log and press the Enter key
Press Shift + i
Change enabled: from no to yes
Press the Esc key
Enter :wq and then, press the Enter key
suricata -r /root/Desktop/PCAPs/tls-suricata-ids-org.pcap
ls /var/log/suricata
You will see something similar to the below.
1. fast.log
cat fast.log
less stats.log
● alert-debug
cat /var/log/suricata/eve.json | jq -c
'.event_type'|sort|uniq -c|sort -nr
You will notice that EveBox parsed the whole eve.json and
presented it to you in a much more organized way. Feel free
to look around and get familiar with EveBox's layout and
capabilities.
Additional Resources:
1. https://suricata.readthedocs.io/en/latest/output/eve/eve
-json-examplesjq.html?highlight=jq
2. https://stedolan.github.io/jq/manual/
Scenario
The organization you work for is considering deploying
Suricata to enhance its traffic inspection capabilities. The
IT Security manager provided you with some Suricata rules to
get familiar with their structure. He also provided you with
PCAP files containing malicious traffic so that you can
experiment with writing Suricata detection rules.
Learning Objectives
The learning objective of this lab is not only to get
familiar with the detection capabilities of Suricata but also
to learn effective rule writing of Suricata rules.
Each active rule consumes some of the host's CPU and memory.
Specific guidelines exist to assist effective Suricata rule
writing.
action protocol from_ip port -> to_ip port (msg:"we are under
attack by X"; content:"something"; content:"something else";
sid:10000000; rev:1;)
protocol can be: tcp, udp, icmp, ip, http, tls, smb, dns
The rule header should be alert dns $HOME_NET any -> any any
○ flow:,;
■ from_server, from_client can also be used
○ alert tcp $HOME_NET any -> $EXTERNAL_NET 4444
■ flow:established,to_server;
○ If the protocol is UDP
■ flow:to_server;
● Dsize. Allows matching using the size of the packet
payload (not http, only tcp, and udp). It is based on
TCP segment length, NOT total packet length (Wireshark
filter: tcp.len). Examples:
○ dsize:312;
○ dsize:300<>400;
content:"some thing";
content:"some|20|thing";
content:"User-Agent|3a 20|";
content:"publickey";
content:"DetoxCrypto"; http_user_agent;
content:"publickey"; http_client_body;
■ content:"whatever"; offset:5;
○ content:"whatever"; content:"something";
distance:0;
○ sid:10000000;
● revision. This field informs about the version of the
rule. Example:
○ rev:5;
● pcre:"/something/flags";
● pcre:"/^\/[a-z0-9]{6}\.php$/Ui";
● https://rules.emergingthreats.net/open/
● https://github.com/EmergingThreats/et-luajit-scripts
● https://github.com/ptresearch/AttackDetection
● Other Sources
Recommended tools
● Suricata
● Wiresharkhttp://manpages.ubuntu.com/manpages/trusty/man1
/xxd.1.html
Tasks
Task 1: Analyze the provided Suricata rules
and describe what they look for
Armed with the knowledge you obtained from section 3.
INTRODUCTION TO SURICATA RULES above, analyze the two
Suricata rules below and describe what they look for.
Rule 1:
alert dns $HOME_NET any -> any any (msg:"TROJAN X Rogue DNS
Query Observed"; dns_query; content:"searchcdn.gooogle.com";
isdataat:!1,relative;
reference:url,threatintelprovider.com/trojanx;
classtype:trojan-activity; sid:1; rev:1;)
Rule 2:
SOUTIONS
Below, you can find solutions for every task of this lab. As
a reminder, you can follow your own strategy, which may be
different from the one explained in the following lab.
alert dns $HOME_NET any -> any any (msg:"TROJAN X Rogue DNS
Query Observed" dns_query;
content:"default27061330-a.akamaihd.net";
isdataat:!1,relative;
reference:url,threatintelprovider.com/trojanx;
classtype:trojan-activity; sid:1; rev:1;)
Put these two (2) rules inside the local.rules file residing
in the /etc/suricata/rules directory. You can do so, by
executing-
nano /etc/suricata/rules/local.rules
Now, it's time to test the rule above. You can do so, as
follows.
cd Desktop
./automate_suricata.sh ./PCAPs/Sofacy.pcap
It's time to test the rule above. You can do so, as follows.
cd Desktop
./automate_suricata.sh ./PCAPs/Citi.pcap
You should see the following.
● https://securityintelligence.com/an-analysis-of-the-qada
rs-trojan/
● https://sslbl.abuse.ch/ssl-certificates/sha1/1862c777bab
f298fe5a93406e4dc8456d718abcf/
It's time to test the rule above. You can do so, as follows.
cd Desktop
./automate_suricata.sh ./PCAPs/7ev3n.pcap
You should see the following.
Finally, let's analyze the Malicious_document.pcap
It's time to test the rule above. You can do so, as follows.
cd Desktop
./automate_suricata.sh ./PCAPs/Malicious_document.pcap
You should see the following.
Task 3: Analyze the provided PCAP files and
develop your own rules (Level: Intermediate)
Let's start with DDoSClient.pcap
It's time to test the rule above. You can do so, as follows.
cd Desktop
./automate_suricata.sh ./PCAPs/DDoSClient.pcap
You should see the following.
Now, it's time to analyze the Adobe.pcap
It's time to test the rule above. You can do so, as follows.
cd Desktop
./automate_suricata.sh ./PCAPs/Adobe.pcap
You should see the following.
Suricata Resources:
1. https://www.stamus-networks.com/open-source/
2. https://resources.sei.cmu.edu/asset_files/Presentation/2
016_017_001_449890.pdf
3. https://blog.inliniac.net/2014/04/08/detecting-openssl-h
eartbleed-with-suricata/
4. https://www.trustwave.com/en-us/resources/blogs/spiderla
bs-blog/decoding-hancitor-malware-with-suricata-and-lua/
5. https://www.trustwave.com/en-us/resources/blogs/spiderla
bs-blog/advanced-malware-detection-with-suricata-lua-scr
ipting/
LAB 6
Scenario
The organization you work for is considering deploying Zeek
(now known as Bro) to enhance its traffic inspection
capabilities. Your IT Security manager tasked you with
thoroughly analyzing zeek's capabilities. He also provided
you with PCAP files containing malicious traffic, so that you
can experiment with writing zeek detection scripts and
signatures.
Learning Objectives
The learning objective of this lab is to not only get
familiar with the detection capabilities of zeek but also to
learn effective zeek scripting.
Specifically, you will learn how to use zeek's capabilities
in order to:
Introduction To Zeek
Zeek's creators describe it as an open-source traffic
analyzer. It is typically used to inspect all traffic on a
link (in depth) for signs of malicious or suspicious
activity. That being said, Zeek can also be used for network
troubleshooting and various measurements within a network. By
deploying Zeek, blue teams can immediately access a variety
of log files that contain all kinds of network activity, at a
high level. More specifically, those logs contain not only
detailed records of every connection on the wire but also
application-layer transcripts (for example - DNS requests and
the respective replies, whole HTTP sessions, etc.). Zeek does
a lot more than just keeping track of the aforementioned. It
is also shipped with a whole range of analysis and detection
capabilities/functions.
● IPv6 support
● Scripting Language
○ Domain-aware
● Interfacing
○ Outputs to well-structured ASCII logs, by default
Zeek logs:
Note that in its default setup, Zeek will gzip compress log
files every passing hour. The old logs will be moved into a
directory with a YYYY-MM-DD format. In the case of dealing
with compressed logs, you can use alternative tools such as
gzcat to print logs or zgrep to search in them.
For zeek examples, use cases and the basics of writing Bro
scripts, refer to the following link:
https://docs.zeek.org/en/stable/examples/index.html
Recommended tools
● Zeek (Already installed on the lab setup)
Tasks
Task 1: Write a zeek script to alert you on
any RDP connection initiated by a user
different than "admin"
Consider the RDP-004.pcap file stored in the
/root/Desktop/PCAPs directory.Write a Zeek script that will
extract the username(s) that initiated the RDP connection
attempts and alert you in case a username is different than
"admin".
Resources:
1. https://docs.zeek.org/en/stable/scripts/base/bif/plugins
/Bro_RDP.events.bif.bro.html
2. https://docs.zeek.org/en/stable/examples/scripting/index
.html
3. https://docs.zeek.org/en/stable/frameworks/notice.html?h
ighlight=notice
SOLUTIONS
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy (which
may be different from the one explained in the following lab.
export PATH=/opt/zeek/bin/:$PATH
NOTE: If you are closing this lab, you need to run the above
mentioned command again in order to set the zeek's path.
cd ~/Desktop
mkdir zeek
cd zeek
nano test.zeek
@load base/protocols/rdp
event rdp_connect_request(c: connection, cookie:string)
{
print cookie;
}
Placing a Zeek script at the end of the command will load the
specified Zeek script.
@load base/protocols/rdp
event rdp_connect_request(c:connection, cookie:string)
{
local start_time = strftime("%Y-%m-%d %H:%M:%S",
c$start_time );
print fmt("New RDP Requst from: %s at %s by user %s",
c$id$orig_h, start_time , cookie);
}
Now, let's execute Zeek and specify the RDP-004.pcap PCAP
file as well as the extended script we just created.
@load base/protocols/rdp
@load base/frameworks/notice
export { redef enum Notice::Type += {Suspicious_RDP}; }
event rdp_connect_request(c: connection, cookie:string){
if (cookie != "admin"){
local start_time = strftime("%Y-%m-%d %H:%M:%S",
c$start_time );
local message = fmt("New RDP Request from: %s at %s
by user %s", c$id$orig_h, start_time , cookie);
NOTICE([$note= Suspicious_RDP, $msg=message]);
}
}
You should see nothing in the standard output, but you will
find a new Zeek log named notice.log in the current
directory.
Run -
cd ..
rm -r zeek
mkdir zeek
cd zeek
Now run ls -l
Let's take a look at weird.log. weird.log contains
unusual/exceptional activity that can indicate malformed
connections, traffic that doesn't conform to a particular
protocol or even a malicious actor trying to evade or confuse
a sensor.
cat weird.log
First of all, notice that even though we see port 4433 (TCP),
Zeek was still able to identify that what it sees is SSL
traffic. Disregard 127.0.0.1, the PCAP is from a run using
local loopback.
We should not forget that malicious actors are known for both
using self-signed SSL certificates and being lazy, so, let's
take a closer look.
@load protocols/ssl/extract-certs-pem
redef SSL::extract_certs_pem = ALL_HOSTS;
If you run zeek once again, you will notice this big
certs-remote.pem file, in the current directory.
Run -
mkdir temp
mv certs-remote.pem temp
cd temp
awk ' split_after == 1 {close(n".pem"); n++;split_after=0}
/-----END CERTIFICATE-----/ {split_after=1} { print >
n".pem"}' <certs-remote.pem
You should be able to see something similar to the below, if
you list the temp directory.
Run-
ls
For more on the attacking technique being used, check out the
following link:
https://www.fidelissecurity.com/threatgeek/threat-intelligenc
e/x509-vulnerabilities>
Run -
cd ../..
rm -r zeek
mkdir zeek
cd zeek
Now, let's start our analysis, by executing Zeek as follows.
cat conn.log
Run -
cd ..
rm -r zeek
mkdir zeek
cd zeek
cat conn.log
cat ssl.log
Run -
cd ..
rm -r zeek
mkdir zeek
cd zeek
cat conn.log
Further down Zeek's conn.log, we can see that there are some
long-running connections with a remote machine. Find out
which, as an exercise.
A viable Zeek script to detect such long-running connections
can be found below. Create it through nano and save it in
current directory as detect-long-connections.zeek.
@load base/protocols/conn
@load base/utils/time
# This is probably not so great to reach into the Conn
namespace..
module Conn;
export {
function set_conn_log_data_hack(c: connection)
{
Conn::set_conn(c, T);
}
}
# Now onto the actual code for this script\...
module LongConnection;
export {
redef enum Log::ID += { LOG };
## Aliasing vector of interval values as
## "Durations"
type Durations: vector of interval;
##The default duration that you are locally
##considering a connection to be "long".
const default_durations = Durations(10min, 30min, 1hr,
12hr, 24hrs, 3days) &redef;
## These are special cases for particular hosts or
subnets
## that you may want to watch for longer or shorter
## durations than the default.
const special_cases: table[subnet] of Durations = {}
&redef;
}
redef record connection += {
##Offset of the currently watched connection duration by
the long-connections script.
long_conn_offset: count &default=0;
};
event zeek_init() &priority=5
{
Log::create_stream(LOG, [$columns=Conn::Info,
$path="conn_long"]);
}
function get_durations(c: connection): Durations
{
local check_it: Durations;
if ( c$id$orig_h in special_cases )
check_it = special_cases[c$id$orig_h];
else if ( c$id$resp_h in special_cases )
check_it = special_cases[c$id$resp_h];
else
check_it = default_durations;
return check_it;
}
function long_callback(c: connection, cnt: count): interval
{
local check_it = get_durations(c);
if ( c$long_conn_offset < |check_it| && c$duration >=
check_it[c$long_conn_offset] )
{
Conn::set_conn_log_data_hack(c);
Log::write(LongConnection::LOG, c$conn);
local message = fmt("%s -> %s:%s remained alive for
longer than %s",
c$id$orig_h, c$id$resp_h,
c$id$resp_p, duration_to_mins_secs(c$duration));
++c$long_conn_offset;
}
# Keep watching if there are potentially more thresholds.
if ( c$long_conn_offset < |check_it| )
return check_it[c$long_conn_offset];
else
return -1sec;
}
event connection_established(c: connection)
{
local check = get_durations(c);
if ( |check| > 0 )
{
ConnPolling::watch(c, long_callback, 1, check[0]);
}
}
zeek -C -b -r ~/Desktop/PCAPs/incident_4.pcap
detect-long-connections.zeek
Run -
cd ..
rm -r zeek
mkdir zeek
cd zeek
nano zeroaccess.sig
signature zeroaccess {
ip-proto == udp
payload /....\x28\x94\x8d\xab.*/
event "zeroaccess"
}
nano zeroaccess.zeek
@load base/frameworks/notice
@load base/frameworks/signatures/main
@load base/utils/addrs
@load base/utils/directions-and-hosts
@load-sigs ./zeroaccess.sig
redef Signatures::ignored_ids += /zeroaccess/;
module ZeroAccess;
export {
redef enum Notice::Type += {
##Raised when a host doing Bitcoin mining is found.
ZeroAccess_Client,
##Raised when a host is serving work to Bitcoin
miners.
ZeroAccess_Server
};
##Type of ZeroAccessHost which, on discovery, should
raise a notice.
const notice_zeroaccess_hosts = LOCAL_HOSTS &redef;
const notice_zeroaccess_hosts = LOCAL_HOSTS &redef;
const zeroaccess_timeout = 60 mins &redef;
global zeroaccess_tracker: set[addr];
}
event signature_match(state: signature_state, msg: string,
data: string)
&priority=-5
{
if ( /zeroaccess/ !in state$sig_id ) return;
if ( state$conn$id$orig_h !in zeroaccess_tracker )
{
add zeroaccess_tracker[state$conn$id$orig_h];
NOTICE([$note=ZeroAccess::ZeroAccess_Client,
$msg=fmt("Probably ZeroAccess P2P Client Access:
"),
$sub=data,
$conn=state$conn,
$identifier=fmt("%s%s", state$conn$id$orig_h,
state$conn$id$resp_h)]);
}
}
Let's now put the Zeek signature and the accompanying Zeek
script to the test, as follows.
Run -
cat notice.log
Scenario
The organization you work for is considering deploying Snort
to enhance its traffic inspection capabilities. Your IT
Security manager tasked you with thoroughly analyzing Snort's
capabilities. He also provided you with PCAP files containing
malicious traffic, so that you can experiment with writing
Snort detection rules.
Introduction To Snort
Snort is an open source IDS and IPS, that can also be used as
a packet sniffer or packet logger. Just like Suricata, Snort
inspects all traffic on a link for malicious activity and can
extensively log all flows seen on the wire, producing
high-level situational awareness and detailed application
layer transaction records. It needs specific rules (holding
instructions) to tell it not only how to inspect the traffic
it looks at but also what to look for. It was designed to
perform on commodity and purpose-built hardware.
● Intrusion Detection
● Network Security Monitoring
● Anomaly Detection
● Multitenancy
- Passive IDS
- NIDS
.
|-- admin |-- bin |-- etc |-- lib |-- preproc_rules |-- rules
|-- share |-- so_rules `-- src In the context of this lab, we
will use Snort from inside a Security Onion distribution.
Security Onion has its own Snort directory structure. Snort
rules: Snort rules are very much like Suricata rules. They
consist of two major parts, the rule header, and the rule
options. Examples: action protocol src_addr src_port
direction dst_addr dst_port Options alert tcp any any -> any
21 (msg: "FTP Traffic";) The part in bold is the header
whereas the remaining part is options. Even though Snort
rules are similar to Suricata rules. Dedicate some time to
study Snort rule writing from the following resource:
http://manual-snort-org.s3-website-us-east-1.amazonaws.com/no
de27.html The latest Snort rules can be downloaded from
snort.org or the Emerging Threats website. Remember that the
location of the rules can be specified in the snort.conf
file. Example: include $RULE_PATH/backdoor.rules
Snort logs:
Testing Snort:
Snort configuration:
5. Configure preprocessors
Recommended tools
● Snort
Tasks
Task 1: Write a Snort rule that detects an
ICMP Echo request (ping) or Echo reply
message
An icmp.pcap PCAP file exists inside the /root/Desktop/PCAPs
directory that contains ICMP traffic towards the network
subnet you are protecting (192.168.1.0/24).
Introduce a Snort rule into its local.rules file that
detects an ICMP Echo request (ping) or Echo reply message
towards your organization's subnet (192.168.1.0/24).
SOLUTIONS
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy, which
may be different from the one explained in the following lab.
Updated snort.conf
vim /etc/snort/rules/local.rules
alert icmp any any -> $HOME_NET any (msg: "ICMP test";
sid:1000001; rev:1; classtype:icmp-event;)
Rule Header
Rule Options
cd PCAPs
snort -q -A console --daq pcap -c /etc/snort/snort.conf -r
icmp.pcap
Task 2: Analyze the provided PCAP file and
write Snort rules to detect successful buffer
overflow attacks
Let's start our analysis by executing tcpdump as follows.
cd PCAPs
tcpdump -nnttttAr eternalblue.pcap
Starting from the bottom up, you should see something similar
to the below image.
The above looks quite similar to what you saw inside the
included cert_trafficwireshark.pdf resource in the 6. FOLLOW
TCP STREAM section. In this case, the buffer overflow attempt
happens over SMB (notice the 445 port). Let's use this buffer
overflow-related portion of the traffic to create our rule.
vim /etc/snort/rules/local.rules
cd PCAPs
tcpdump -nnttttAr eternalblue.pcap
Starting from the bottom up, you should see something similar
to the below image.
Let's create a Snort rule that will detect Window (7) shell
access on the wire, as follows.
vim /etc/snort/rules/local.rules
ssl.record.content_type == 24
If you look carefully enough, 40 00 is the equivalent of
16384 in decimal. Specifically, the attacker specified that
the payload length is 16384 bytes, but no additional data
were actually sent. According to the Heartbleed
vulnerability, if the server is vulnerable, it should send
more data than it typically should.
vim /etc/snort/rules/local.rules
Inside vim enter the below.
alert tcp $EXTERNAL_NET any -> $EXTERNAL_NET 443
(msg:"Potential Heartbleed attack";
flow:to_server,established; content:"|18 03 02 00 03 01 40
00|"; rawbytes; isdataat:!1,relative; sid:1000004; rev:1;)
● flowbits:isset,netbios.lsass.bind.attempt; *flowbits* is
Snort's way of identifying conditions that occurred in
previous traffic. In this case, a NetBIOS connection and
an attempt to connect and bind to the LSASS process
should have already occurred.
Snort Resources:
1. http://web.archive.org/web/20121214114552/http://www.sno
rt.org/assets/173/SnortUsersWebcast-Rules_pt1.pdf
2. https://snort-org-site.s3.amazonaws.com/production/docum
ent_files/files/000/000/046/original/SnortUsersWebcast-R
ules_pt2.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Cred
ential=AKIAIXACIED2SPMSC7GA%2F20190222%2Fus-east-1%2Fs3%
2Faws4_request&X-Amz-Date=20190222T230448Z&X-Amz-Expires
=172800&X-Amz-SignedHeaders=host&X-Amz-Signature=2390ecd
554e08833cd90e39220a74e6332f094d711ee1392d287d9197ba58d0
a
Scenario
When it comes to responding to an incident on enterprise
environments, time to respond and visibility are everything.
There will be incidents, when waiting until an IR team is
deployed or remotely logging into each under-investigation
endpoint and issuing numerous commands, won't be the optimum
response approach.
● win10-server.els-child.eLS.local
● jumpbox.els-child.eLS.local
● xubuntu
Learning Objectives
The learning objective of this lab, is to make you familiar
with GRR, in order to perform quicker and more efficient IR
activities.
Recommended tools
● GRR
● GRR server
○ IP: 10.100.11.122
● Connection Type: VNC
2. Navigate to localhost:8000
Tasks
Note: Before proceeding to incident analysis or identifying
an abnormality, some required information should be gathered
first. Such information are network interactions, listening
ports, running processes, running services, logged in users
etc. The two cheatsheets we provided you with, while studying
the first module of the IHRP course, contain the minimum
information you should gather. Feel free to extend them...
Hints:
SOLUTIONS
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy (which
may be different from the one explained in the following
lab).
First things first! Once you are logged into the GRR
administration panel (information on how to do so can be
found above, in the Network Configuration & Credentials
section), you can list all the deployed GRR clients, by
clicking on the Search box and pressing nothing other than
Enter.
What about the registry? Let's try and list everything under
the
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion
location (which, as mentioned in the first module, is usually
abused by attackers to trigger malware).
Now, click on Render all the data... (May take a while). You
will be presented with something similar to the below.
How this endpoint got infected in the first place, you may
ask. Give the Downloads directory a closer look, in case
something malicious has been downloaded and executed.
1. https://grr-doc.readthedocs.io/en/latest/
2. https://www.blackhat.com/docs/us-14/materials/us-14-Cast
le-GRR-Find-All-The-Badness-Collect-All-The-Things.pdf
3. https://www.youtube.com/watch?v=ren6QSvwFvg
4. https://chip-dfir.techanarchy.net/?p=395
5. https://www.osdfcon.org/presentations/2012/OSDF-2012-GRR
-Rapid-Response-Darren-Bilby.pdf
6. https://storage.googleapis.com/docs.grr-response.com/GRR
%20Hunting%20for%20meetup%20Oct%202015.pdf
Scenario
This lab continues from where the lab "Enterprise-wide
Incident Response (Part 1: GRR)" left off.
Learning Objectives
The learning objective of this lab, is to make you familiar
with Velociraptor, in order to perform quicker and more
efficient IR activities.
Recommended tools
● Velociraptor
● Velociraptor server
○ IP: 10.100.11.121
● Connection Type: VNC
**
Tasks
Note: Before proceeding to incident analysis or identifying
an abnormality, some required information should be gathered
first. Such information are network interactions, listening
ports, running processes, running services, logged in users
etc. The two cheatsheets we provided you with, while studying
the first module of the IHRP course, contain the minimum
information you should gather. Feel free to extend them...
Hints:
SOLUTIONS
Below, you can find solutions for every task of this lab.
Remember though, that you can follow your own strategy (which
may be different from the one explained in the following
lab).
First things first! Once you are logged into the Velociraptor
administration panel (information on how to do so can be
found above, in the Network Configuration & Credentials
section), you can list all the deployed Velociraptor clients,
by clicking on the Search box and pressing nothing other
than Enter.
Velociraptor Resource:
1. https://www.velocidex.com/blog/