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 7c31fec556ea660653e895b53ad2cce2b3671db6 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 10:51:11 2015 +0100 affichage des ip scannees --- .gitignore | 1 + app/app.py | 13 +++++++++---- app/detection_modules/nmap_detection.py | 16 ++++++++++++---- res.xml | 6 +++--- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 6ba581a..6bc525c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ venv node_modules *~ .idea +res.xml \ No newline at end of file diff --git a/app/app.py b/app/app.py index 71aac06..2052de6 100755 --- a/app/app.py +++ b/app/app.py @@ -1,7 +1,7 @@ __author__ = 'aguilbaud' from bottle import * -from detection_modules.nmap_detection import check_ip_range, get_current_ip +from detection_modules.nmap_detection import check_ip_range, get_current_ip, get_scanned_ip import threading state = "" @@ -9,7 +9,6 @@ state = "" class ThreadDetect(threading.Thread): def __init__(self, ip_range): - print 'init' threading.Thread.__init__(self) self.ip_range = ip_range def run(self): @@ -29,7 +28,6 @@ def angular(): def start_first_detection(ip_range): #ip_range = request.forms.get('ip_range') global state - print ip_range if re.search('^\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?$', ip_range): state = "Scan de l'adresse : " t = ThreadDetect(ip_range) @@ -53,7 +51,14 @@ def bower_files(filepath): @get('/getstate') def getstate(): global state - return state + get_current_ip() + scanned_ip = get_scanned_ip() + res = state + get_current_ip() + print scanned_ip + if scanned_ip != {}: + res += "\n Completed : \n" + for ip in scanned_ip: + res += ip + ' : ' + scanned_ip[ip] + return res ''' app = Bottle() diff --git a/app/detection_modules/nmap_detection.py b/app/detection_modules/nmap_detection.py index b1d43cc..87fa9e7 100644 --- a/app/detection_modules/nmap_detection.py +++ b/app/detection_modules/nmap_detection.py @@ -3,6 +3,9 @@ import pexpect import json current_ip = "" + +scanned_ip = {} + # fonction qui permet de decomposer les differentes plages d'ip # lance la detection nmap pour chacune des ip comprises dans cette plage def check_ip_range(ip_range): @@ -80,7 +83,7 @@ def launch_detection(b1, b2, b3, b4): res += child.before + '<br/>' except pexpect.EOF: res += ' A FINI' - parse_res() + parse_res(ip) except pexpect.TIMEOUT: res += ' TIMEOUT' current_ip = "" @@ -92,9 +95,14 @@ def get_current_ip(): return current_ip +def get_scanned_ip(): + global scanned_ip + return scanned_ip + # parse le resultat xml de nmap pour ne conserver que les valeurs interssantes # envoie directement le resultat sur le service ElasticSearch -def parse_res(): +def parse_res(ip): + global scanned_ip # Ouverture du fichier xml avec le parseur minidom root = minidom.parse("res.xml") collection = root.documentElement @@ -135,6 +143,6 @@ def parse_res(): list_dict_port.append(dict_port) dict_host['openports'] = list_dict_port # sauvegarde de l'host dans la base elasticsearch avec pour ID son IP - print dict_host['addr'] pexpect.run('curl -XPUT \'localhost:9200/host/external/' + dict_host['addr'] + '?pretty\' -d \'' + - json.dumps(dict_host) + '\'') \ No newline at end of file + json.dumps(dict_host) + '\'') + scanned_ip[ip] = "localhost:9200/host/external/" + ip \ No newline at end of file diff --git a/res.xml b/res.xml index f27de2a..59b7716 100644 --- a/res.xml +++ b/res.xml @@ -1,10 +1,10 @@ <?xml version="1.0"?> <?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?> -<!-- Nmap 6.40 scan initiated Wed Jan 28 14:53:28 2015 as: /usr/bin/nmap -A -oX res.xml 109.190.17.195 --> -<nmaprun scanner="nmap" args="/usr/bin/nmap -A -oX res.xml 109.190.17.195" start="1422453208" startstr="Wed Jan 28 14:53:28 2015" version="6.40" xmloutputversion="1.04"> +<!-- Nmap 6.40 scan initiated Thu Jan 29 10:08:46 2015 as: /usr/bin/nmap -A -oX res.xml 198.116.0.10 --> +<nmaprun scanner="nmap" args="/usr/bin/nmap -A -oX res.xml 198.116.0.10" start="1422522526" startstr="Thu Jan 29 10:08:46 2015" version="6.40" xmloutputversion="1.04"> <scaninfo type="connect" protocol="tcp" numservices="1000" services="1,3-4,6-7,9,13,17,19-26,30,32-33,37,42-43,49,53,70,79-85,88-90,99-100,106,109-111,113,119,125,135,139,143-144,146,161,163,179,199,211-212,222,254-256,259,264,280,301,306,311,340,366,389,406-407,416-417,425,427,443-445,458,464-465,481,497,500,512-515,524,541,543-545,548,554-555,563,587,593,616-617,625,631,636,646,648,666-668,683,687,691,700,705,711,714,720,722,726,749,765,777,783,787,800-801,808,843,873,880,888,898,900-9 [...] <verbose level="0"/> <debugging level="0"/> -<runstats><finished time="1422453211" timestr="Wed Jan 28 14:53:31 2015" elapsed="3.15" summary="Nmap done at Wed Jan 28 14:53:31 2015; 1 IP address (0 hosts up) scanned in 3.15 seconds" exit="success"/><hosts up="0" down="1" total="1"/> +<runstats><finished time="1422522530" timestr="Thu Jan 29 10:08:50 2015" elapsed="3.14" summary="Nmap done at Thu Jan 29 10:08:50 2015; 1 IP address (0 hosts up) scanned in 3.14 seconds" exit="success"/><hosts up="0" down="1" total="1"/> </runstats> </nmaprun> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.