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 173e6f2740849a33b777ef22af74383cff6c553f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 5 14:38:52 2015 +0100 scan : le nom du fichier xml pour l'output de nmap est généré --- app/modules/detection_modules/nmap_detection.py | 11 +++++++---- views/scan.html | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/modules/detection_modules/nmap_detection.py b/app/modules/detection_modules/nmap_detection.py index 78af18b..4e78d7e 100644 --- a/app/modules/detection_modules/nmap_detection.py +++ b/app/modules/detection_modules/nmap_detection.py @@ -3,6 +3,8 @@ __author__ = 'aguilbaud' from xml.dom import minidom import pexpect import json +from random import choice +from string import letters class nmap_detection: @@ -10,6 +12,7 @@ class nmap_detection: self.opt = opt self.db = db self.ws = ws + self.filename = "".join(choice(letters) for i in range(10)) + ".xml" # generating a filename for xml output self.scanned_ip = [] self.list_mod_conn = list_mod_conn self.dict_mod_monitoring = dict_mod_monitoring @@ -85,7 +88,7 @@ class nmap_detection: ip = str(byte_1) + '.' + str(byte_2) + '.' + str(byte_3) + '.' + str(byte_4) self.ws.send(json.dumps({"30": "Scanning ip : " + ip})) try: - child = pexpect.spawn('nmap ' + self.opt + ' ' + ip + ' -oX res.xml') + child = pexpect.spawn('nmap ' + self.opt + ' ' + ip + ' -oX ' + self.filename) while child.isalive(): child.expect('Completed', timeout=None) except pexpect.EOF: @@ -101,7 +104,7 @@ class nmap_detection: def launch_detection_with_hostname(self, hostname): self.ws.send(json.dumps({"30": "Scanning host : " + hostname})) try: - child = pexpect.spawn('nmap ' + self.opt + ' ' + hostname + ' -oX res.xml') + child = pexpect.spawn('nmap ' + self.opt + ' ' + hostname + ' -oX ' + self.filename) while child.isalive(): child.expect('Completed', timeout=None) except pexpect.EOF: @@ -119,7 +122,7 @@ class nmap_detection: # save directly it on the database def parse_res(self, ip): # opening the xml file with minidom parser - root = minidom.parse("res.xml") + root = minidom.parse(self.filename) collection = root.documentElement # get every <host> of the collection @@ -167,4 +170,4 @@ class nmap_detection: # the host have its IP for ID on the db self.db.add_host(dict_host['addr'], json.dumps(dict_host), self.list_mod_conn, self.dict_mod_monitoring) self.scanned_ip.append(dict_host['addr']) - pexpect.run("rm -f res.xml") \ No newline at end of file + pexpect.run("rm -f " + self.filename) \ No newline at end of file diff --git a/views/scan.html b/views/scan.html index 8ce7833..53e22f1 100644 --- a/views/scan.html +++ b/views/scan.html @@ -4,7 +4,7 @@ <div ng-show="validated == false" class="ng-hide"> <form class="form-inline" ng_submit="post_val()"> <label for="input_ip_range">Enter a hostname, a single IP or an IP range to scan (example : 198.116.0.1-10)</label> - <input type="text" class="form-control" id="input_ip_range" ng-model="ip_range"/>{{ip_range}}<br/> + <input type="text" class="form-control" id="input_ip_range" ng-model="ip_range"/><br/> <button type="button" class="btn btn-danger" ng-click="show_opt = !show_opt">Show nmap options (careful)</button> <input type="text" class="form-control" ng-show="show_opt == true" ng-model="nmap_options"/> <button type="submit" class="btn btn-primary" ng-click="validated = true">Scan now</button> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.