Make --live-test Metasploit integration cases work, added more test cases for PostgreSQL and code refactoring (issue #312)

This commit is contained in:
Bernardo Damele
2013-01-14 13:42:50 +00:00
parent 279f6cb9ce
commit 3e2c3851f3
3 changed files with 108 additions and 25 deletions

View File

@@ -444,6 +444,7 @@ class Metasploit:
def _controlMsfCmd(self, proc, func):
stdin_fd = sys.stdin.fileno()
initiated_properly = False
while True:
returncode = proc.poll()
@@ -493,6 +494,14 @@ class Metasploit:
out = recv_some(proc, t=.1, e=0)
blockingWriteToFD(sys.stdout.fileno(), out)
# Dirty hack to allow Metasploit integration to be tested
# in --live-test mode
if initiated_properly and conf.liveTest:
try:
send_all(proc, "exit\n")
except TypeError:
continue
# For --os-pwn and --os-bof
pwnBofCond = self.connectionStr.startswith("reverse")
pwnBofCond &= "Starting the payload handler" in out
@@ -509,6 +518,9 @@ class Metasploit:
else:
send_all(proc, "uname -a ; id\n")
time.sleep(2)
initiated_properly = True
metSess = re.search("Meterpreter session ([\d]+) opened", out)
if metSess: