Module: Msf::Payload::Aix

Defined in:
lib/msf/core/payload/aix.rb

Overview

This class is here to implement advanced features for AIX-based payloads. AIX payloads are expected to include this module if they want to support these features.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aixObject (protected)

Returns the value of attribute aix.



185
186
187
# File 'lib/msf/core/payload/aix.rb', line 185

def aix
  @aix
end

#cal_acceptObject (protected)

Returns the value of attribute cal_accept.



188
189
190
# File 'lib/msf/core/payload/aix.rb', line 188

def cal_accept
  @cal_accept
end

#cal_bindObject (protected)

Returns the value of attribute cal_bind.



189
190
191
# File 'lib/msf/core/payload/aix.rb', line 189

def cal_bind
  @cal_bind
end

#cal_closeObject (protected)

Returns the value of attribute cal_close.



192
193
194
# File 'lib/msf/core/payload/aix.rb', line 192

def cal_close
  @cal_close
end

#cal_connectObject (protected)

Returns the value of attribute cal_connect.



191
192
193
# File 'lib/msf/core/payload/aix.rb', line 191

def cal_connect
  @cal_connect
end

#cal_execveObject (protected)

Returns the value of attribute cal_execve.



186
187
188
# File 'lib/msf/core/payload/aix.rb', line 186

def cal_execve
  @cal_execve
end

#cal_getpeernameObject (protected)

Returns the value of attribute cal_getpeername.



187
188
189
# File 'lib/msf/core/payload/aix.rb', line 187

def cal_getpeername
  @cal_getpeername
end

#cal_kfcntlObject (protected)

Returns the value of attribute cal_kfcntl.



193
194
195
# File 'lib/msf/core/payload/aix.rb', line 193

def cal_kfcntl
  @cal_kfcntl
end

#cal_socketObject (protected)

Returns the value of attribute cal_socket.



190
191
192
# File 'lib/msf/core/payload/aix.rb', line 190

def cal_socket
  @cal_socket
end

Instance Method Details

#generate(*args) ⇒ Object

Overload the generate() call to prefix our stubs and detect AIX version



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/msf/core/payload/aix.rb', line 32

