<?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 XQLs for powershell script logging? in Cortex XDR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xqls-for-powershell-script-logging/m-p/542059#M4342</link>
    <description>&lt;P&gt;Hello dear community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;has anyone of you some usefull powershell script block XQLs for event logs to share them with us?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Rob&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 13 May 2023 22:19:45 GMT</pubDate>
    <dc:creator>RFeyertag</dc:creator>
    <dc:date>2023-05-13T22:19:45Z</dc:date>
    <item>
      <title>XQLs for powershell script logging?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xqls-for-powershell-script-logging/m-p/542059#M4342</link>
      <description>&lt;P&gt;Hello dear community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;has anyone of you some usefull powershell script block XQLs for event logs to share them with us?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Rob&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 22:19:45 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xqls-for-powershell-script-logging/m-p/542059#M4342</guid>
      <dc:creator>RFeyertag</dc:creator>
      <dc:date>2023-05-13T22:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: XQLs for powershell script logging?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xqls-for-powershell-script-logging/m-p/542483#M4376</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/190671"&gt;@RFeyertag&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Hi Rob-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i understood your request correctly, we can utilize the deeper inspection mechanism that is built-in for scripting services in windows that is part of the&amp;nbsp;Antimalware Scan Interface (AMSI).&lt;BR /&gt;In that, we can look at the content of the&amp;nbsp;Antimalware Scan Interface (AMSI) buffer (AmsiScanBuffer ) and retrieve the information we are looking for , either from the event log message or form the event log data fields itself , where we can get information such as (a snippet from a lab environment below):&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;"appname": "VBScript",&lt;BR /&gt;"session": "0x0",&lt;BR /&gt;"content": "IHost.CreateObject(\"WScript.Shell\");\r\nIWshShell3.Run(\"C:\\xampp\\htdocs\\update.bat\", \"0\", \"true\");\r\n",&lt;BR /&gt;"scanStatus": "0",&lt;BR /&gt;"contentname": "C:\\xampp\\htdocs\\vb.vbs",&lt;BR /&gt;"scanResult": "1",&lt;BR /&gt;"originalsize": "196",&lt;BR /&gt;"contentsize": "196",&lt;BR /&gt;"hash": "0xB3D07F9F1DDFD9C26EB15A41DB734BA380360F5577015B0C70CC9858849DB8FD",&lt;BR /&gt;"contentFiltered": "false",&lt;BR /&gt;"hashoriginalcontent": "0x0000000000000000000000000000000000000000000000000000000000000000"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Now, for us to extract those information form the "string represented in JSON" filed or from he event log message we can use some extraction techniques provided by XQL , i will referee you to a detailed webinar we had that goes over the extraction for the event log messages in both cases ( Webinar Link in case you would like to get more information in this regard - &lt;A href="https://live.paloaltonetworks.com/t5/cortex-xdr-webinars/cortex-xdr-customer-success-webinar-advanced-xql-workshop/ta-p/540388" target="_blank" rel="noopener"&gt;https://live.paloaltonetworks.com/t5/cortex-xdr-webinars/cortex-xdr-customer-success-webinar-advanced-xql-workshop/ta-p/540388&lt;/A&gt;) .&lt;BR /&gt;&lt;BR /&gt;Back to your question about a query that can return these results, we can use the below one:&lt;BR /&gt;Config case_sensitive = false &lt;BR /&gt;| dataset = xdr_data // or you can use perset = preset = xdr_event_log&lt;BR /&gt;| filter event_type = EVENT_LOG and action_evtlog_message = "AmsiScanBuffer"&lt;BR /&gt;| alter app_name = json_extract_scalar(action_evtlog_data_fields, "$.appname")&lt;BR /&gt;| alter content = json_extract_scalar(action_evtlog_data_fields, "$.content")&lt;BR /&gt;| alter content_name = json_extract_scalar(action_evtlog_data_fields, "$.contentname")&lt;BR /&gt;| fields agent_hostname, content, content_name, app_name, action_evtlog_data_fields, action_evtlog_message ,actor_effective_username, actor_process_image_path, actor_process_command_line&lt;BR /&gt;| sort desc _time&lt;BR /&gt;&lt;BR /&gt;Additional filtering can be added to the "content" field depending on the use case you are trying to achieve.&lt;BR /&gt;&lt;BR /&gt;Please give this a try and let me know if it helps&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Z&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 17:22:54 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xqls-for-powershell-script-logging/m-p/542483#M4376</guid>
      <dc:creator>zarnous</dc:creator>
      <dc:date>2023-05-18T17:22:54Z</dc:date>
    </item>
  </channel>
</rss>

