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

Skip to content

Commit 43892cd

Browse files
committed
some updates
1 parent 8b0a132 commit 43892cd

6 files changed

Lines changed: 31 additions & 5 deletions

File tree

lib/controller/checks.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,28 @@ def checkSqlInjection(place, parameter, value, parenthesis):
9696

9797
return None
9898

99+
def heuristicCheckSqlInjection(place, parameter, value):
100+
prefix = ""
101+
postfix = ""
102+
103+
if conf.prefix or conf.postfix:
104+
if conf.prefix:
105+
prefix = conf.prefix
106+
107+
if conf.postfix:
108+
postfix = conf.postfix
109+
110+
payload = "%s%s%s" % (prefix, randomStr(length=10, alphabet=['"', '\'', ')', '(']), postfix)
111+
Request.queryPage(payload, place)
112+
result = kb.lastErrorPage and kb.lastErrorPage[0]==kb.lastRequestUID
113+
infoMsg = "heuristics show that %s parameter '%s' is " % (place, parameter)
114+
if result:
115+
infoMsg += "injectable"
116+
logger.info(infoMsg)
117+
else:
118+
infoMsg += "not injectable"
119+
logger.warning(infoMsg)
120+
99121
def checkDynParam(place, parameter, value):
100122
"""
101123
This function checks if the url parameter is dynamic. If it is

lib/controller/controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from lib.controller.action import action
2626
from lib.controller.checks import checkSqlInjection
27+
from lib.controller.checks import heuristicCheckSqlInjection
2728
from lib.controller.checks import checkDynParam
2829
from lib.controller.checks import checkStability
2930
from lib.controller.checks import checkString
@@ -232,6 +233,7 @@ def start():
232233
kb.testedParams.add(paramKey)
233234

234235
if testSqlInj:
236+
heuristicCheckSqlInjection(place, parameter, value)
235237
for parenthesis in range(0, 4):
236238
logMsg = "testing sql injection on %s " % place
237239
logMsg += "parameter '%s' with " % parameter

lib/core/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def randomInt(length=4):
551551

552552
return int("".join([random.choice(string.digits) for _ in xrange(0, length)]))
553553

554-
def randomStr(length=4, lowercase=False):
554+
def randomStr(length=4, lowercase=False, alphabet=None):
555555
"""
556556
@param length: length of the random string.
557557
@type length: C{int}
@@ -560,7 +560,9 @@ def randomStr(length=4, lowercase=False):
560560
@rtype: C{str}
561561
"""
562562

563-
if lowercase:
563+
if alphabet:
564+
rndStr = "".join([random.choice(alphabet) for _ in xrange(0, length)])
565+
elif lowercase:
564566
rndStr = "".join([random.choice(string.lowercase) for _ in xrange(0, length)])
565567
else:
566568
rndStr = "".join([random.choice(string.letters) for _ in xrange(0, length)])

lib/core/option.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ def __setKnowledgeBaseAttributes():
10241024

10251025
kb.parenthesis = None
10261026
kb.partRun = None
1027-
kb.requestUID = 0
1027+
kb.lastRequestUID = 0
10281028
kb.queryCounter = 0
10291029
kb.resumedQueries = {}
10301030
kb.stackedTest = None

lib/parse/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def startElement(self, name, attrs):
5757
if self.__match:
5858
self.dbms = self.__dbms
5959
self.__match = None
60-
kb.lastErrorPage = (kb.requestUID, self.__page)
60+
kb.lastErrorPage = (kb.lastRequestUID, self.__page)
6161

6262
def htmlParser(page):
6363
"""

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def getPage(**kwargs):
9090
requestHeaders = ""
9191
responseHeaders = ""
9292

93-
kb.requestUID += 1
93+
kb.lastRequestUID += 1
9494

9595
try:
9696
if silent:

0 commit comments

Comments
 (0)