Security Use Cases Using Splunk
Security Use Cases Using Splunk
Version: 6.3.2
Install Splunk
1. Down Splunk latest release from Splunk.com
2. Run the downloaded exe.
3. Below screen will come. Accept the agreement
Use Cases
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
2
system files, etc., so that any possible attack underway will get noticed and treated before the attack
succeeds. Organizations generally apply these security policies via a Group Policy Object (GPO) to all the
hosts in their network.
Problem Statement: Alert in real time whenever a user failed to do a successful login for more than 2
times.
How to read this query: We are monitoring windows security even logs and looking for EventCode 4625
which is “Failed Logins”. Every space in splunk is a AND operator. Then we are performing a statically
search of count variable on Account_Name and report where count is greater than 2 i.e. it will report
when a user(Account_Name) has performed more than 2(count) failed logins.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
3
b. Click Local Policies > Audit Policies. Make sure Auditing for failure, success event is
turned on. If it is not double click and select failure events.Below should be the final
screen for this:
2. Start Splunk: Navigate to Splunk directory > bin and execute command : splunk start.
3. Open Splunk Web . usually It will be at localhost:8000. If 8000 is occupied it will be 8001.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
4
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
5
c. Click on Security Logs. Logs from Windows events will go to splunk default index which is
called as “main”.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
6
9. You might get 0 results here. Not to worry we still have to do unsuccessful logins.
10. Click on Save As> Alerts , to save this search as a alert.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
7
13. Open Splunk. Navigate to Activity>Triggered Alert. There you can see the alert triggered. You
will see a lot of alerts because alert is configured to run in real time so it will continue to run
14. Click on the View Results on the top most alert which actually resulted from unsuccessful logins
to see results.
How to read this query: we are collection windows security event logsand will moitor EventCode 46663
which throws back actions being taken on the file. Space in splunk is a AND operator. Then we are
performing a statistical operation on files with username and action. Finally I am just renaming the fields
to make them more understandable.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
8
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
9
6. Open Splunk. We do not need to add new data for this use. Windows Security Event logs will be
good enough. IF you have not followed Use Case 1, please see above on how to feed splunk.
7. Open Splunk And write this query: sourcetype="WinEventLog:Security" EventCode=4663 | stats
count by Account_Name ,Object_Name ,Accesses| rename Account_Name as
UserName,Object_Name as FileName,Accesses as Action | table UserName,FileName,Action
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
10
11. Open Test _Access file and the see the triggered alert under Activity>Triggered Alert. Most
probably you will not see anything. Why? Because your alert is configured to run at 0th minute
past every hour.
12. To run this alert now, navigate to Settings >’Searches, reports and Alerts’.
13. There you will see all the alerts. Find Alert Name File Access and Click on Run
14. Below result screen will come to tell you that who(Username) has performed what Action on
what Resouce(FileName).
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
11
Problem Statement: Alert in schedule time whenever a registry SetAction event took place
How to read this query: We are collection registry events in splunk default index main and monitoring
for Action Values (which is set in this case) and performing a statisctics over the values as shown in.
Remember every space in splunk is converted into an AND operator and | is a pipeline. At the end we
are just renaming the fields to make them more understandable.
3. Click New
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
12
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
13
‘Set’ action will generate a Set event when a program executes a SetValue method on a Registry
subkey, thus setting a value or overwriting an existing value on an existing Registry entry.
6. Now Click on Windows Start button and type ‘regedit’ to open registry. Navigate to HKLM
>Software >Splunk .
7. On the right hand pane, double click on ProductName and Change the value from ‘Splunk
Enterprise’ to ‘Splunk Use Case Infosec Institute’and click OK.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
14
10. Since this is also a scheduled alert, navigate to Settings >’Searches, reports and Alerts’.
11. There you will see all the alerts. Find Alert Name Reg_Mon_Alert and Click on Run
12. Below is the result screen which states the following parameter:
a. Path to subkey: Path to subkey which has changed
b. Action: What sort of action has taken place.In this case it will be SetAction
c. Host: On which host this has changed.
d. New Value: What the value of this subkey. I have taken values(data) to concatenate all
changed values for this subkey. You can see the changed value “Splunk Use Case Infosec
Institute” in the result.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
15
This query will perform a lookup of perimeter_firewall logs for TCP/UDP 53 with all the known
local/internal DNS names and will list all other DNS names which can possibly is a rouge Name server.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
16
What this will do is to lookout for traffic at perimeter firewall for IP other than the mentioned
proxy ip addressee’s which might possible a rouge proxy server. In this also we can leverage the
splunk lookup feature.
Netstat –ln| egrep “^tcp|^udp” and write the data to log file. If the resulting log file is local
to Splunk then we can take this file directly as an input into Splunk or if resulting log file is
remote it can be collected using Splunk Universal Forwarder. Then we can monitor for
insecure ports and services.
Index=endpoint_log [inputlookup insecure_list append =t port, services] | table hostname, port, service
I this the lookup list insecure_list contain the known insecure port and services which in turn gets
matched up the endpoint logs. If match found alert is raised.
Monitoring of XSS
One of the famous payload used to carry out XSS attack is to <script>alert(‘XSS attack’)</script>. If all
the interactions with an application are logged then it is very easy to find such a payload in logs like
below
It will look out of “script” tag in a case insensitive fashion in the application logs. Now my
application logs has the attacker –location which states that it is insider or not, ip which will be
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
17
proxy one. These logs will then have to checked against proxy logs to look put for actual IP which
has the payload containing script tag.
Id=’ or ‘1’=’1
employee’; drop table employee;--
Now these payloads can be monitored in splunk provided all the interaction are being logged.
This query will look out for quote and = sign OR quote or semicolon. In some cases when
attackers exploit sql injection to drop tables at the backend , this query will look out for drop
keyword OR – sign which is used to ignore the rest of SQL statement.
To counter such malformed actions, SIEM should be configured to raise an alert if a host stops
forwarding logs after a threshold limit. For example, the below search query (SPL) in Splunk will
raise an alert if a host has not forwarded the logs for more than one hour.
| metadata type=hosts| where recentTime < now() -3600 | convert cTime(recentTime) as "Last
time the log source reported" | rename host as "Log Sources" | table " Log Sources" "Last time
the log source reported"
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |
18
As soon as an alert is received with the IP address of the machin under attack, the Incident
Response Team (IRT) can start mitigating this issue.
So as you can see virtually almost every type of data can be monitored in Splunk. Even what came to
rescue to lot of developers is lot of new apps which actually parse the data for the proprietary log
format and you just have to run commands.
http://www.infosecinstitute.com/courses/incident_respone_network_forensics.html
SECURITY USE CASES USING SPLUNK |