Skip to content

Commit 4882927

Browse files
author
Brent Cook
committed
Land rapid7#8021, Add new core_native_arch method to Meterpreter
2 parents bbf271f + 031285d commit 4882927

File tree

10 files changed

+33
-8
lines changed

10 files changed

+33
-8
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PATH
1414
metasploit-concern
1515
metasploit-credential
1616
metasploit-model
17-
metasploit-payloads (= 1.2.15)
17+
metasploit-payloads (= 1.2.16)
1818
metasploit_data_models
1919
metasploit_payloads-mettle (= 0.1.7)
2020
msgpack
@@ -169,7 +169,7 @@ GEM
169169
activemodel (~> 4.2.6)
170170
activesupport (~> 4.2.6)
171171
railties (~> 4.2.6)
172-
metasploit-payloads (1.2.15)
172+
metasploit-payloads (1.2.16)
173173
metasploit_data_models (2.0.14)
174174
activerecord (~> 4.2.6)
175175
activesupport (~> 4.2.6)

lib/msf/base/sessions/meterpreter.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,15 @@ def arch
536536
end
537537
end
538538

539+
#
540+
# Get a string representation of the architecture of the process in which the
541+
# current session is running. This defaults to the same value of arch but can
542+
# be overridden by specific meterpreter implementations to add support.
543+
#
544+
def native_arch
545+
arch
546+
end
547+
539548
#
540549
# Generate a binary suffix based on arch
541550
#

lib/msf/base/sessions/meterpreter_python.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def lookup_error(error_code)
108108
unknown_error
109109
end
110110

111+
def native_arch
112+
@native_arch ||= self.core.native_arch
113+
end
114+
111115
def supports_ssl?
112116
false
113117
end

lib/rex/post/meterpreter/client_core.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,18 @@ def machine_id(timeout=nil)
325325
Rex::Text.md5(mid.to_s.downcase.strip)
326326
end
327327

328+
def native_arch(timeout=nil)
329+
# Not all meterpreter implementations support this
330+
request = Packet.create_request('core_native_arch')
331+
332+
args = [ request ]
333+
args << timeout if timeout
334+
335+
response = client.send_request(*args)
336+
337+
response.get_tlv_value(TLV_TYPE_STRING)
338+
end
339+
328340
def transport_remove(opts={})
329341
request = transport_prepare_request('core_transport_remove', opts)
330342

lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def add_function(name, return_type, params, windows_name=nil, calling_conv="stdc
119119
def process_function_call(function, args, client)
120120
raise "#{function.params.length} arguments expected. #{args.length} arguments provided." unless args.length == function.params.length
121121

122-
if client.arch == ARCH_X64
122+
if client.native_arch == ARCH_X64
123123
native = 'Q<'
124124
else
125125
native = 'V'

metasploit-framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Gem::Specification.new do |spec|
6565
# are needed when there's no database
6666
spec.add_runtime_dependency 'metasploit-model'
6767
# Needed for Meterpreter
68-
spec.add_runtime_dependency 'metasploit-payloads', '1.2.15'
68+
spec.add_runtime_dependency 'metasploit-payloads', '1.2.16'
6969
# Needed for the next-generation POSIX Meterpreter
7070
spec.add_runtime_dependency 'metasploit_payloads-mettle', '0.1.7'
7171
# Needed by msfgui and other rpc components

modules/payloads/singles/python/meterpreter_bind_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module MetasploitModule
1414

15-
CachedSize = 53182
15+
CachedSize = 53370
1616

1717
include Msf::Payload::Single
1818
include Msf::Payload::Python

modules/payloads/singles/python/meterpreter_reverse_http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module MetasploitModule
1414

15-
CachedSize = 53142
15+
CachedSize = 53334
1616

1717
include Msf::Payload::Single
1818
include Msf::Payload::Python

modules/payloads/singles/python/meterpreter_reverse_https.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module MetasploitModule
1414

15-
CachedSize = 53146
15+
CachedSize = 53334
1616

1717
include Msf::Payload::Single
1818
include Msf::Payload::Python

modules/payloads/singles/python/meterpreter_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module MetasploitModule
1414

15-
CachedSize = 53098
15+
CachedSize = 53286
1616

1717
include Msf::Payload::Single
1818
include Msf::Payload::Python

0 commit comments

Comments
 (0)