<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>WebstersProdigy &#187; nessus</title>
	<atom:link href="http://webstersprodigy.net/tag/nessus/feed/" rel="self" type="application/rss+xml" />
	<link>http://webstersprodigy.net</link>
	<description>Updates every other Friday... usually</description>
	<lastBuildDate>Sat, 26 May 2012 06:58:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='webstersprodigy.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>WebstersProdigy &#187; nessus</title>
		<link>http://webstersprodigy.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://webstersprodigy.net/osd.xml" title="WebstersProdigy" />
	<atom:link rel='hub' href='http://webstersprodigy.net/?pushpress=hub'/>
		<item>
		<title>Nessus Grep</title>
		<link>http://webstersprodigy.net/2010/02/07/updated-nessus-grep/</link>
		<comments>http://webstersprodigy.net/2010/02/07/updated-nessus-grep/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 20:22:00 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[nessus]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=663</guid>
		<description><![CDATA[This program takes a regular expression for a problem and returns the
affected hosts. It iterates through all reports saved in a .nessus file
making no attempt at uniqueness, (eg if you scanned a host more than once) 
searching through titles, data, port, and IDs for matches.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=663&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The code is pretty self explanatory. It searches through a .nessus file and spits out matching hosts.</p>
<p><pre class="brush: python;">
#!/usr/bin/python

def usage():
  print &quot;&quot;&quot;
This program takes a regular expression for a problem and returns the
affected hosts. It iterates through all reports saved in a .nessus file
making no attempt at uniqueness, (eg if you scanned a host more than once) 
searching through titles, data, port, and IDs for matches.

It prints one host per line, relying on tools like wc, tr, sort, uniq

USAGE:
arg[0] [--dns]  myfile.nessus regex

For a regex reference, see http://docs.python.org/library/re.html

The --dns flag will print out the dns name in addition to what was given for 
the scan

EXAMPLES:

#search for hosts that ran the nikto plugin
python nessus_grep.py scan.nessus nikto

#case insensitive search for nikto
python nessus_grep.py scan.nessus &quot;(?i)nikto&quot;

#it's usually probably ok to just check for id, but be careful
#as an added precaution I give it the beginning end of lines
python nessus_grep.py scan.nessus &quot;^10386$&quot; 

#find all hosts with either the SSL Cipher &quot;bug&quot; or running SSL Version 2
python nessus_grep.py scan.nessus &quot;(SSL Weak Cipher Suites Supported|SSL 
Version 2 (v2) Protocol Detection)&quot;
&quot;&quot;&quot;

import sys
import re
from lxml import etree

def regexsearch(regex, *strings):
  for i in strings:
    try:
      if re.search(regex, i):
        return True
    except TypeError:
      pass

&quot;&quot;&quot;
Although there is some repeating logic in dotnessusparse
and dotxmlparse, they are two different formats and are
kept separate in case of changes to only one
&quot;&quot;&quot;
def dotnessusparse(nessus_xml, hostprint=False):
  for report in nessus_xml.getroot():
    if &quot;Report&quot; in repr(report.tag):
      for host in report:
        if &quot;ReportHost&quot; in host.tag:
          hostname = (host.find(&quot;HostName&quot;).text)
          dnsname = host.find(&quot;dns_name&quot;).text.rstrip(&quot;.\n&quot;)
          if (&quot;(unknown)&quot; in dnsname):
            dnsname = &quot;&quot;
          reptitem = (host.findall(&quot;ReportItem&quot;))
          for issue in reptitem:
            data = issue.find(&quot;data&quot;).text
            pluginname = issue.find(&quot;pluginName&quot;).text
            pluginid = issue.find(&quot;pluginID&quot;).text
            port = issue.find(&quot;port&quot;).text
            if regexsearch(regex, data, pluginname, pluginid, port):
              if hostprint:
                hostname = hostname + &quot; (&quot; + dnsname + &quot;)&quot;
              print hostname
              break

def dotxmlparse(nessus_xml, hostprint=False):
  for report in nessus_xml.getroot():
    if &quot;Report&quot; in repr(report.tag):
      for host in report:
        if &quot;ReportHost&quot; in host.tag:
          hostname = host.get(&quot;name&quot;)
          dnsname = &quot;&quot;
          hostprops = host.find(&quot;HostProperties&quot;).findall(&quot;tag&quot;)
          for prop in hostprops:
            if prop.get(&quot;name&quot;) == &quot;host-fqdn&quot;:
              dnsname = prop.text
          reptitem = (host.findall(&quot;ReportItem&quot;))
          for issue in reptitem:
            data = sol = syn = plugout = None
            if issue.find(&quot;description&quot;) is not None:
              data = issue.find(&quot;description&quot;).text
            if issue.find(&quot;solution&quot;) is not None:
              sol = issue.find(&quot;solution&quot;).text
            if issue.find(&quot;synopsis&quot;) is not None:
              syn = issue.find(&quot;synopsis&quot;).text
            if issue.find(&quot;plugin_output&quot;) is not None:
              plugout = issue.find(&quot;plugin_output&quot;).text
            pluginname = issue.get(&quot;pluginName&quot;)
            pluginId = issue.get(&quot;pluginID&quot;)
            if regexsearch(regex, sol, syn, plugout, pluginname, pluginId):
              if hostprint:
                hostname = hostname + &quot; (&quot; + dnsname + &quot;)&quot;
              print hostname
              break

if __name__ == &quot;__main__&quot;:
  re.IGNORECASE
  if len(sys.argv) &lt; 3:
    usage()
    sys.exit(0)
  filelist = sys.argv[1:-1]
  try:
    filelist.remove(&quot;--dns&quot;)
    hostprint = True
  except ValueError:
    hostprint = False
  regex = sys.argv[-1]
  for nessusfile in filelist:
    nessus_xml = etree.parse(nessusfile)
    if nessusfile.endswith(&quot;.nessus&quot;):
      dotnessusparse(nessus_xml, hostprint)          
    if nessusfile.endswith(&quot;.xml&quot;):
      dotxmlparse(nessus_xml, hostprint) 
</pre> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webstersprodigy.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webstersprodigy.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webstersprodigy.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webstersprodigy.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/webstersprodigy.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/webstersprodigy.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/webstersprodigy.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/webstersprodigy.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webstersprodigy.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webstersprodigy.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webstersprodigy.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webstersprodigy.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webstersprodigy.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webstersprodigy.wordpress.com/663/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webstersprodigy.net&#038;blog=35949064&#038;post=663&#038;subd=webstersprodigy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2010/02/07/updated-nessus-grep/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be2c27a28b3788a3b9a7a8fa243d2978?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">webstersprodigy</media:title>
		</media:content>
	</item>
	</channel>
</rss>
