<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Regex to pull a filename out of a process field path in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334589#M99448</link>
    <description>&lt;P&gt;I want a regular expression to pull a file name out of a path that is the process field. The path could be any directory, and the filename could be named anything.&lt;/P&gt;

&lt;P&gt;Sample logs. &lt;/P&gt;

&lt;P&gt;Oct 25 14:47:20 server.domain.local Oct 25 14:47:19 172.23.0.24 system event:  text="Modification (Create Key) of registry '\registry\machine\system\currentcontrolset\services\napagent\qecs\' by 'company\user' was allowed." type="Policy Enforcement" subtype="Report write (registry rule)" hostname="domain\computer" username="domain\user" date="10/25/2017 7:46:25 PM" ip_address="172.23.1.13" process="c:\windows\system32\mmc.exe" policy="Windows Medium Enforcement" rule_name="FIM_OSSEC" process_key="00000000-0000-15e8-01d3-490915c2f584" server_version="7.2.1.1903" process_trust="10" process_threat="0"&lt;/P&gt;

&lt;P&gt;Oct 25 13:31:5""0 server2.domain.local Oct 25 13:31:43 172.23.0.24 1 2017-10-25T18:31:43Z server2.domain.local - - - - event:  text="'c:\users\user\appdata\roaming\microsoft\windows\start menu\programs\administrative tools' was created by 'domain\user'." type="Policy Enforcement" subtype="Report write (custom rule)" hostname="domain\user" username="domain\user" date="10/25/2017 6:30:38 PM" ip_address="172.16.1.12" process="c:\windows\system32\mmc.exe" file_path="c:\users\dccon\appdata\roaming\microsoft\windows\start menu\programs\administrative tools" file_name="administrative tools" policy="Windows High Enforcement" rule_name="FIM_Directory" process_key="00000000-0000-0848-01d3-4d9cda329d68" server_version="7.2.1.1903" process_trust="10" process_threat="0"&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 16:28:41 GMT</pubDate>
    <dc:creator>jared_anderson</dc:creator>
    <dc:date>2020-09-29T16:28:41Z</dc:date>
    <item>
      <title>Regex to pull a filename out of a process field path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334589#M99448</link>
      <description>&lt;P&gt;I want a regular expression to pull a file name out of a path that is the process field. The path could be any directory, and the filename could be named anything.&lt;/P&gt;

&lt;P&gt;Sample logs. &lt;/P&gt;

&lt;P&gt;Oct 25 14:47:20 server.domain.local Oct 25 14:47:19 172.23.0.24 system event:  text="Modification (Create Key) of registry '\registry\machine\system\currentcontrolset\services\napagent\qecs\' by 'company\user' was allowed." type="Policy Enforcement" subtype="Report write (registry rule)" hostname="domain\computer" username="domain\user" date="10/25/2017 7:46:25 PM" ip_address="172.23.1.13" process="c:\windows\system32\mmc.exe" policy="Windows Medium Enforcement" rule_name="FIM_OSSEC" process_key="00000000-0000-15e8-01d3-490915c2f584" server_version="7.2.1.1903" process_trust="10" process_threat="0"&lt;/P&gt;

&lt;P&gt;Oct 25 13:31:5""0 server2.domain.local Oct 25 13:31:43 172.23.0.24 1 2017-10-25T18:31:43Z server2.domain.local - - - - event:  text="'c:\users\user\appdata\roaming\microsoft\windows\start menu\programs\administrative tools' was created by 'domain\user'." type="Policy Enforcement" subtype="Report write (custom rule)" hostname="domain\user" username="domain\user" date="10/25/2017 6:30:38 PM" ip_address="172.16.1.12" process="c:\windows\system32\mmc.exe" file_path="c:\users\dccon\appdata\roaming\microsoft\windows\start menu\programs\administrative tools" file_name="administrative tools" policy="Windows High Enforcement" rule_name="FIM_Directory" process_key="00000000-0000-0848-01d3-4d9cda329d68" server_version="7.2.1.1903" process_trust="10" process_threat="0"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:28:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334589#M99448</guid>
      <dc:creator>jared_anderson</dc:creator>
      <dc:date>2020-09-29T16:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to pull a filename out of a process field path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334590#M99449</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;^.+\sprocess="(?&amp;lt;filename&amp;gt;.+?)".+$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 22:38:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334590#M99449</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2017-10-25T22:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to pull a filename out of a process field path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334591#M99450</link>
      <description>&lt;P&gt;Try this to get &lt;CODE&gt;filename&lt;/CODE&gt; and &lt;CODE&gt;directory&lt;/CODE&gt; in two separate fields.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events 
| rex "\sprocess=\"(?&amp;lt;directory&amp;gt;(\S+\\))(?&amp;lt;filename&amp;gt;[^\"]+)\""
| table directory, filename
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/d7EYPQ/1"&gt;See above regex here&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you need all in one field called &lt;CODE&gt;file&lt;/CODE&gt; then try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| rex "\sprocess=\"(?&amp;lt;file&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/d7EYPQ/2"&gt;See above regex here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 03:22:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334591#M99450</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2017-10-26T03:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to pull a filename out of a process field path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334592#M99451</link>
      <description>&lt;P&gt;Ah, so i didn't account for file paths with spaces like below. &lt;/P&gt;

&lt;P&gt;Oct 26 07:51:38 server.domain.local Oct 26 07:51:37 172.23.0.24 system event:  text="'c:\users\user\appdata\locallow\microsoft\cryptneturlcache\metadata\7396c420a8e1bc1da97f1af0d10bad21' was created by 'domain\user'." type="Policy Enforcement" subtype="Report write (custom rule)" hostname="domain\user" username="domain\user" date="10/26/2017 12:50:01 PM" ip_address="172.12.0.12" process="c:\program files\microsoft sql server\mssql10_50.mssqlserver\mssql\binn\databasemail.exe" file_path="c:\users\user\appdata\locallow\microsoft\cryptneturlcache\metadata\7396c420a8e1bc1da97f1af0d10bad21" file_name="7396c420a8e1bc1da97f1af0d10bad21" policy="Windows High Enforcement" rule_name="FIM_Directory" process_key="00000000-0000-1bc4-01d3-4e58efc90f89" server_version="7.2.1.1903" process_trust="10" process_threat="0"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:29:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334592#M99451</guid>
      <dc:creator>jared_anderson</dc:creator>
      <dc:date>2020-09-29T16:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to pull a filename out of a process field path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334593#M99452</link>
      <description>&lt;P&gt;process=".+\(?[^"]+)" (policy|file_path)=&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 14:00:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-pull-a-filename-out-of-a-process-field-path/m-p/334593#M99452</guid>
      <dc:creator>jared_anderson</dc:creator>
      <dc:date>2017-10-26T14:00:50Z</dc:date>
    </item>
  </channel>
</rss>

