<?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 Re: How to unhide 'user_name: ******;' when calling custom script as a SmartEvent correlation rule? in Firewall and Security Management</title>
    <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165699#M70010</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2022 17:27:56 GMT</pubDate>
    <dc:creator>David_Herselman</dc:creator>
    <dc:date>2022-12-20T17:27:56Z</dc:date>
    <item>
      <title>How to unhide 'user_name: ******;' when calling custom script as a SmartEvent correlation rule?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165685#M70008</link>
      <description>&lt;P&gt;I'm just not finding references to unhiding additional fields when calling a custom correlation rule, as detailed here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://sc1.checkpoint.com/documents/R81/WebAdminGuides/EN/CP_R81_LoggingAndMonitoring_AdminGuide/Topics-LMG/Creating-External-Script-Automatic-reaction.htm" target="_blank" rel="noopener"&gt;https://sc1.checkpoint.com/documents/R81/WebAdminGuides/EN/CP_R81_LoggingAndMonitoring_AdminGuide/Topics-LMG/Creating-External-Script-Automatic-reaction.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I essentially have a script which will simply log all input passed to it:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;&lt;FONT color="#999999"&gt;[Expert@checkpoint-management:0]#&lt;/FONT&gt; &lt;STRONG&gt;cat $RTDIR/bin/ext_commands/block_on_clearpass&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;#!/bin/bash&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;EVENT=$(cat)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;echo $EVENT &amp;gt;&amp;gt; /tmp/block_on_clearpass&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;This in turn yields the following data being collected:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;&lt;FONT color="#999999"&gt;[Expert@checkpoint-management:0]#&lt;/FONT&gt; &lt;STRONG&gt;tail -n 1 /tmp/block_on_clearpass&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;(StartTime: 20Dec2022 11:10:26; Uuid: deadbeef-dead-beef-dead-beef00000000; rowid: ENdeadbeef-dead-beef-dead-beef00000000; id_generated_by_indexer: false; first: true; sequencenum: 1; log_id: 2000; DisplayName: IP_Block_from_DNS_Trap; Category: User Defined Events; cu_rule_id: DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF; is_correlated: 1; num_of_updates: 0; is_last: 0; event_start_time: 1671534625; detection_time: 2022-12-20T09:10:26Z; time_interval: 60; max_num_count_detected: 2; cu_log_count: 2; cu_detected_by_hostname: checkpoint-management; cu_detected_by: 172.254.254.23; users_repetitions: 2; aba_customer: SMC User; source_repetitions: 2; origin_repetitions: 2; destination_repetitions: 2; service_repetitions: 2; Severity: High; type: Correlated; ProductName: VPN-1 &amp;amp; FireWall-1; product_family: Access; Destination: (hostname: ******; countryname: Israel; IP: 62.0.58.94; repetitions: 1) ; Origin: (IP: 0; hostname: redacted-fw01; repetitions: 1) ; Service: (port: 443; protocol: 6; servicename: https; repetitions: 1) ; Source: (user_name: ******; IP: 172.254.254.23; machine_name: ******; repetitions: 1) ; logid: 392281947) ;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT size="2"&gt;PS: I understand the importance of sanitising input variables, is this possibly simply a safety mechanism so that people can be warned about the dangers?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logs themselves do contain user identities:&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cp_correlation_rule.png" style="width: 864px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18863iD46899CEDE4DEE68/image-size/large?v=v2&amp;amp;px=999" role="button" title="cp_correlation_rule.png" alt="cp_correlation_rule.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SmartEvent is configured as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cp_correlation_rule_detail_1.png" style="width: 954px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18858i6DA12BFD69582A65/image-size/large?v=v2&amp;amp;px=999" role="button" title="cp_correlation_rule_detail_1.png" alt="cp_correlation_rule_detail_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cp_correlation_rule_detail_2.png" style="width: 598px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18859i18A756DA87C7AAFA/image-size/large?v=v2&amp;amp;px=999" role="button" title="cp_correlation_rule_detail_2.png" alt="cp_correlation_rule_detail_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We did add the 'Users' event field with the 'src_user_name' field:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cp_correlation_rule_detail_3.png" style="width: 575px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18860i70CDF5E715DDC32C/image-size/large?v=v2&amp;amp;px=999" role="button" title="cp_correlation_rule_detail_3.png" alt="cp_correlation_rule_detail_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This then has two actions, the first to drop traffic from that source:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cp_correlation_rule_action_1.png" style="width: 706px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18861iDAAF3685D022A0C4/image-size/large?v=v2&amp;amp;px=999" role="button" title="cp_correlation_rule_action_1.png" alt="cp_correlation_rule_action_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the 2nd to stop the device being able to communicate with other devices in the same subnet. For now I'm simply calling the custom script detailed above:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cp_correlation_rule_action_2.png" style="width: 437px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18862iB72E2C58674ED3FC/image-size/large?v=v2&amp;amp;px=999" role="button" title="cp_correlation_rule_action_2.png" alt="cp_correlation_rule_action_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;David Herselman&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 15:41:10 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165685#M70008</guid>
      <dc:creator>David_Herselman</dc:creator>
      <dc:date>2022-12-20T15:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to unhide 'user_name: ******;' when calling custom script as a SmartEvent correlation rule?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165687#M70009</link>
      <description>&lt;P&gt;An old known issue:&amp;nbsp;&lt;A class="cp_link sc_ellipsis" href="https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&amp;amp;solutionid=sk68020&amp;amp;partition=Advanced&amp;amp;product=SmartEvent" target="_blank"&gt;sk68020: In E-mail alerts sent by SmartEvent, the &lt;STRONG&gt;user&lt;/STRONG&gt; &lt;STRONG&gt;name&lt;/STRONG&gt; field contains '*** Confidential ***' instead of real data&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 15:44:31 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165687#M70009</guid>
      <dc:creator>G_W_Albrecht</dc:creator>
      <dc:date>2022-12-20T15:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to unhide 'user_name: ******;' when calling custom script as a SmartEvent correlation rule?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165699#M70010</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 17:27:56 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165699#M70010</guid>
      <dc:creator>David_Herselman</dc:creator>
      <dc:date>2022-12-20T17:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to unhide 'user_name: ******;' when calling custom script as a SmartEvent correlation rule?</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165778#M70011</link>
      <description>&lt;P&gt;Hope the following saves someone else time in future, it should hopefully:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Sanitise input&lt;/LI&gt;&lt;LI&gt;Extract the username who's devices we wish to drop off the network&lt;/LI&gt;&lt;LI&gt;Call an API&lt;/LI&gt;&lt;LI&gt;Log debug information&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[Expert@checkpoint-management:0]# cat $RTDIR/bin/ext_commands/block_on_clearpass
