<?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 to parse grepable Nmap output? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/658759#M227528</link>
    <description>&lt;P&gt;got nasty gram for posting links&lt;/P&gt;&lt;P&gt;search online for freeload101 github in scripts nmap_fruit.sh&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2024 18:12:54 GMT</pubDate>
    <dc:creator>RMcCurdyDOTcom</dc:creator>
    <dc:date>2024-03-06T18:12:54Z</dc:date>
    <item>
      <title>How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238421#M70825</link>
      <description>&lt;P&gt;I have several events with similar to this raw data field that I would like to break down into a new event for each IP, port, etc:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host: 172.30.x.x () Ports: 22/open/tcp//ssh///, 80/open/tcp//http///, 443/open/tcp//https///, 5000/open/tcp//upnp///, 5564/open/tcp/////, 5570/open/tcp/////, 5678/open/tcp//rrac///, 5988/open/tcp//wbem-http///, 5989/open/tcp//wbem-https///, 8008/open/tcp//http///, 8099/open/tcp//unknown///, 45454/open/tcp/////
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So in my search (for this example) I want 12 lines that start with this IP address and in the second column have each of the ports listed respectively, followed by the columns port, status, proto, and desc.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = ports_services sourcetype = nonwindows:ports Host Ports
| rex field=_raw "(?i)Host:\s(?&amp;lt;dest_ip&amp;gt;\S+)\s+\(\)\s+Ports:\s+(?&amp;lt;port&amp;gt;\d+)\/(?&amp;lt;status&amp;gt;\w+)\/(?&amp;lt;proto&amp;gt;\w+)\/\/(?&amp;lt;desc&amp;gt;\w+)"
| table _time dest_ip port status proto desc
| sort dest_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Currently my search works properly for the first port, but does not iterate through to create a new line for each consecutive port.  I have read a lot about the makemv delim, but can't seem to make this work.  Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 19:13:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238421#M70825</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-17T19:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238422#M70826</link>
      <description>&lt;P&gt;Search Output should look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                                dest_ip           port     status     proto     desc
2015-11-17 10:23:38     172.30.x.x      22         open       tcp        ssh
2015-11-17 10:23:38     172.30.x.x      80         open       tcp        http
2015-11-17 10:23:38     172.30.x.x      443       open       tcp        https
2015-11-17 10:23:38     172.30.x.x      5000     open       tcp        upnp
2015-11-17 10:23:38     172.30.x.x      5564     open       tcp        
2015-11-17 10:23:38     172.30.x.x      5570     open       tcp        rrac
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so on and so forth.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 19:18:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238422#M70826</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-17T19:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238423#M70827</link>
      <description>&lt;P&gt;There will be variable number of ports, not always 12.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 19:20:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238423#M70827</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-17T19:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238424#M70828</link>
      <description>&lt;P&gt;This should give you an idea&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
