<?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: How do I run NMAP on search results? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242551#M3075</link>
    <description>&lt;P&gt;OK, I created a custom command, but I'm not configured correctly.  It won't pass the search result to the script.&lt;/P&gt;

&lt;P&gt;Here is my script (/etc/apps/search/bin/scanip.py):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import subprocess,sys,os

nmap = "nmap -A " + sys.argv[1]


p = subprocess.Popen(nmap, shell=True, stderr=subprocess.PIPE)
while True:
    out = p.stderr.read(1)
    if out == '' and p.poll() != None:
        break
    if out != '':
        sys.stdout.write(out)
        sys.stdout.flush()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=WinDNS | table source_address | head 1 | scanip source_address
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the output from the search:&lt;/P&gt;

&lt;P&gt;Starting Nmap 7.31 ( &lt;A href="https://nmap.org"&gt;https://nmap.org&lt;/A&gt; ) at 2016-11-20 20:07 EST &lt;BR /&gt;
Failed to resolve "source_address".&lt;BR /&gt;
WARNING:Nmap done: 0 IP addresses (0 hosts up) scanned in 0.29 seconds&lt;BR /&gt;
No targets were specified &lt;/P&gt;

&lt;P&gt;Yet, I if run the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| scanip 10.10.10.10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the expected nmap results.&lt;/P&gt;

&lt;P&gt;So how to I get splunk to pass the value of source_address or whatever field instead of the string?&lt;/P&gt;

&lt;P&gt;It seems to have something to do with &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/AdvancedDev/Searchscripts"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/AdvancedDev/Searchscripts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;but I can't get the syntax right.&lt;/P&gt;

&lt;P&gt;Thanks for any suggestions or links with better examples.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2016 01:17:25 GMT</pubDate>
    <dc:creator>reswob4</dc:creator>
    <dc:date>2016-11-21T01:17:25Z</dc:date>
    <item>
      <title>How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242549#M3073</link>
      <description>&lt;P&gt;Is there a way I can run Splunk against search results?&lt;/P&gt;

&lt;P&gt;For example in pseudo-code:  &lt;CODE&gt;destination_url=bad_site.com | nmap -A source_ip&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The assumption would be that there would only be a few IPs.&lt;/P&gt;

&lt;P&gt;All the searches on Answers have returned several apps such as Asset Discovery and Simple NMAP, but nothing so far about sending IPs found into NMAP.  &lt;/P&gt;

&lt;P&gt;Should I wrap NMAP into a python or shell script and do it that way?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 20:44:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242549#M3073</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2016-11-18T20:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242550#M3074</link>
      <description>&lt;P&gt;Consider creating  custom command to run nmap against a provided IP address.  See &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/Search/Aboutcustomsearchcommands"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.0/Search/Aboutcustomsearchcommands&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Nov 2016 00:29:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242550#M3074</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-11-20T00:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242551#M3075</link>
      <description>&lt;P&gt;OK, I created a custom command, but I'm not configured correctly.  It won't pass the search result to the script.&lt;/P&gt;

&lt;P&gt;Here is my script (/etc/apps/search/bin/scanip.py):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import subprocess,sys,os

nmap = "nmap -A " + sys.argv[1]


p = subprocess.Popen(nmap, shell=True, stderr=subprocess.PIPE)
while True:
    out = p.stderr.read(1)
    if out == '' and p.poll() != None:
        break
    if out != '':
        sys.stdout.write(out)
        sys.stdout.flush()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=WinDNS | table source_address | head 1 | scanip source_address
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the output from the search:&lt;/P&gt;

&lt;P&gt;Starting Nmap 7.31 ( &lt;A href="https://nmap.org"&gt;https://nmap.org&lt;/A&gt; ) at 2016-11-20 20:07 EST &lt;BR /&gt;
Failed to resolve "source_address".&lt;BR /&gt;
WARNING:Nmap done: 0 IP addresses (0 hosts up) scanned in 0.29 seconds&lt;BR /&gt;
No targets were specified &lt;/P&gt;

&lt;P&gt;Yet, I if run the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| scanip 10.10.10.10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the expected nmap results.&lt;/P&gt;

&lt;P&gt;So how to I get splunk to pass the value of source_address or whatever field instead of the string?&lt;/P&gt;

&lt;P&gt;It seems to have something to do with &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/AdvancedDev/Searchscripts"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/AdvancedDev/Searchscripts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;but I can't get the syntax right.&lt;/P&gt;

&lt;P&gt;Thanks for any suggestions or links with better examples.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 01:17:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242551#M3075</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2016-11-21T01:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242552#M3076</link>
      <description>&lt;P&gt;Try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | scanip $source_address$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Nov 2016 12:53:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242552#M3076</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-11-21T12:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242553#M3077</link>
      <description>&lt;P&gt;sourcetype=WinDNS | table source_address | head 1 | scanip $source_address$&lt;/P&gt;

&lt;P&gt;Starting Nmap 7.31 ( &lt;A href="https://nmap.org" target="_blank"&gt;https://nmap.org&lt;/A&gt; ) at 2016-11-21 07:54 EST &lt;BR /&gt;
Failed to resolve "$".&lt;BR /&gt;
WNmap done: 0 IP addresses (0 hosts up) scanned in 0.72 seconds&lt;BR /&gt;
ARNING: No targets were specified &lt;/P&gt;

&lt;P&gt;sourcetype=WinDNS | table source_address | head 1 | scanip $$source_address$$&lt;/P&gt;

&lt;P&gt;Starting Nmap 7.31 ( &lt;A href="https://nmap.org" target="_blank"&gt;https://nmap.org&lt;/A&gt; ) at 2016-11-21 07:55 EST &lt;BR /&gt;
Failed to resolve "45981source_address45981".&lt;BR /&gt;
WARNmap done: 0 IP addresses (0 hosts up) scanned in 0.30 seconds&lt;BR /&gt;
NING: No targets were specified &lt;/P&gt;

&lt;P&gt;sourcetype=WinDNS | table source_address | head 1 | scanip \$source_address\$ &lt;/P&gt;

&lt;P&gt;Starting Nmap 7.31 ( &lt;A href="https://nmap.org" target="_blank"&gt;https://nmap.org&lt;/A&gt; ) at 2016-11-21 07:56 EST &lt;BR /&gt;
Failed to resolve "$source_address$".&lt;BR /&gt;
WARNNmap done: 0 IP addresses (0 hosts up) scanned in 0.46 seconds&lt;BR /&gt;
ING: No targets were specified&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:54:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242553#M3077</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2020-09-29T11:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242554#M3078</link>
      <description>&lt;P&gt;One last guess:&lt;/P&gt;

&lt;P&gt;... | scanip 'source_address'&lt;BR /&gt;
Note the single quotes.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 13:57:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242554#M3078</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-11-21T13:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242555#M3079</link>
      <description>&lt;P&gt;Nope&lt;/P&gt;

&lt;P&gt;Starting Nmap 7.31 ( &lt;A href="https://nmap.org"&gt;https://nmap.org&lt;/A&gt; ) at 2016-11-21 09:46 EST &lt;BR /&gt;
Failed to resolve "source_address".&lt;BR /&gt;
WANmap done: 0 IP addresses (0 hosts up) scanned in 0.45 seconds&lt;BR /&gt;
RNING: No targets were specified &lt;/P&gt;

&lt;P&gt;It shows double quotes in the response whether or not I put single or double quotes in the search bar.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 14:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242555#M3079</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2016-11-21T14:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242556#M3080</link>
      <description>&lt;P&gt;After looking as this and asking around some other sources, it seems the best way to do this is to export the list of ips to a CSV, call a script to run nmap against that csv, which either exports to a XML which is then re-imported back into Splunk or send the nmap output to ANOTHER script which puts the output into csv which then can be used as a lookup table.&lt;/P&gt;

&lt;P&gt;So for now, this effort is going on the back burner.&lt;/P&gt;

&lt;P&gt;Thanks to @richgalloway for the suggestions provided.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 15:40:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/242556#M3080</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2016-12-12T15:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run NMAP on search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/654755#M11157</link>
      <description>&lt;P&gt;XtremeNmapParser FTW to convert the xml to JSON and then used HEC to send it all to Spunk!&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/xtormin/XtremeNmapParser/issues/1" target="_blank"&gt;https://github.com/xtormin/XtremeNmapParser/issues/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 19:03:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-NMAP-on-search-results/m-p/654755#M11157</guid>
      <dc:creator>RMcCurdyDOTcom</dc:creator>
      <dc:date>2023-08-17T19:03:09Z</dc:date>
    </item>
  </channel>
</rss>

