def eval_py(code, paste_multiline=True): attempts = 0 while True: try: output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n') # sometimes the API returns a blank string on first attempt, lets try again # and make sure it is actually supposed to be a blank string. ._. if output == "": output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n') break except http.HTTPError: if attempts > 2: return "Failed to execute code." else: attempts += 1 continue if "Traceback (most recent call last):" in output: status = "Python error: " else: status = "Code executed sucessfully: " if "\n" in output and paste_multiline: return status + web.haste(output) else: return output
def get_beer(): global bar, stock LED(LED.RED).on() try: bar_json = http.get("https://bar.emf.camp/location/Bar.json").raise_for_status().content stock_json = http.get("https://bar.emf.camp/stock.json").raise_for_status().content bar = ujson.loads(bar_json) stock = ujson.loads(stock_json) except: print('oh poop') LED(LED.RED).off() draw_screen()
def getApps(deviceid): """Fetches the list of apps compatible with the given device Note: The US locale is used. This may return apps that aren't available in the region connected to your account. We want to get Dollar prices however. Returns: [{ 'id': 'app id', 'name': 'app name', 'img': 'image url', 'status': '$1.00 / Install / Installed', }, ...] """ data = http.get(constants.baseUrl + '/wifiall.php', headers={ 'User-Agent': constants.cameraUserAgent, }, cookies={ 'deviceid': deviceid, 'localeid': constants.localeUs, }) r = re.compile( '<td class="app-name">(?P<name>.*?)</td>.*?<a href="\./wifidetail\.php\?EID=(?P<id>.*?)&.*?<img src="(?P<img>.*?)".*?<td class="app-status">(?P<status>.*?)</td>', re.DOTALL) apps = [m.groupdict() for m in r.finditer(data)] for app in apps: app['name'] = app['name'].replace('<br />', ' ') return apps
def __request(self, method, url, headers, body, error): """ Launch a request and returns its response :param method: method used ex: POST, GET, DELETE, etc :param url: <IP>:<port>/<path> :param headers: headers used :param body: body in case of POST method :param error: error types :return: response """ headers['X-Auth-Token'] = utils.errorLabel(headers['X-Auth-Token'], error) url = utils.errorUrl(url, error) if error == "GET" or error == "PUT" or error == "POST" or error == "DELETE": method = error if method == "GET": response = http.get(url, headers) elif method == "POST": response = http.post(url, headers, body) elif method == "PUT": response = http.put(url, headers, body) elif method == "DELETE": response = http.delete(url, headers) #utils.printRequest(method,url,headers,body) # show request #utils.printResponse(response) # show response return response
def ip(self): url = 'https://api.threatminer.org/v2/host.php?q=%s&rt=2' % self.artifact[ 'name'] # check for passive DNS results try: status, response = get(url) if status: data = response.json() if data['status_code'] == '200' and 'status_message' == 'Results found.': self.artifact['data']['threatminer'] = { 'passivedns': data['results'] } # check for potential children artifacts if isinstance(self.artifact['data']['threatminer'], dict): for entry in self.artifact['data']['threatminer'][ 'passivedns']: if detect_type(entry['domain']) == 'host': self.artifact['children'].append({ 'name': entry['domain'], 'type': 'host', 'subtype': 'fqdn', 'source': 'threatminer' }) except Exception as err: warning('Caught exception in module (%s)' % str(err))
def get_products(self): url = "%s/%s" % (self.sdc_url, "catalog/product") headers = {'Accept': "application/json"} #headers={'X-Auth-Token': self.token, # 'Accept': "application/json"} response = http.get(url, headers) ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON. if response.status != 200: print 'error to obtain the token' sys.exit(1) else: data = json.loads(response.read()) products_string = data["product"] for product_string in products_string: product = Product(product_string['name']) try: attributes = product['attributes'] var = var + ' atts:' for att in attributes: var = var + '\t' + att['key'] + ":" + att['value'] except: pass try: metadatas = product['metadatas'] var = var + ' metas:' for meta in metadatas: var = var + '\t' + meta['key'] + ":" + meta['value'] except: pass print var
def run(self): url = 'https://www.twitter.com/%s' % self.artifact['name'] try: status, response = get(url, headers=self.headers) if status: soup = BeautifulSoup(response.content, 'lxml') self.artifact['data']['twitter'] = {} self.artifact['data']['twitter']['name'] = soup.find( 'h1').contents[1].text try: self.artifact['data']['twitter']['location'] = soup.find( 'span', class_='ProfileHeaderCard-locationText u-dir' ).contents[1].text except: self.artifact['data']['twitter']['location'] = None self.artifact['data']['twitter']['description'] = soup.find( 'div', class_='ProfileHeaderCard').contents[5].text self.artifact['data']['twitter']['created'] = soup.find( 'div', class_='ProfileHeaderCard-joinDate').contents[3].text except: pass
def __get__(self, url): """ Executes a get request to Nova service :param url: Full URL to GET :return: HTTPlib request """ return http.get(url, self.default_headers)
def __get_environment(self, url): headers = { 'X-Auth-Token': self.token, 'Tenant-Id': self.vdc, 'Accept': "application/json" } return http.get(url, headers)
def __request(self, method, url, headers, body, error): """ Launch a request and returns its response :param method: method used ex: POST, GET, DELETE, etc :param url: <IP>:<port>/<path> :param headers: headers used :param body: body in case of POST method :param error: error types :return: response """ headers['X-Auth-Token'] = utils.errorLabel (headers['X-Auth-Token'], error) url = utils.errorUrl(url, error) if error == "GET" or error == "PUT" or error == "POST" or error == "DELETE": method = error if method == "GET": response = http.get(url, headers) elif method == "POST": response = http.post(url, headers, body) elif method == "PUT": response = http.put(url, headers, body) elif method == "DELETE": response = http.delete(url, headers) #utils.printRequest(method,url,headers,body) # show request #utils.printResponse(response) # show response return response
def top_left_logo(): ugfx.clear(ugfx.html_color(0x000000)) try: logo = http.get("https://i.imgur.com/5HXmXBU.png").raise_for_status().content ugfx.display_image(0, 5, bytearray(logo)) except: pass
def download_avatar(): avatar_url = db.get("avatar_url", "") if avatar_url: if (avatar_url.endswith(".png") or avatar_url.startswith("http")): try: image = http.get(avatar_url).raise_for_status().content ugfx.orientation(90) ugfx.display_image(0, 0, bytearray(image)) #f = open(avatar_file_name, 'w') #f.write(image) #f.close() #ugfx.display_image(0,0,bytearray(image)) except: ugfx.clear(ugfx.html_color(0x000000)) ugfx.orientation(270) ugfx.text(3, 65, "Couldn't download the avatar.", ugfx.RED) return False else: ugfx.clear(ugfx.html_color(0x000000)) ugfx.orientation(270) ugfx.text(3, 65, "Invalid avatar url.", ugfx.RED) return False else: ugfx.clear(ugfx.html_color(0x000000)) ugfx.orientation(270) ugfx.text(3, 65, "No avatar url.", ugfx.RED) return True
def query_claim(headers, *body): """ Performs a Query Claim using the href in post claim Compares the messages returned in Query claim with the messages returned on Post Claim """ test_result_flag = False msg_list = body[0] msg_list = json.loads(msg_list) location = headers["Location"] url = common.functionlib.create_url_from_appender(location) header = common.functionlib.create_marconi_headers() get_msg = http.get(url, header) if get_msg.status_code == 200: query_body = json.loads(get_msg.text) query_msgs = query_body["messages"] test_result_flag = verify_query_msgs(query_msgs, msg_list) if test_result_flag: return test_result_flag else: print "URL" print url print "HEADER" print header print "Messages returned by Query Claim" print querymsgs print "# of Messages returned by Query Claim", len(querymsgs) print "Messages returned by Claim Messages" print msg_list print "# of Messages returned by Claim messages", len(msg_list) assert test_result_flag, "Query Claim Failed"
def get_alias(es_url): response = io.BytesIO() response = http.get(es_url, response) value = response.getvalue().decode('UTF-8') response.close() print("\nList of aliases (" + es_url.split("@")[1].split("/_cat")[0] + "):\n" + value)
def run(self): url = 'http://api.ipstack.com/%s?access_key=%s&hostname=1' % ( self.artifact['name'], self.api_key) try: status, response = get(url, headers=self.headers) if status: results = response.json() self.artifact['data']['geoip'] = results if 'hostname' in results.keys(): if results['hostname'] != self.artifact[ 'name'] and results['hostname'] != '': self.artifact.children.append({ 'name': results['hostname'], 'type': 'host', 'subtype': 'fqdn', 'source': 'ipstack' }) except Exception as err: warning('Caught exception in module (%s)' % str(err))
def downloadSpk(url): """Downloads an spk file Returns: The contents of the spk file """ return http.get(url, auth = (constants.downloadAuthUser, constants.downloadAuthPassword))
def update_metadata_image(sdc_url, token, vdc, product, metadata_image): """It updates the product metadada for image filtered :param glance_url: the sdc url :param token: the valid token :param metadata_image: image name :param product: image name """ print 'update metadata' print product url = sdc_url+ "/catalog/product/"+product print url headers = {'X-Auth-Token': token, 'Tenant-Id': vdc, 'Accept': "application/json", 'Content-Type': 'application/json'} print headers response = http.get(url, headers) print url if response.status != 200: print 'error to get the product ' + str(response.status) return else: payload = '{"key":"image","value":"' + metadata_image + '"}' print payload response = http.put(url + "/metadatas/image", headers, payload) print response if response.status != 200: print 'error to update the product ' + product \ + ' ' + str(response.status)
def get_qiku_balance(params, sandbox=False): method = 'GET' url_path = '/mpay/get_balance_m' sig = hmac_sha1_sig(method, url_path, params, APP_KEY) params['sig'] = sig if sandbox: url = '%s%s?%s' % (QIKU_SANDBOX_VERIFY_RECEIPTS_URL, url_path, urllib.urlencode(params)) else: url = '%s%s?%s' % (QIKU_VERIFY_RECEIPTS_URL, url_path, urllib.urlencode(params)) cookies = '; '.join(['session_id=openid', 'session_type=kp_actoken', 'org_loc=%s' % url_path]) headers = HTTPHeaders() headers.add("Cookie", cookies) # http = HTTPClient() # request = HTTPRequest(url, headers=headers) # response = http.fetch(request, validate_cert=False) # rc, data = response.code, response.body rc, data = http.get(url, headers=headers) if sandbox: path = os.path.join(settings.BASE_ROOT, 'logs', 'pay_%s_%s.txt' % ('qk_balance', time.strftime('%F-%T'))) f = open(path, 'w') f.write(repr({'headers': headers, 'url': url, 'response': data})) f.close() data = json.loads(data) return data['ret'], data
def get_product_info(self, product_name): #headers={'X-Auth-Token': self.token, # 'Accept': "application/json"} headers = {'Accept': "application/json"} #get product release url = "%s/%s/%s" % (self.sdc_url, "catalog/product", product_name ) response = http.get(url, headers) if response.status != 200: print 'error to get the product ' + product_name + ' ' + str(response.status) sys.exit(1) else: data = json.loads(response.read()) print data if data == None: return None product = Product(data['name'], data['description']) try: for att in data['attributes']: attribute = Attribute(att['key'], att['version']); product.add_attribute(attribute) except: pass return product
def fqdn(self): parameters = {'domain': self.artifact['name'], 'apikey': self.api_key} url = 'https://www.virustotal.com/vtapi/v2/domain/report' try: status, response = get(url, params=parameters) if status: data = response.json() if data['response_code'] == 1: self.artifact['data']['virustotal'] = data if len(data['resolutions']) > 0: for host in data['resolutions']: if detect_type(host['ip_address']) == 'host': self.artifact['children'].append({ 'name': host['ip_address'], 'type': 'host', 'subtype': 'ipv4', 'source': 'VirusTotal' }) except: pass
def get_product_info(self, product_name): #headers={'X-Auth-Token': self.token, # 'Accept': "application/json"} headers = { 'X-Auth-Token': self.token, 'Tenant-Id': self.vdc, 'Accept': "application/json" } #get product release url = "%s/%s/%s" % (self.sdc_url, "catalog/product", product_name) response = http.get(url, headers) if response.status != 200: print 'error to get the product ' + product_name + ' ' + str( response.status) sys.exit(1) else: data = json.loads(response.read()) print data if data == None: return None product = Product(data['name'], data['description']) try: for att in data['attributes']: attribute = Attribute(att['key'], att['version']) product.add_attribute(attribute) except: pass return product
def email(self): url = 'http://pgp.mit.edu/pks/lookup?op=index&search=%s' % self.artifact[ 'name'] try: status, response = get(url, headers=self.headers) if status: if 'No results found' in response.text: pass else: data = BeautifulSoup(response.text) hrefs = data.fetch('a') for href in hrefs: content = href.contents if self.artifact['name'] in content[0]: try: name = content[0].split('<')[0] if isinstance(self.artifact['data']['pgp'], list): self.artifact['data']['pgp'].append(name) else: self.artifact['data']['pgp'] = [] self.artifact['data']['pgp'].append(name) except IndexError: pass except: pass
def torrents(plugin=None): conf = config.config(plugin) try: return http.get(url = 'http://127.0.0.1:' + str(conf['port']) + '/torrents', params = {}) except HttpError: xbmcgui.Dialog().ok('DelugeStream', *xbmcaddon.Addon('script.module.delugestream').getLocalizedString(30050).split('|')) return []
def run(self): url = 'https://api.github.com/users/%s' % self.artifact['name'] headers = { 'User-Agent': 'OSINT Omnibus (https://github.com/InQuest/Omnibus)' } try: status, response = get(url, headers=headers) if status: self.artifact.data['github'] = response.json() if 'email' in self.artifact.data['github'].keys(): if self.artifact.data['github']['email']: self.artifact['children'].append({ 'name': self.artifact.data['github']['email'], 'type': 'email', 'subtype': None, 'source': 'github' }) except Exception as err: warning('Caught exception in module (%s)' % str(err))
def fqdn(self): url = 'http://pgp.mit.edu/pks/lookup?op=index&search=%s' % self.artifact[ 'name'] try: status, response = get(url, headers=self.headers) if status: if 'No results found' in response.text: pass else: data = BeautifulSoup(response.text) items = data.fetch('a') for item in items: matches = re.findall(re_email, item) for m in matches: if isinstance(self.artifact['data']['pgp'], list): self.artifact['data']['pgp'].append(m) else: self.artifact['data']['pgp'] = [] self.artifact['data']['pgp'].append(m) self.artifact['children'].append({ 'name': m, 'type': 'email', 'source': 'PGP', 'subtype': None }) except: pass
def delete_claimed_msgs(*claim_response): """ Deletes claimed messages. Verifies that the deletes were successful by doing a GET on the deleted msg """ test_result_flag = False urllist = create_urllist_fromhref(*claim_response) header = common.functionlib.create_marconi_headers() for url in urllist: delete_response = http.delete(url, header) if delete_response.status_code == 204: print url get_deleted = http.get(url, header) if get_deleted.status_code == 404: test_result_flag = True else: print "GET deleted message: {}".format(url) print get_deleted.status_code print get_deleted.headers print get_deleted.text else: print "DELETE message with claim ID: {}".format(url) print delete_response.status_code print delete_response.headers print delete_response.text if not test_result_flag: assert test_result_flag, "DELETE message with claim ID failed"
def _auth(self, refresh=False): """ api access auth """ if len(self._apiKey) == 32 or self._isCloudUser == True: self._isCloudUser = True return #未过期 if not refresh: tm = self._authObj.get('time', 0) + int( self._authObj.get('expire_in', 0)) - 30 if tm > int(time.time()): return self._authObj obj = json.loads( http.get(self.__accessTokenUrl, params={ 'grant_type': 'client_credentials', 'client_id': self._apiKey, 'client_secret': self._secretKey, })) self._isCloudUser = not self._isPermission(obj) return obj
def get(name): query_url = base_url + "&q=" + urllib.quote(name.encode("utf-8")) print query_url r = http.get(query_url) json_r = json.loads(r.content) if "items" in json_r: try: item = json_r["items"][0] return_item = dict() if "title" in item["volumeInfo"]: return_item["title"] = item["volumeInfo"]["title"] if "authors" in item["volumeInfo"]: return_item["authors"] = item["volumeInfo"]["authors"] if "description" in item["volumeInfo"]: return_item["description"] = item["volumeInfo"]["description"][:140] + " [...]" # if 'description' in item['volumeInfo']: return_item['description'] = item['volumeInfo']['subtitle'] if "imageLinks" in item["volumeInfo"]: return_item["images"] = item["volumeInfo"]["imageLinks"] if "infoLink" in item["volumeInfo"]: return_item["infoLink"] = item["volumeInfo"]["infoLink"] return return_item except KeyError: pass else: print ("no data found")
def run(self): url = 'http://urlvoid.com/scan/%s/' % self.artifact['name'] try: status, response = get(url, headers=self.headers) if status: data = BeautifulSoup(response.text) if data.findAll('div', attrs={'class': 'bs-callout bs-callout-info'}): pass elif data.findAll('div', attrs={ 'class': 'bs-callout bs-callout-warning' }): self.artifact['data']['urlvoid'] = {} for each in data.findAll('img', alt='Alert'): site = each.parent.parent.td.text.lstrip() url = each.parent.a['href'] self.artifact['data']['urlvoid'][site] = url except: pass
def get_unauthorized_request_token(self): oauth_request = oauth.OAuthRequest.from_consumer_and_token(self.consumer, http_url = self.request_token_url) oauth_request.sign_request(self.signature_method, self.consumer, None) url = oauth_request.to_url() response = get(url) token = oauth.OAuthToken.from_string(response) return token
def getApps(deviceid): """Fetches the list of apps compatible with the given device Note: The US locale is used. This may return apps that aren't available in the region connected to your account. We want to get Dollar prices however. Returns: [{ 'id': 'app id', 'name': 'app name', 'img': 'image url', 'status': '$1.00 / Install / Installed', }, ...] """ data = http.get(constants.baseUrl + '/wifiall.php', headers = { 'User-Agent': constants.cameraUserAgent, }, cookies = { 'deviceid': deviceid, 'localeid': constants.localeUs, }) r = re.compile('<td class="app-name">(?P<name>.*?)</td>.*?<a href="\./wifidetail\.php\?EID=(?P<id>.*?)&.*?<img src="(?P<img>.*?)".*?<td class="app-status">(?P<status>.*?)</td>', re.DOTALL) apps = [m.groupdict() for m in r.finditer(data)] for app in apps: app['name'] = app['name'].replace('<br />', ' ') return apps
def pay(login_type, params, is_sandbox=False): """ 扣除游戏币接口, 微信登录态和手Q登录态使用的支付接口相同,支付ID相同; 服务端使用的appid和appkey都使用手Qappid和appkey :param login_type: 环境 1: 手机QQ 2: 微信 :param params: :param is_sandbox: 是否沙箱 """ basic_env = mapping['1'] env = mapping[login_type] config = PLATFORM_SETTINGS.get(env) if not config: return False basic_config = PLATFORM_SETTINGS.get(basic_env) if env == 'wechat': # 微信 session_type = 'wc_actoken', session_id = 'hy_gameid' else: # 手机QQ session_type = 'kp_actoken', session_id = 'openid' cookie = { 'org_loc': urllib.quote(config['pay']), 'session_id': session_id, 'session_type': session_type, # 'appip': basic_config['app_id'] } headers = { 'Cookie': "; ".join('%s=%s' % (k, v) for k, v in cookie.items()), } app_key = get_platform_app_key(basic_config, is_sandbox) app_key = '%s&' % app_key params['appid'] = basic_config['app_id'] params['ts'] = int(time.time()) params['sig'] = hmac_sha1_sig('GET', config['pay'], params, app_key) host = get_host(is_sandbox) url = '%s%s?%s' % (host, config['pay'], urllib.urlencode(params)) http_code, content = http.get(url, headers=headers, timeout=10) if http_code != 200: return False obj = json.loads(content) if obj['ret'] != 0: return False obj['game_platform'] = config['name'] return obj
def getPluginInstallText(): """Fetches the English help text for installing the PMCA Downloader plugin""" data = json.loads(http.get(constants.baseUrl + '/dialog.php?case=installingPlugin', cookies = { 'localeid': constants.localeUs, })) contents = data['installingPlugin']['contents'] r = re.compile('<div id="notinstallpopup".*?>(.*?)</div>', re.DOTALL) return r.search(contents).group(1)
def __get_product_sdc(self, url): """ Get product from SDC """ headers = { 'X-Auth-Token': self.token, 'Tenant-Id': self.vdc, 'Content-Type': "application/xml" } return http.get(url, headers)
def request_access_token(self, code): # May need a different redirect_uri here? token_path = "https://graph.facebook.com/oauth/access_token?client_id=" + self.client_id + \ "&redirect_uri=" + self.redirect_uri + "&client_secret=" + self.client_secret + \ "&code=" + code response = http.get(token_path) print response.content return response.content
def pastes(self): url = 'https://haveibeenpwned.com/api/v2/pasteaccount/%s' % self.artifact['name'] try: status, response = get(url, headers=self.headers) if status: self.artifact['data']['hibp']['pastes'] = response.json() except: pass
def run(self): url = 'https://blockchain.info/rawaddr/%s' % self.artifact['name'] try: status, response = get(url, headers=self.headers) if status: self.artifact['data']['blockchain'] = response.json() except: pass
def run(self): url = 'https://blockchain.info/rawaddr/%s' % self.artifact['name'] try: status, response = get(url, headers=self.headers) if status: self.artifact['data']['blockchain'] = response.json() except Exception as err: warning('Caught exception in module (%s)' % str(err))
def run(self): url = 'https://censys.io/api/v1/view/ipv4/%s' % self.artifact['name'] try: status, response = get(url, auth=(self.api_key['token'], self.api_key['secret']), headers=self.headers) if status: self.artifact['data']['censys'] = response.json() except Exception as err: warning('Caught exception in module (%s)' % str(err))
def downloadSpk(url): """Downloads an spk file Returns: The contents of the spk file """ return http.get(url, auth=(constants.downloadAuthUser, constants.downloadAuthPassword))
def get_strip(): global strip LED(LED.RED).on() try: strip_json = http.get("https://xkcd.com/info.0.json").raise_for_status().content strip = ujson.loads(strip_json) except: print('couldn't fetch strip json') LED(LED.RED).off() LED(LED.GREEN).on() try: strip_img = http.get(strip['img']).raise_for_status().content ugfx.display_image(0,0,bytearray(strip_img)) except: print('couldn't fetch strip image') LED(LED.GREEN).off()
def hash(self): url = 'https://otx.alienvault.com:443/api/v1/indicators/file/%s/' % self.artifact['name'] try: status, response = get(url) if status: self.artifact['data']['otx'] = response.json() except: pass
def run(self): url = 'http://ipinfo.io/%s/json' % self.artifact['name'] try: status, response = get(url, auth=(self.api_key['token'], self.api_key['secret']), headers=self.headers) if status: self.artifact['data']['ipinfo'] = response.json() except: pass
def ip(self): url = 'https://api.shodan.io/shodan/host/%s?key=%s' % (self.artifact['name'], self.api_key) try: status, response = get(url, headers=self.headers) if status: self.artifact['data']['shodan'] = response.json() except: pass
def run(self): url = 'https://censys.io/api/v1/view/ipv4/%s' % self.artifact['name'] try: status, response = get(url, auth=(self.api_key['token'], self.api_key['secret']), headers=self.headers) if status: self.artifact['data']['censys'] = response.json() except: pass
def fqdn(self): url = 'https://api.shodan.io/shodan/host/search?key=%s&query=hostname:%s&facets={facets}' % (self.api_key, self.artifact['name']) try: status, response = get(url, headers=self.headers) if status: self.artifact['data']['shodan'] = response.json() except: pass
def get_access_token_and_secret(self, pin): oauth_request = oauth.OAuthRequest.from_consumer_and_token(self.consumer, http_url = self.access_token_url, verifier = pin, token = self.request_token) oauth_request.sign_request(self.signature_method, self.consumer, self.request_token) url = oauth_request.to_url() response = get(url) self.access_token = oauth.OAuthToken.from_string(response) # create both .key and .secret attributes return self.access_token.key, self.access_token.secret
def load_decryption_key(cls, event_id): """ Load master decryption key. @param event_id: current event id. @type event_id: C{int}. """ response = http.get('http://{0}/reg/getkey/{1}.asp' .format(http.F1_LIVE_SERVER, event_id.zfill(5)), params={'auth': cls.user_token}) cls.key = int(response.get_content(), 16)
def get_access_token_and_secret(self, verifier): oauth_request = oauth.OAuthRequest.from_consumer_and_token(oauth_consumer=self.consumer, token = self.request_token, callback="oob", verifier = str(verifier), http_url = self.access_token_url) oauth_request.sign_request(self.signature_method, self.consumer, self.request_token) url = oauth_request.to_url() response = get(url) access_token = oauth.OAuthToken.from_string(response) return access_token.key, access_token.secret
def run(self): url = 'https://hacked-emails.com/api?q=%s' % self.artifact['name'] headers = {'User-Agent': 'OSINT Omnibus (https://github.com/InQuest/Omnibus)'} try: status, response = get(url, headers=headers) if status: results = response.json() self.artifact['data']['hackedemails'] = results except: pass
def get(self, path, tail=-1, last=-1, since=-1): if (tail > -1): option = "?tail=" + str(tail) elif (last > -1): option = "?last=" + str(last) elif (since > -1): option = "?since=" + str(since) else: option = "" [res, data] = http.get(self._host, self.path_string(path)+option) print "HTTP Response:", res.status, res.reason return json.loads(data)
def run(self): url = 'https://keybase.io/_/api/1.0/user/lookup.json?usernames=%s' % self.artifact['name'] try: status, response = get(url, auth=(self.api_key['token'], self.api_key['secret']), headers=self.headers) if status: data = response.json() if data['them'][0] is not None: self.artifact['data']['keybase'] = data['them'][0] except: pass
def th01_reference_to_map_generator(references): """Generator that fetches the th01 wafermaps for a list containing the name and reference >>> [(name, wmap[:4]) for name, wmap in th01_reference_to_map_generator([('test', '716c6b31cc6f3be514269de58c4097da89abdcdc')])] [('test', 'WMAP')]""" for name,ref in references: url = WMDS_WEBSERVICE + ref logger.debug('Getting %s' % url) r = requests.get(url) if r.status_code > 300: raise BaseException("Wafermap with key %s was not found in the datastore" % ref) yield (name, r.text)
def pull(server, secret, name): """ Pull a blueprint from the secret and name on the configured server. """ r = http.get('/{0}/{1}'.format(secret, name), server=server) if 200 == r.status: b = Blueprint.load(r, name) for filename in b.sources.itervalues(): logging.info('fetching source tarballs - this may take a while') r = http.get('/{0}/{1}/{2}'.format(secret, name, filename), server=server) if 200 == r.status: try: f = open(filename, 'w') f.write(r.read()) except OSError: logging.error('could not open {0}'.format(filename)) return None finally: f.close() elif 404 == r.status: logging.error('{0} not found'.format(filename)) return None elif 502 == r.status: logging.error('upstream storage service failed') return None else: logging.error('unexpected {0} fetching tarball'. format(r.status)) return None return b elif 404 == r.status: logging.error('blueprint not found') elif 502 == r.status: logging.error('upstream storage service failed') else: logging.error('unexpected {0} fetching blueprint'.format(r.status)) return None