import requests import json # 设置Mobsf API的URL地址和密钥 base_url='http://127.0.0.1:8000/' api_url = base_url+'api/v1/' api_key = '' # 构建API请求的头信息 headers = {'Authorization': api_key} #curl --url "http://localhost:8000/api/v1/scans?page=1&page_size=10" -H "X-Mobsf-Api-Key:xxxxxxxxx" # 发送API请求,获取Mobsf前100项扫描结果 r = requests.get(api_url + 'scans?page=1&page_size=90', headers=headers) #scan_id = r.json()['content'][0]['FILE_NAME'] jslen=len(r.json()['content']) proxies={'http':'127.0.0.1:8080'} keywords="HQ9" for j in range(jslen): appmd5 = r.json()['content'][j]['MD5'] datas = {'hash': appmd5} url = base_url+"find/" # 参数拼凑,附件上传格式如picurl参数,其他表单参数值拼成tuple格式: proxies = { "http": "127.0.0.1:8080" } headers = { "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryjvmMdroaobco6uyJ" } md5 =appmd5 datas = """------WebKitFormBoundaryjvmMdroaobco6uyJ\r\nContent-Disposition: form-data; name="md5"\r\n\r\n"""+md5+"""\r\n------WebKitFormBoundaryjvmMdroaobco6uyJ\r\nContent-Disposition: form-data; name="q"\r\n\r\n"""+keywords+"""\r\n------WebKitFormBoundaryjvmMdroaobco6uyJ\r\nContent-Disposition: form-data; name="code"\r\n\r\njava\r\n------WebKitFormBoundaryjvmMdroaobco6uyJ\r\nContent-Disposition: form-data; name="search_type"\r\n\r\ncontent\r\n------WebKitFormBoundaryjvmMdroaobco6uyJ\r\nContent-Disposition: form-data; name="api"\r\n\r\ntrue\r\n\r\n------WebKitFormBoundaryjvmMdroaobco6uyJ--""" res = requests.post(url, data=datas, headers=headers) if(res.status_code==500): continue js=json.loads(res.json()) if (len(js['matches'])>=1): print(r.json()['content'][j]['FILE_NAME']+" is matched keywords: "+keywords) # else: # print(r.json()['content'][j]['FILE_NAME']+" is not matched") for i in range(len(js['matches'])): print(" "+js['matches'][i])
自用,大家自行修改
本文作者为MCtech,转载请注明。