准备用python调用metasploit中的msfvenom命令然而,metasploit安装时用了rvm,在python中不知道怎么调用这样做能用,每次都source下rvm。。。#!/usr/bin/envpython#-*-coding:utf-8-*-"""TOgeneraterandomshellcodesamplesfrommsfvenomcommand="msfvenom-plinux/x86/shell/reverse_tcp-ex86/shikata_ga_nai-fraw""""importrandomfrominfoimport*importuuidimportosimportsubprocessimportsysos.chdir('/opt/metasploit-framework/')count=int(sys.argv[1])while(count>0):count-=1e=encoders[random.randint(0,len(encoders)-1)]payloads=linux_x86_shellcodes+windows_x86_shellcodesp=payloads[random.randint(0,len(payloads)-1)]command="./msfvenom-p{0}-e{1}-fraw>/var/tmp/data/".format(p,e)+str(uuid.uuid4())subprocess.Popen("source/usr/local/rvm/scripts/rvm;"+command,shell=True,executable='/bin/bash')但感觉很奇怪,有没有能先准备好shell执行环境,然后在执行后面的命令。在stackoverflow上看到类似的需求,但是并不能成功调用http://stackoverflow.com/questions/5087302/running-three-commands-in-the-same-process-with-python
2 回答
Cats萌萌
TA贡献1805条经验 获得超9个赞
command="exportHEHE=1"shell=subprocess.Popen(command,shell=True,executable="/bin/bash",stdin=subprocess.PIPE,stdout=subprocess.PIPE)so,se=shell.communicate("echo$HEHE\n")print"[]",so,sealias也不行。。。
添加回答
举报
0/150
提交
取消