这篇文章主要介绍“如何利用sqlmapapi批量检测”,在日常操作中,相信很多人在如何利用sqlmapapi批量检测问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何利用sqlmapapi批量检测”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
获取sqlmapapi接口信息
python.exe sqlmapapi.py -s
开发当前项目过程(利用sqlmapapi接口实现批量url注入安全检测
1 创建新任务记录任务ID @get("/task/new")
2 设置任务ID扫描信息 @post("/option/<taskid>/set")
3 开始扫描对应ID任务 @post("/scan/<taskid>/start")
4 读取扫描状态判断结果 @get("/scan/<taskid>/status")
5 如果结束删除ID并获取结果 @get("/task/<taskid>/delete")
6 扫描结果查看 @get("/scan/<taskid>/data)
import requests import json #创建任务ID task_new_rul='http://127.0.0.1:8775/task/new' resp = requests.get(task_new_rul) print(resp.json()['taskid'])
返回结果获取ID (ID值每次都不同)
url用的本地搭建的sqllabs
#设置任务ID的配置信息(扫描信息) data = { 'url':'http://127.0.0.1/sqlilabs/Less-2/?id=1' } headers={ 'Content-Type':'application/json' } task_set_url = 'http://127.0.0.1:8775/option/'+task_id+'/set' print(task_set_url) task_set_resp=requests.post(task_set_url,data=json.dumps(data),headers=headers) #print(task_set_resp.content.decode('utf-8'))
返回结果:
http://127.0.0.1:8775/option/895795f56c98f534/set
#启动对应ID的扫描任务 task_start_url = 'http://127.0.0.1:8775/scan/'+task_id+'/start' task_start_resp=requests.post(task_set_url,data=json.dumps(data),headers=headers) print(task_start_resp.content.decode('utf-8'))
返回结果为true
#获取对应ID的扫描状态 task_status_url='http://127.0.0.1:8775/scan/'+task_id+'/status' task_status_resp=requests.get(task_status_url) print(task_status_resp.content.decode('utf-8'))
出现的问题,每运行一次ID值都会改变,状态一直都是running
改进代码假如判定条件
1.txt里可以加入批量待检测的url
import requests import json import time def sqlmapapi(url): data = { 'url': url } headers = { 'Content-Type': 'application/json' } task_new_rul = 'http://127.0.0.1:8775/task/new' resp = requests.get(task_new_rul) task_id = resp.json()['taskid'] if 'success' in resp.content.decode('utf-8'): print('sqlmapapi task create success!') task_set_url = 'http://127.0.0.1:8775/option/' + task_id + '/set' task_set_resp = requests.post(task_set_url, data=json.dumps(data), headers=headers) if 'success' in task_set_resp.content.decode('utf-8'): print('sqlmapapi task set success!') task_start_url = 'http://127.0.0.1:8775/scan/' + task_id + '/start' task_start_resp = requests.post(task_start_url, data=json.dumps(data), headers=headers) if 'success' in task_start_resp.content.decode('utf-8'): print('sqlmapapi start success!') while 1: task_status_url = 'http://127.0.0.1:8775/scan/' + task_id + '/status' task_status_resp = requests.get(task_status_url) if 'running' in task_status_resp.content.decode('utf-8'): print('sqlmapapi taskid scan running') pass else: task_data_url='http://127.0.0.1:8775/scan/' + task_id + '/data' task_data_resp= requests.get(task_data_url) print(task_data_resp.content.decode('utf-8')) break time.sleep(3) if __name__ == '__main__': for url in open('1.txt'): url = url.replace('/n','') sqlmapapi(url)
其实还可以更加完善,比如把检测的结果导出到一个文件,这样就可以从网上爬取带参数的地址批量导入sqlmap里去检测
到此,关于“如何利用sqlmapapi批量检测”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!
原创文章,作者:kirin,如若转载,请注明出处:https://blog.ytso.com/230080.html