added switch --check-tor

This commit is contained in:
Miroslav Stampar 2011-10-25 17:37:43 +00:00
parent 24d495368e
commit 86b4a3562f
5 changed files with 29 additions and 2 deletions

View File

@ -1732,6 +1732,19 @@ def __setTorProxySettings():
raise sqlmapConnectionException, errMsg raise sqlmapConnectionException, errMsg
def __checkTor():
infoMsg = "checking Tor connection"
logger.info(infoMsg)
if conf.checkTor:
page, _, _ = Request.getPage(url="https://check.torproject.org/", raise404=False)
if not page or 'Congratulations' not in page:
errMsg = "it seems that your Tor connection is not properly set"
raise sqlmapConnectionException, errMsg
else:
infoMsg = "Tor connection is properly set"
logger.info(infoMsg)
def __basicOptionValidation(): def __basicOptionValidation():
if conf.limitStart is not None and not (isinstance(conf.limitStart, int) and conf.limitStart > 0): if conf.limitStart is not None and not (isinstance(conf.limitStart, int) and conf.limitStart > 0):
errMsg = "value for --start (limitStart) option must be an integer value greater than zero (>0)" errMsg = "value for --start (limitStart) option must be an integer value greater than zero (>0)"
@ -1795,6 +1808,10 @@ def __basicOptionValidation():
errMsg = "switch --tor is incompatible with switch --proxy" errMsg = "switch --tor is incompatible with switch --proxy"
raise sqlmapSyntaxException, errMsg raise sqlmapSyntaxException, errMsg
if conf.checkTor and not conf.tor:
errMsg = "switch --check-tor requires usage of switch --tor"
raise sqlmapSyntaxException, errMsg
if conf.skip and conf.testParameter: if conf.skip and conf.testParameter:
errMsg = "switch --skip is incompatible with switch -p" errMsg = "switch --skip is incompatible with switch -p"
raise sqlmapSyntaxException, errMsg raise sqlmapSyntaxException, errMsg
@ -1881,6 +1898,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
__setGoogleDorking() __setGoogleDorking()
__setBulkMultipleTargets() __setBulkMultipleTargets()
__urllib2Opener() __urllib2Opener()
__checkTor()
__setCrawler() __setCrawler()
__findPageForms() __findPageForms()
__setDBMS() __setDBMS()

View File

@ -167,7 +167,8 @@ optDict = {
"parseErrors": "boolean", "parseErrors": "boolean",
"replicate": "boolean", "replicate": "boolean",
"updateAll": "boolean", "updateAll": "boolean",
"tor": "boolean" "tor": "boolean",
"checkTor": "boolean"
}, },
"Miscellaneous": { "Miscellaneous": {

View File

@ -348,7 +348,7 @@ SQL_SCALAR_REGEX = r"\A(SELECT(?!\s+DISTINCT\(?))?\s*\w*\("
LOCALHOST = "127.0.0.1" LOCALHOST = "127.0.0.1"
# Default ports used in Tor proxy bundles # Default ports used in Tor proxy bundles
DEFAULT_TOR_PORTS = (8118, 8123) DEFAULT_TOR_PORTS = (8123, 8118)
# Percentage below which comparison engine could have problems # Percentage below which comparison engine could have problems
LOW_TEXT_PERCENT = 20 LOW_TEXT_PERCENT = 20

View File

@ -520,6 +520,10 @@ def cmdLineParser():
action="store_true", action="store_true",
help="Use default Tor (Vidalia/Privoxy/Polipo) proxy address") help="Use default Tor (Vidalia/Privoxy/Polipo) proxy address")
general.add_option("--check-tor", dest="checkTor",
action="store_true",
help="Check to see if Tor is used properly")
general.add_option("--update", dest="updateAll", general.add_option("--update", dest="updateAll",
action="store_true", action="store_true",
help="Update sqlmap") help="Update sqlmap")

View File

@ -563,6 +563,10 @@ replicate = False
# Valid: True or False # Valid: True or False
tor = False tor = False
# Check to see if Tor is used properly
# Valid: True or False
checkTor = False
# Update sqlmap. # Update sqlmap.
# Valid: True or False # Valid: True or False
updateAll = False updateAll = False