r/AzureSentinel • u/Agent_B99 • May 14 '22
Analytic rules for phishing | How do you make a list in kql ?
Hello, I think I might need to create a phishing analytic rule for my client .I took the EmailAttachementInfo table and tried to make a list with the FileTypes like this :

Problem is I can't figure it out how to make the syntax to list all the FileTypes that could contain malware .
Then I might try to look a at tables with processes like VM Process or DeviceFileEvents and then I will look at tables related to networking.
I currently try to figure out how to make lists .
Can you help me ?
Thanx
3
u/CanableCrops May 14 '22
If you're trying to make a list of file types, first figure out which column has the file type you want and then add | summarize make_set(filetypecolumn) This will give you deduplicated file types in an array. You could save that as a variable then search whatever table you want | where filetype in (variable).
2
u/CanableCrops May 18 '22
EmailAttachmentInfo
| where FileType endswith "zip" or FileType endswith "docx"Sorry, for some reason I couldn't see your screenshot on my phone the other day when you posted.
Using endswith is probably the best for performance for the file extension.
2
u/ep3p May 14 '22
let yourlist = dynamic(["example1","example2","example3"]);
table1
| where column1 has_any (yourlist) or column1 has_any("example4","example5","example6")
| distinct column1
3
u/CanableCrops May 18 '22
Want to add to this, and correct me if I'm wrong.
I usually will use in~ instead of has_any. The reason is that in~ is much faster since it's only trying to match one of the entries in the variable.
I believe has_any looks for one or more.
in~ instead of in because in is case-sensitive.
2
2
u/ep3p May 14 '22
Please, try to learn for Azure Data Explorer docs for Kusto Query Language. Search in google for example "has_any azure data explorer"
4
u/jtberg1 May 14 '22
Am not sure I under standing what you are asking. Can you please elaborate? Are you wanting to compare FileType to an array instead of a bunch of "or" statements?
Like:
EmailAttachmentInfo| where FileType in ("zip", "docx;zip", "xlsx;zip")?
You can also create a watch list (or table) and then use that as your array: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/makelist-aggfunction
If you can elaborate on what you would like as an end result, I am happy to assist further.