Add tool to find users for compromised keys on aws
This commit is contained in:
parent
0938f86a61
commit
2cc257b3e4
1 changed files with 21 additions and 0 deletions
21
tools/find-iam-user-for-access-key.py
Normal file
21
tools/find-iam-user-for-access-key.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import boto.iam
|
||||||
|
import sys
|
||||||
|
|
||||||
|
TARGET_ACCESS_KEY = sys.argv[1]
|
||||||
|
|
||||||
|
iam = boto.connect_iam()
|
||||||
|
|
||||||
|
users = iam.get_all_users('/')['list_users_response']['list_users_result']['users']
|
||||||
|
|
||||||
|
def find_key():
|
||||||
|
for user in users:
|
||||||
|
for key_result in iam.get_all_access_keys(user['user_name'])['list_access_keys_response']['list_access_keys_result']['access_key_metadata']:
|
||||||
|
aws_access_key = key_result['access_key_id']
|
||||||
|
if aws_access_key == TARGET_ACCESS_KEY:
|
||||||
|
print 'Target key belongs to:'
|
||||||
|
print 'user : ' + user['user_name']
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not find_key():
|
||||||
|
print 'Did not find access key (' + TARGET_ACCESS_KEY + ') in ' + str(len(users)) + ' IAM users.'
|
Loading…
Reference in a new issue