Skip to content

Commit 3b2e5e0

Browse files
committed
Add a new core_native_arch method for meterpreter
1 parent 09c9e9b commit 3b2e5e0

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

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

0 commit comments

Comments
 (0)