Module: Msf::Post::Architecture

Defined in:
lib/msf/core/post/architecture.rb

Instance Method Summary collapse

Instance Method Details

#get_os_architectureString, Nil

Get the architecture of the target’s operating system.

Returns:

  • (String, Nil)

    Returns a string containing the target OS architecture if known, or Nil if its not known.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/msf/core/post/architecture.rb', line 22

def get_os_architecture
  if session.type == 'meterpreter'
    return sysinfo['Architecture']
  else
    case session.platform
    when 'windows', 'win'
      # Check for 32-bit process on 64-bit arch
      arch = get_env('PROCESSOR_ARCHITEW6432')
      if arch.strip.empty? or arch =~ /PROCESSOR_ARCHITEW6432/
        arch = get_env('PROCESSOR_ARCHITECTURE')
      end
      if arch =~ /AMD64/m
        return ARCH_X64
      elsif arch =~ /86/m
        return ARCH_X86
      elsif arch =~ /ARM64/m
        return ARCH_AARCH64
      else
        print_error('Target is running Windows on an unsupported architecture!')
        return nil
      end
    end
  end
end

#initialize(info = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/msf/core/post/architecture.rb', line 5

def initialize(info = {})
  super(
    update_info(
      info,
      'Compat' => {
        'Meterpreter' => {
          'Commands' => %w[
            stdapi_railgun_api
          ]
        }
      }
    )
  )
end