如何在Python中使用subprocess准备shell执行环境,pythonsubprocess,准备用python调用m
如何在Python中使用subprocess准备shell执行环境,pythonsubprocess,准备用python调用m
准备用python调用metasploit中的msfvenom命令
然而,metasploit安装时用了rvm,在python中不知道怎么调用
这样做能用,每次都source下rvm。。。
#! /usr/bin/env python # -*- coding: utf-8 -*-"""TO generate random shellcode samples from msfvenomcommand = "msfvenom -p linux/x86/shell/reverse_tcp -e x86/shikata_ga_nai -f raw""""import randomfrom info import *import uuidimport osimport subprocessimport sysos.chdir('/opt/metasploit-framework/')count = int(sys.argv[1])while (count > 0): count -= 1 e = encoders[random.randint(0, len(encoders)-1)] payloads = linux_x86_shellcodes + windows_x86_shellcodes p = payloads[random.randint(0, len(payloads)-1)] command = "./msfvenom -p {0} -e {1} -f raw > /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
编橙之家文章,
相关内容
- Flask 中 url for 不理解是什么意思.甚至不理解其作用,
- flask-sqlalchemy 如何查询关系表中的一个字段?,,class
- 如何在mac上用python批量将word文件转成txt文件,pythontx
- python 字符问题'utf8' codec can't decode byte 0xe6 in position 0,
- peewee postgres ArrayField 和JSONField怎么update数据,peeweepos
- 线上环境部署Django,线上部署django,请问大家是如何在线
- windows下python控制台输出中文乱码问题?,,在做爬虫的
- web2py db.define_table(),,中的format关键字参
- 自己写的Flask mysql操作类出错?,flaskmysql,操作类如下#
- 两个 js 加密函数写成 python 怎么写,jspython,function aes
评论关闭