Splunk Search

How do I write a lookup after a lookup is search matches?

HansNL
Loves-to-Learn

Hi, am working on a lookup in a lookup.

i have the following search:

index=* source="*WinEventLog:Security" EventCode=4688
[| inputlookup attacktoolsh.csv WHERE discovery_or_attack=attack | stats values(filename) as
search | format]
| transaction host maxpause=10m
| where eventcount>=5
| fields - _raw closed_txn field_match_sum linecount
|table ComputerName, New_Process_Name, Process_Command_Line, _time, eventcount



This works fine, the lookup attactoolsh.csv has the tools, an i have a hit on a client.

now i would like to intergrate a second lookup file in the search that looks a file with a computername/username in it, that if the search hits on attacktoolsh.csv it looks in the second file and if a computer/user is in that file the search should not produce a notable. 

in short, computer A is running "nmap" this is allowed on computer A and Computer A is in the second file. Computer B is running "nmap" and is not allowed to run this, so produce a notable / warning.

anybody an idea how to intergrate this toghter.

Thanks.

Labels (1)
Tags (2)
0 Karma

HansNL
Loves-to-Learn

OK fixed the lookup command, apperantly the lookup table was corrupted during import.
But still, this did not do the trick, the output is still empty.

just to give some more input.
Attacktoolsh.csv has a content of:
"discovery_or_attack",filename,hash,platform
attack,nmap,,linux
attack,nc,,linux
attack,tcpdump,,linux
attack,putty,,windows


the secondlookup.csv  file has:

filename,computername,username
nmap,pc001,
putty,pc002,user1

the default search give an output of all so no problem there.

but what i am lookin for it that primary search only show computers that are not in the secondlookup.csv list.
so pc003 that runned putty should be displayed.

0 Karma

marysan
Communicator

 

 

Hello. you need a common field between your first and primary search that computername can be a common field :
index=* source="*WinEventLog:Security" EventCode=4688
[| inputlookup attacktoolsh.csv WHERE discovery_or_attack=attack | stats values(filename) as
search | format]
| transaction host maxpause=10m
| where eventcount>=5
| fields - _raw closed_txn field_match_sum linecount
|table ComputerName, New_Process_Name, Process_Command_Line, _time, eventcount
|lookup  secondlookup.csv computername as ComputerName output filename
|search NOT filename=*
(for pc003, there is no filename field in your second lookup  )

 

0 Karma

marysan
Communicator

@HansNL
did this work for you?

0 Karma

marysan
Communicator

Hi
Assuming your second lookup is contaning 3 fields :filename,computername,username this query shoud be worked :

index=* source="*WinEventLog:Security" EventCode=4688 [| inputlookup attacktoolsh.csv WHERE discovery_or_attack=attack | stats values(filename) as filename| format]
|mvexpand filename
|lookup secondlookup.csv filename as filename output computername,username
|search computername=*
| transaction host maxpause=10m | where eventcount>=5 | fields - _raw closed_txn field_match_sum linecount |table ComputerName, New_Process_Name, Process_Command_Line, _time, eventcount

Tags (2)
0 Karma

HansNL
Loves-to-Learn

Hi, and thanks for the fast response.
Sadly this does not work, i do get an " lookup command: could not construckt lookup.

have tried diverent settings but keeps up comming with this error after the mvexpand command.

any ideas

 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...