Skip to content

Commit

Permalink
ajout front profiling machine
Browse files Browse the repository at this point in the history
  • Loading branch information
CrystalRays committed Mar 12, 2022
1 parent 12fada4 commit f4b4912
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion echosounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,4 @@ def data_creation_services_discovery(target_ip, dev: bool) -> List[dict]:
if __name__ == "__main__":
print("TEST")
# data_creation_fast_ping('192.168.1.0/24')
data_creation_services_discovery('192.168.1.0/24', dev=True)
data_creation_services_discovery('192.168.1.0/24', dev=False)
28 changes: 17 additions & 11 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ EchoApp.controller("leftPanelMenu", function($scope, $rootScope, $http) {
}

$scope.$on('updatePanelNodeData',function(event, nodedata, nodetype) {
console.log("test change machine");
console.log(nodedata);
console.log(nodetype);
if(nodetype == 'IP') { // on prend que les IP
if('IP' in nodedata) { // on vérifie qu'il y a une IP dans le nodedata
$scope.machineCible = nodedata['IP'];
$scope.$apply();
}
$scope.machineCible = nodedata.data_ip;
$scope.$apply();
}
});
});
Expand All @@ -54,8 +49,9 @@ EchoApp.controller("rightPanelMenu", function($scope, $rootScope, $http) {
$scope.nodedata = undefined;

$scope.$on('updatePanelNodeData', function(event, node, typenode) {
console.log(node);
if(typenode == 'IP') { // on déclenche l'affichage du menu 1 avec les données du node
$scope.nodedata = node;
$scope.nodedata = node.data;
$scope.showMenu1 = true;
$scope.showMenu2 = false;
$scope.showMenu3 = false;
Expand Down Expand Up @@ -165,8 +161,8 @@ EchoApp.controller("graphNetwork", function($scope, $rootScope, $http) {
function(response) {
$scope.$parent.sendToastData('Profiling Scan', "réception d'un scan");
console.log(response.data);
// on appel la fonction de création de graphs :
//$scope.createCytoGraph(response.data);
// on met à jour le node concerné via une fonction de sélection de node
$scope.updateNodebyIP(cible, 'profiling', response.data['scan']);
},
// si la requête échoue :
function(error) {
Expand Down Expand Up @@ -237,6 +233,7 @@ EchoApp.controller("graphNetwork", function($scope, $rootScope, $http) {
label : ("gateway " + scan_data.local_data.gateway_ip + "\n" + scan_data.local_data.gateway_mac),
type : 'IP',
data : scan_data.local_data,
data_ip : scan_data.local_data.gateway_ip,
},
}
);
Expand All @@ -252,6 +249,7 @@ EchoApp.controller("graphNetwork", function($scope, $rootScope, $http) {
label : (nodeAdd.IP + '\n' + nodeAdd.mac),
type : 'IP',
data : nodeAdd,
data_ip : nodeAdd.IP,
},
}
);
Expand Down Expand Up @@ -281,10 +279,18 @@ EchoApp.controller("graphNetwork", function($scope, $rootScope, $http) {
$scope.layout.run();
};

// fonction de mise à jour d'un noeud spécifique
$scope.updateNodebyIP = function(ip_node, update_key, update_data) {
// on cherche le noeud à updater par IP
let node_update = $scope.cyto.elements("node[data_ip = '" + ip_node + "']");
// on met la donnée dans la key du node depuis data
node_update.data('data')[update_key] = update_data;
}

// évènement en cas de clic sur un noeud :
$scope.cyto.on('tap', 'node', function(evt){
// on envoie au parent le noeud à afficher :
$scope.$parent.$broadcast("updatePanelNodeData", evt.target.data('data'), evt.target.data('type'));
$scope.$parent.$broadcast("updatePanelNodeData", evt.target.data(), evt.target.data('type'));
});

$scope.$on('request_fast_ping', function(event, args) {
Expand Down
7 changes: 7 additions & 0 deletions webchosounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def scan_rapide():
return jsonify(local_data=local_ip_mac_and_gateway, scan=ip_mac_os)


@app.route('/json/profiling_scan', methods=['POST'])
def scan_profiling():
if not if_contain_cible(request.json):
return {'error': "malformed request"}
else:
return jsonify(scan=echosounder.creation_data_nmap(request.json['cible']))

def if_contain_cible(test_target) -> bool:
return 'cible' in test_target

Expand Down

0 comments on commit f4b4912

Please sign in to comment.