mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 01:26:42 +03:00
implemented basic smoke testing mechanism
This commit is contained in:
parent
f033943815
commit
092829c189
|
@ -34,21 +34,21 @@ def hideAscii(data):
|
|||
retVal += chr(ord(data[i]) ^ 127)
|
||||
else:
|
||||
retVal += data[i]
|
||||
|
||||
|
||||
return retVal
|
||||
|
||||
def cloak(inputFile):
|
||||
f = open(inputFile, 'rb')
|
||||
data = bz2.compress(f.read())
|
||||
f.close()
|
||||
|
||||
|
||||
return hideAscii(data)
|
||||
|
||||
|
||||
def decloak(inputFile):
|
||||
f = open(inputFile, 'rb')
|
||||
data = bz2.decompress(hideAscii(f.read()))
|
||||
f.close()
|
||||
|
||||
|
||||
return data
|
||||
|
||||
def main():
|
||||
|
@ -71,7 +71,7 @@ def main():
|
|||
if not os.path.isfile(args.inputFile):
|
||||
print 'ERROR: the provided input file \'%s\' is not a regular file' % args.inputFile
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if not args.decrypt:
|
||||
data = cloak(args.inputFile)
|
||||
else:
|
||||
|
@ -82,7 +82,7 @@ def main():
|
|||
args.outputFile = args.inputFile + '_'
|
||||
else:
|
||||
args.outputFile = args.inputFile[:-1]
|
||||
|
||||
|
||||
fpOut = open(args.outputFile, 'wb')
|
||||
sys.stdout = fpOut
|
||||
sys.stdout.write(data)
|
||||
|
|
|
@ -33,6 +33,7 @@ from lib.core.common import getUnicode
|
|||
from lib.core.common import paramToDict
|
||||
from lib.core.common import parseTargetUrl
|
||||
from lib.core.common import readInput
|
||||
from lib.core.common import smokeTest
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
|
@ -93,6 +94,9 @@ def start():
|
|||
if not conf.start:
|
||||
return
|
||||
|
||||
if conf.smokeTest:
|
||||
smokeTest()
|
||||
|
||||
if conf.direct:
|
||||
initTargetEnv()
|
||||
setupTargetEnv()
|
||||
|
|
|
@ -57,6 +57,7 @@ from lib.core.data import queries
|
|||
from lib.core.data import temp
|
||||
from lib.core.convert import urlencode
|
||||
from lib.core.exception import sqlmapFilePathException
|
||||
from lib.core.exception import sqlmapGenericException
|
||||
from lib.core.exception import sqlmapNoneDataException
|
||||
from lib.core.exception import sqlmapMissingDependence
|
||||
from lib.core.exception import sqlmapSyntaxException
|
||||
|
@ -471,7 +472,7 @@ def readInput(message, default=None):
|
|||
|
||||
data = default
|
||||
else:
|
||||
data = raw_input(message.encode(conf.dataEncoding))
|
||||
data = raw_input(message.encode(sys.stdout.encoding))
|
||||
|
||||
if not data:
|
||||
data = default
|
||||
|
@ -1410,3 +1411,18 @@ def longestCommonPrefix(*sequences):
|
|||
|
||||
def commonFinderOnly(initial, sequence):
|
||||
return longestCommonPrefix(*filter(lambda x: x.startswith(initial), sequence))
|
||||
|
||||
def smokeTest():
|
||||
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
|
||||
for file in files:
|
||||
if os.path.splitext(file)[1].lower() == '.py' and file != '__init__.py':
|
||||
path = os.path.join(root, os.path.splitext(file)[0])
|
||||
path = path.replace(paths.SQLMAP_ROOT_PATH, '.')
|
||||
path = path.replace(os.sep, '.').lstrip('.')
|
||||
try:
|
||||
module = __import__(path)
|
||||
except Exception, msg:
|
||||
raise sqlmapGenericException, "smoke test failed at importing module '%s' (%s):\n\n%s" % (path, os.path.join(paths.SQLMAP_ROOT_PATH, file), msg)
|
||||
|
||||
infoMsg = "smoke test passed"
|
||||
logger.info(infoMsg)
|
|
@ -108,7 +108,7 @@ def cmdLineParser():
|
|||
request.add_option("--auth-cred", dest="aCred",
|
||||
help="HTTP authentication credentials "
|
||||
"(name:password)")
|
||||
|
||||
|
||||
request.add_option("--auth-cert", dest="aCert",
|
||||
help="HTTP authentication certificate ("
|
||||
"key_file,cert_file)")
|
||||
|
@ -457,6 +457,9 @@ def cmdLineParser():
|
|||
parser.add_option("--common-prediction", dest="useCommonPrediction", action="store_true",
|
||||
help=SUPPRESS_HELP)
|
||||
|
||||
parser.add_option("--smoke-test", dest="smokeTest", action="store_true",
|
||||
help=SUPPRESS_HELP)
|
||||
|
||||
parser.add_option_group(target)
|
||||
parser.add_option_group(request)
|
||||
parser.add_option_group(injection)
|
||||
|
@ -471,7 +474,7 @@ def cmdLineParser():
|
|||
|
||||
(args, _) = parser.parse_args([utf8decode(arg) for arg in sys.argv])
|
||||
|
||||
if not args.direct and not args.url and not args.list and not args.googleDork and not args.configFile and not args.requestFile and not args.updateAll:
|
||||
if not args.direct and not args.url and not args.list and not args.googleDork and not args.configFile and not args.requestFile and not args.updateAll and not args.smokeTest:
|
||||
errMsg = "missing a mandatory parameter ('-d', '-u', '-l', '-r', '-g', '-c' or '--update'), "
|
||||
errMsg += "-h for help"
|
||||
parser.error(errMsg)
|
||||
|
|
|
@ -23,7 +23,6 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
"""
|
||||
|
||||
import codecs
|
||||
import locale
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
@ -33,6 +32,7 @@ import warnings
|
|||
warnings.filterwarnings(action="ignore", message=".*was already imported", category=UserWarning)
|
||||
|
||||
# NOTE: This breaks SQL shell and OS shell history and TAB functionalities
|
||||
#import locale
|
||||
#sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user