mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-23 15:54:24 +03:00
code refactoring
This commit is contained in:
parent
af22679605
commit
01cf1394a4
|
@ -1532,7 +1532,17 @@ def wasLastRequestDBMSError():
|
|||
Returns True if the last web request resulted in a (recognized) DBMS error page
|
||||
"""
|
||||
|
||||
return kb.lastErrorPage and kb.lastErrorPage[0]==kb.lastRequestUID
|
||||
return kb.lastErrorPage and kb.lastErrorPage[0] == kb.lastRequestUID
|
||||
|
||||
def wasLastRequestDelayed():
|
||||
"""
|
||||
Returns True if the last web request resulted in a time-delay
|
||||
"""
|
||||
|
||||
# 99.9999999997440% of all non time-based sql injection
|
||||
# affected durations should be inside +-7*stdev(durations)
|
||||
# (Math reference: http://www.answers.com/topic/standard-deviation)
|
||||
return (kb.lastQueryDuration >= average(kb.responseTimes) + 7 * stdev(kb.responseTimes))
|
||||
|
||||
def extractErrorMessage(page):
|
||||
"""
|
||||
|
|
|
@ -25,6 +25,7 @@ from lib.core.common import getUnicode
|
|||
from lib.core.common import logHTTPTraffic
|
||||
from lib.core.common import readInput
|
||||
from lib.core.common import stdev
|
||||
from lib.core.common import wasLastRequestDelayed
|
||||
from lib.core.convert import urlencode
|
||||
from lib.core.common import urlEncodeCookieValues
|
||||
from lib.core.data import conf
|
||||
|
@ -420,10 +421,7 @@ class Connect:
|
|||
conf.cj.clear()
|
||||
|
||||
if timeBasedCompare:
|
||||
# 99.9999999997440% of all non time-based sql injection
|
||||
# affected durations should be inside +-7*stdev(durations)
|
||||
# (Reference: http://www.answers.com/topic/standard-deviation)
|
||||
return (kb.lastQueryDuration >= average(kb.responseTimes) + 7 * stdev(kb.responseTimes))
|
||||
return wasLastRequestDelayed()
|
||||
else:
|
||||
kb.responseTimes.append(kb.lastQueryDuration)
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@ See the file 'doc/COPYING' for copying permission
|
|||
|
||||
from lib.core.common import randomStr
|
||||
from lib.core.common import readInput
|
||||
from lib.core.common import wasLastRequestDelayed
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.core.exception import sqlmapUnsupportedFeatureException
|
||||
from lib.core.unescaper import unescaper
|
||||
from lib.request import inject
|
||||
from lib.techniques.blind.timebased import timeUse
|
||||
|
||||
class xp_cmdshell:
|
||||
"""
|
||||
|
@ -88,13 +88,11 @@ class xp_cmdshell:
|
|||
inject.goStacked(cmd)
|
||||
|
||||
def __xpCmdshellCheck(self):
|
||||
query = self.xpCmdshellForgeCmd("ping -n %d 127.0.0.1" % (conf.timeSec * 2))
|
||||
duration = timeUse(query)
|
||||
cmd = self.xpCmdshellForgeCmd("ping -n %d 127.0.0.1" % (conf.timeSec * 2))
|
||||
|
||||
if duration >= conf.timeSec:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
inject.goStacked(cmd)
|
||||
|
||||
return wasLastRequestDelayed()
|
||||
|
||||
def xpCmdshellForgeCmd(self, cmd):
|
||||
self.__randStr = randomStr(lowercase=True)
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
$Id$
|
||||
|
||||
Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
|
||||
See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
from lib.core.agent import agent
|
||||
from lib.core.common import calculateDeltaSeconds
|
||||
from lib.core.common import getDelayQuery
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.request import inject
|
||||
from lib.request.connect import Connect as Request
|
||||
|
||||
def timeUse(query):
|
||||
start = time.time()
|
||||
_, _ = inject.goStacked(query)
|
||||
duration = calculateDeltaSeconds(start)
|
||||
|
||||
return duration
|
Loading…
Reference in New Issue
Block a user