I am cannot quite get the regex working that I am looking for. I want to extract AcroRd32.exe
Here is the sample text.
<Data Name='ProcessId'>12784</Data>
<Data Name='Image'>C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe</Data>
<Data Name='CurrentDirectory'>C:\Users\abcv\AppData\Local\Microsoft\Windows\Temporary Internet Files\</Data>
<Data Name='TerminalSessionId'>1</Data><Data Name='IntegrityLevel'>Low</Data>
(?s)'Image'(?P[^<]+)
This pulls out this
'Image'>C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe
Working with this text now
'Image'>C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe
This regex pulls out what I want
[^\\]+$
AcroRd32.exe
I need to put this together or do the regex God's have a better way?
Like this:
REGEX = (^|[\r\n])<Data Name='(.*?)'>(.*?)<\/Data>
FORMAT = $1::$2
And then you use the other answers on field=Image
Hi kinkster,
I have another solution for the regular expression you asked for.
(?=\'Image\').+\\(?<program>[^\<]+)(?=\<\/Data\>$)
https://regex101.com/r/Y0hINA/2
PS: Please don't forget to upvote and click accept as woodcock already said, thx!
Like this:
REGEX = (^|[\r\n])<Data Name='(.*?)'>(.*?)<\/Data>
FORMAT = $1::$2
And then you use the other answers on field=Image
Check out the add-on for Microsoft Sysmon. This app includes field extractions such as the above as well as some helpful workflow actions. If you have a LOT of computers pushing sysmon data you may want to consider creation of an accelerated data model.
Generally as a safety practice I would replace the use of lazy .*? with a negative character class [^>] and a possessive quantifier ++ or (?>...) when you can. It's quite common syntax in Splunk configs because of the elimination of backtracking and performance boost. Splunk has the potential to apply your regex to huge numbers of events that will NOT match and this will speed up the failures. ( Speed up the matches as well )
I do have the the latest TA for sysmon. The TA does extract out the CurrentDirectory for instance but nothing for the Image filename. I can look at the TA and see if that helps. Great idea on the accelerated data model. I will take a look.
The app should extract the file name of the Image as "process".
See line 23 of the props configuration file in the TA.
Alrighty then! You are correct again. It is right there as "process". This is what I needed. Thanks for you help!
Don't forget to UpVote
anything helpful and click Accept
on the best answer.
Give this a try
Image\'([^\\]+\\)+(?<Image>\w+\.\w+)\<
OR (I believe this will work in Splunk configs)
Image\'([^\\\]+\\\)+(?<Image>\w+\.\w+)\<
Test result on your sample data.
https://regex101.com/r/JTpEXe/1