Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86b4a35

Browse files
committed
added switch --check-tor
1 parent 24d4953 commit 86b4a35

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

lib/core/option.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,19 @@ def __setTorProxySettings():
17321732

17331733
raise sqlmapConnectionException, errMsg
17341734

1735+
def __checkTor():
1736+
infoMsg = "checking Tor connection"
1737+
logger.info(infoMsg)
1738+
1739+
if conf.checkTor:
1740+
page, _, _ = Request.getPage(url="https://check.torproject.org/", raise404=False)
1741+
if not page or 'Congratulations' not in page:
1742+
errMsg = "it seems that your Tor connection is not properly set"
1743+
raise sqlmapConnectionException, errMsg
1744+
else:
1745+
infoMsg = "Tor connection is properly set"
1746+
logger.info(infoMsg)
1747+
17351748
def __basicOptionValidation():
17361749
if conf.limitStart is not None and not (isinstance(conf.limitStart, int) and conf.limitStart > 0):
17371750
errMsg = "value for --start (limitStart) option must be an integer value greater than zero (>0)"
@@ -1795,6 +1808,10 @@ def __basicOptionValidation():
17951808
errMsg = "switch --tor is incompatible with switch --proxy"
17961809
raise sqlmapSyntaxException, errMsg
17971810

1811+
if conf.checkTor and not conf.tor:
1812+
errMsg = "switch --check-tor requires usage of switch --tor"
1813+
raise sqlmapSyntaxException, errMsg
1814+
17981815
if conf.skip and conf.testParameter:
17991816
errMsg = "switch --skip is incompatible with switch -p"
18001817
raise sqlmapSyntaxException, errMsg
@@ -1881,6 +1898,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
18811898
__setGoogleDorking()
18821899
__setBulkMultipleTargets()
18831900
__urllib2Opener()
1901+
__checkTor()
18841902
__setCrawler()
18851903
__findPageForms()
18861904
__setDBMS()

lib/core/optiondict.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@
167167
"parseErrors": "boolean",
168168
"replicate": "boolean",
169169
"updateAll": "boolean",
170-
"tor": "boolean"
170+
"tor": "boolean",
171+
"checkTor": "boolean"
171172
},
172173

173174
"Miscellaneous": {

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348
LOCALHOST = "127.0.0.1"
349349

350350
# Default ports used in Tor proxy bundles
351-
DEFAULT_TOR_PORTS = (8118, 8123)
351+
DEFAULT_TOR_PORTS = (8123, 8118)
352352

353353
# Percentage below which comparison engine could have problems
354354
LOW_TEXT_PERCENT = 20

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ def cmdLineParser():
520520
action="store_true",
521521
help="Use default Tor (Vidalia/Privoxy/Polipo) proxy address")
522522

523+
general.add_option("--check-tor", dest="checkTor",
524+
action="store_true",
525+
help="Check to see if Tor is used properly")
526+
523527
general.add_option("--update", dest="updateAll",
524528
action="store_true",
525529
help="Update sqlmap")

sqlmap.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,10 @@ replicate = False
563563
# Valid: True or False
564564
tor = False
565565

566+
# Check to see if Tor is used properly
567+
# Valid: True or False
568+
checkTor = False
569+
566570
# Update sqlmap.
567571
# Valid: True or False
568572
updateAll = False

0 commit comments

Comments
 (0)