Lab 3
June 17, 2016 ยท View on GitHub
Table of Contents
Advanced Splunk Search and Dashboards
In this lab we will be performing more complex searches and adding to our security dashboard.
Resources:
- http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Search
- http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex
- http://regexr.com/
- http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats
- http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eval
Reporting Security Events
Create a report showing when Rails Goat file upload mechanism is abused to perform command injection.
-
Login to Splunk by opening the Splunk Console with your browser. Splunk Console: https://54.186.140.211/en-US/account/login?return_to=%2Fen-US%2F
-
Click on
Search & Reportingand search for your instance's Rails Goat logs, these should be under themainindex. E.g.,index=main host=<Private DNS> source="/home/ec2-user/railsgoat/log/mysql.log". SelectAll timefrom the time range picker and clickSearch. -
Search for events containing
filename. Do you see any events? If not, go back to Week 3 Lab 3 and do Exercise 2. -
Pipe the current search results to
rexto extract the injected command into a new field namedcmd. Do NOT use the field extractor UI (+ Extract New Fields) for this exercise.
Example: if my event returns something like ...filename=\"test.rtf;+mkdir+pwn\"\r\nContent-Type:... I am interested in capturing everything between the first plus-sign and the following back-slash, i.e., mkdir+pwn.
Hint 1: | rex " filename=(?<cmd>.*) .*". Hint 2: escaping back-slashes within rex is special, you need 3 back-slashes to escape one back-slash.
- Pipe the results to another
rexcommand to substitute the plus-signs (+) with spaces ().
To do this you will need to 1) filter on the cmd field (| rex field=cmd), 2) put rex in sed mode (see resources above) and 3) substitute the plus-sign with a space using a sed style regular expression, e.g., "s/\+/ /g".
-
Use the
statscommand to display thevaluesofcmdbyhost. -
Save the search as a report. Click
Save As>Reportand enter<STUDENT ID> - Cmd Injectionas the report title and clickSave. ClickAdd to Dashboard, selectExistingand select the dashboard you created during the last lab. ClickSaveand clickView Dashboard.
Create a Splunk Alert
Create a Splunk alert that will trigger when Rails Goat file upload mechanism is abused to perform command injection.
-
Go to reports, open the report you just created. Select
Edit>Open in Search -
Modify the timeframe for the current search from
All timetoLast 60 minutes. You can do this by selecting time range picker, chooseLast 60 minutesand clicksearch. -
From the upper-right select
Save As>Alert. Use these values for the following fields:Title:<STUDENT ID> - Cmd Injection,Schedule:Run every hour, select the next closest interval to the current time from 0, 15, 30, 45 for theminutes past the hourselector. Click+ Add Actions>Add to Triggered Alertsand selectHighfor theSeverity. ClickSaveand close the dialog by clickingxon the upper-right.
Dashboard Challenge
Using knowledge gained during previous labs, add two additional panels to your new dashboard as per the following specification:
-
HTTP Codes. A pie chart displaying the distribution of HTTP codes returned by Rails Goat.
-
A panel showing SQL injections / SQL errors. This is a report which extracts SQL related errors in Rails Goat.
See:
