• No results found

Splunk Search Pro Tips

N/A
N/A
Protected

Academic year: 2021

Share "Splunk Search Pro Tips"

Copied!
56
0
0

Loading.... (view fulltext now)

Full text

(1)

© 2015 The MITRE Corporation. All rights reserved. Approved for Public Release; Distribution Unlimited. 15-2752.

Dan Aiello

Principal Cyber Security

Engineer, MITRE

Dan Aiello, Principal Cyber Security Engineer

Splunk Search Pro Tips

(2)

Agenda

§

My background

§

Comments

§

Search by index

§

In the year 2000

§

Red Card

§

Watch Lists

§

Search Job Inspector

§

More fun with subsearches

§

Carrier signal

§

Imaginary events

(3)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

My Splunk background

§

4 years Splunk experience

§

SOC is primary user base

§

6 indexers

§

350 GB data/day

§

90 indexes

(4)

/ / N o c o m m e n t

comments

(5)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Comment your Splunk search

sourcetype=access_combined_wcookie    

|  eval  COMMENT="This  is  my  comment"  

 

or

 

sourcetype=access_combined_wcookie    

|  rename  COMMENT  -­‐>  "This  is  my  comment"  

 

(6)

rename vs. eval for comments?

§

In practice, it does not seem to matter

§

In a few odd circumstances, I have seen rename be

faster than eval

(7)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

(8)

(9)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Searching by index and sourcetype

Specifying an index in

your search speeds it up

This difference is less

pronounced in Fast Mode

(10)

I n t h e y e a r 3 0 0 0

(11)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Get with the times

§

Timestamps are extremely important for Splunk data

§

Detected at index time, set forever

§

Cannot be fixed if they’re wrong

§

Common errors:

Incorrect time zone interpretation

(12)

Past, present, future

If this search ever returns events, you have timestamp

problems

1

:

index=*  earliest=+30m  latest=+9y  

This requires some tweaking, depending on your

expected delay:

index=*  |  eval  delta=_indextime-­‐_time  |  where  

delta>300  

1

Or a flux capacitor

2 2

Or a TARDIS

(13)

© 2015 The MITRE Corporation. All rights reserved.

y o u r a p p r o x i m a t e w a i t t i m e i s …

red card

(14)

Calculate average delay proxy logs

index=main    

|  eval  delta  =  _indextime  -­‐  _time    

|  timechart  span=1h  avg(delta)  

(15)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

(16)

Calculate average delay proxy logs

Solution:

*/5  *  *  *  *  wget  http://testdomain.zzz  

 

index=main  

testdomain.zzz

 

|  eval  delta  =  _indextime  -­‐  _time    

|  timechart  span=1h  avg(delta)  

 

Search terms

Duration

index=main

453 s

(17)

© 2015 The MITRE Corporation. All rights reserved.

b e t t e r t h a n g r e p - f

watchlists

(18)

Watchlist examples

§

Known “evil” IP addresses

§

Known “evil” domain names

§

List of your DMZ web servers

(19)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

(20)

Conventional way

to use watchlists

This is essentially

grep -F

(21)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

(22)

What’s the difference?

Both return the same events

(23)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

What’s the difference?

(24)

Saving time on a search

can be important for large

or frequent searches

Small watchlists and

large datasets make

this difference greater

(25)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Just the subsearch

How does it work?

(26)

Subsearches

implicitly end with

|  format

 

Add it explicitly to

see what’s

(27)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

sourcetype=access_combined_wcookie    

[  |  inputlookup  ip_watchlist.csv  |  search  

type=malicious  |  fields  clientip  ]    

…after the subsearch is evaluated becomes this:

sourcetype=access_combined_wcookie    

(  (  clientip="131.178.233.243"  )  OR  

(  clientip="212.58.253.71"  )  OR  …  )  

(28)
(29)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Why is

sourcetype=access_combined_wcookie    

(  (  clientip="131.178.233.243"  )  OR  

(  clientip="212.58.253.71"  )  OR  …  )  

Better than

sourcetype=access_combined_wcookie    

|  lookup  ip_watchlist.csv  clientip  |  search  

type=malicious  

(30)

… e x p l a i n s i t a l l

(31)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

This icon means there’s

some debugging message

you should examine

Inspect Job

(32)
(33)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Debugging message

(34)

The slowest parts of a Splunk

search are usually field extraction

(35)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Approximate order of operations for searches

1.

Search index for keywords

2.

Read matching events from disk

3.

Extract fields (as necessary)

4.

Match keywords to fields (as necessary)

5.

Filter (e.g. additional “where” or “search” pipes)

(36)
(37)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

A stitch in time saves nine

lookup

subsearch

2

21 Check index for keywords

39,000

2,700 Read matching events from disk

39,000

2,700 Extract fields (i.e. regex)

39,000

2,700 Match keywords to fields

39,000

2,700 Filter

* This is illustrative and approximate, not precise

(38)

sourcetype=access_

combined_wcookie

( ( clientip="131.178.2

33.243" ) OR

( clientip="212.58.253.

71" ) OR … )

lookup method reads

and regexes all this data

subsearch method

reads only this data

(39)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

(40)
(41)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Field name mismatch with subsearch

For lookup and subsearch, sometimes fields need to be

renamed

lookup method

 |  lookup  watchlist.csv  foo  AS  bar  

subsearch method

 [  |  inputlookup  watchlist.csv    

           |  rename  foo  AS  bar  ]  

(42)

If you rename a field to

“query”, you can search

anywhere in the event rather

(43)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Large subsearches

43

If your watchlist is >10000

lines, the subsearch method

(44)

Large subsearches

Add “|format”

explicitly to fix it!

Warning is

gone

We have

(45)

© 2015 The MITRE Corporation. All rights reserved.

(46)

What’s the problem with watchlists?

When they don’t alert, is it because:

§

the watchlist is broken?

(47)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Label your test domain as

type=test in the watchlist

And adjust your

subsearch accordingly

(48)

Label your test domain as

type=test in the watchlist

And adjust your

subsearch accordingly

Add test cases to your watchlist

What’s so great about that?

We could have just used

(49)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

With your wget, you know

precisely how many to

expect and you can alert

only when it’s erroneous

(50)

w e l a n d e d o n t h e m o o n

imaginary events

(51)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

(52)

How is this helpful?

You can add to a

watchlist inline

(53)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Creating data on the fly with timestamps

53

This will also

provide a current

(54)
(55)

© 2015 The MITRE Corporation. All rights reserved. © 2015 The MITRE Corporation. All rights reserved.

Overall lessons

§

Read Splunk Search Manual

§

Try multiple methods

§

Use the Job Inspector

(56)

References

Related documents

Febrile children were random- ly assigned to the intervention (clinical decision model; n=219) or the control group (usual care; n=220). The clinical decision model included

As a starting point, this research explores the use of two educational theories - Experiential Learning Theory (ELT) and Self-Regulated Learning (SRL) theory as the

ruling on each of the objections).. that Chapter 9 violates the Tenth Amendment. Indeed, at this point, a discussion of the objections themselves is largely moot, as the Detroit

presented in higher non university school networking websites and the documents produced by colleges on quality management system subject, seeking to collect the information about

8 Please bring (if applicable) copies of your child’s report cards, multi-factored evaluations/ETR, IEP, 504 Plan, cognitive testing (Iowa Test, SCOGAT, Stanford Tests,

Analizamos a ontinua ión el omportamiento de la traye toria solu ión del modelo de. red neuronal

1977 - La Unión Internacional para la Conservación de la Naturaleza y sus Recursos; 1977 - La Unión Internacional para la Conservación de la Naturaleza y sus

E.g., files being processed (in Elan, Toolbox or Flex) and ancillary files (.typ, .prj, etc) that are only necessary while working to create the..