Oct 29 2020 12:52 PM
new to kql here, is it possible to build a query that search's across logs looking for machines that connected to any of ip addresses in the watchlist? Any examples ? Plan would be to turn that query into a log analytic rule to create events and eventually a playbook.
thanks
Oct 30 2020 05:27 AM
@roadruner Here is a simple example of how to do this. I created a CSV file that has all the IPAddresses I have cleared and uploaded that into the Watchlist using "ClearedIPAddreses" as the alias.
Oct 30 2020 07:15 AM
@Gary Bushey Hi, i tried that query with alias of test1 which is alias of watchlist and received an error,
Oct 30 2020 09:08 AM
@roadruner You CSV file would need to have the column headers in the first row. One of mine was "IPAddresses", you would need to substitute whatever you called your columns for that.
I used the term "cleared" only because my watchlist contained those IP Addresses that I want to allow. You can call you watchlist whatever makes sense to you.
Oct 30 2020 10:53 AM
@Gary Bushey Thanks I tracked the error I had, which was the columns. It runs with no errors now. I did run a quick test and hit one of the ip's in watchlist and then ran the query and no results found. Does the query search out all of sentinel? I tried just putting CommonSecurityLog to see if it would just search through those logs, since that's where the hit should be.
Here is what i tried, didn't work.
CommonSecurityLog
let ClearedIPAddresses=_GetWatchlist('test1');
Heartbeat
| join ClearedIPAddresses on $left.ComputerIP == $right.IPAddresses
Oct 30 2020 11:13 AM
@roadruner It will only search the one table.
There really is no way to search all tables for multiple values. There is the "search" command, https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/searchoperator, that allows you to search for a single term although I do not know if this can be used in a Analytic rule or not.
Oct 30 2020 12:14 PM
@Gary Bushey Hmm ok, thanks. How can i search one table? say CommonSecurityLog
I tried this but no dice.
CommonSecurityLog
let ClearedIPAddresses=_GetWatchlist('test1');
Heartbeat
| join ClearedIPAddresses on $left.ComputerIP == $right.IPAddress
Oct 30 2020 12:45 PM
Solution@roadruner This is the starting query for something like that.
let ClearedIPAddresses=_GetWatchlist('test1');
CommonSecurityLog
| join ClearedIPAddresses on $left.SourceIP== $right.IPAddress
Oct 30 2020 01:12 PM
@Gary Bushey Thanks! This worked. Just replaced sourceip to destip. and .found the test hits to the list. either way works.
Jul 01 2021 06:45 AM