<?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: Searching for Multiple Commands In Succession in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450297#M127507</link>
    <description>&lt;P&gt;You should avoid &lt;CODE&gt;transaction&lt;/CODE&gt; except for limited ad-hoc cases; it should &lt;EM&gt;NEVER&lt;/EM&gt; be used in a scheduled search.  Try something like this (assumes your data has a field named &lt;CODE&gt;command&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=YouShouldAlwaysSpecifyANIndex AND sourcetype=AndSourcetypeToo AND [|inputlookup YourLookupFileWithOneCommandOnEachLineWithTheFIeldNamedTheSameAsYourDataUses.csv]
| streamstats values(command) AS commands dc(command) AS commandCount BY host user _time span=2m
| where commandCount &amp;gt;= 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 29 Jun 2019 15:02:29 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-06-29T15:02:29Z</dc:date>
    <item>
      <title>Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450287#M127497</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I am looking at endpoint data and I want to see if I can make a search query to look at certain commands that are run in fairly quick succession, say a minute or two. Essentially, someone running cp, then chown, then using kextcache or something of that nature. &lt;/P&gt;

&lt;P&gt;The idea is to gather results of people performing these commands right after another or within a minute or so to see someone trying to install something malicious. I saw another post talking about streamstats but it doesn't seem to work the way I want it. To be honest, I don't have much of a query yet so I would appreciate any input that could describe how to do this.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 20:10:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450287#M127497</guid>
      <dc:creator>cxr5971</dc:creator>
      <dc:date>2019-06-26T20:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450288#M127498</link>
      <description>&lt;P&gt;how does your data looks like?&lt;BR /&gt;
can you share some samples?&lt;BR /&gt;
is it the good old .bash history? do you have auditd?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 02:40:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450288#M127498</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-06-27T02:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450289#M127499</link>
      <description>&lt;P&gt;Hello @adonio I can't really share what the data looks like in picture form but I can't describe it the best I can. Each event has one command that a user performed called "CommandLine". Each event also has a bunch of other data, but the important thing here is a UID and other things to identify each user.&lt;/P&gt;

&lt;P&gt;I'm looking for something that will look at all the data, and say hey he typed this command, let's say we look for a user typing "cp -R abc.kext /&lt;EM&gt;" and then not even a minute later there's another event via the same UID saying  "chown -R root:wheel&lt;/EM&gt;". Then another event with him linking certain things. I want to show this data somehow. I want to clump those events together and say "here's the string of commands that he did".&lt;/P&gt;

&lt;P&gt;Also it may be beneficial to search for these commands in the order they occurred.&lt;/P&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 12:31:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450289#M127499</guid>
      <dc:creator>cxr5971</dc:creator>
      <dc:date>2019-06-27T12:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450290#M127500</link>
      <description>&lt;P&gt;Instead of doing a heavy SPL I would suggest you try to take a look at &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/Knowledge/Setupasearchworkflowaction"&gt;Workflow Actions&lt;/A&gt;. &lt;BR /&gt;
That is what they're here for - doing things in sequence. &lt;/P&gt;

&lt;P&gt;Skalli&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 16:36:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450290#M127500</guid>
      <dc:creator>skalliger</dc:creator>
      <dc:date>2019-06-27T16:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450291#M127501</link>
      <description>&lt;P&gt;I don't think that this will work for me as I am looking to use this search in different alerting mechanisms so I don't believe that works very well with workflow actions.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 18:52:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450291#M127501</guid>
      <dc:creator>cxr5971</dc:creator>
      <dc:date>2019-06-27T18:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450292#M127502</link>
      <description>&lt;P&gt;I've looked into transactions as well. Is this a viable solution? Any sort of pseudo-spl would be great &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 19:42:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450292#M127502</guid>
      <dc:creator>cxr5971</dc:creator>
      <dc:date>2019-06-27T19:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450293#M127503</link>
      <description>&lt;P&gt;Alright, I tried. I'll convert to a comment. I don't have other ideas right now. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 21:23:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450293#M127503</guid>
      <dc:creator>skalliger</dc:creator>
      <dc:date>2019-06-27T21:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450294#M127504</link>
      <description>&lt;P&gt;Hi @cxr5971 ,&lt;/P&gt;

&lt;P&gt;You could play around with the &lt;CODE&gt;transaction&lt;/CODE&gt; command to see if it gives you what you're looking for:&lt;BR /&gt;
&lt;PRE&gt;index=[your command history index] sourcetype=[your command sourcetype] command IN ("cp", "chown", ... etc)&lt;BR /&gt;
| transaction user maxspan=2m&lt;/PRE&gt;&lt;BR /&gt;
This will group all events for the field &lt;CODE&gt;user&lt;/CODE&gt; together as long as they are in a 2 minute span of time.  You could also use &lt;CODE&gt;startswith&lt;/CODE&gt; to tell transaction only to group events that start with a certain event, &lt;CODE&gt;command=cp&lt;/CODE&gt; as an example.  There is also &lt;CODE&gt;endswith&lt;/CODE&gt; to put an end to the transaction chain.  But you would only use those if you have a specific starting and ending point for the list of commands.&lt;BR /&gt;
You can reference the &lt;CODE&gt;transaction&lt;/CODE&gt; docs for more information (&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Transaction"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Transaction&lt;/A&gt;)&lt;/P&gt;

&lt;P&gt;This way, if you have a group of commands that get found by transaction in a 2 minute period of time, if the count is greater than 1, you could create an alert.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 22:08:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450294#M127504</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-27T22:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450295#M127505</link>
      <description>&lt;P&gt;I appreciate the post though! Got me looking into workflow actions more &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 12:26:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450295#M127505</guid>
      <dc:creator>cxr5971</dc:creator>
      <dc:date>2019-06-28T12:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450296#M127506</link>
      <description>&lt;P&gt;Transactions seem to be very useful and almost exactly what I need except of course they are very resource intensive and draining on our infrastructure as a whole. Does anyone have some tips on making transaction searches more efficient or an SPL heavy statement that could do something very similar?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 14:00:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450296#M127506</guid>
      <dc:creator>cxr5971</dc:creator>
      <dc:date>2019-06-28T14:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450297#M127507</link>
      <description>&lt;P&gt;You should avoid &lt;CODE&gt;transaction&lt;/CODE&gt; except for limited ad-hoc cases; it should &lt;EM&gt;NEVER&lt;/EM&gt; be used in a scheduled search.  Try something like this (assumes your data has a field named &lt;CODE&gt;command&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=YouShouldAlwaysSpecifyANIndex AND sourcetype=AndSourcetypeToo AND [|inputlookup YourLookupFileWithOneCommandOnEachLineWithTheFIeldNamedTheSameAsYourDataUses.csv]
| streamstats values(command) AS commands dc(command) AS commandCount BY host user _time span=2m
| where commandCount &amp;gt;= 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Jun 2019 15:02:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450297#M127507</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-29T15:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for Multiple Commands In Succession</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450298#M127508</link>
      <description>&lt;P&gt;Yes, it is resource intensive.  And as @woodcock mentions, you should try to avoid using it if you can.  It does have its uses and can be considered in limited situations.  You can try his suggestion below, using &lt;CODE&gt;streamstats&lt;/CODE&gt;.  Just be aware that streamstats is memory restricted (default is 200MB per search), so if you have a very large set of data to search through, streamstats will stop calculating at some point.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jun 2019 15:46:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-for-Multiple-Commands-In-Succession/m-p/450298#M127508</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-29T15:46:58Z</dc:date>
    </item>
  </channel>
</rss>

