<?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: Detect Brute Force auth success after multiple failures in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509820#M142510</link>
    <description>&lt;P&gt;sample:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=10000
| eval status="failed", count=1
| accum count
| eval status = if( count % 10 = 1,"success",status), user=mvindex(split("testA,testB,testC",","),random() % 3)
| eval src_ip=mvindex(split("X.X.X.X,Y.Y.Y.Y",","),random() % 2)
| eval _time=_time - count 
| sort 0 _time
| streamstats global=f count(eval(status="success")) as session by user src_ip
| streamstats count(eval(status="failed")) as failed_count by session user src_ip
| table _time src_ip user status failed_count
| sort user src_ip _time&lt;/LI-CODE&gt;&lt;P&gt;how about this?&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jul 2020 00:19:17 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-07-18T00:19:17Z</dc:date>
    <item>
      <title>Detect Brute Force auth success after multiple failures</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509814#M142507</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to detect brute force activity by detecting multiple auth failures followed by success.&amp;nbsp; I started with the following search which works and shows when there has been over 20 failures and at least 1 success, but the success can happen anywhere during the search period. It could be 1 success followed by 20 failures or the success can happen in the middle.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype="wineventlog" (EventCode=4624 OR EventCode=4625) Logon_Type IN (2,3,8,10,11) user!=*$
  | bin _time span=5m as Time 
  | stats count(eval(match(Keywords,"Audit Failure"))) as Failed,
       count(eval(match(Keywords,"Audit Success"))) as Success,
       count(eval(match(lower(Status),"0xc0000224"))) as "PwChangeReq",
       count(eval(match(lower(Sub_Status),"0xc0000071"))) as "Expired",
       count(eval(match(lower(Status),"0xc0000234"))) as "Locked" by Time user src_ip
  | where Success&amp;gt;0 AND Failed&amp;gt;=20 AND PwChangeReq=0 AND Locked=0 AND Expired=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the query to only trigger if the success happens after 20 failures. I found some examples using streamstats so I created the following search but it's not working properly because the *reset_after* clears the failure_count for all src_ip. Therefore as long as there is 1 success from any IP address, the failure_count gets reset and I'm not seeing the failure count reach 20.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype="wineventlog" EventCode IN (4624,4625) Logon_Type IN (2,3,8,10,11) 
 | eval action=if(match(Keywords,"Audit Failure"),"failed","success")
 | reverse
 | streamstats window=0 current=true reset_after="("action==\"success\"")" count as failure_count by src_ip
 | where action="success" and failure_count &amp;gt; 20
 | table _time, user, src_ip, action, failure_count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is streamstats the way to go? Or how can I setup a query to detect the success after more than 20 failures?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 22:17:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509814#M142507</guid>
      <dc:creator>gnoriega</dc:creator>
      <dc:date>2020-07-17T22:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Brute Force auth success after multiple failures</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509817#M142508</link>
      <description>&lt;P&gt;sample:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=100000
| eval status="failed", count=1
| eval status = if( count = random() % 20,"success",status), user=mvindex(split("testA,testB,testC",","),random() % 3)
| eval src_ip=mvindex(split("X.X.X.X,Y.Y.Y.Y",","),random() % 2)
| accum count
| eval _time=_time - count 
| sort 0 _time
| streamstats global=f count(eval(status="failed")) as Failed by user src_ip reset_before="status=\"success\""
| table _time src_ip user status Failed
| where Failed &amp;gt; 20&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try&amp;nbsp;&lt;STRONG&gt;streamstats global=f ...&lt;BR /&gt;&lt;/STRONG&gt;The data is randomly generated, so the results may not be available.&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 23:20:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509817#M142508</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-17T23:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Brute Force auth success after multiple failures</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509818#M142509</link>
      <description>&lt;P&gt;I tried using global=f but I get the same behavior. Once a success is seen and the stats reset they are reset for all src_ip.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 23:55:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509818#M142509</guid>
      <dc:creator>gnoriega</dc:creator>
      <dc:date>2020-07-17T23:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Brute Force auth success after multiple failures</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509820#M142510</link>
      <description>&lt;P&gt;sample:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=10000
| eval status="failed", count=1
| accum count
| eval status = if( count % 10 = 1,"success",status), user=mvindex(split("testA,testB,testC",","),random() % 3)
| eval src_ip=mvindex(split("X.X.X.X,Y.Y.Y.Y",","),random() % 2)
| eval _time=_time - count 
| sort 0 _time
| streamstats global=f count(eval(status="success")) as session by user src_ip
| streamstats count(eval(status="failed")) as failed_count by session user src_ip
| table _time src_ip user status failed_count
| sort user src_ip _time&lt;/LI-CODE&gt;&lt;P&gt;how about this?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 00:19:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/509820#M142510</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-18T00:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Brute Force auth success after multiple failures</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/510067#M142591</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;&amp;nbsp;thanks but I'm still not getting the behavior I need. I do see that it properly keeps count of each "session" and only resets the failure_count when there is a success for that user,src_ip which is better.&lt;/P&gt;&lt;P&gt;The issue I have is that I need to filter when there is a success and the failed count had reached over a certain amount. So if for example my threshold is 15, in the screenshot below I see that the success occurred after 19 failures which is what I need to detect. But I don't have a way to detect it.&lt;/P&gt;&lt;P&gt;With the previous "reset_after" command, the row with the success had the failed_count total, so I could do:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where failed_count&amp;gt;15 AND status="success"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would there be a way for the row with the status="success" to have the failed_count reached so far before resetting?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="streamstats1.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9789iAF84F3CE3B719DF7/image-size/large?v=v2&amp;amp;px=999" role="button" title="streamstats1.PNG" alt="streamstats1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 16:48:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/510067#M142591</guid>
      <dc:creator>gnoriega</dc:creator>
      <dc:date>2020-07-20T16:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Brute Force auth success after multiple failures</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/510085#M142602</link>
      <description>&lt;P&gt;I found the solution. I had to replace line:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| reverse&lt;/LI-CODE&gt;&lt;P&gt;with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sort src_ip _time&lt;/LI-CODE&gt;&lt;P&gt;So that streamstats resets the counter each time the action is "success" for each src_ip.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Working code:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main sourcetype="wineventlog" EventCode IN (4624,4625) Logon_Type IN (2,3,8,10,11) 
 | eval action=if(match(Keywords,"Audit Failure"),"failed","success")
 | sort src_ip _time
 | streamstats window=0 current=true reset_after="("action==\"success\"")" count as failure_count by src_ip
 | where action="success" and failure_count &amp;gt; 20
 | table _time, user, src_ip, action, failure_count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 18:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detect-Brute-Force-auth-success-after-multiple-failures/m-p/510085#M142602</guid>
      <dc:creator>gnoriega</dc:creator>
      <dc:date>2020-07-20T18:05:11Z</dc:date>
    </item>
  </channel>
</rss>

