Knowledge Management

Comparing logs with inputlookup files

harrysof
Explorer

Hey all,

I have a fairly simple question.

I have a web proxy index that has a url field.

I have a CSV that contains malicious TLD's (.ru, .cn).

I'm trying to create the right query to match the CSV to this field in the web proxy index ?
So if traffic is seen for url=hackingsite.ru, that it gets compared to the CSV and sees that a .ru domain is bad (so it matches).

index=webproxy [|inputlookup MalciousDNSTLD.csv | fields dns] | eval dns=url | table url

But, I know I am missing something from the query, looking for some generous help.

Thanks.

Tags (2)
0 Karma
1 Solution

woodcock
Esteemed Legend

First, install URL toolbox:
https://splunkbase.splunk.com/app/2734/

Then do this:

index=webproxy
| lookup ut_parse_extended_lookup url
| rex field=ut_domain "\.(<tld>[^\.]+)$"
| lookup MalciousDNSTLD.csv dns AS tld OUTPUT dns AS malicious
| where isnotnull(malicious)

View solution in original post

woodcock
Esteemed Legend

First, install URL toolbox:
https://splunkbase.splunk.com/app/2734/

Then do this:

index=webproxy
| lookup ut_parse_extended_lookup url
| rex field=ut_domain "\.(<tld>[^\.]+)$"
| lookup MalciousDNSTLD.csv dns AS tld OUTPUT dns AS malicious
| where isnotnull(malicious)

niketn
Legend

@harrysof depends on what is the value of url field in the webproxy index and what is the value of dns in the TLD csv file?

Based on the description seems like TLD csv only has TLD info like .ru or .cn. What are you matching this against in the index?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

skalliger
Motivator

Still many people try to use | inputlookup when it's not needed. What you rather want to use is | lookup which maps to your use case perfectly. Be sure to have a lookup definition because usually you don't call lookups by "lookup.csv" but by it's lookup definition name (stanza name).
Will be something like

 index=webproxy
| lookup MalciousDNSTLD field1 AS field2 OUTPUT field2 as field2
| where isnull(field2)

.. or isnotnull() depending what you want (is in the badurls list or isn't.
Look at the docs for a description of which field to use where. It's rather simple. 🙂

Skalli

starcher
Influencer

Consider also making the lookup values wildcard match type.

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 ...