python-scan(awvs)

2017-03-27  本文已影响0人  amazing_bing

awvs web接口如下:

awvs接口:
* /api/auth - 认证 
* /api/listLoginSeq - 认证 
* /api/listProfiles - 查看扫描配置 
* /api/listReports - 查看报表 
* /api/listScans - 查看扫描任务 
* /api/listSettings - 扫描配置 
* /api/listTemplates - 
* /api/addScan - 新建扫描(批量、单任务) 
add_api:
scan,scanList
target,targetList
recurse[-1一次,0 每天,9 每周,10 每月]  
date strftime("%m/%d/%Y", gmtime())
time "%s:%s" % (datetime.now().hour, datetime.now().minute+1)
deleteAfterCompletion "False"
"params":{"profile":"Default",
         "loginSeq":"<none>",
         "settings":"Default",
         "scanningmode":"heuristic",
         "excludedhours":"<none>",
         "savetodatabase":"True",
         "savelogs":"False",
         "generatereport":"False",
         "reportformat":"PDF",
         "reporttemplate":"WVSDeveloperReport.rep ",
         "emailaddress":""}
}

* /api/editScan - 编辑扫描任务 
* /api/getScanHistory - 扫描历史纪录 
* /api/clearScanHistory - 删除扫描记录 
* /api/pauseScan - 暂停扫描 
* /api/resumeScan - 恢复扫描 
* /api/stopScan - 停止扫描 
* /api/deleteAllScans - 删除所有扫描 
* /api/deleteScans - 删除单一扫描任务 
* /api/getScanResults - 查看扫描结果 
* /api/deleteScanResults - 删除扫描结果 
* /api/download/+scanid - 下载扫描结果 

直接调用接口增加扫描任务,代码如下:

'''
# coding:utf-8
# Author : Bing
# Date : 27/3/2017
# Email : amazing_bing@outlook.com
# Description :
'''

import httplib,json
from datetime import datetime
from time import gmtime, strftime

class SqlScanTask:
    def __init__(self):
        self.api_url = "127.0.0.1"
        self.api_port = 8183
        self.api_header = {
                            "Content-Type": "application/json; charset=UTF-8",
                            "X-Requested-With": "XMLHttpRequest",
                            "Accept": "application/json, text/javascript, */*; q=0.01",
                            "RequestValidated": "true"
                        }

    def awvs_list_mod(self):
        pass
    
    def awvs_add_mod(self,domain):
        ACUDATA = {"scanType":"scan",
                   "targetList":"",
                   "target":["%s" % domain],
                   "recurse":"-1",
                   "date":strftime("%m/%d/%Y", gmtime()),
                   "dayOfWeek":"1",
                   "dayOfMonth":"1",
                   "time": "%s:%s" % (datetime.now().hour, datetime.now().minute+1),
                   "deleteAfterCompletion":"False",
                   "params":{"profile":"Default",
                             "loginSeq":"<none>",
                             "settings":"Default",
                             "scanningmode":"heuristic",
                             "excludedhours":"<none>",
                             "savetodatabase":"True",
                             "savelogs":"False",
                             "generatereport":"False",
                             "reportformat":"PDF",
                             "reporttemplate":"WVSDeveloperReport.rep ",
                             "emailaddress":""}
                   }

        conn = httplib.HTTPConnection(self.api_url, self.api_port)
        add_data = json.dumps(ACUDATA)
        conn.request("POST", "/api/addScan", add_data , self.api_header)
        resp = conn.getresponse()
        content = resp.read()
        #{"result":"FAIL","errorMessage":"invalid website URL!"}
        #{"result":"OK","data":["6"]}
        status = resp.status
        if status == 200 and "OK" in content :
            return 1
        else:
            return 0

    def awvs_del_mod(self):
        pass




task = SqlScanTask()
result = task.awvs_add_mod("http://www.bau.com")
print result

    

项目地址:https://github.com/Canbing007/awvs_agent

截图:

111.png 222.png
上一篇 下一篇

猜你喜欢

热点阅读