From 2b6ee06de093864dd398e5a62f7024e78f15b9f2 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Thu, 20 Dec 2012 09:30:13 +0000 Subject: [PATCH 1/3] minor bug fix to correctly parse unicode chars --- lib/core/testing.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/core/testing.py b/lib/core/testing.py index 3937c40d5..3bb869568 100644 --- a/lib/core/testing.py +++ b/lib/core/testing.py @@ -191,7 +191,6 @@ def initCase(switches=None): logger.debug("using output directory '%s' for this test case" % paths.SQLMAP_OUTPUT_PATH) - LOGGER_HANDLER.stream = sys.stdout = StringIO.StringIO() cmdLineOptions = cmdLineParser() cmdLineOptions.liveTest = cmdLineOptions.smokeTest = False @@ -210,7 +209,7 @@ def runCase(switches=None, parse=None): initCase(switches) - LOGGER_HANDLER.stream = sys.stdout = StringIO.StringIO() + LOGGER_HANDLER.stream = sys.stdout = tempfile.SpooledTemporaryFile() retVal = True exception = None result = False @@ -240,10 +239,12 @@ def runCase(switches=None, parse=None): ifile.close() for item, console_output in parse: + from lib.core.common import getUnicode + from lib.core.settings import UNICODE_ENCODING if console_output is True: - parse_on = console + parse_on = getUnicode(console, UNICODE_ENCODING) else: - parse_on = content + parse_on = getUnicode(content, UNICODE_ENCODING) if item.startswith("r'") and item.endswith("'"): if not re.search(item[2:-1], parse_on, re.DOTALL): From ac77724970419799163b2a450615bfc17e489d87 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Thu, 20 Dec 2012 09:30:48 +0000 Subject: [PATCH 2/3] attempt to handle standard input from --live-test --- lib/core/testing.py | 4 ++-- lib/takeover/metasploit.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/core/testing.py b/lib/core/testing.py index 3bb869568..63fea1cd4 100644 --- a/lib/core/testing.py +++ b/lib/core/testing.py @@ -18,6 +18,7 @@ from extra.beep.beep import beep from lib.controller.controller import start from lib.core.common import clearConsoleLine from lib.core.common import dataToStdout +from lib.core.common import getUnicode from lib.core.common import randomStr from lib.core.common import readXmlFile from lib.core.data import conf @@ -26,6 +27,7 @@ from lib.core.data import paths from lib.core.log import LOGGER_HANDLER from lib.core.option import init from lib.core.optiondict import optDict +from lib.core.settings import UNICODE_ENCODING from lib.parse.cmdline import cmdLineParser failedItem = None @@ -239,8 +241,6 @@ def runCase(switches=None, parse=None): ifile.close() for item, console_output in parse: - from lib.core.common import getUnicode - from lib.core.settings import UNICODE_ENCODING if console_output is True: parse_on = getUnicode(console, UNICODE_ENCODING) else: diff --git a/lib/takeover/metasploit.py b/lib/takeover/metasploit.py index 4f874ccfc..9302a3635 100644 --- a/lib/takeover/metasploit.py +++ b/lib/takeover/metasploit.py @@ -486,6 +486,9 @@ class Metasploit: else: proc.stdin.write("uname -a ; id\n") + if conf.liveTest: + proc.stdin.write("exit\n") + metSess = re.search("Meterpreter session ([\d]+) opened", out) if metSess: From 1d64742842b1edd116c778d60f1a888c78d77693 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Thu, 20 Dec 2012 09:31:17 +0000 Subject: [PATCH 3/3] added more test cases --- xml/livetests.xml | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/xml/livetests.xml b/xml/livetests.xml index 8903e35ec..73f3fa945 100644 --- a/xml/livetests.xml +++ b/xml/livetests.xml @@ -7,7 +7,7 @@ - + @@ -741,7 +741,7 @@ - + @@ -776,7 +776,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +