<?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 Detecting successful login after multiple failed logins in a transaction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Detecting-successful-login-after-multiple-failed-logins-in-a/m-p/697517#M236947</link>
    <description>&lt;P&gt;I'm not very good with SPL. I currently have Linux application logs that show the IP address, user name, and if the user failed or had a successful login.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm interested in finding a successful login after one or more failed login attempts.&amp;nbsp;I currently have the following search. The transaction command is necessary where it is or otherwise, all the events are split up into separate events of varying line counts.&lt;/P&gt;&lt;PRE&gt;index=honeypot sourcetype=honeypotLogs&lt;BR /&gt;| transaction sessionID&lt;BR /&gt;| search "SSH2_MSG_USERAUTH_FAILURE" OR "SSH2_MSG_USERAUTH_SUCCESS"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Below is an example event. For clarity, I replaced details/omitted details from the logs below.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[02] Tue 27Aug24 15:20:57 - (143323) Connected to 1.2.3.4
...
...
[30] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_REQUEST: user: bob
[31] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_FAILURE
...
[30] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_REQUEST: user: bob
[02] Tue 27Aug24 15:20:57 - (143323) User "bob" logged in
[31] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_SUCCESS: successful login&lt;/LI-CODE&gt;&lt;P&gt;Any tips on getting my search to find events like this?&amp;nbsp;Currently I only have field extractions for the IP (1.2.3.4), user (bob), and sessionID (143323). I can possibly create a field extraction for the SSH2 messages but I don't know if that will help or not.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 27 Aug 2024 19:38:05 GMT</pubDate>
    <dc:creator>st1</dc:creator>
    <dc:date>2024-08-27T19:38:05Z</dc:date>
    <item>
      <title>Detecting successful login after multiple failed logins in a transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detecting-successful-login-after-multiple-failed-logins-in-a/m-p/697517#M236947</link>
      <description>&lt;P&gt;I'm not very good with SPL. I currently have Linux application logs that show the IP address, user name, and if the user failed or had a successful login.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm interested in finding a successful login after one or more failed login attempts.&amp;nbsp;I currently have the following search. The transaction command is necessary where it is or otherwise, all the events are split up into separate events of varying line counts.&lt;/P&gt;&lt;PRE&gt;index=honeypot sourcetype=honeypotLogs&lt;BR /&gt;| transaction sessionID&lt;BR /&gt;| search "SSH2_MSG_USERAUTH_FAILURE" OR "SSH2_MSG_USERAUTH_SUCCESS"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Below is an example event. For clarity, I replaced details/omitted details from the logs below.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[02] Tue 27Aug24 15:20:57 - (143323) Connected to 1.2.3.4
...
...
[30] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_REQUEST: user: bob
[31] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_FAILURE
...
[30] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_REQUEST: user: bob
[02] Tue 27Aug24 15:20:57 - (143323) User "bob" logged in
[31] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_SUCCESS: successful login&lt;/LI-CODE&gt;&lt;P&gt;Any tips on getting my search to find events like this?&amp;nbsp;Currently I only have field extractions for the IP (1.2.3.4), user (bob), and sessionID (143323). I can possibly create a field extraction for the SSH2 messages but I don't know if that will help or not.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 19:38:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detecting-successful-login-after-multiple-failed-logins-in-a/m-p/697517#M236947</guid>
      <dc:creator>st1</dc:creator>
      <dc:date>2024-08-27T19:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting successful login after multiple failed logins in a transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detecting-successful-login-after-multiple-failed-logins-in-a/m-p/697547#M236953</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223508"&gt;@st1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;don't use transaction command because it's very slow, please try something like this, adapting my solution to your use case (e.g. the thresholds in the last row):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=honeypot sourcetype=honeypotLogs ("SSH2_MSG_USERAUTH_FAILURE" OR "SSH2_MSG_USERAUTH_SUCCESS")
