├── demo.png ├── awvs.txt ├── README.md └── AwvsBatchImport.py /demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BetterDefender/AwvsBatchImport/HEAD/demo.png -------------------------------------------------------------------------------- /awvs.txt: -------------------------------------------------------------------------------- 1 | http://www.example.com 2 | http://www.example.com 3 | http://www.example.com 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AwvsBatchImport 2 | AwvsBatchImport is used to help AWVS12 && AWVS13 scanner users import multiple targets and start scanning more quickly. 3 | 4 | ## How it works 5 | image 6 | 7 | ## Install 8 | ``` 9 | git clone https://github.com/BetterDefender/AwvsBatchImport.git 10 | ``` 11 | 12 | ## Usage 13 | Please modify the `URL` and `API` values in the `AwvsBatchImport.py` file when using it. 14 | image 15 | 16 | 17 | ``` 18 | python3 AwvsBatchImport.py 19 | ``` 20 | 21 | Default file:`awvs.txt` 22 | ``` 23 | http://www.example.com 24 | http://www.example.com 25 | http://www.example.com 26 | ``` 27 | 28 | 29 | -------------------------------------------------------------------------------- /AwvsBatchImport.py: -------------------------------------------------------------------------------- 1 | import json 2 | import queue 3 | import requests 4 | 5 | requests.packages.urllib3.disable_warnings() 6 | 7 | 8 | def run(): 9 | print(' ______ ____ __ __ ') 10 | print('/\ _ \ /\ _`\ /\ \__ /\ \ ') 11 | print('\ \ \L\ \ __ __ __ __ __ ____ \ \ \L\ \ __ \ \ ,_\ ___\ \ \___ ') 12 | print(" \ \ __ \/\ \/\ \/\ \/\ \/\ \ /',__\ \ \ _ <' /'__`\ \ \ \/ /'___\ \ _ `\ ") 13 | print(" \ \ \/\ \ \ \_/ \_/ \ \ \_/ |/\__, `\ \ \ \L\ \/\ \L\.\_\ \ \_/\ \__/\ \ \ \ \ ") 14 | print(" \ \_\ \_\ \___x___/'\ \___/ \/\____/ \ \____/\ \__/.\_\\ \__\ \____\\ \_\ \_\ ") 15 | print(' \/_/\/_/\/__//__/ \/__/ \/___/ \/___/ \/__/\/_/ \/__/\/____/ \/_/\/_/') 16 | print(' ______ __ ') 17 | print(' /\__ _\ /\ \__ ') 18 | print(' \/_/\ \/ ___ ___ _____ ___ _ __\ \ ,_\ ') 19 | print(" \ \ \ /' __` __`\/\ '__`\ / __`\/\`'__\ \ \/ ") 20 | print(' \_\ \__/\ \/\ \/\ \ \ \L\ \/\ \L\ \ \ \/ \ \ \_ ') 21 | print(' /\_____\ \_\ \_\ \_\ \ ,__/\ \____/\ \_\ \ \__\ ') 22 | print(' \/_____/\/_/\/_/\/_/\ \ \/ \/___/ \/_/ \/__/') 23 | print(' \ \_\ ') 24 | print(' \/_/ ') 25 | print("\n") 26 | print(' Github:https://github.com/BetterDefender/AwvsBatchImport.git') 27 | print(' Author:BetterDefender') 28 | print(' Version:1.1') 29 | 30 | class AwvsScan(object): 31 | def __init__(self): 32 | self.scanner = 'https://172.16.0.13:3443' # Modify URL 33 | self.api = '1986ad8c0a5b3df4d7028d5f3c06e936c18af8a8998154d1c8bb4d9c40573f477' # Modify API 34 | self.ScanMode = '11111111-1111-1111-1111-111111111111' # ScanMode 35 | self.headers = {'X-Auth': self.api, 'content-type': 'application/json'} 36 | self.targets_id = queue.Queue() 37 | self.scan_id = queue.Queue() 38 | self.site = queue.Queue() 39 | 40 | def main(self): 41 | print("") 42 | print("|"+'=' * 35+"|") 43 | print("|Please select the function to use:|") 44 | print("""| 1.Add scan task using awvs.txt |\n| 2.Delete all tasks |""") 45 | print("|"+'=' * 35+"|") 46 | choice = input(">") 47 | if choice == '1': 48 | self.scans() 49 | if choice == '2': 50 | self.del_targets() 51 | self.main() 52 | 53 | def openfile(self): 54 | with open('awvs.txt') as cent: 55 | for web_site in cent: 56 | web_site = web_site.strip('\n\r') 57 | self.site.put(web_site) 58 | 59 | def targets(self): 60 | self.openfile() 61 | while not self.site.empty(): 62 | website = self.site.get() 63 | try: 64 | data = {'address': website, 65 | 'description': 'awvs-auto', 66 | 'criticality': '10'} 67 | response = requests.post(self.scanner + '/api/v1/targets', data=json.dumps(data), headers=self.headers, 68 | verify=False) 69 | cent = json.loads(response.content) 70 | target_id = cent['target_id'] 71 | self.targets_id.put(target_id) 72 | except Exception as e: 73 | print('Error:Target is not website! {}'.format(website)) 74 | print("Please check if the URL in awvs.txt is correct!") 75 | exit() 76 | 77 | def scans(self): 78 | self.targets() 79 | while not self.targets_id.empty(): 80 | data = {'target_id': self.targets_id.get(), 81 | 'profile_id': self.ScanMode, 82 | 'schedule': {'disable': False, 'start_date': None, 'time_sensitive': False}} 83 | 84 | response = requests.post(self.scanner + '/api/v1/scans', data=json.dumps(data), headers=self.headers, 85 | allow_redirects=False, verify=False) 86 | if response.status_code == 201: 87 | cent = response.headers['Location'].replace('/api/v1/scans/', '') 88 | print(cent) 89 | 90 | def get_targets_id(self): 91 | response = requests.get(self.scanner + "/api/v1/targets", headers=self.headers, verify=False) 92 | content = json.loads(response.content) 93 | for cent in content['targets']: 94 | self.targets_id.put([cent['address'], cent['target_id']]) 95 | 96 | def del_targets(self): 97 | while True: 98 | self.get_targets_id() 99 | if self.targets_id.qsize() == 0: 100 | break 101 | else: 102 | while not self.targets_id.empty(): 103 | targets_info = self.targets_id.get() 104 | response = requests.delete(self.scanner + "/api/v1/targets/" + targets_info[1], 105 | headers=self.headers, verify=False) 106 | if response.status_code == 204: 107 | print('delete targets {}'.format(targets_info[0])) 108 | 109 | 110 | if __name__ == '__main__': 111 | run() 112 | Scan = AwvsScan() 113 | Scan.main() 114 | --------------------------------------------------------------------------------