Skip to content

Commit

Permalink
Replace URL regexes for urlsplit in acunetix plugin.
Browse files Browse the repository at this point in the history
Also put resolution in the correct field, not in description
QA #4191
  • Loading branch information
cript0nauta committed Jul 28, 2017
1 parent b154c8e commit 4c24a64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ New features in the latest update

TBA
---
* Improved Acunetix plugin to avoid conflicts and missing imported data
* Improved Acunetix plugin to avoid conflicts and missing imported data, and to correctly parse URLs and resolutions

July 19, 2017:
---
Expand Down
33 changes: 12 additions & 21 deletions plugins/repo/acunetix/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from __future__ import with_statement
from plugins import core
from model import api
from urlparse import urlsplit
import socket
import sys
import re
Expand Down Expand Up @@ -125,24 +126,14 @@ def __init__(self, item_node):
self.node = item_node

self.url = self.get_text_from_subnode('StartURL')
mregex = re.search(
"(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)"
"*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]"
")\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0"
")\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0"
")\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|"
"localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil"
"|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))[\:"
"]*([0-9]+)*([/]*($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+)).*?$",
self.url)

self.protocol = mregex.group(1)
self.host = mregex.group(4)
self.port = 80
if self.protocol == 'https':
self.port = 443
if mregex.group(11) is not None:
self.port = mregex.group(11)
url_data = urlsplit(self.url)

self.protocol = url_data.scheme
self.host = url_data.hostname

# Use the port in the URL if it is defined, or 80 or 443 by default
self.port = url_data.port or (443 if url_data.scheme == "https"
else 80)

self.ip = self.resolve(self.host)
self.os = self.get_text_from_subnode('Os')
Expand Down Expand Up @@ -194,10 +185,9 @@ def __init__(self, item_node):
self.desc = self.get_text_from_subnode('Description')

if self.get_text_from_subnode('Recommendation'):
self.desc += "\nSolution: " + self.get_text_from_subnode(
'Recommendation')
self.resolution = self.get_text_from_subnode('Recommendation')
else:
self.desc += ""
self.resolution = ""

if self.get_text_from_subnode('reference'):
self.desc += "\nDetails: " + self.get_text_from_subnode('Details')
Expand Down Expand Up @@ -299,6 +289,7 @@ def parseOutputString(self, output, debug=False):
item.desc,
website=site.host,
severity=item.severity,
resolution=item.resolution,
path=item.uri,
params=item.parameter,
request=item.request,
Expand Down

0 comments on commit 4c24a64

Please sign in to comment.