准备用python调用metasploit中的msfvenom命令
然而,metasploit安装时用了rvm,在python中不知道怎么调用
这样做能用,每次都source下rvm。。。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
TO generate random shellcode samples from msfvenom
command = "msfvenom -p linux/x86/shell/reverse_tcp -e x86/shikata_ga_nai -f raw"
"""
import random
from info import *
import uuid
import os
import subprocess
import sys
os.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上看到类似的需求,但是并不能成功调用