mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 19:13:48 +03:00
Warn user of HTTP error codes in HTTP responses
This commit is contained in:
parent
b4ce8fe361
commit
574880ba73
|
@ -167,26 +167,29 @@ class Connect:
|
||||||
exceptionMsg = "not authorized, try to provide right HTTP "
|
exceptionMsg = "not authorized, try to provide right HTTP "
|
||||||
exceptionMsg += "authentication type and valid credentials"
|
exceptionMsg += "authentication type and valid credentials"
|
||||||
raise sqlmapConnectionException, exceptionMsg
|
raise sqlmapConnectionException, exceptionMsg
|
||||||
|
elif e.code == 404:
|
||||||
|
exceptionMsg = "page not found"
|
||||||
|
raise sqlmapConnectionException, exceptionMsg
|
||||||
else:
|
else:
|
||||||
page = e.read()
|
page = e.read()
|
||||||
code = e.code
|
code = e.code
|
||||||
status = e.msg
|
status = e.msg
|
||||||
responseHeaders = e.info()
|
responseHeaders = e.info()
|
||||||
|
|
||||||
except (urllib2.URLError, socket.error, socket.timeout, httplib.BadStatusLine), _:
|
debugMsg = "got HTTP error code: %d" % code
|
||||||
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
|
except (urllib2.URLError, socket.error, socket.timeout, httplib.BadStatusLine), e:
|
||||||
tbMsg = traceback.format_exc()
|
tbMsg = traceback.format_exc()
|
||||||
|
|
||||||
if "URLError" in tbMsg or "error" in tbMsg:
|
if "URLError" in tbMsg or "error" in tbMsg:
|
||||||
warnMsg = "unable to connect to the target url"
|
warnMsg = "unable to connect to the target url"
|
||||||
|
|
||||||
elif "timeout" in tbMsg:
|
elif "timeout" in tbMsg:
|
||||||
warnMsg = "connection timed out to the target url"
|
warnMsg = "connection timed out to the target url"
|
||||||
|
|
||||||
elif "BadStatusLine" in tbMsg:
|
elif "BadStatusLine" in tbMsg:
|
||||||
warnMsg = "the target url responded with an unknown HTTP "
|
warnMsg = "the target url responded with an unknown HTTP "
|
||||||
warnMsg += "status code, try to force the HTTP User-Agent "
|
warnMsg += "status code, try to force the HTTP User-Agent "
|
||||||
warnMsg += "header with option --user-agent or -a"
|
warnMsg += "header with option --user-agent or -a"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
warnMsg = "unable to connect to the target url"
|
warnMsg = "unable to connect to the target url"
|
||||||
|
|
||||||
|
@ -201,7 +204,6 @@ class Connect:
|
||||||
|
|
||||||
if silent:
|
if silent:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
elif conf.retriesCount < conf.retries:
|
elif conf.retriesCount < conf.retries:
|
||||||
conf.retriesCount += 1
|
conf.retriesCount += 1
|
||||||
|
|
||||||
|
@ -212,7 +214,6 @@ class Connect:
|
||||||
|
|
||||||
socket.setdefaulttimeout(conf.timeout)
|
socket.setdefaulttimeout(conf.timeout)
|
||||||
return Connect.__getPageProxy(**kwargs)
|
return Connect.__getPageProxy(**kwargs)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
socket.setdefaulttimeout(conf.timeout)
|
socket.setdefaulttimeout(conf.timeout)
|
||||||
raise sqlmapConnectionException, warnMsg
|
raise sqlmapConnectionException, warnMsg
|
||||||
|
|
Loading…
Reference in New Issue
Block a user