| eval kind=if(searchmatch("SSH2_MSG_USERAUTH_FAILURE", "success","failure")
| stats 
     dc(kind) AS kind_count)
     count(eval(kind="success)) As success_count
     count(eval(kind="failure)) As failure_count
     BY sessionID
| where kind_count=2 AND success_count&amp;gt;0 AND failure_count&amp;gt;10&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 06:25:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detecting-successful-login-after-multiple-failed-logins-in-a/m-p/697547#M236953</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-08-28T06:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting successful login after multiple failed logins in a transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Detecting-successful-login-after-multiple-failed-logins-in-a/m-p/697552#M236954</link>
      <description>&lt;P&gt;Yes, SSH2 message is key. &amp;nbsp;The actual solution kind of depends on your exact use case/requirement. &amp;nbsp;If you don't particularly care if the user had multiple failures, transaction will do just fine. &amp;nbsp;Assuming your sessionID is unique for each connection and that you don't care if attempted user name is the same, simply add startswith and endswith.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=honeypot sourcetype=honeypotLogs
| rex "\s(?&amp;lt;action&amp;gt;Connected) to (?&amp;lt;IP&amp;gt;\S+)"
| rex "\sUser \"(?&amp;lt;user&amp;gt;\S+)\" (?&amp;lt;action&amp;gt;logged in)"
| rex "\sSSH2_MSG_(?&amp;lt;ssh2_msg_type&amp;gt;\w+)"
| rex ": (?&amp;lt;ssh2_message&amp;gt;.+)"
| rex field=ssh2_message "user: (?&amp;lt;user&amp;gt;\S+)"
| transaction sessionID startswith=ssh2_msg_type=USERAUTH_FAILURE endswith=ssh2_msg_type=USERAUTH_SUCCESS&lt;/LI-CODE&gt;&lt;P&gt;The above maybe goes a little overboard in extraction but usually, these semantic elements can be of interest.&lt;/P&gt;&lt;P&gt;If you care about attempted user name, you can add user to transaction. &amp;nbsp;If you care about multiple failed attempts, streamstats could be a better approach.&lt;/P&gt;&lt;P&gt;The following is an extended emulation; it shows that&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;transaction will only pick up sessions with at least one USERAUTH_FAILURE, and&lt;/LI&gt;&lt;LI&gt;transaction will only include the last event with USERAUTH_FAILURE.&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="_raw
[02] Tue 27Aug24 15:20:56 - (143323) Connected to 1.2.3.4
[30] Tue 27Aug24 15:20:56 - (143323) SSH2_MSG_USERAUTH_REQUEST: user: bob
[31] Tue 27Aug24 15:20:56 - (143323) SSH2_MSG_USERAUTH_FAILURE
[30] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_REQUEST: user: bob
[31] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_FAILURE
[30] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_REQUEST: user: bob
[02] Tue 27Aug24 15:20:57 - (143323) User \"bob\" logged in
[31] Tue 27Aug24 15:20:57 - (143323) SSH2_MSG_USERAUTH_SUCCESS: successful login
[02] Tue 27Aug24 15:20:58 - (143523) Connected to 1.2.3.4
[30] Tue 27Aug24 15:20:58 - (143523) SSH2_MSG_USERAUTH_REQUEST: user: alice
[02] Tue 27Aug24 15:20:58 - (143523) User \"alice\" logged in
[31] Tue 27Aug24 15:20:58 - (143523) SSH2_MSG_USERAUTH_SUCCESS: successful login"
| rex "^(\S+\s+){2}(?&amp;lt;_time&amp;gt;\S+\s+\S+) - \((?&amp;lt;sessionID&amp;gt;\d+)"
| eval _time = strptime(_time, "%d%b%y %T")
| reverse
``` the above emulates
index=honeypot sourcetype=honeypotLogs
```&lt;/LI-CODE&gt;&lt;P&gt;Play with the emulation and compare with real data.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 07:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Detecting-successful-login-after-multiple-failed-logins-in-a/m-p/697552#M236954</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-08-28T07:10:49Z</dc:date>
    </item>
  </channel>
</rss>

