python使用sqlmap API檢測SQL注入


0x00前言:

大家都知道sqlmap是非常強大的sql注入工具,最近發現他有個sqlmap API,上網查了一下。發現這是

sqlmap的微端。(可以叫做sqlmap在線檢測sql注入= =)

0x001准備:

環境:

Ubuntu 16.04

Python3 

Python2

用到的庫:requests,parform,os

0x002正文:


首先我們來啟動sqlmapapi 

sqlmapi -s

出現如下圖就成功了:

sqlmapapi介紹:

http://127.0.0.1:8775/task/new 創建一個新的任務 GET請求

http://127.0.0.1:8775/scan/id + 要請求的值 並設置header頭為(Content-Type:application/json) post請求 (這里的ID就是剛剛new的時候獲取到的)

http://127.0.01:8775/scan/id/status 查看狀態 GET請求

http://127.0.0.1:8775/scan/id/data 查看掃描結果 如果掃描結果返回空則代表無sql注入,如果返回不是空則有sql注入 GET請求

 

http://127.0.0.1:8775/task/delete 刪除一個ID GET請求

http://127.0.0.1:8775/scan/kalii 殺死一個進程 GET請求

http://127.0.0.1:8775/scan/logo 查看掃描日志

http://127.0.0.1:8775/scan/stop 停止掃描

代碼:

import requests
import json
import platform
import os
logo="#sqlmap api制作" \
     "#九世制作"
print(logo)
print('[1]Manually open sqlmapapi')
print('[2]Automatically open sqlmapapi')
while True:
    start=input("Please choose:")
    if start == "1":
        print('[*]You choose to open sqlmapapi manually')
        break
    elif start == "2":
        print('[*]You choose to automatically open sqlmapapi')
        os.system('sqlmapapi.py -s')
        break
    else:
        print('[-]There is no choice')
        continue

while True:
    user=input('Please enter the web site you want to scan:')
    if user==None:
        print('[-]You have nothing to enter')
        continue
    else:
        break

vsersion=platform.uname()
for p in vsersion:
    print('[*]Your operating system type is:{}'.format(p))

print(' ')

def sqlmap(host):
    urlnew="http://127.0.0.1:8775/task/new"
    urlscan="http://127.0.0.1:8775/scan/"
    headers={"user-agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"}
    pd=requests.get(url=urlnew,headers=headers)
    print('[*]New task')
    jsons=pd.json()
    print("[*]id:",jsons['taskid'])
    print("[*]success:",jsons["success"])
    id=jsons['taskid']
    scan=urlscan+id+"/start"
    print("[*]scanurl:",scan)
    data=json.dumps({"url":"{}".format(host)})
    headerss={"Content-Type":"application/json"}
    scans=requests.post(url=scan,headers=headerss,data=data)
    swq=scans.json()
    print('--------SCAN-----------')
    print('[*]scanid:',swq["engineid"])
    print('[*]scansuccess:',swq["success"])
    print('--------STATUS---------')
    status="http://127.0.0.1:8775/scan/{}/status".format(id)
    print(status)
    while True:
        staw=requests.get(url=status,headers=headers)
        if staw.json()['status'] == 'terminated':
            datas=requests.get(url='http://127.0.0.1:8775/scan/{}/data'.format(id))
            dat=datas.json()['data']
            print('[*]data:',dat)
            break
        elif staw.json()['status'] == 'running':
            continue

sqlmap(user.strip())

掃描結果:

插入一曲BGM:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM