Skip to content

Commit 0407bb7

Browse files
committed
fix: changes based on review comments
1 parent 8098907 commit 0407bb7

File tree

52 files changed

+167
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+167
-167
lines changed

lib/msf/base/sessions/mettle_config.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
module Msf
77
module Sessions
88
module MettleConfig
9-
109
include Msf::Payload::TransportConfig
1110

1211
def initialize(info = {})
@@ -19,15 +18,21 @@ def initialize(info = {})
1918
'Fork a new process if the functionality is available',
2019
default: false
2120
),
22-
OptEnum.new(
23-
'MeterpreterLinuxMinKernel',
24-
[true, 'Linux minimum kernel version for compatibility', '2.6+', ['2.6+', '3.17+']]
25-
)
2621
]
2722
)
23+
unless staged?
24+
register_advanced_options(
25+
[
26+
OptEnum.new(
27+
'PayloadLinuxMinKernel',
28+
[true, 'Linux minimum kernel version for compatibility', '2.6+', ['2.6+', '3.17+']]
29+
)
30+
]
31+
)
32+
end
2833
end
2934

30-
def generate_uri(opts={})
35+
def generate_uri(opts = {})
3136
ds = opts[:datastore] || datastore
3237
uri_req_len = ds['StagerURILength'].to_i
3338

@@ -37,7 +42,7 @@ def generate_uri(opts={})
3742
end
3843

3944
if uri_req_len < 5
40-
raise ArgumentError, "Minimum StagerURILength is 5"
45+
raise ArgumentError, 'Minimum StagerURILength is 5'
4146
end
4247

4348
generate_uri_uuid_mode(:init_connect, uri_req_len, uuid: opts[:uuid])
@@ -80,7 +85,7 @@ def generate_tcp_uri(opts)
8085
target_uri
8186
end
8287

83-
def generate_config(opts={})
88+
def generate_config(opts = {})
8489
ds = opts[:datastore] || datastore
8590

8691
opts[:background] = ds['MeterpreterTryToFork'] ? 1 : 0
@@ -121,7 +126,6 @@ def encode_stage?
121126

122127
false
123128
end
124-
125129
end
126130
end
127131
end

lib/msf/core/payload/linux/aarch64/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/aarch64/elf_loader.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
# Parameters: x0-x7
88
# Syscall offset: x8
99
# Return Address for BL: x30
10-
11-
module Msf::Payload::Linux::Aarch64::MeterpreterLoader
10+
#
11+
module Msf::Payload::Linux::Aarch64::ElfLoader
1212
def in_memory_load(payload)
1313
in_memory_loader = [
14-
# fd = memfd_create(NULL,MFD_CLOEXEC)
14+
# fd = memfd_create(NULL,MFD_CLOEXEC)
1515
0x0a0080d2, # 0x1000: mov x10, #0 0x0a0080d2
1616
0xea0300f9, # 0x1004: str x10, [sp] 0xea0300f9
1717
0xe0030091, # 0x1008: mov x0, sp 0xe0030091

lib/msf/core/payload/linux/armbe/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/armbe/elf_loader.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#
32
# In memory loader used to execute Mettle ELF file.
43
# Compatible with Kernel Linux >= 3.17 (where memfd_create is introduced)
@@ -8,8 +7,8 @@
87
# Parameters: r0-r6
98
# Syscall offset: r7
109
# Return Address: lr/r14
11-
12-
module Msf::Payload::Linux::Armbe::MeterpreterLoader
10+
#
11+
module Msf::Payload::Linux::Armbe::ElfLoader
1312
def in_memory_load(payload)
1413
in_memory_loader = [
1514
# fd = memfd_create(NULL,MFD_CLOEXEC)

lib/msf/core/payload/linux/armle/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/armle/elf_loader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# Parameters: r0-r6
88
# Syscall offset: r7
99
# Return Address: lr/r14
10-
11-
module Msf::Payload::Linux::Armle::MeterpreterLoader
10+
#
11+
module Msf::Payload::Linux::Armle::ElfLoader
1212
def in_memory_load(payload)
1313
in_memory_loader = [
1414
# fd = memfd_create(NULL,MFD_CLOEXEC)

lib/msf/core/payload/linux/mips64/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/mips64/elf_loader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Parameters: a0-a3
1010
# Syscall offset: v0
1111
# Return Address: ra
12-
13-
module Msf::Payload::Linux::Mips64::MeterpreterLoader
12+
#
13+
module Msf::Payload::Linux::Mips64::ElfLoader
1414
def in_memory_load(payload)
1515
size = payload.length
1616
size_h = size >> 16

lib/msf/core/payload/linux/mipsbe/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/mipsbe/elf_loader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Parameters: a0-a3
1010
# Syscall offset: v0
1111
# Return Address: ra
12-
13-
module Msf::Payload::Linux::Mipsbe::MeterpreterLoader
12+
#
13+
module Msf::Payload::Linux::Mipsbe::ElfLoader
1414
def in_memory_load(payload)
1515
size = payload.length
1616
size_h = size >> 16

lib/msf/core/payload/linux/mipsle/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/mipsle/elf_loader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Parameters: a0-a3
1010
# Syscall offset: v0
1111
# Return Address: ra
12-
13-
module Msf::Payload::Linux::Mipsle::MeterpreterLoader
12+
#
13+
module Msf::Payload::Linux::Mipsle::ElfLoader
1414
def in_memory_load(payload)
1515
size = payload.length
1616
size_h = size >> 16

lib/msf/core/payload/linux/ppc/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/ppc/elf_loader.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# Compatible with Kernel Linux >= 3.17 (where memfd_create is introduced)
44
# Author: Martin Sutovsky <martin_sutovsky[at]rapid7.com>
55
# Resource and Credits: https://magisterquis.github.io/2018/03/31/in-memory-only-elf-execution.html
6-
# PPC conventions
6+
# PPC conventions
77
# Syscall Offset: r0
88
# Return value: r3
99
# Return Address: lr
1010
# Stack Pointer: r1
1111
# Parameters: r3-r10
12-
13-
module Msf::Payload::Linux::Ppc::MeterpreterLoader
12+
#
13+
module Msf::Payload::Linux::Ppc::ElfLoader
1414
def in_memory_load(payload)
1515
in_memory_loader = [
1616
# jump to address 0x105c
@@ -53,6 +53,4 @@ def in_memory_load(payload)
5353
].pack('N*')
5454
in_memory_loader
5555
end
56-
5756
end
58-

lib/msf/core/payload/linux/ppc64le/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/ppc64le/elf_loader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Return Address: lr
1010
# Stack Pointer: r1
1111
# Parameters: r3-r10
12-
13-
module Msf::Payload::Linux::Ppc64le::MeterpreterLoader
12+
#
13+
module Msf::Payload::Linux::Ppc64le::ElfLoader
1414
def in_memory_load(payload)
1515
in_memory_loader = [
1616
# jump to address 0x105c

lib/msf/core/payload/linux/ppce500v2/meterpreter_loader.rb renamed to lib/msf/core/payload/linux/ppce500v2/elf_loader.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
# Return Address: lr
1010
# Stack Pointer: r1
1111
# Parameters: r3-r10
12-
13-
module Msf::Payload::Linux::Ppce500v2::MeterpreterLoader
12+
#
13+
module Msf::Payload::Linux::Ppce500v2::ElfLoader
1414
def in_memory_load(payload)
1515
in_memory_loader = [
1616
# jump to address 0x105c
1717
0x4800005c, # 0x1000: b 0x105c 0x4800005c
1818

19-
# move from link register (lr) to r15
19+
# move from link register (lr) to r15
2020
0x7de802a6, # 0x1004: mflr r15 0x7de802a6
2121

2222
# fd = memfd_create(NULL,MFD_CLOEXEC)
@@ -52,5 +52,4 @@ def in_memory_load(payload)
5252
].pack('N*')
5353
in_memory_loader
5454
end
55-
5655
end

0 commit comments

Comments
 (0)