branch develop updated (5cf361f -> 0b5c9d1)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository mum. See http://git.chorem.org/mum.git from 5cf361f index.html dynamique avec angular. mais serveur avec thread et le client demande regulierement l'etat du serveur new 7c31fec affichage des ip scannees new 293d414 mise en place des websocket jusqu'au traitemenent des erreurs... new d129a22 websocket en place pour la premiere detection new 09d34dd nettoyage du code new 7f264a9 suppression des controlleurs non utilisés new 0b5c9d1 suppression de res.xml The 6 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 0b5c9d122635d3d518d40f002148e2142a9217a7 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 16:02:36 2015 +0100 suppression de res.xml commit 7f264a9598ffcf10704e7bdf93fb021594bae62d Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 16:01:34 2015 +0100 suppression des controlleurs non utilisés commit 09d34dd7fca6e32779a6a5f56738f00e91f078cd Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 15:59:31 2015 +0100 nettoyage du code commit d129a22a2d8df344d9585e2e79348afd7553e9ad Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 15:44:22 2015 +0100 websocket en place pour la premiere detection commit 293d414a66bd69593baf4e9d51d6a0ec7c97f181 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 15:23:20 2015 +0100 mise en place des websocket jusqu'au traitemenent des erreurs... commit 7c31fec556ea660653e895b53ad2cce2b3671db6 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 10:51:11 2015 +0100 affichage des ip scannees Summary of changes: .gitignore | 1 + app/app.py | 82 ++++++++++++++++----------------- app/detection_modules/nmap_detection.py | 34 +++++++------- requirements.txt | 2 +- res.xml | 10 ---- static/js/DetectCtrl.js | 44 ------------------ static/js/controllers/app.js | 27 ----------- static/js/controllers/detectCtrl.js | 36 +++++++++++++++ static/js/controllers/script.js | 70 ---------------------------- views/index.html | 4 +- 10 files changed, 98 insertions(+), 212 deletions(-) delete mode 100644 res.xml delete mode 100644 static/js/DetectCtrl.js delete mode 100644 static/js/controllers/app.js create mode 100644 static/js/controllers/detectCtrl.js delete mode 100644 static/js/controllers/script.js -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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>.
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 293d414a66bd69593baf4e9d51d6a0ec7c97f181 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 15:23:20 2015 +0100 mise en place des websocket jusqu'au traitemenent des erreurs... --- app/app.py | 37 +++++++++++++---- requirements.txt | 2 +- res.xml | 6 +-- static/js/DetectCtrl.js | 44 -------------------- static/js/controllers/detectCtrl.js | 82 +++++++++++++++++++++++++++++++++++++ views/index.html | 4 +- 6 files changed, 118 insertions(+), 57 deletions(-) diff --git a/app/app.py b/app/app.py index 2052de6..01b77e4 100755 --- a/app/app.py +++ b/app/app.py @@ -2,6 +2,10 @@ __author__ = 'aguilbaud' from bottle import * from detection_modules.nmap_detection import check_ip_range, get_current_ip, get_scanned_ip +from bottle_websocket import GeventWebSocketServer +from bottle_websocket import websocket +import json + import threading state = "" @@ -24,16 +28,19 @@ def index(section='home'): def angular(): return template('angular') -@post('/detect/<ip_range>') -def start_first_detection(ip_range): +#@post('/detect/<ip_range>') +def start_first_detection(ip_range, ws): #ip_range = request.forms.get('ip_range') - global state + #global state + req = {} 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 : " + #state = "Scan de l'adresse : " t = ThreadDetect(ip_range) t.start() else: - state = "La plage d'IP est mal formatee" + req["error"] = "La plage d'IP est mal formatee" + ws.send(json.dumps(req)) + #state = "La plage d'IP est mal formatee" @error(404) def error404(error): @@ -53,13 +60,29 @@ def getstate(): global state 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 + +@get('/websocket', apply=[websocket]) +def echo(ws): + while True: + response = ws.receive() + if response is not None: + msg = json.loads(response) + for title in msg: + if title == "Sending_ip_range": + #print "launching scan for" + msg["Sending_ip_range"] + start_first_detection(msg["Sending_ip_range"], ws) + #if msg is not None: + # ws.send(msg) + #else: + # break + + ''' app = Bottle() @@ -86,4 +109,4 @@ server.serve_forever() if __name__ == '__main__': port = int(os.environ.get('PORT', 1337)) - run(host='0.0.0.0', port=port, debug=True, reloader=True) + run(host='0.0.0.0', port=port, debug=True, reloader=True, server=GeventWebSocketServer) diff --git a/requirements.txt b/requirements.txt index 58a8847..b689fc6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ bottle==0.12.7 pysnmp pexpect paramiko -gevent-websocket \ No newline at end of file +bottle-websocket \ No newline at end of file diff --git a/res.xml b/res.xml index 59b7716..d4a0732 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 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"> +<!-- Nmap 6.40 scan initiated Thu Jan 29 12:45:57 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="1422531957" startstr="Thu Jan 29 12:45:57 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="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><finished time="1422531961" timestr="Thu Jan 29 12:46:01 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 12:46:01 2015; 1 IP address (0 hosts up) scanned in 3.15 seconds" exit="success"/><hosts up="0" down="1" total="1"/> </runstats> </nmaprun> diff --git a/static/js/DetectCtrl.js b/static/js/DetectCtrl.js deleted file mode 100644 index 08c781a..0000000 --- a/static/js/DetectCtrl.js +++ /dev/null @@ -1,44 +0,0 @@ -var app = angular.module("myApp", []); - -/* Contrôleur principal -================================================== */ - -app.controller("MainCtrl", ["$scope", "userService", - function($scope, userService) { - $scope.state = userService.getState(); - } -]); - -/* Un premier service -================================================== */ - -app.service("userService", ["utilsService", "$interval", - function(utilsService, $timeout) { - //Variable privée - var state = { - state: "a", - }; - - //Getter pour la variable state - this.getState = function() { - //Cette méthode fait appel à un autre service - $http.get('/whatstate'). - success(function(data, status, headers, config) { - state = data - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - }); - return state; - }; - - //5 secondes après le chargement de la page, la valeur d'une propriété change dans le service. - //La view est mise à jour automatiquement - $interval(function() { - app.service.getState() - }, 5000); - - - } -]); diff --git a/static/js/controllers/detectCtrl.js b/static/js/controllers/detectCtrl.js new file mode 100644 index 0000000..6ff43a1 --- /dev/null +++ b/static/js/controllers/detectCtrl.js @@ -0,0 +1,82 @@ +var formExample = angular.module('formExample', []); + +formExample.controller('ExampleController', ['$scope', '$http', '$interval', function($scope, $http, $interval) { + $scope.master = {}; + $scope.ip_range = "198.116.0.1-10" // la plage d'ip entree dans le champ + $scope.state = ""; // l'etat general du scan en cours + $scope.validated = false; // pour afficher ou non certaines parties de la page + var ws = new WebSocket("ws://0.0.0.0:1337/websocket"); + + /*ws.onopen = function() { + ws.send("Hello, world"); + };*/ + ws.onmessage = function (evt) { + JSON.parse(evt.data, function (key, value) { + if(key == "state"){ + $scope.$apply(function(){ + $scope.state = value + }); + } + if(key == "error"){ + $scope.$apply(function(){ + $scope.state = "Erreur : " + value + }); + } + }); + + }; + + //lace la detection apres remplissage du champ + $scope.post_val = function(){ + var request = '{"Sending_ip_range" : "' + $scope.ip_range + '"}'; + ws.send(request); + } + + /*$scope.check_state = function(){ + $interval(function() { + $http.get('/getstate'). + success(function(data, status, headers, config) { + $scope.state = data + // when the response is available + }). + error(function(data, status, headers, config) { + alert("Impossible d'acceder à l'état") + // called asynchronously if an error occurs + // or server returns response with an error status. + }); + }, 10000); + }*/ + + }]); + + +/*formExample.service("ipService", ["stateService", "$interval", + function(stateService, $timeout) { + //Variable privée + var current_ip = { + current_ip: "a", + }; + + //Getter pour la variable current_ip + this.get_current_ip = function() { + //Cette méthode fait appel à un autre service + $http.get('/getval'). + success(function(data, status, headers, config) { + current_ip = data + }). + error(function(data, status, headers, config) { + // called asynchronously if an error occurs + // or server returns response with an error status. + }); + return current_ip; + }; + + //5 secondes après le chargement de la page, la valeur d'une propriété change dans le service. + //La view est mise à jour automatiquement + $interval(function() { + formExample.service.get_current_ip() + }, 5000); + + + } +]);*/ diff --git a/views/index.html b/views/index.html index fd52f64..0c276a6 100644 --- a/views/index.html +++ b/views/index.html @@ -11,7 +11,7 @@ <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script> <script src="bower_components/angular/angular.js"></script> - <script src="static/js/controllers/script.js"></script> + <script src="static/js/controllers/detectCtrl.js"></script> <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="static/css/main.css" rel="stylesheet" media="screen"> @@ -22,7 +22,7 @@ <form ng_submit="post_val()"> <div ng-show="validated == false" class="ng-hide"> Plage d'IP à scanner (exemple : 198.116.0.1-10) : <input name="ip_range" ng-model="ip_range" /> - <input value="Valider" type="submit" ng-click="validated = true ; check_state()"/> + <input value="Valider" type="submit" ng-click="validated = true"/> </div> <div ng-show="validated == true"> <p>{{state}}</p> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 d129a22a2d8df344d9585e2e79348afd7553e9ad Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 15:44:22 2015 +0100 websocket en place pour la premiere detection --- app/app.py | 19 ++++++++++--------- app/detection_modules/nmap_detection.py | 17 ++++++++--------- res.xml | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/app.py b/app/app.py index 01b77e4..566a6d7 100755 --- a/app/app.py +++ b/app/app.py @@ -1,24 +1,24 @@ __author__ = 'aguilbaud' from bottle import * -from detection_modules.nmap_detection import check_ip_range, get_current_ip, get_scanned_ip +from detection_modules.nmap_detection import check_ip_range from bottle_websocket import GeventWebSocketServer from bottle_websocket import websocket import json import threading -state = "" - class ThreadDetect(threading.Thread): - def __init__(self, ip_range): + def __init__(self, ip_range, ws): threading.Thread.__init__(self) self.ip_range = ip_range + self.ws = ws def run(self): - global state - check_ip_range(self.ip_range) - state = "Scan termine" + req = {} + check_ip_range(self.ip_range, self.ws) + req["state"] = "Scan termine" + self.ws.send(json.dumps(req)) @route('/') def index(section='home'): @@ -35,7 +35,7 @@ def start_first_detection(ip_range, ws): req = {} 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) + t = ThreadDetect(ip_range, ws) t.start() else: req["error"] = "La plage d'IP est mal formatee" @@ -55,6 +55,7 @@ def static(filepath): def bower_files(filepath): return static_file(filepath, root='bower_components') +""" @get('/getstate') def getstate(): global state @@ -65,7 +66,7 @@ def getstate(): for ip in scanned_ip: res += ip + ' : ' + scanned_ip[ip] return res - +""" @get('/websocket', apply=[websocket]) def echo(ws): diff --git a/app/detection_modules/nmap_detection.py b/app/detection_modules/nmap_detection.py index 87fa9e7..45e8f26 100644 --- a/app/detection_modules/nmap_detection.py +++ b/app/detection_modules/nmap_detection.py @@ -2,13 +2,11 @@ from xml.dom import minidom 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): +def check_ip_range(ip_range, ws): # separation des 4 octets byte1 = ip_range.split('.')[0] byte2 = ip_range.split('.')[1] @@ -51,7 +49,7 @@ def check_ip_range(ip_range): for j in range(int(split_byte2[0]), int(split_byte2[1]) + 1): for k in range(int(split_byte3[0]), int(split_byte3[1]) + 1): for l in range(int(split_byte4[0]), int(split_byte4[1]) + 1): - launch_detection(i, j, k, l) + launch_detection(i, j, k, l, ws) # verifie que la plage de donnee entree est dans l'ordre croissant @@ -70,10 +68,11 @@ def check_order_and_under_255(tab_val): # lance la detection a l'aide de nmap sur l'ip representee par les 4 octets passes en parametres -def launch_detection(b1, b2, b3, b4): - global current_ip +def launch_detection(b1, b2, b3, b4, ws): + req = {} ip = str(b1) + '.' + str(b2) + '.' + str(b3) + '.' + str(b4) - current_ip = ip + req["state"] = "Scan de l'IP " + ip + " en cours..." + ws.send(json.dumps(req)) child = pexpect.spawn('nmap', ['-A', ip, '-oX', 'res.xml']) res = '' # ici : possibilite de verifier l'avancement du scan, si option verbose (-v3) activee dans la commande nmap @@ -86,10 +85,9 @@ def launch_detection(b1, b2, b3, b4): parse_res(ip) except pexpect.TIMEOUT: res += ' TIMEOUT' - current_ip = "" return res - +''' def get_current_ip(): global current_ip return current_ip @@ -98,6 +96,7 @@ def get_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 diff --git a/res.xml b/res.xml index d4a0732..ef6f0d4 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 Thu Jan 29 12:45:57 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="1422531957" startstr="Thu Jan 29 12:45:57 2015" version="6.40" xmloutputversion="1.04"> +<!-- Nmap 6.40 scan initiated Thu Jan 29 15:43:56 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="1422542636" startstr="Thu Jan 29 15:43:56 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="1422531961" timestr="Thu Jan 29 12:46:01 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 12:46:01 2015; 1 IP address (0 hosts up) scanned in 3.15 seconds" exit="success"/><hosts up="0" down="1" total="1"/> +<runstats><finished time="1422542639" timestr="Thu Jan 29 15:43:59 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 15:43:59 2015; 1 IP address (0 hosts up) scanned in 3.15 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>.
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 09d34dd7fca6e32779a6a5f56738f00e91f078cd Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 15:59:31 2015 +0100 nettoyage du code --- app/app.py | 67 +++++++++------------------------ app/detection_modules/nmap_detection.py | 15 +++----- res.xml | 6 +-- static/js/controllers/detectCtrl.js | 54 ++------------------------ 4 files changed, 30 insertions(+), 112 deletions(-) diff --git a/app/app.py b/app/app.py index 566a6d7..cedca86 100755 --- a/app/app.py +++ b/app/app.py @@ -1,3 +1,5 @@ +# -*- coding: utf8 -*- +from __future__ import unicode_literals __author__ = 'aguilbaud' from bottle import * @@ -5,69 +7,64 @@ from detection_modules.nmap_detection import check_ip_range from bottle_websocket import GeventWebSocketServer from bottle_websocket import websocket import json - import threading +# Pour lancer la detection nmap avec un nouveau thread class ThreadDetect(threading.Thread): def __init__(self, ip_range, ws): threading.Thread.__init__(self) self.ip_range = ip_range self.ws = ws + def run(self): req = {} check_ip_range(self.ip_range, self.ws) - req["state"] = "Scan termine" + req["state"] = "Scan terminé" self.ws.send(json.dumps(req)) + @route('/') def index(section='home'): return template('index') + @route('/angular') def angular(): return template('angular') -#@post('/detect/<ip_range>') + +# Lancement de la detection apres reception d'une plage d'ip def start_first_detection(ip_range, ws): - #ip_range = request.forms.get('ip_range') - #global state req = {} + # Verification que l'ip est bien formatee 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 : " + # Si oui on lance la detection avec le module nmap_detection t = ThreadDetect(ip_range, ws) t.start() else: - req["error"] = "La plage d'IP est mal formatee" + # Si non, on envoie un message d'erreur + req["error"] = "La plage d'IP est mal formatée" ws.send(json.dumps(req)) - #state = "La plage d'IP est mal formatee" @error(404) def error404(error): return '<h1>Cette page n\'existe pas</h1>' +# Pour recuperer les fichiers statiques via l'url @get('/static/<filepath:path>') def static(filepath): return static_file(filepath, root='static') + +# Pour recuperer les dependances bower via l'url @get('/bower_components/<filepath:path>') def bower_files(filepath): return static_file(filepath, root='bower_components') -""" -@get('/getstate') -def getstate(): - global state - scanned_ip = get_scanned_ip() - res = state + get_current_ip() - if scanned_ip != {}: - res += "\n Completed : \n" - for ip in scanned_ip: - res += ip + ' : ' + scanned_ip[ip] - return res -""" +# Creation d'une websocket pour permettre la communication avec le client @get('/websocket', apply=[websocket]) def echo(ws): while True: @@ -76,38 +73,10 @@ def echo(ws): msg = json.loads(response) for title in msg: if title == "Sending_ip_range": - #print "launching scan for" + msg["Sending_ip_range"] start_first_detection(msg["Sending_ip_range"], ws) - #if msg is not None: - # ws.send(msg) - #else: - # break - - -''' -app = Bottle() - -@app.route('/websocket') -def handle_websocket(): - wsock = request.environ.get('wsgi.websocket') - if not wsock: - abort(400, 'Expected WebSocket request.') - while True: - try: - message = wsock.receive() - print message - wsock.send("Your message was: %r" % message) - except WebSocketError: - break -from gevent.pywsgi import WSGIServer -from geventwebsocket import WebSocketError -from geventwebsocket.handler import WebSocketHandler -server = WSGIServer(("0.0.0.0", 8181), app, - handler_class=WebSocketHandler) -server.serve_forever() -''' +# Lancement du serveur a l'adresse 0.0.0.0:1337 if __name__ == '__main__': port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, reloader=True, server=GeventWebSocketServer) diff --git a/app/detection_modules/nmap_detection.py b/app/detection_modules/nmap_detection.py index 45e8f26..7d59fd1 100644 --- a/app/detection_modules/nmap_detection.py +++ b/app/detection_modules/nmap_detection.py @@ -1,9 +1,14 @@ +# -*- coding: utf8 -*- +from __future__ import unicode_literals +__author__ = 'aguilbaud' + from xml.dom import minidom import pexpect import json 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, ws): @@ -87,16 +92,6 @@ def launch_detection(b1, b2, b3, b4, ws): res += ' TIMEOUT' return res -''' -def get_current_ip(): - global 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 diff --git a/res.xml b/res.xml index ef6f0d4..0337730 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 Thu Jan 29 15:43:56 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="1422542636" startstr="Thu Jan 29 15:43:56 2015" version="6.40" xmloutputversion="1.04"> +<!-- Nmap 6.40 scan initiated Thu Jan 29 15:52:38 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="1422543158" startstr="Thu Jan 29 15:52:38 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="1422542639" timestr="Thu Jan 29 15:43:59 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 15:43:59 2015; 1 IP address (0 hosts up) scanned in 3.15 seconds" exit="success"/><hosts up="0" down="1" total="1"/> +<runstats><finished time="1422543161" timestr="Thu Jan 29 15:52:41 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 15:52:41 2015; 1 IP address (0 hosts up) scanned in 3.15 seconds" exit="success"/><hosts up="0" down="1" total="1"/> </runstats> </nmaprun> diff --git a/static/js/controllers/detectCtrl.js b/static/js/controllers/detectCtrl.js index 6ff43a1..6bd55aa 100644 --- a/static/js/controllers/detectCtrl.js +++ b/static/js/controllers/detectCtrl.js @@ -10,6 +10,8 @@ formExample.controller('ExampleController', ['$scope', '$http', '$interval', fun /*ws.onopen = function() { ws.send("Hello, world"); };*/ + + // actions effectuees lors de la reception d'un message via la websocket ws.onmessage = function (evt) { JSON.parse(evt.data, function (key, value) { if(key == "state"){ @@ -26,57 +28,9 @@ formExample.controller('ExampleController', ['$scope', '$http', '$interval', fun }; - //lace la detection apres remplissage du champ + //lace la detection apres remplissage du champ et validation du formulaire $scope.post_val = function(){ var request = '{"Sending_ip_range" : "' + $scope.ip_range + '"}'; ws.send(request); } - - /*$scope.check_state = function(){ - $interval(function() { - $http.get('/getstate'). - success(function(data, status, headers, config) { - $scope.state = data - // when the response is available - }). - error(function(data, status, headers, config) { - alert("Impossible d'acceder à l'état") - // called asynchronously if an error occurs - // or server returns response with an error status. - }); - }, 10000); - }*/ - - }]); - - -/*formExample.service("ipService", ["stateService", "$interval", - function(stateService, $timeout) { - //Variable privée - var current_ip = { - current_ip: "a", - }; - - //Getter pour la variable current_ip - this.get_current_ip = function() { - //Cette méthode fait appel à un autre service - $http.get('/getval'). - success(function(data, status, headers, config) { - current_ip = data - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - }); - return current_ip; - }; - - //5 secondes après le chargement de la page, la valeur d'une propriété change dans le service. - //La view est mise à jour automatiquement - $interval(function() { - formExample.service.get_current_ip() - }, 5000); - - - } -]);*/ +}]); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 7f264a9598ffcf10704e7bdf93fb021594bae62d Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 16:01:34 2015 +0100 suppression des controlleurs non utilisés --- res.xml | 6 ++-- static/js/controllers/app.js | 27 ---------------- static/js/controllers/script.js | 70 ----------------------------------------- 3 files changed, 3 insertions(+), 100 deletions(-) diff --git a/res.xml b/res.xml index 0337730..ded372a 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 Thu Jan 29 15:52:38 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="1422543158" startstr="Thu Jan 29 15:52:38 2015" version="6.40" xmloutputversion="1.04"> +<!-- Nmap 6.40 scan initiated Thu Jan 29 16:01:03 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="1422543663" startstr="Thu Jan 29 16:01:03 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="1422543161" timestr="Thu Jan 29 15:52:41 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 15:52:41 2015; 1 IP address (0 hosts up) scanned in 3.15 seconds" exit="success"/><hosts up="0" down="1" total="1"/> +<runstats><finished time="1422543666" timestr="Thu Jan 29 16:01:06 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 16:01:06 2015; 1 IP address (0 hosts up) scanned in 3.15 seconds" exit="success"/><hosts up="0" down="1" total="1"/> </runstats> </nmaprun> diff --git a/static/js/controllers/app.js b/static/js/controllers/app.js deleted file mode 100644 index 19e467e..0000000 --- a/static/js/controllers/app.js +++ /dev/null @@ -1,27 +0,0 @@ -angular.module('myAppName', []) - .controller('MainCtrl', function($scope,$http) { - $http.get("getval") - .success(function(response) {$scope.text = response;}); - /*$scope.title = "Boucle sur un objet javascript" - $scope.users = [ - {name:'Sébastien',age:21}, - {name:'Marion',age:24}, - {name:'Laura',age:25}, - {name:'Morgan',age:23} - ];*/ - }); - -//var MainCtrl = function ($scope) { - -//}; -//var SecondCtrl = function ($scope) { - -//}; -/*angular.module('myAppName', []) - .controller('SecondCtrl', function($scope) { - $scope.title = "Appel d'une fonction" - $scope.ohHey = function () { - alert("Oh hey"); - }; - }); -*/ diff --git a/static/js/controllers/script.js b/static/js/controllers/script.js deleted file mode 100644 index 41a8b90..0000000 --- a/static/js/controllers/script.js +++ /dev/null @@ -1,70 +0,0 @@ -var formExample = angular.module('formExample', []); - -formExample.controller('ExampleController', ['$scope', '$http', '$interval', function($scope, $http, $interval) { - $scope.master = {}; - $scope.ip_range = "198.116.0.1-10" // la plage d'ip entree dans le champ - $scope.state = ""; // l'etat general du scan en cours - $scope.validated = false; // pour afficher ou non certaines parties de la page - - //lace la detection apres remplissage du champ - $scope.post_val = function(){ - $http.post('/detect/' + $scope.ip_range). - success(function(data, status, headers, config) { - // this callback will be called asynchronously - // when the response is available - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - }); - } - - $scope.check_state = function(){ - $interval(function() { - $http.get('/getstate'). - success(function(data, status, headers, config) { - $scope.state = data - // when the response is available - }). - error(function(data, status, headers, config) { - alert("Impossible d'acceder à l'état") - // called asynchronously if an error occurs - // or server returns response with an error status. - }); - }, 1000); - } - - }]); - - -/*formExample.service("ipService", ["stateService", "$interval", - function(stateService, $timeout) { - //Variable privée - var current_ip = { - current_ip: "a", - }; - - //Getter pour la variable current_ip - this.get_current_ip = function() { - //Cette méthode fait appel à un autre service - $http.get('/getval'). - success(function(data, status, headers, config) { - current_ip = data - }). - error(function(data, status, headers, config) { - // called asynchronously if an error occurs - // or server returns response with an error status. - }); - return current_ip; - }; - - //5 secondes après le chargement de la page, la valeur d'une propriété change dans le service. - //La view est mise à jour automatiquement - $interval(function() { - formExample.service.get_current_ip() - }, 5000); - - - } -]); -*/ \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 0b5c9d122635d3d518d40f002148e2142a9217a7 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jan 29 16:02:36 2015 +0100 suppression de res.xml --- res.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/res.xml b/res.xml deleted file mode 100644 index ded372a..0000000 --- a/res.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?> -<!-- Nmap 6.40 scan initiated Thu Jan 29 16:01:03 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="1422543663" startstr="Thu Jan 29 16:01:03 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="1422543666" timestr="Thu Jan 29 16:01:06 2015" elapsed="3.15" summary="Nmap done at Thu Jan 29 16:01:06 2015; 1 IP address (0 hosts up) scanned in 3.15 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>.
participants (1)
-
chorem.org scm