def poll_status(options, forced=False): # /api/activities/get/?workspace=duckduckgo.com&modules=SubdomainScanning ws = utils.get_workspace(options=options) module = options.get('CURRENT_MODULE', False) if module: url = options.get( 'REMOTE_API' ) + "/api/activities/get/?workspace={0}&module={1}".format(ws, module) else: url = options.get( 'REMOTE_API') + "/api/activities/get/?workspace={0}".format(ws) headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') if forced: r = send.send_post(url, data=None, headers=headers) else: r = send.send_get(url, data=None, headers=headers) if r and r.json().get('status') == 'Done': return False if not r or r.json().get('status') != 'Done': return True
def login(options): url = options.get('remote_api') + "/auth/api/token/" body = { "username": options.get('credentials')[0], "password": options.get('credentials')[1] } r = send.send_post(url, body, is_json=True) if r.json().get('access'): utils.print_good("Authentication success") jwt = 'Osmedeus ' + r.json().get('access') options['JWT'] = jwt return options utils.print_bad("Authentication failed") return False
def exports_to_file(options): ws = utils.get_workspace(options=options) ts = str(utils.gen_ts()) output = options.get('OUTPUT', '') url = options.get('REMOTE_API') + "/api/exports/csv/" headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') body = { "workspace": ws, 'filename': options.get('WORKSPACE') + f'/{output}_{ts}', } r = send.send_post(url, body, headers=headers, is_json=True) if r and r.json().get('message'): return r.json().get('message') return False
def get_workspace_info(options): url = options.get('remote_api') + "/api/workspace/get/" headers = send.osmedeus_headers headers['Authorization'] = options.get( 'JWT') if options.get('JWT') else options.get('jwt') body = { "workspace": options.get('workspace'), } r = send.send_post(url, body, headers=headers, is_json=True) if r and r.json().get('status') == 200: return r.json() utils.print_bad("Workpsace not found") return False
def clear_activities(options): ws = utils.get_workspace(options=options) module = options.get('CURRENT_MODULE', False) url = options.get('REMOTE_API') + "/api/activities/clear/" body = { "workspace": ws, "module": module, } headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') r = send.send_post(url, body, headers=headers, is_json=True) if r and r.json().get('status') == 200: utils.print_good("Clean old activities for {0}:{1}".format(ws, module)) return True return False
def push_with_file(options, final_output, update_type='partial'): utils.print_good("Update Summaries table from: {0}".format(final_output)) ws = utils.get_workspace(options=options) url = options.get('REMOTE_API') + "/api/summaries/set/" headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') body = { "domains_file": final_output, "domains": [], "workspace": ws, "update_type": update_type } # print(body) r = send.send_post(url, body, headers=headers, is_json=True) # return too soon or 500 status we have something wrong if r and r.json().get('status') == 200: return True return False
def login(options): url = options.get('remote_api') + "/auth/api/token/" body = { "username": options.get('credentials')[0], "password": options.get('credentials')[1] } r = send.send_post(url, body, is_json=True) try: if r.json().get('access'): utils.print_good("Authentication success") jwt = 'Osmedeus ' + r.json().get('access') options['JWT'] = jwt return options except: utils.print_bad("Authentication failed at: " + url) print(''' [!] This might happened by running Osmedeus with sudo but the install process running with normal user You should install the whole Osmedeus and running it with root user. Or whitelist masscan + nmap in sudoers file because it's required sudo permission. ''') return False
def init_workspace(options): url = options.get('remote_api') + "/api/workspace/create/" headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') body = { "raw_target": options.get('raw_target'), 'mode': options.get('mode'), 'modules': options.get('modules', 'None'), 'speed': options.get('speed'), 'forced': options.get('forced'), 'debug': options.get('debug'), } if options.get('workspace', False): body["workspace"] = options.get('workspace') r = send.send_post(url, body, headers=headers, is_json=True) if r: options['workspace'] = r.json().get('workspace') # just print some log if r.json().get('status') == 200: utils.print_good("New workspace created") elif r.json().get('status') == 442: utils.print_info( "Workspaces already exists. Use '-w <new workspace name>' option if you want to create new one" ) arguments = get_workspace_info(options) if arguments: options = {**options, **arguments} # just upper all key final_options = {} for key in options.keys(): final_options[key.upper()] = options.get(key) return final_options utils.print_bad("Fail to create new workspace") return False