<?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 How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218417#M64185</link>
    <description>&lt;P&gt;Few days ago, a developer has added to John the Ripper the ability to timestamp every line of logs, allowing me to feed them to Splunk in order to derive statistics from this data.&lt;BR /&gt;
JtR's logs are complex, starting with a header of several lines giving details about the current session:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-23T20:43:57+0100 1 0:00:00:00 Starting a new session
2016-02-23T20:43:57+0100 1 0:00:00:00 Loaded a total of 15151 password hashes with 15151 different salts
2016-02-23T20:43:57+0100 1 0:00:00:00 Sorting salts, for performance
2016-02-23T20:43:57+0100 1 0:00:00:00 Remaining 14755 password hashes with 14755 different salts
2016-02-23T20:43:57+0100 1 0:00:00:00 - Node numbers 1-4 of 4 (fork)
2016-02-23T20:43:57+0100 1 0:00:00:00 Command line: ./john --fork=4 --wordlist=password.lst --rules=JUMBO dump.txt 
2016-02-23T20:43:57+0100 1 0:00:00:00 - UTF-8 input encoding enabled
2016-02-23T20:43:57+0100 1 0:00:00:00 - Passwords will be stored UTF-8 encoded in .pot file
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After this header, each cracked password yields to a new line, and periodically an info line is printed:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-23T20:50:38+0100 2 0:00:06:41 + Cracked foo
2016-02-23T20:50:50+0100 1 0:00:06:53 + Cracked bar
2016-02-23T20:50:47+0100 3 0:00:06:49 + pot sync removed 2 hashes; Remaining 14583 hashes with 14583 different salts
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The session can end by exhaustion (no more passwords, or no more candidates), or by interrupt (ctrl-c). Message is either:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-23T22:17:06+0100 2 0:01:33:09 Session completed
or
2016-02-24T11:03:47+0100 4 0:00:38:22 Session aborted
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to be able to track down and compare efficiency of different sessions. Each session has different parameters that can be read from the header ("Command line:" and other header log lines).&lt;BR /&gt;
Efficiency can be measured as the number of "Cracked" in a given period of time. Difficulty for me is to make a timechart , chart, or stats calculation for each session from a single Splunk request so everything is displayed on one graph/chart.&lt;/P&gt;

&lt;P&gt;I've started investigating transactions, that's quite easy with a first line containing "Starting a new session" and the last containing "Session *ted". But it seems I can't work inside a transaction to create timechart.&lt;/P&gt;

&lt;P&gt;Any hint?&lt;/P&gt;</description>
    <pubDate>Wed, 24 Feb 2016 22:31:40 GMT</pubDate>
    <dc:creator>patpro</dc:creator>
    <dc:date>2016-02-24T22:31:40Z</dc:date>
    <item>
      <title>How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218417#M64185</link>
      <description>&lt;P&gt;Few days ago, a developer has added to John the Ripper the ability to timestamp every line of logs, allowing me to feed them to Splunk in order to derive statistics from this data.&lt;BR /&gt;
