<?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: Count repeated failured logons following a successful logon in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474568#M133442</link>
    <description>&lt;P&gt;@tmontney -&lt;BR /&gt;
&lt;CODE&gt;transaction&lt;/CODE&gt; is highly expensive, and almost every use case the same search can be done better with less resources by proper use of &lt;CODE&gt;stats&lt;/CODE&gt;, &lt;CODE&gt;streamstats&lt;/CODE&gt; and/or &lt;CODE&gt;eventstats&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Plus, if you engineer your search to use exactly those, then you know exactly what it is doing.  &lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 16:03:08 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2020-04-15T16:03:08Z</dc:date>
    <item>
      <title>Count repeated failured logons following a successful logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474563#M133437</link>
      <description>&lt;P&gt;Here's what I got so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myindex" (host="192.168.0.100" OR host="192.168.0.101") (msg="login OK" OR msg="login FAILED")
| transaction user maxspan=30s  endswith="login OK"
| eval FailedLogons=eventcount-1
| where msg="login FAILED" AND FailedLogons &amp;gt;= 3
| table _time user FailedLogons
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For example, a user's account quickly fails to logon 3 times, then successfully logs on. I consider this strange activity and want to track it. This query gets me mostly there; however, assumes all events before "login OK" are failures (which may not always be the case). &lt;CODE&gt;Transaction&lt;/CODE&gt; combines &lt;CODE&gt;msg&lt;/CODE&gt; to where there's only one value of each; however, &lt;CODE&gt;_raw&lt;/CODE&gt; contains the combined fields.&lt;/P&gt;

&lt;P&gt;Is there a way to look for 3 consecutive failures that end with success?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 19:06:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474563#M133437</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-04-09T19:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count repeated failured logons following a successful logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474564#M133438</link>
      <description>&lt;P&gt;The Splunk Security Essentials app has a example query that does something similar.  Look for the "Brute Force Login Attempts" use case.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 20:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474564#M133438</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-04-09T20:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Count repeated failured logons following a successful logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474565#M133439</link>
      <description>&lt;P&gt;I've always been meaning to look at this, good idea.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 14:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474565#M133439</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-04-10T14:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count repeated failured logons following a successful logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474566#M133440</link>
      <description>&lt;P&gt;&lt;CODE&gt;transaction&lt;/CODE&gt; is almost never the answer.  This is a job for &lt;CODE&gt;streamstats&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="myindex" (host="192.168.0.100" OR host="192.168.0.101") (msg="login OK" OR msg="login FAILED")

 | rename COMMENT as "mark logons and then number them, remembering their time"
 | eval OK_flag=case(msg="login OK",1) 
 | streamstats sum(OK_flag) as OK_group last(eval(case(OK_flag=1,_time))) as next_logon by user

 | rename COMMENT as "for each group, count the number of fails"
 | eval fail_flag=case(msg="login FAILED",1)
 | eval fail_time=case(msg="login FAILED",_time)
 | eventstats max(next_logon) as next_logon sum(fail_flag) as fail_count by user OK_group

 | rename COMMENT as "drop all groups with less than 3 fails"
 | where fail_count &amp;gt;=3 

 | rename COMMENT as "you can stop here, or analyze a little more, since we haven't limited the time of fails to 30 sec"
 | where (next_logon &amp;lt; _time+30)

 | rename COMMENT as "roll up each group"
 | stats sum(fail_flag) as fail_count min(fail_time) as first_fail_time max(fail_time) as last_fail_time values(_time) as _time max(next_logon) as logon_time by user OK_group 

 | convert ctime(*_time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above is aircode, but it should be pretty close .&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 22:55:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474566#M133440</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-04-10T22:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Count repeated failured logons following a successful logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474567#M133441</link>
      <description>&lt;P&gt;Why is transaction "almost never the answer"?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 15:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474567#M133441</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-04-15T15:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Count repeated failured logons following a successful logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474568#M133442</link>
      <description>&lt;P&gt;@tmontney -&lt;BR /&gt;
&lt;CODE&gt;transaction&lt;/CODE&gt; is highly expensive, and almost every use case the same search can be done better with less resources by proper use of &lt;CODE&gt;stats&lt;/CODE&gt;, &lt;CODE&gt;streamstats&lt;/CODE&gt; and/or &lt;CODE&gt;eventstats&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Plus, if you engineer your search to use exactly those, then you know exactly what it is doing.  &lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 16:03:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-repeated-failured-logons-following-a-successful-logon/m-p/474568#M133442</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-04-15T16:03:08Z</dc:date>
    </item>
  </channel>
</rss>

