Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update aws_escalate.py #16

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions tools/aws-pentest-tools/aws_escalate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,30 @@ def main(args):
access_key_id = args.access_key_id
secret_access_key = args.secret_key
session_token = args.session_token
profile = args.profile

if args.access_key_id is None or args.secret_key is None:
print('IAM keys not passed in as arguments, enter them below:')
access_key_id = input(' Access Key ID: ')
secret_access_key = input(' Secret Access Key: ')
session_token = input(' Session Token (Leave blank if none): ')
if session_token.strip() == '':
session_token = None

if args.profile is None:
if args.access_key_id is None or args.secret_key is None:
print('IAM keys not passed in as arguments, enter them below:')
access_key_id = input(' Access Key ID: ')
secret_access_key = input(' Secret Access Key: ')
session_token = input(' Session Token (Leave blank if none): ')
if session_token.strip() == '':
session_token = None
else:
aws_session_token = boto3.session.Session(profile_name=profile)
# Begin permissions enumeration
current_user = None
users = []
client = boto3.client(
'iam',
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
aws_session_token=session_token
)
if aws_session_token is None:
client = boto3.client(
'iam',
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
aws_session_token=session_token
)
else:
client = aws_session_token.client('iam')
if args.all_users is True:
response = client.list_users()
for user in response['Users']:
Expand Down Expand Up @@ -528,6 +534,7 @@ def parse_document(document, user):
parser.add_argument('--access-key-id', required=False, default=None, help='The AWS access key ID to use for authentication.')
parser.add_argument('--secret-key', required=False, default=None, help='The AWS secret access key to use for authentication.')
parser.add_argument('--session-token', required=False, default=None, help='The AWS session token to use for authentication, if there is one.')
parser.add_argument('--profile', required=False, default=None, help='The AWS profile to use for authentication, if there is one.')

args = parser.parse_args()
main(args)
main(args)