#!/bin/bash
INPUT=$(cat);
CURL_OUTPUT='';
EVENT="${INPUT//[^a-zA-Z0-9 ().,:;+_-]}";
USERID=`echo "$EVENT" | sed -r "/user_name/ s/.*user_name: ([[:alnum:]_-]+).*/\1/"`;

[ ${#USERID} -ge 4 ] &amp;amp;&amp;amp; [ ${#USERID} -le 20 ] &amp;amp;&amp;amp; CURL_OUTPUT=`curl_cli -kX POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/RANDOMSTRINGPROVIDEDBYSLACK --fail --silent --show-error 2&amp;gt;&amp;amp;1`;

if [ ${#CURL_OUTPUT} -gt 0 ]; then
  echo -e "User: $USERID\nCurl debug data: \n$CURL_OUTPUT" &amp;gt;&amp;gt; /tmp/block_on_clearpass;
else
  echo -e "User: $USERID - Curl return code: $? - Sanitised event data:\n$EVENT" &amp;gt;&amp;gt; /tmp/block_on_clearpass;
fi&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 07:55:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/How-to-unhide-user-name-when-calling-custom-script-as-a/m-p/165778#M70011</guid>
      <dc:creator>David_Herselman</dc:creator>
      <dc:date>2022-12-22T07:55:48Z</dc:date>
    </item>
  </channel>
</rss>

