def do_transform(self, request, response, config): service = request.entity # Test for properties & get Workspace Credentials --------------------------------// try: ws_url = config[ 'EffectiveCouscous.local.baseurl'] + 'workspaces/{0}'.format( service.workspace_id) workspace = apitools.get_json_dict(ws_url, config)['name'] url = config['EffectiveCouscous.local.baseurl'] + 'credentials' params = ( ('workspace', '{0}'.format(workspace)), ('svcs', '{0}'.format(service.name)), ) creds = apitools.get_json_dict(url, config, params=params) except KeyError: raise MaltegoException( "This IPv4Address is not tied to a Metasploit Host. \ Please associate it with a Host before running this transform" ) return response # REWRITE FOR ALL CASES WHERE CREDENTIAL PROPERTIES ARE NOT EXISTING !!!!!!!!!!!!!!!!! # Filter for Service for cred in creds: try: if (int(cred['logins'][0]['service_id'])) == int(service.id): cred_entity = MetasploitCredential() cred_entity.id = cred['id'] cred_entity.logins_count = cred['logins_count'] cred_entity.pub_username = cred['public']['username'] cred_entity.pub_type = cred['public']['type'] cred_entity.priv_data = cred['private']['data'] cred_entity.priv_type = cred['private']['type'] cred_entity.priv_jtr_format = cred['private']['jtr_format'] cred_entity.origin_service_id = cred['origin'][ 'service_id'] cred_entity.origin_type = cred['origin']['type'] cred_entity.origin_module = cred['origin'][ 'module_full_name'] cred_entity.name = '{}/{}'.format(cred_entity.pub_username, cred_entity.priv_data) # Link Style cred_entity.link_color = LinkColor.DarkGreen cred_entity.link_thickness = 3 response += cred_entity except KeyError as e: continue except IndexError as f: continue return response
def do_transform(self, request, response, config): ip = request.entity # Test for properties ------------------------------------------------// try: url = config[ 'EffectiveCouscous.local.baseurl'] + 'workspaces/{0}'.format( ip['workspace_id']) workspace = apitools.get_json_dict(url, config)['name'] s_url = config['EffectiveCouscous.local.baseurl'] + 'services' params = (('workspace', '{0}'.format(workspace)), ) services = apitools.get_json_dict(s_url, config, params=params) except KeyError: raise MaltegoException( "This IPv4Address is not tied to a Metasploit Host. \ Please associate it with a Host before running this transform" ) return response # Fill properties ----------------------------------------------------// for service in services: if int(service['host']['id']) == int(ip['id']): # Get Service Entity msf_service = getServiceEntity(service['name'], service['info']) msf_service.display = "{port}:{proto}/{name}".format( port=service['port'], proto=service['proto'], name=service['name']) msf_service.info = service['info'] msf_service.name = service['name'] msf_service.proto = service['proto'] msf_service.port = service['port'] msf_service.host_id = service['host_id'] msf_service.id = service['id'] msf_service.workspace_id = ip['workspace_id'] msf_service.created_at = service['created_at'] msf_service.updated_at = service['updated_at'] msf_service.state = service['state'] # Icons msf_service.origin_tool = 'Metasploit' # Link Style msf_service.link_color = LinkColor.LightGray msf_service.link_thickness = 3 response += msf_service return response
def do_transform(self, request, response, config): msf_service = request.entity # Test for properties ----------------------------------------------// try: test = msf_service['id'] except KeyError: raise MaltegoException( "This Service is not tied to a Metasploit Service. \ Please associate it with a Service before running this transform" ) return response url = config['EffectiveCouscous.local.baseurl'] + 'services/{0}'.format( msf_service['id']) service = apitools.get_json_dict(url, config) msf_service.info = service['info'] msf_service.name = service['name'] msf_service.proto = service['proto'] msf_service.port = service['port'] msf_service.host_id = service['host']['id'] msf_service.service_id = service['id'] msf_service.workspace_id = service['host']['workspace_id'] msf_service.created_at = service['created_at'] msf_service.updated_at = service['updated_at'] msf_service.state = service['state'] raise MaltegoException( 'Due to implementation limitations, it is not possible to refresh this Entity "as is". \ Please suppress it and spawn it again from its parent Entity to see it with its new properties.' ) return response
def do_transform(self, request, response, config): ip_address = request.entity # Test for properties try: url = config[ 'EffectiveCouscous.local.baseurl'] + 'hosts/{0}'.format( ip_address['id']) host = apitools.get_json_dict(url, config) except KeyError: raise MaltegoException( "This IPv4Address is not tied to a Metasploit Host. \ Please associate it with a Host before running this transform" ) return response # Spawn Host (NEW) h = getOsEntity(host['os_name'], host['name']) h.ipv4address = ip_address['ipv4-address'] h.id = '-' if host['id'] is None else host['id'] h.mac = '-' if host['mac'] is None else host['mac'] h.comm = '-' if host['comm'] == '' else host['comm'] h.name = '-' if host['name'] is None else host['name'] h.state = '-' if host['state'] is None else host['state'] h.os_family = '-' if host['os_family'] is None else host['os_family'] h.os_name = '-' if host['os_name'] is None else host['os_name'] h.os_flavor = '-' if host['os_flavor'] is None else host['os_flavor'] h.os_sp = '-' if host['os_sp'] is None else host['os_sp'] h.os_lang = '-' if host['os_lang'] is None else host['os_lang'] h.arch = '-' if host['arch'] is None else host['arch'] h.workspace_id = '-' if host['workspace_id'] is None else host[ 'workspace_id'] h.purpose = '-' if host['purpose'] is None else host['purpose'] h.info = '-' if host['info'] is None else host['info'] h.comments = '-' if host['comments'] is None else host['comments'] h.scope = '-' if host['scope'] is None else host['scope'] h.virtual_host = '-' if host['virtual_host'] is None else host[ 'virtual_host'] h.note_count = '-' if host['note_count'] is None else host['note_count'] h.vuln_count = '-' if host['vuln_count'] is None else host['vuln_count'] h.service_count = '-' if host['service_count'] is None else host[ 'service_count'] h.host_detail_count = '-' if host[ 'host_detail_count'] is None else host['host_detail_count'] h.exploit_attempt_count = '-' if host[ 'exploit_attempt_count'] is None else host['exploit_attempt_count'] h.cred_count = '-' if host['cred_count'] is None else host['cred_count'] h.detected_arch = '-' if host['detected_arch'] is None else host[ 'detected_arch'] h.created_at = host['created_at'] h.updated_at = host['updated_at'] # Origin Tool h.origin_tool = 'Metasploit' # Link Style h.link_color = LinkColor.Black h.link_thickness = 3 response += h return response
def do_transform(self, request, response, config): # Get Credential JSON dictionary credential = request.entity # Test for properties try: url = config[ 'EffectiveCouscous.local.baseurl'] + 'credentials/{0}'.format( credential['id']) except KeyError: raise MaltegoException( "This Credential is not tied to a Metasploit Credential. Please associate it with a Credential before running this transform" ) return response cred = apitools.get_json_dict(url, config) # Fetch values credential.id = cred['id'] credential.logins_count = cred['logins_count'] credential.pub_username = cred['public']['username'] credential.pub_type = cred['public']['type'] credential.priv_data = cred['private']['data'] credential.priv_type = cred['private']['type'] credential.priv_jtr_format = cred['private']['jtr_format'] credential.origin_service_id = cred['origin']['service_id'] credential.origin_type = cred['origin']['type'] credential.origin_module = cred['origin']['module_full_name'] raise MaltegoException( 'Due to implementation limitations, it is not possible to refresh this Entity "as is". Please suppress it and spawn it again from its parent Entity to see it with its new properties.' ) return response
def do_transform(self, request, response, config): # Get Credential JSON dictionary credential = request.entity # Test for properties try: url = config[ 'EffectiveCouscous.local.baseurl'] + 'credentials/{0}'.format( credential['id']) except KeyError: raise MaltegoException( "This Credential is not tied to a Metasploit Credential. Please associate it with a Credential before running this transform" ) return response cred = apitools.get_json_dict(url, config)[0] # THIS IS NOT WORKING: THE DICTIONARY ASKED FOR THE PUT METHOD IS # WEIRD, THEREFORE IT NEEDS TO BE COPIED ANOTHER WAY THAN THIS ONE # Push values # cred['id'] = int(credential.id) # cred['logins_count'] = int(credential.logins_count) # cred['public']['username'] = credential.pub_username # cred['public']['type'] = credential.pub_type # cred['private']['data'] = credential.priv_data # cred['private']['type'] = credential.priv_type # cred['private']['jtr_format'] = credential.priv_jtr_format # cred['origin']['service_id'] = credential.origin_service_id # cred['origin']['type'] = credential.origin_type # cred['origin']['module_full_name'] = credential.origin_module # data = json.dumps(cred) # update = apitools.post_json(url, data) return response
def do_transform(self, request, response, config): ws = request.entity # Test for properties try: test = ws['workspace_id'] except KeyError: raise MaltegoException( "This Netblock/Host is not tied to a Metasploit Workspace. \ Please associate it with a workspace before running this transform" ) return response url = config[ 'EffectiveCouscous.local.baseurl'] + 'workspaces/{0}'.format( ws['workspace_id']) workspace = apitools.get_json_dict(url, config) ws['workspace_id'] = workspace['id'] ws['name'] = workspace['name'] ws['created_at'] = workspace['created_at'] ws['updated_at'] = workspace['updated_at'] ws['boundary'] = workspace['boundary'] ws['description'] = workspace['description'] ws['owner_id'] = workspace['owner_id'] ws['limit_to_network'] = workspace['limit_to_network'] ws['import_fingerprint'] = workspace['import_fingerprint'] return response
def do_transform(self, request, response, config): host_input = request.entity # Get workspace & Test for Properties ---------------------------------// url = config['EffectiveCouscous.local.baseurl'] + 'workspaces' workspaces = apitools.get_json_dict(url, config) workspace_name = '' try: for workspace in workspaces: if workspace['id'] == host_input.workspace_id: workspace_name = workspace['name'] url = config['EffectiveCouscous.local.baseurl'] + 'hosts' params = (('workspace', '{0}'.format(workspace_name)), ) hosts = apitools.get_json_dict(url, config, params=params) except KeyError: raise MaltegoException( "This Host is not tied to a Metasploit Workspace. \ Please associate it with a workspace before running this transform" ) return response # Select Hosts --------------------------------------------------------// for host in hosts: if (host['name'] == host_input.name) and (host['os_name'] == host_input.os_name): ip_entity = IPv4Address() ip_entity['ipv4-address'] = host_input['address'] ip_entity.host_id = host_input['id'] ip_entity.workspace_id = host_input['workspace_id'] ip_entity.icon_url = network_interface ip_entity.origin_tool = 'Metasploit' # Link Style ip_entity.link_color = LinkColor.Black ip_entity.link_thickness = 3 response += ip_entity return response
def do_transform(self, request, response, config): ip = request.entity # Test for properties -------------------------------------------// try: ws_url = config[ 'EffectiveCouscous.local.baseurl'] + 'workspaces/{0}'.format( ip['workspace_id']) workspace = apitools.get_json_dict(ws_url, config)['name'] url = config['EffectiveCouscous.local.baseurl'] + 'hosts' params = (('workspace', '{0}'.format(workspace)), ) hosts = apitools.get_json_dict(url, config, params=params) except KeyError: raise MaltegoException( "This IPv4Address is not tied to a Metasploit Host. \ Please associate it with a Host before running this transform" ) return response # Enumerate IP addresses ----------------------------------------// for host in hosts: if host['id'] == ip.host_id: pass else: ip_entity = IPv4Address() ip_entity['ipv4-address'] = host['address'] ip_entity.host_id = host['id'] ip_entity.workspace_id = host['workspace_id'] ip_entity.icon_url = network_interface ip_entity.origin_tool = 'Metasploit' # Link Style ip_entity.link_color = LinkColor.LightGray ip_entity.link_thickness = 4 response += ip_entity return response
def do_transform(self, request, response, config): msf_host = request.entity # Test for properties try: url = config[ 'EffectiveCouscous.local.baseurl'] + 'hosts/{0}'.format( msf_host['id']) host = apitools.get_json_dict(url, config) except KeyError: raise MaltegoException( "This Host is not tied to a Metasploit Host. Please associate it with a Host before running this transform" ) return response msf_host['id'] = host['id'] msf_host['ipv4-address'] = host['address'] msf_host['mac'] = host['mac'] msf_host['comm'] = host['comm'] msf_host['name'] = host['name'] msf_host['state'] = host['state'] msf_host['os_name'] = host['os_name'] msf_host['os_flavor'] = host['os_flavor'] msf_host['os_sp'] = host['os_sp'] msf_host['os_lang'] = host['os_lang'] msf_host['os_family'] = host['os_family'] msf_host['arch'] = host['arch'] msf_host['detected_arch'] = host['detected_arch'] msf_host['workspace_id'] = host['workspace_id'] msf_host['purpose'] = host['purpose'] msf_host['info'] = host['info'] msf_host['comments'] = host['comments'] msf_host['scope'] = host['scope'] msf_host['virtual_host'] = host['virtual_host'] msf_host['note_count'] = host['note_count'] msf_host['vuln_count'] = host['vuln_count'] msf_host['service_count'] = host['service_count'] msf_host['host_detail_count'] = host['host_detail_count'] msf_host['exploit_attempt_count'] = host['exploit_attempt_count'] msf_host['cred_count'] = host['cred_count'] msf_host['created_at'] = host['created_at'] msf_host['updated_at'] = host['updated_at'] return response
def do_transform(self, request, response, config): netblock = request.entity # Test for properties try: url = config['EffectiveCouscous.local.baseurl'] + 'hosts' params = (('workspace', '{0}'.format(netblock['name'])), ) hosts = apitools.get_json_dict(url, config, params=params) title = "Host Choice" msg = "Choose one or more Hosts for IPv4Address enumeration" except KeyError: raise MaltegoException( "This Netblock is not tied to a Metasploit Workspace. \ Please associate it with a workspace before running this transform" ) return response # Select Hosts host_infos = [] host_map = {} for host in hosts: info = '{0} {1}'.format(host['address'], host['name']) host_infos.append(info) host_map[host['address']] = info raw_choices = gui.multchoicebox(title=title, msg=msg, choices=(host_infos)) for choice in raw_choices: for (address, mapped) in host_map.items(): if choice == mapped: for host in hosts: if address == str(host['address']): ip_entity = IPv4Address() ip_entity['ipv4-address'] = host['address'] ip_entity.host_id = host['id'] ip_entity.workspace_id = host['workspace_id'] ip_entity.icon_url = network_interface ip_entity.origin_tool = 'Metasploit' response += ip_entity return response
def do_transform(self, request, response, config): service_entity = request.entity # Find workspace with ID -------------------------------// url = config['EffectiveCouscous.local.baseurl'] + 'workspaces' workspaces = apitools.get_json_dict(url, config) ws_name = '' for workspace in workspaces: if workspace['id'] == service_entity.workspace_id: ws_name = workspace['name'] # Create Service in Metasploit -------------------------// dict = {} dict['workspace'] = ws_name dict['host'] = service_entity.host_id dict['port'] = service_entity.port dict['proto'] = service_entity.proto dict['name'] = service_entity.name dict['info'] = service_entity.info dict['state'] = service_entity.state data = json.dumps(dict) post = apitools.post_json(service_url, data) # Fetch new Service in Metasploit ----------------------// new = post.json()['data'] msf_service = getServiceEntity(new['name'], new['info']) msf_service.info = new['info'] msf_service.name = new['name'] msf_service.proto = new['proto'] msf_service.host_id = new['host']['id'] msf_service.id = new['id'] msf_service.workspace_id = new['host']['workspace_id'] msf_service.display = "{port}:{proto}/{name}".format( port=new['port'], proto=new['proto'], name=new['name']) msf_service.state = new['state'] msf_service.created_at = new['created_at'] msf_service.updated_at = new['updated_at'] response += msf_service return response
def do_transform(self, request, response, config): netblock = request.entity # Select Workspaces url = config['EffectiveCouscous.local.baseurl'] + 'workspaces' workspaces = apitools.get_json_dict(url, config) title = "Workspace Choice" msg = "Choose a Metasploit workspace to associate with this Netblock" ws_names = [workspace['name'] for workspace in workspaces] ws_names.append('Add Workspace') workspace = {} choice = gui.choicebox(msg=msg, title=title, choices=(ws_names)) if choice == "Add Workspace": workspace['name'] = "Add Workspace" else: for ws in workspaces: if ws['name'] == choice: workspace = ws # If Existing Workspace --------------------------------------------------------------- // if workspace['name'] != "Add Workspace": # Set Values netblock.name = '-' if workspace['name'] is None else workspace[ 'name'] netblock.workspace_id = workspace['id'] netblock.boundary = '-' if workspace[ 'boundary'] is None else workspace['boundary'] netblock.description = '-' if workspace[ 'description'] is None else workspace['description'] netblock.owner_id = '-' if workspace[ 'owner_id'] is None or '-' else workspace['owner_id'] netblock.limit_to_network = workspace['limit_to_network'] netblock.import_fingerprint = workspace['import_fingerprint'] netblock.created_at = workspace['created_at'] netblock.updated_at = workspace['updated_at'] netblock.origin_tool = 'Metasploit' # IP Range and Boundary if workspace['boundary'] is not None: netblock['ipv4-range'] = netblock.boundary # Add to response response + netblock # If New Workspace ------------------------------------------------------------------- // if workspace['name'] == "Add Workspace": msg = "New Workspace" fieldNames = ["Name"] fieldValues = gui.multenterbox(msg, fields=fieldNames) while 1: if fieldValues == None: break errmsg = "" for i in range(len(fieldNames)): if fieldValues[i].strip() == "": errmsg += ('"%s" is a required field.\n\n' % fieldNames[i]) if errmsg == "": break fieldValues = gui.multenterbox(errmsg, fieldValues, fieldNames) # Create and Fetch Workspace in Metasploit dict = {} dict['name'] = fieldValues[0] data = json.dumps(dict) post = apitools.post_json(url, data, config) workspaces = apitools.get_json_dict(url, config) ws = [] for workspace in workspaces: if workspace['name'] == dict['name']: ws.append(workspace) workspace = ws[0] # Set Values netblock.name = '-' if workspace['name'] is None else workspace[ 'name'] netblock.workspace_id = workspace['id'] netblock.boundary = '-' if workspace[ 'boundary'] is None else workspace['boundary'] netblock.description = '-' if workspace[ 'description'] is None else workspace['description'] netblock.owner_id = '-' if workspace[ 'owner_id'] is None else workspace['owner_id'] netblock.limit_to_network = workspace['limit_to_network'] netblock.import_fingerprint = workspace['import_fingerprint'] netblock.created_at = workspace['created_at'] netblock.updated_at = workspace['updated_at'] netblock.origin_tool = 'Metasploit' # IP Range and Boundary if workspace['boundary'] is not None: netblock['ipv4-range'] = netblock.boundary # Add to response response + netblock return response
def do_transform(self, request, response, config): service_entity = request.entity # Select workspace & Service --------------------------------------// url = config['EffectiveCouscous.local.baseurl'] + 'workspaces' workspaces = apitools.get_json_dict(url, config) title = "Workspace Choice" msg = """Choose a Metasploit Workspace for Service selection""" ws_names = [workspace['name'] for workspace in workspaces] ws_choice = gui.choicebox(title=title, msg=msg, choices=(ws_names)) # Select Service -------------------------------------------------// service_url = config['EffectiveCouscous.local.baseurl'] + 'services' params = (('workspace', '{0}'.format(ws_choice)), ) services = apitools.get_json_dict(service_url, config, params=params) title = "Service Choice" msg = """Choose a Metasploit Service to associate with this Service""" service_names = [] service_infos = [] for service in services: info = '%s %s %s' % (service['host']['address'], service['port'], service['info']) service_infos.append(info) service_names.append(service['info']) service_infos.append("Add Service") raw_choice = gui.choicebox(title=title, msg=msg, choices=(service_infos)) service = {} if "Add Service" in raw_choice: service['info'] = "Add Service" else: for s in services: if (s['info'] in raw_choice) and (str(s['port']) in raw_choice): service = s # If existing Service --------------------------------------// if service['info'] != "Add Service": msf_service = getServiceEntity(service['name'], service['info']) if service['info'] == '': msf_service.info = '-' else: msf_service.info = service['info'] if service['name'] == '': msf_service.name = '-' else: msf_service.name = service['name'] if service['proto'] == '': msf_service.proto = '-' else: msf_service.proto = service['proto'] if service['port'] == '': msf_service.port = '-' else: msf_service.port = service['port'] if service['host']['id'] is None: msf_service.host_id = '-' else: msf_service.host_id = service['host']['id'] if service['id'] == '': msf_service.id = '-' else: msf_service.service_id = service['id'] if service['host']['workspace_id'] == '': msf_service.workspaceid = '-' else: msf_service.workspace_id = service['host']['workspace_id'] msf_service.display = "{port}:{proto}/{name}".format( port=service['port'], proto=service['proto'], name=service['name']) msf_service.state = service['state'] msf_service.created_at = service['created_at'] msf_service.updated_at = service['updated_at'] response += msf_service # If new Service -------------------------------------------------// if service['info'] == "Add Service": title = "New Service" msg = "Add properties to create a Service in Metasploit" field_names = [ 'Workspace', 'Host IP', 'Port number', 'Protocol', 'Service Name', 'Text (Info)', 'State' ] field_values = [] field_values = gui.multenterbox(msg, fields=field_names) while 1: if field_values == None: break errmsg = "" for i in range(len(field_names)): if field_values[i].strip() == "": errmsg += ('"%s" is a required field.\n\n' % field_names[i]) if errmsg == "": break field_values = gui.multenterbox(errmsg, field_values, fields=field_names) # Create Service in Metasploit dict = {} dict['workspace'] = field_values[0] dict['host'] = field_values[1] dict['port'] = field_values[2] dict['proto'] = field_values[3] dict['name'] = field_values[4] dict['info'] = field_values[5] dict['state'] = field_values[6] data = json.dumps(dict) post = apitools.post_json(service_url, data) # Fetch new Service in Metasploit new = post.json()['data'] msf_service = getServiceEntity(service['name'], service['info']) msf_service.info = new['info'] msf_service.name = new['name'] msf_service.proto = new['proto'] msf_service.host_id = new['host']['id'] msf_service.id = new['id'] msf_service.workspace_id = new['host']['workspace_id'] msf_service.display = "{port}:{proto}/{name}".format( port=new['port'], proto=new['proto'], name=new['name']) msf_service.state = new['state'] msf_service.created_at = new['created_at'] msf_service.updated_at = new['updated_at'] response += msf_service return response
def do_transform(self, request, response, config): ip_entity = request.entity # Test for properties -------------------------------------------// try: test = ip_entity['id'] if ip_entity['id'] is not None: title = "Confirmation" msg = """This IPv4Address is already bound to a Metasploit Host. \n Do you really want to change the concerned properties ?""" confirm = gui.choicebox(title=title, msg=msg, choices=['Yes', 'No']) if confirm == 'No': return response except KeyError: pass # Select Workspaces & Hosts -------------------------------------// url = config['EffectiveCouscous.local.baseurl'] + 'workspaces' workspaces = apitools.get_json_dict(url, config) title = "Workspace Choice" msg = "Please choose a workspace for Host selection" ws_names = [workspace['name'] for workspace in workspaces] choice = gui.choicebox(title=title, msg=msg, choices=(ws_names)) # Select Hosts url = config['EffectiveCouscous.local.baseurl'] + 'hosts' params = (('workspace', '{0}'.format(choice)), ) hosts = apitools.get_json_dict(url, config, params=params) title = "Host Choice" msg = "Choose a Metasploit Host to associate with this IPv4Address" host_infos = [] host_names = [] for host in hosts: info = '{0} {1}'.format(host['address'], host['name']) host_infos.append(info) host_names.append(host['name']) host_infos.append("Add Host") raw_choice = gui.choicebox(title=title, msg=msg, choices=(host_infos)) host = {} if "Add Host" in raw_choice: host['name'] = "Add Host" else: for h in hosts: if h['address'] in raw_choice: host = h # If existing host ---------------------------------------------// if host['name'] != "Add Host": ip_entity['ipv4-address'] = host['address'] ip_entity.host_id = host['id'] ip_entity.workspace_id = host['workspace_id'] ip_entity.icon_url = network_interface ip_entity.origin_tool = 'Metasploit' response + ip_entity # If New Host --------------------------------------------------// if host['name'] == 'Add Host': url = config['EffectiveCouscous.local.baseurl'] + 'hosts' title = "New Host" msg = """Enter Host properties for creating a Host in Metasploit""" field_names = [ "Address", "MAC", "Host Name", "OS Name", "OS Flavor", 'OS SP', 'OS Language', 'Purpose', 'Info', 'Comments', 'Scope', 'Virtual Host', 'Architecture', 'State' ] field_values = [] field_values = gui.multenterbox(title=title, msg=msg, fields=field_names, values=field_values) while 1: if field_values == None: break errmsg = "" for i in range(len(field_names)): if field_values[i].strip() == "": errmsg += ('"%s" is a required field.\n\n' % field_names[i]) if errmsg == "": break field_values = gui.multenterbox(errmsg, field_values, fields=field_names) # Post Host dict = {} dict['workspace'] = choice dict['host'] = field_values[0] dict['mac'] = field_values[1] dict['name'] = field_values[2] dict['os_name'] = field_values[3] dict['os_flavor'] = field_values[4] dict['os_sp'] = field_values[5] dict['os_lang'] = field_values[6] dict['purpose'] = field_values[7] dict['info'] = field_values[8] dict['comments'] = field_values[9] dict['scope'] = field_values[10] dict['virtual_host'] = field_values[11] dict['arch'] = field_values[12] dict['state'] = field_values[13] data = json.dumps(dict) post = apitools.post_json(url, data, config) # Fetch attributes of new Host host_dict = post.json()['data'] ip_entity['ipv4-address'] = host_dict['address'] ip_entity.host_id = host_dict['id'] ip_entity.workspace_id = host_dict['workspace_id'] ip_entity.icon_url = network_interface ip_entity.origin_tool = 'Metasploit' response + ip_entity return response