JtR's logs are complex, starting with a header of several lines giving details about the current session:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-23T20:43:57+0100 1 0:00:00:00 Starting a new session
2016-02-23T20:43:57+0100 1 0:00:00:00 Loaded a total of 15151 password hashes with 15151 different salts
2016-02-23T20:43:57+0100 1 0:00:00:00 Sorting salts, for performance
2016-02-23T20:43:57+0100 1 0:00:00:00 Remaining 14755 password hashes with 14755 different salts
2016-02-23T20:43:57+0100 1 0:00:00:00 - Node numbers 1-4 of 4 (fork)
2016-02-23T20:43:57+0100 1 0:00:00:00 Command line: ./john --fork=4 --wordlist=password.lst --rules=JUMBO dump.txt 
2016-02-23T20:43:57+0100 1 0:00:00:00 - UTF-8 input encoding enabled
2016-02-23T20:43:57+0100 1 0:00:00:00 - Passwords will be stored UTF-8 encoded in .pot file
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After this header, each cracked password yields to a new line, and periodically an info line is printed:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-23T20:50:38+0100 2 0:00:06:41 + Cracked foo
2016-02-23T20:50:50+0100 1 0:00:06:53 + Cracked bar
2016-02-23T20:50:47+0100 3 0:00:06:49 + pot sync removed 2 hashes; Remaining 14583 hashes with 14583 different salts
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The session can end by exhaustion (no more passwords, or no more candidates), or by interrupt (ctrl-c). Message is either:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-23T22:17:06+0100 2 0:01:33:09 Session completed
or
2016-02-24T11:03:47+0100 4 0:00:38:22 Session aborted
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to be able to track down and compare efficiency of different sessions. Each session has different parameters that can be read from the header ("Command line:" and other header log lines).&lt;BR /&gt;
Efficiency can be measured as the number of "Cracked" in a given period of time. Difficulty for me is to make a timechart , chart, or stats calculation for each session from a single Splunk request so everything is displayed on one graph/chart.&lt;/P&gt;

&lt;P&gt;I've started investigating transactions, that's quite easy with a first line containing "Starting a new session" and the last containing "Session *ted". But it seems I can't work inside a transaction to create timechart.&lt;/P&gt;

&lt;P&gt;Any hint?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 22:31:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218417#M64185</guid>
      <dc:creator>patpro</dc:creator>
      <dc:date>2016-02-24T22:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218418#M64186</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;If you replace transaction with streamstats + stats you should be able to gain some extra control that you can use for your own benefit.&lt;BR /&gt;
I've written the following based on your logs that replaces the use of transaction, if you could explain with an example what you are expecting to see in a tabular format it would definitely help a lot:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="johntheripper" index=foo
| rex "^\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}[+|-]\d{4} \d (?&amp;lt;session_time_D&amp;gt;\d{1,2}):(?&amp;lt;session_time_H&amp;gt;\d{2}):(?&amp;lt;session_time_M&amp;gt;\d{2}):(?&amp;lt;session_time_S&amp;gt;\d{2}) (?&amp;lt;message_text&amp;gt;.+)$"
| eval message_type = case (
    match(message_text, "Starting a new session"), "SESSION_START",
    match(message_text, "Session completed") OR match(message_text, "Session aborted"), "SESSION_END",
    match(message_text, "Command line"), "COMMAND_LINE",
    match(message_text, "Cracked"), "PASSWORD_CRACKED",
    1==1, "NOT_CLASSIFIED"
)
| eval transaction_end = if(match(message_type, "SESSION_END"), 1, 0)
| eval password_cracked = if(match(message_type, "PASSWORD_CRACKED"), 1, 0)
| eval session_time = session_time_D * 86400 + session_time_H * 3600 + session_time_M * 60 + session_time_S
| reverse
| streamstats count(eval(match(message_type, "SESSION_START"))) as transaction_id
| stats
    earliest(_time) as start_time
    latest(_time) as end_time
    range(_time) as duration
    list(message_type) as message_type
    list(message_text) as message_text
    list(session_time) as session_time
    sum(password_cracked) as passwords_cracked
    sum(transaction_end) as is_transaction_closed
    by transaction_id
