Skip to content

Commit

Permalink
Merge branch 'tkt_white_4132_improve_nexpose_full' into white/integra…
Browse files Browse the repository at this point in the history
…cion
  • Loading branch information
micabot committed Aug 2, 2017
2 parents 038ebbc + 11e0222 commit 659dd79
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TBA:
---
* Updated Core Impact plugin to be compatible with 2016 version
* Improved loading of fields request and website in Burp Plugin
* Improved Nexpose Full plugin

July 19, 2017:
---
Expand Down
37 changes: 25 additions & 12 deletions plugins/repo/nexpose-full/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class NexposeFullXmlParser(object):

def __init__(self, xml_output):
tree = self.parse_xml(xml_output)
vulns = self.get_vuln_definitions(tree)
self.vulns = self.get_vuln_definitions(tree)

if tree:
self.items = self.get_items(tree, vulns)
self.items = self.get_items(tree, self.vulns)
else:
self.items = []

Expand Down Expand Up @@ -90,14 +90,14 @@ def parse_html_type(self, node):
ret += self.parse_html_type(child)
else:
ret += node.text.encode(
"ascii", errors="backslashreplace").strip() if node.get('text') else ""
"ascii", errors="backslashreplace").strip() if node.text else ""
if tag == 'listitem':
if len(list(node)) > 0:
for child in list(node):
ret += self.parse_html_type(child)
else:
ret = node.text.encode(
"ascii", errors="backslashreplace").strip() if node.get('text') else ""
"ascii", errors="backslashreplace").strip() if node.text else ""
if tag == 'orderedlist':
i = 1
for item in list(node):
Expand All @@ -109,7 +109,7 @@ def parse_html_type(self, node):
ret += self.parse_html_type(child)
else:
ret += node.text.encode("ascii",
errors="backslashreplace") if node.get('text') else ""
errors="backslashreplace") if node.text else ""
if tag == 'unorderedlist':
for item in list(node):
ret += "\t" + "* " + self.parse_html_type(item) + "\n"
Expand All @@ -134,11 +134,16 @@ def parse_tests_type(self, node, vulnsDefinitions):
"""
vulns = list()

for tests in node.iter('tests'):
for tests in node.findall('tests'):
for test in tests.iter('test'):
vuln = dict()
if test.get('id').lower() in vulnsDefinitions:
vuln = vulnsDefinitions[test.get('id').lower()]
vuln = vulnsDefinitions[test.get('id').lower()].copy()
key = test.get('key', '')
if key.startswith('/'):
# It has the path where the vuln was found
# Example key: "/comments.asp||content"
vuln['path'] = key[:key.find('|')]
for desc in list(test):
vuln['desc'] += self.parse_html_type(desc)
vulns.append(vuln)
Expand All @@ -162,7 +167,8 @@ def get_vuln_definitions(self, tree):
'refs': ["vector: " + vector, vid],
'resolution': "",
'severity': (int(vulnDef.get('severity')) - 1) / 2,
'tags': list()
'tags': list(),
'is_web': vid.startswith('http-')
}

for item in list(vulnDef):
Expand All @@ -179,8 +185,8 @@ def get_vuln_definitions(self, tree):
vuln['refs'].append(title + ' ' + link)
if item.tag == 'references':
for ref in list(item):
if ref.get('text'):
rf = ref.get('text').encode(
if ref.text:
rf = ref.text.encode(
"ascii", errors="backslashreplace").strip()
vuln['refs'].append(rf)
if item.tag == 'solution':
Expand Down Expand Up @@ -291,8 +297,15 @@ def parseOutputString(self, output, debug=False):
status=s['status'],
version=version)
for v in s['vulns']:
v_id = self.createAndAddVulnToService(h_id, s_id, v['name'], v['desc'], v[
'refs'], v['severity'], v['resolution'])
if v['is_web']:
v_id = self.createAndAddVulnWebToService(
h_id, s_id, v['name'], v['desc'], v['refs'],
v['severity'], v['resolution'],
path=v.get('path',''))
else:
v_id = self.createAndAddVulnToService(
h_id, s_id, v['name'], v['desc'], v['refs'],
v['severity'], v['resolution'])
del parser

def processCommandString(self, username, current_path, command_string):
Expand Down

0 comments on commit 659dd79

Please sign in to comment.