def generate(*args)
  @aix = datastore['AIX']

  #if not assoc_exploit.nil?
  #	note = find_note(assoc_exploit.rhost, 'AIX')

  #	if not note.nil?
  #		@aix = note['data']
  #	end
  #end

  if (not @aix)
    raise RuntimeError, 'AIX version is not set!'
  end

  #
  # NOTE:
  #
  # To add a syscall set, add a aix_XXXX_syscalls hash as seen below,
  # and add a line to the versions hash using that version.
  #

  aix_614_syscalls = {
    :__NR_execve      => 7,
    :__NR_getpeername => 211,
    :__NR_accept      => 237,
    :__NR_listen      => 240,
    :__NR_bind        => 242,
    :__NR_socket      => 243,
    :__NR_connect     => 244,
    :__NR_close       => 278,
    :__NR_kfcntl      => 658
  }

  aix_613_syscalls = {
    :__NR_execve      => 7,
    :__NR_getpeername => 205,
    :__NR_accept      => 232,
    :__NR_listen      => 235,
    :__NR_bind        => 237,
    :__NR_socket      => 238,
    :__NR_connect     => 239,
    :__NR_close       => 272,
    :__NR_kfcntl      => 644
  }

  aix_612_syscalls = {
    :__NR_execve      => 7,
    :__NR_getpeername => 205,
    :__NR_accept      => 232,
    :__NR_listen      => 235,
    :__NR_bind        => 237,
    :__NR_socket      => 238,
    :__NR_connect     => 239,
    :__NR_close       => 272,
    :__NR_kfcntl      => 635
  }

  aix_611_syscalls = {
    :__NR_execve      => 7,
    :__NR_getpeername => 202,
    :__NR_accept      => 229,
    :__NR_listen      => 232,
    :__NR_bind        => 234,
    :__NR_socket      => 235,
    :__NR_connect     => 236,
    :__NR_close       => 269,
    :__NR_kfcntl      => 614
  }

  aix_610_syscalls = {
    :__NR_execve      => 6,
    :__NR_getpeername => 203,
    :__NR_accept      => 229,
    :__NR_listen      => 232,
    :__NR_bind        => 234,
    :__NR_socket      => 235,
    :__NR_connect     => 236,
    :__NR_close       => 269,
    :__NR_kfcntl      => 617
  }

  aix_53x_syscalls = {
    :__NR_execve      => 6,
    :__NR_getpeername => 198,
    :__NR_accept      => 214,
    :__NR_listen      => 215,
    :__NR_bind        => 216,
    :__NR_socket      => 217,
    :__NR_connect     => 218,
    :__NR_close       => 245,
    :__NR_kfcntl      => 493
  }

  aix_51_syscalls = {
    :__NR_execve      => 5,
    :__NR_getpeername => 122,
    :__NR_accept      => 138,
    :__NR_listen      => 139,
    :__NR_bind        => 140,
    :__NR_socket      => 141,
    :__NR_connect     => 142,
    :__NR_close       => 160,
    :__NR_kfcntl      => 322
  }

  versions = {
    '6.1.4'  => aix_614_syscalls,
    '6.1.3'  => aix_613_syscalls,
    '6.1.2'  => aix_612_syscalls,
    '6.1.1'  => aix_611_syscalls,
    '6.1.0'  => aix_610_syscalls,
    '5.3.10' => aix_53x_syscalls,
    '5.3.9'  => aix_53x_syscalls,
    '5.3.8'  => aix_53x_syscalls,
    '5.3.7'  => aix_53x_syscalls,
    '5.1'    => aix_51_syscalls
  }

  if (not versions[@aix])
    # Dynamically build the support version array :)
    supported = versions.sort.reverse.map { |k,v| k.to_s }.join(', ')
    raise RuntimeError, "Invalid AIX version: \"#{@aix}\".  Supported versions: #{supported}"
  else
    syscalls = versions[@aix]
  end

  __CAL = 2047
  __NC_execve      = -(__CAL - syscalls[:__NR_execve])
  __NC_getpeername = -(__CAL - syscalls[:__NR_getpeername])
  __NC_accept      = -(__CAL - syscalls[:__NR_accept])
  __NC_listen      = -(__CAL - syscalls[:__NR_listen])
  __NC_bind        = -(__CAL - syscalls[:__NR_bind])
  __NC_socket      = -(__CAL - syscalls[:__NR_socket])
  __NC_connect     = -(__CAL - syscalls[:__NR_connect])
  __NC_close       = -(__CAL - syscalls[:__NR_close])
  __NC_kfcntl      = -(__CAL - syscalls[:__NR_kfcntl])

  cal = "\x38\x5d"
  @cal_execve      = cal + [__NC_execve].pack('n')
  @cal_getpeername = cal + [__NC_getpeername].pack('n')
  @cal_accept      = cal + [__NC_accept].pack('n')
  @cal_listen      = cal + [__NC_listen].pack('n')
  @cal_bind        = cal + [__NC_bind].pack('n')
  @cal_socket      = cal + [__NC_socket].pack('n')
  @cal_connect     = cal + [__NC_connect].pack('n')
  @cal_close       = cal + [__NC_close].pack('n')
  @cal_kfcntl      = cal + [__NC_kfcntl].pack('n')

  return ''
end

#initialize(info = {}) ⇒ Object

This mixin is chained within payloads that target the AIX platform. It provides special prepends, to support things like chroot and setuid and detect AIX version.



17
18
19
20
21
22
23
24
25
26
# File 'lib/msf/core/payload/aix.rb', line 17

def initialize(info = {})
  ret = super(info)

  register_options(
    [
      Msf::OptString.new('AIX', [ true, 'IBM AIX Version', '6.1.4' ]),
    ], Msf::Payload::Aix)

  ret
end