def do_scan(self, args): arg = args.split() if len(arg) > 3 or len(arg) < 2: print( "*** Invalid number of arguments\nType 'help scan' to see documentation" ) return ipRange = arg[0] module = arg[1] ports = "all" if len(arg) == 3: ports = arg[2] if "-p" not in ports: print( "*** Invalid arguments\nType 'help scan' to see documentation" ) return ports = ports.replace("-p", "") channel = grpc.insecure_channel(serverIp + ":" + serverPort) stub = scan_pb2_grpc.ScanStub(channel) message = scan_pb2.ScanRequest(IpRange=ipRange, Modulo=module, Ports=ports) resp = stub.ScanIp(message) channel.close() if resp.Resposta == "ERROR": print("Invalid arguments\nType 'help scan' to see documentation") return if "No matching ports" in resp.Resposta: print("There is no port: " + ports + " in module " + module) return printOutput(resp.Resposta)
def do_list(self, inp): channel = grpc.insecure_channel(serverIp + ":" + serverPort) stub = scan_pb2_grpc.ScanStub(channel) message = scan_pb2.ModulesRequest(RequestModulesName="GetAllModules") resp = stub.ListModules(message) channel.close() print("Listing current modules:") for module in resp.ModulesNames: print("\t" + module)
def do_description(self, module): channel = grpc.insecure_channel(serverIp + ":" + serverPort) stub = scan_pb2_grpc.ScanStub(channel) message = scan_pb2.DescriptionRequest(Modulo=module) resp = stub.ScanDescription(message) channel.close() if resp.Description == "ERROR": print( "Module not found\nType 'help description' to see documentation" ) else: print("Description: " + resp.Description)
def sendCustomScan(worker,range,moduleUrl): def GetScanResults(done): results.append(done.result().RespostaCustomScan) replaceValueDic(workerList,worker,True) channel = grpc.insecure_channel(worker) replaceValueDic(workerList,worker,False) stub = scan_pb2_grpc.ScanStub(channel) message =scan_pb2.CustomScanRequest(IpRange=range,ModuloUrl=moduleUrl) call_future= stub.CustomScan.future(message) call_future.add_done_callback(GetScanResults)
def sendScan(worker,range,module,portas): def GetScanResult(done): results.append(done.result().Resposta) replaceValueDic(workerList,worker,True) channel = grpc.insecure_channel(worker) replaceValueDic(workerList,worker,False) stub = scan_pb2_grpc.ScanStub(channel) message =scan_pb2.ScanRequest(IpRange=range,Modulo=module,Ports=portas) call_future= stub.ScanIp.future(message) call_future.add_done_callback(GetScanResult)
def do_customScan(self, args): arg = args.split() if len(arg) > 2: print( "*** Invalid number of arguments\nType 'help scan' to see documentation" ) return ipRange = arg[0] moduleUrl = arg[1] channel = grpc.insecure_channel(serverIp + ":" + serverPort) stub = scan_pb2_grpc.ScanStub(channel) message = scan_pb2.CustomScanRequest(IpRange=ipRange, ModuloUrl=moduleUrl) resp = stub.CustomScan(message) channel.close() #if resp.Resposta == "ERROR": # print("Invalid arguments\nType 'help scan' to see documentation") # return printOutput(resp.RespostaCustomScan)