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
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():
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)"
@ -1795,6 +1808,10 @@ def __basicOptionValidation():
errMsg = "switch --tor is incompatible with switch --proxy"
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:
errMsg = "switch --skip is incompatible with switch -p"
raise sqlmapSyntaxException, errMsg
@ -1881,6 +1898,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
__setGoogleDorking()
__setBulkMultipleTargets()
__urllib2Opener()
__checkTor()
__setCrawler()
__findPageForms()
__setDBMS()

View File

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

View File

@ -348,7 +348,7 @@ SQL_SCALAR_REGEX = r"\A(SELECT(?!\s+DISTINCT\(?))?\s*\w*\("
LOCALHOST = "127.0.0.1"
# 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
LOW_TEXT_PERCENT = 20

View File

@ -520,6 +520,10 @@ def cmdLineParser():
action="store_true",
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",
action="store_true",
help="Update sqlmap")

View File

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