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 get_custom_report(options, grep_string='slack', module=None): # ws = utils.get_workspace(options=options) if not module and module is not False: module = options.get('CURRENT_MODULE', False) if module: url = options.get( 'REMOTE_API') + "/api/reports/raw/?module={0}".format(module) else: url = options.get('REMOTE_API') + "/api/reports/raw/" headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') r = send.send_get(url, data=None, headers=headers) if not r: return False reports = utils.resolve_commands(options, r.json().get('reports')) final_reports = [] if grep_string: for item in reports: if grep_string in item.get('note').lower(): final_reports.append(item.get('report_path')) else: final_reports = reports if len(final_reports) == 1: return final_reports[0] return final_reports
def list_workspaces(options): url = options.get('REMOTE_API') + "/api/workspaces/" headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') r = send.send_get(url, data=None, headers=headers) if r and r.json().get('workspaces'): return r.json().get('workspaces') return False
def get_cmd(options): mode = options.get('MODE', 'general') url = options.get( 'REMOTE_API') + '/api/commands/get/?module={0}&mode={1}'.format( options.get('CURRENT_MODULE'), mode) headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') r = send.send_get(url, data=None, headers=headers) if r: return r.json().get('commands') else: return False
def get_summary(options, sum_type='full'): ws = utils.get_workspace(options=options) url = options.get('REMOTE_API') + \ "/api/summaries/get/?workspace={0}".format(ws) headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') r = send.send_get(url, None, headers=headers, is_json=True) # return too soon or 500 status we have something wrong if r and r.json().get('summaries'): return r.json().get('summaries') return False
def full_reports(options, grouped=True): ws = utils.get_workspace(options=options) url = options.get('REMOTE_API') + \ "/api/reports/real/?workspace={0}&grouped=true".format(ws) headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') r = send.send_get(url, None, headers=headers, is_json=True) # return too soon or 500 status we have something wrong if r and r.json().get('reports'): return r.json().get('reports') return False