AWVS 13批量添加任務(wù)

import requests

import json

from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

apikey = '1986ad8c0a5b3df4d7028d5f3c06e936c2429284486f94bf499c8b7fd74d2d221'#API

headers = {'Content-Type': 'application/json',"X-Auth": apikey}

def addTask(url,target):

? ? try:

? ? ? ? url = ''.join((url, '/api/v1/targets/add'))

? ? ? ? data = {"targets":[{"address": target,"description":""}],"groups":[]}

? ? ? ? r = requests.post(url, headers=headers, data=json.dumps(data), timeout=30, verify=False)

? ? ? ? result = json.loads(r.content.decode())

? ? ? ? return result['targets'][0]['target_id']

? ? except Exception as e:

? ? ? ? return e

def scan(url,target,Crawl,user_agent,profile_id):

? ? scanUrl = ''.join((url, '/api/v1/scans'))

? ? target_id = addTask(url,target)

? ? if target_id:

? ? ? ? data = {"target_id": target_id, "profile_id": profile_id, "incremental": False, "schedule": {"disable": False, "start_date": None, "time_sensitive": False}}

? ? ? ? try:

? ? ? ? ? ? configuration(url,target_id,Crawl,user_agent)

? ? ? ? ? ? response = requests.post(scanUrl, data=json.dumps(data), headers=headers, timeout=30, verify=False)

? ? ? ? ? ? result = json.loads(response.content)

? ? ? ? ? ? return result['target_id']

? ? ? ? except Exception as e:

? ? ? ? ? ? print(e)

def configuration(url,target_id,Crawl,user_agent):

? ? configuration_url = ''.join((url,'/api/v1/targets/{0}/configuration'.format(target_id)))

? ? data = {"scan_speed":"fast","login":{"kind":"none"},"ssh_credentials":{"kind":"none"},"sensor": False,"user_agent": user_agent,"case_sensitive":"auto","limit_crawler_scope": True,"excluded_paths":[],"authentication":{"enabled": False},"technologies":[],"custom_headers":[],"custom_cookies":[],"debug":False,"client_certificate_password":"","issue_tracker_id":"","excluded_hours_id":""}

? ? r = requests.patch(url=configuration_url,data=json.dumps(data), headers=headers, timeout=30, verify=False)

def main():

? ? Crawl = False

? ? awvs_url = 'https://192.168.1.36:23443/' #awvs url

? ? with open('url.txt','r',encoding='utf-8') as f:

? ? ? ? targets = f.readlines()

? ? profile_id = "11111111-1111-1111-1111-111111111111"

? ? user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.21" #掃描默認(rèn)UA頭

? ? if Crawl:

? ? ? ? profile_id = "11111111-1111-1111-1111-111111111117"

? ? for target in targets:

? ? ? ? target = target.strip()

? ? ? ? if scan(awvs_url,target,Crawl,user_agent,profile_id):

? ? ? ? ? ? print("{0} 添加成功".format(target))

if __name__ == '__main__':

? ? main()

基于https://www.imzzj.com/2020/05/18/shi-yong-python-gei-awvs13-pi-liang-tian-jia-ren-wu.html修改過來的,去掉了代理。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容