This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 5b34f6f9b59d0b6dc13bf3d4c1701fc2f906ffb4 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu May 7 15:23:19 2015 +0200 added try/catch blocks on xml nmap parsing --- README | 2 ++ app/modules/nmap_detection.py | 59 ++++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/README b/README index 62e7019..482b7bd 100644 --- a/README +++ b/README @@ -56,6 +56,8 @@ git pull bower install ./install.sh +(If you updated your python system, compatibility problems may occure while running pip. If you get any issue on the +previous step, delete the venv folder and launch the install.sh script again) Edit local configuration file by following the latest model (mum.conf) diff --git a/app/modules/nmap_detection.py b/app/modules/nmap_detection.py index 8a00109..f3c75c0 100644 --- a/app/modules/nmap_detection.py +++ b/app/modules/nmap_detection.py @@ -150,32 +150,39 @@ class nmap_detection: #dict_host['state'] = status.getAttribute('state') dict_host['os'] = 'unknown' # par defaut dict_host['hostname'] = '' - - hostnames_elem = host.getElementsByTagName('hostnames')[0] - hostnames = hostnames_elem.getElementsByTagName('hostname') - for hostname in hostnames: - dict_host['hostname'] = hostname.getAttribute("name") - - ports_elem = host.getElementsByTagName('ports')[0] - ports = ports_elem.getElementsByTagName('port') - list_dict_port = [] - for port in ports: - dict_port = {} - state = port.getElementsByTagName('state')[0] - service = port.getElementsByTagName('service')[0] - if service.hasAttribute("ostype"): - dict_host['os'] = service.getAttribute("ostype").lower() - if state.getAttribute('state') == 'open': - dict_port['portid'] = port.getAttribute('portid') - dict_port['portname'] = service.getAttribute('name') - list_dict_port.append(dict_port) - trace_elem = host.getElementsByTagName('trace')[0] - dict_host['traceroute'] = [] - for hop in trace_elem.getElementsByTagName('hop'): - dict_host['traceroute'].append(hop.getAttribute("ipaddr")) - if dict_host['addr'] in dict_host['traceroute']: - dict_host['traceroute'].remove(dict_host['addr']) - dict_host['openports'] = list_dict_port + try: + hostnames_elem = host.getElementsByTagName('hostnames')[0] + hostnames = hostnames_elem.getElementsByTagName('hostname') + for hostname in hostnames: + dict_host['hostname'] = hostname.getAttribute("name") + except IndexError: + pass + try: + ports_elem = host.getElementsByTagName('ports')[0] + ports = ports_elem.getElementsByTagName('port') + list_dict_port = [] + for port in ports: + dict_port = {} + state = port.getElementsByTagName('state')[0] + service = port.getElementsByTagName('service')[0] + if service.hasAttribute("ostype"): + dict_host['os'] = service.getAttribute("ostype").lower() + if state.getAttribute('state') == 'open': + dict_port['portid'] = port.getAttribute('portid') + dict_port['portname'] = service.getAttribute('name') + list_dict_port.append(dict_port) + dict_host['openports'] = list_dict_port + except IndexError: + dict_host['openports'] = [] + try: + dict_host['traceroute'] = [] + trace_elem = host.getElementsByTagName('trace')[0] + for hop in trace_elem.getElementsByTagName('hop'): + dict_host['traceroute'].append(hop.getAttribute("ipaddr")) + if dict_host['addr'] in dict_host['traceroute']: + dict_host['traceroute'].remove(dict_host['addr']) + except IndexError: + dict_host['traceroute'] = [] # the host have its IP for ID on the db self.db.add_host(dict_host['addr'], json.dumps(dict_host), -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.