| rex field=s max_match=50 "(?i)Host:\s(?\S+)"&lt;BR /&gt;
| rex field=s max_match=50 "[Ports:|,]\s(?\d+)" | table _time dest_ip ports | mvexpand ports&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You should also look at mvzip command.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 19:54:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238424#M70828</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-11-17T19:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238425#M70829</link>
      <description>&lt;P&gt;That gives me an error.  Error in 'rex' command: Encountered the following error while compiling the regex '(?i)Host:\s(?\S+)': Regex: unrecognized character after (? or (?- &lt;/P&gt;

&lt;P&gt;index = ports_services sourcetype = nonwindows:ports Host Ports&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=s max_match=50 "(?i)Host:\s(?\S+)"
| rex field=s max_match=50 "[Ports:|,]\s(?\d+)" 
| table _time dest_ip ports 
| mvexpand ports
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Nov 2015 20:46:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238425#M70829</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-17T20:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238426#M70830</link>
      <description>&lt;P&gt;Sorry, I see, can I do the same thing for the / // /// delimitors?&lt;/P&gt;

&lt;P&gt;index = ports_services sourcetype = nonwindows:ports Host Ports&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw max_match=50 "Ports:\s+(?.+)"
| rex field=_raw max_match=50  (?i)Host:\s(?\S+)
| makemv delim="," ports
| table _time dest_ip ports 
| mvexpand ports
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Nov 2015 20:54:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238426#M70830</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-17T20:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238427#M70831</link>
      <description>&lt;P&gt;That does get me close, just now need to also separate the ports column.&lt;BR /&gt;
-time                            dest_ip         ports&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  22/open/tcp//ssh///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  80/open/tcp//http///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  443/open/tcp//https///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  5000/open/tcp//upnp///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  5564/open/tcp/////&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  5570/open/tcp/////&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  5678/open/tcp//rrac///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  5988/open/tcp//wbem-http///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  5989/open/tcp//wbem-https///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  8008/open/tcp//http///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  8099/open/tcp//unknown///&lt;BR /&gt;&lt;BR /&gt;
2015-11-17 10:23:38  172.30.x.x  45454/open/tcp/// &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = ports_services sourcetype = nonwindows:ports Host Ports
| rex field=_raw max_match=50 "Ports:\s+(?&amp;lt;ports&amp;gt;.+)\/\/"
| rex field=_raw max_match=50  (?i)Host:\s(?&amp;lt;dest_ip&amp;gt;\S+)
| makemv delim="," ports
| table _time dest_ip ports
| sort dest_ip
| mvexpand ports
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Nov 2015 22:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238427#M70831</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-17T22:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238428#M70832</link>
      <description>&lt;P&gt;Build on this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=s max_match=50 "Host:\s(?&amp;lt;dest_ip&amp;gt;\S+)" | rex field=s max_match=50 "[Ports:|,]\s?(?&amp;lt;port&amp;gt;\d+)\/(?&amp;lt;status&amp;gt;\w+)\/(?&amp;lt;proto&amp;gt;\w+)\/\/(?&amp;lt;desc&amp;gt;\w+)" | eval mv=mvzip(port, status) | eval mv=mvzip(mv, proto) | eval mv=mvzip(mv, desc) | mvexpand mv | makemv mv delim="," | eval ports=mvindex(mv, 0) | table dest_ip, ports
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Nov 2015 01:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238428#M70832</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-11-18T01:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238429#M70833</link>
      <description>&lt;P&gt;I am close, the only issue I am having is if there is not a desc, the event does not show up.  I somehow have to capture the null value in the regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = ports_services sourcetype = nonwindows:ports Host Ports
| rex field=_raw max_match=50 "Host:\s(?&amp;lt;dest_ip&amp;gt;\S+)" 
| rex field=_raw max_match=50 "[Ports:|,]\s?(?&amp;lt;port&amp;gt;\d+)\/(?&amp;lt;status&amp;gt;\w+)\/(?&amp;lt;proto&amp;gt;\w+)\/\/(?&amp;lt;desc&amp;gt;\w+)" 
| eval mv=mvzip(port, status) 
| eval mv=mvzip(mv, proto) 
| eval mv=mvzip(mv, desc) 
| mvexpand mv 
| makemv mv delim="," 
| eval ports=mvindex(mv, 0) 
| eval status=mvindex(mv, 1)
| eval proto=mvindex(mv, 2)
| eval desc=mvindex(mv, 3)
| table dest_ip ports status proto desc
| sort dest_ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Nov 2015 12:53:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238429#M70833</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-18T12:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238430#M70834</link>
      <description>&lt;P&gt;Finally got it, thank you for all your help!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = ports_services sourcetype = nonwindows:ports Host Ports
| rex field=_raw max_match=50 "Host:\s(?&amp;lt;dest_ip&amp;gt;\S+)" 
| rex field=_raw max_match=50 "[Ports:|,]\s?(?&amp;lt;port&amp;gt;\d+)\/+(?&amp;lt;status&amp;gt;\w+)\/+(?&amp;lt;proto&amp;gt;\w+)\/+(?&amp;lt;desc&amp;gt;\w+|\/)"
| rex field=_raw "OS:\s(?&amp;lt;os&amp;gt;\w+)"
| eval os = if(isnull(os),"unknown",os)
| eval mv=mvzip(port, status) 
| eval mv=mvzip(mv, proto) 
| eval mv=mvzip(mv, desc) 
| mvexpand mv 
| makemv mv delim="," 
| eval ports=mvindex(mv, 0) 
| eval status=mvindex(mv, 1)
| eval proto=mvindex(mv, 2)
| eval desc=if(mvindex(mv, 3) == "/","null",mvindex(mv,3))
| table dest_ip ports status proto desc os
| sort dest_ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Nov 2015 14:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238430#M70834</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-18T14:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238431#M70835</link>
      <description>&lt;P&gt;I would modify the &lt;CODE&gt;rex&lt;/CODE&gt; for &lt;CODE&gt;desc&lt;/CODE&gt; to something like this &lt;CODE&gt;([\w+|\/])&lt;/CODE&gt; (please test for correctness). OR &lt;CODE&gt;...| eval s=replace(s, "/////", "//unk///") | rex ...&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Also, in the &lt;CODE&gt;rex&lt;/CODE&gt; command, you could change the &lt;CODE&gt;max_match&lt;/CODE&gt; to &lt;CODE&gt;0&lt;/CODE&gt; (unlimited) vs &lt;CODE&gt;50&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 14:27:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238431#M70835</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2015-11-18T14:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238432#M70836</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; index = ports_services sourcetype = nonwindows:ports Host Ports
 | rex field=_raw max_match=50 "Host:\s(?&amp;lt;dest_ip&amp;gt;\S+)" 
 | rex field=_raw max_match=50 "[Ports:|,]\s?(?&amp;lt;port&amp;gt;\d+)\/+(?&amp;lt;status&amp;gt;\w+)\/+(?&amp;lt;proto&amp;gt;\w+)\/+(?&amp;lt;desc&amp;gt;\w+|\/)"
 | rex field=_raw "OS:\s(?&amp;lt;os&amp;gt;\w+)"
 | eval os = if(isnull(os),"unknown",os)
 | eval mv=mvzip(port, status) 
 | eval mv=mvzip(mv, proto) 
 | eval mv=mvzip(mv, desc) 
 | mvexpand mv 
 | makemv mv delim="," 
 | eval ports=mvindex(mv, 0) 
 | eval status=mvindex(mv, 1)
 | eval proto=mvindex(mv, 2)
 | eval desc=if(mvindex(mv, 3) == "/","null",mvindex(mv,3))
 | table dest_ip ports status proto desc os
 | sort dest_ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Nov 2015 14:45:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/238432#M70836</guid>
      <dc:creator>rfiscus</dc:creator>
      <dc:date>2015-11-18T14:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/654753#M226184</link>
      <description>&lt;P&gt;I used&amp;nbsp;XtremeNmapParser from github 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:02:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/654753#M226184</guid>
      <dc:creator>RMcCurdyDOTcom</dc:creator>
      <dc:date>2023-08-17T19:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse grepable Nmap output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/658759#M227528</link>
      <description>&lt;P&gt;got nasty gram for posting links&lt;/P&gt;&lt;P&gt;search online for freeload101 github in scripts nmap_fruit.sh&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 18:12:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-grepable-Nmap-output/m-p/658759#M227528</guid>
      <dc:creator>RMcCurdyDOTcom</dc:creator>
      <dc:date>2024-03-06T18:12:54Z</dc:date>
    </item>
  </channel>
</rss>