| where is_transaction_closed &amp;gt; 0
| fieldformat start_time = strftime(start_time, "%Y-%m-%d %H:%M:%S")
| fieldformat end_time = strftime(end_time, "%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Feb 2016 11:01:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218418#M64186</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-25T11:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218419#M64187</link>
      <description>&lt;P&gt;By the way, apart from my comment above, if i were you I would try to write a very detailed parsing for these logs using the documentation (if there's any). That way you can classify your events, create macros and use more powerful features.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 11:05:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218419#M64187</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-25T11:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218420#M64188</link>
      <description>&lt;P&gt;Thanks javiergn, I guess I'm starting to understand how I could work without true transactions.&lt;BR /&gt;
Unfortunately, as is, your code returns some very odd results that might be caused by the fact a single log file records many successive sessions. If I "zoom" to a period of time where I have only one session, the result is OK, apart from some limitation issues:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE&gt;'stats' command: limit for values of field 'message_text' reached. Some values may have been truncated or ignored.
'stats' command: limit for values of field 'message_type' reached. Some values may have been truncated or ignored.
'stats' command: limit for values of field 'session_time' reached. Some values may have been truncated or ignored.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ideally, the output would be a plot showing for each session the command line (legend for example) and number-of-cracked-pwd=f(time). &lt;BR /&gt;
It means I need to be able to declare: while I'm inside an active session, title=my-command-line (or a part of my-command-line, like my wordlist, my passwd file…)&lt;BR /&gt;
And then timechart count(Cracked) by title.&lt;BR /&gt;
It's even better if I can plot every timechart with the same origin (hence every ploted session seems to start at the same time, allowing a better graphical comparison between them).&lt;BR /&gt;
I know I can do this in just minutes with awk and gnuplot, but the result would be very static (and boring).&lt;BR /&gt;
I've started to configure field extractions, but I'm not finished yet, I need to test every different cases (markov, incremental, wordlist, single, etc.).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 25 Feb 2016 18:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218420#M64188</guid>
      <dc:creator>patpro</dc:creator>
      <dc:date>2016-02-25T18:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218421#M64189</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Unfortunately, as is, your code returns some very odd results that might be caused by the fact a single log file records many successive sessions. &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Hi, regarding this. Do you mean there can be multiple active sessions at the same time and therefore the event lines related to those sessions could be intercalated?&lt;BR /&gt;
If that's the case, is there any way to differentiate sessions that doesn't rely on time? Is there any sort of unique ID we can use?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 09:54:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218421#M64189</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-26T09:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218422#M64190</link>
      <description>&lt;P&gt;No concurrent sessions, it's only one at a time. I've just realized my mistake: the content of columns message_type and message_text are not always aligned (on a line to line basis), because message_text lines can be so long they wrap, yielding to apparent mismatch. Example in the picture :&lt;BR /&gt;
&lt;IMG src="https://www.patpro.net/cafesale/johnlog.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;My bad, no problem here.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:57:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218422#M64190</guid>
      <dc:creator>patpro</dc:creator>
      <dc:date>2020-09-29T08:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218423#M64191</link>
      <description>&lt;P&gt;Hi @patpro,&lt;/P&gt;

&lt;P&gt;Did you come up with a working query?&lt;BR /&gt;
If so, can you post it here and mark it as answered so that others can benefit from it?&lt;/P&gt;

&lt;P&gt;If you need extra assistance please do not hesitate to ask.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J &lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 13:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218423#M64191</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-29T13:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write a timechart search with transaction to compare sessions over time (John the Ripper logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218424#M64192</link>
      <description>&lt;P&gt;Hi @javiergn&lt;BR /&gt;
No solution yet. The more I think about this problem the less I think Splunk can handle it.&lt;BR /&gt;
Your query properly breaks log file into cracking sessions, and classifies events, which is fine. But from here I can't plot a timechart of cracked pwds (and even though, I would have to tune Splunk so it can handle +30-50K events per cracking session).&lt;BR /&gt;
In the end of my second post, I've managed to explain a little bit more clearly what I'm trying to achieve. Tonight I've spent some time on awk/gnuplot to get the result I'm looking for.&lt;BR /&gt;
&lt;IMG src="https://www.patpro.net/cafesale/john.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;It's rough, quick&amp;amp;dirty, probably won't scale very well, but the idea is here.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:58:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-write-a-timechart-search-with-transaction-to-compare/m-p/218424#M64192</guid>
      <dc:creator>patpro</dc:creator>
      <dc:date>2016-02-29T21:58:17Z</dc:date>
    </item>
  </channel>
</rss>

