
AWS IAM 정책 문장 파서 및 쿼리 도구입니다.
IAMActionHunter는 IAM 정책 문장 파서 및 쿼리 도구로, AWS Identity and Access Management(IAM)에서 사용자와 역할에 대한 권한 정책 문장을 수집하고 이해하는 과정을 간소화하는 것을 목표로 합니다. 기능 자체는 간단하지만, 이 도구는 일상적인 AWS 침투 테스트 중 효율적인 솔루션의 필요성에 대응하여 개발되었습니다.
https://rhinosecuritylabs.com/aws/iamactionhunter-aws-iam-permissions/
이 도구는 다양한 AWS IAM 작업을 쿼리하여 AWS 계정에서 잠재적인 권한 상승 기회를 검색하는 데 사용할 수 있습니다. 다른 도구가 권한 상승 위험을 식별하기 위해 스캔을 수행하는 반면, 이 도구는 보다 수동적인 접근 방식을 가능하게 하여 사용자가 권한을 조사하고 적용되는 역할, 사용자 및 리소스를 빠르게 검토하여 대상 분석을 수행할 수 있습니다.
이 도구는 또한 쿼리 결과를 CSV 형식으로 출력하고 저장하는 기능을 제공하므로, AWS 계정 내 보안 팀이 주요 권한과 리소스에 대한 개략적인 개요를 원할 때 유용합니다. 예를 들어, 계정에서 iam:put* 권한을 가진 사용자와 역할을 식별하려는 경우, 쿼리를 실행하고 CSV를 생성하면 이러한 권한을 가진 모든 사용자와 역할, 그리고 액세스 권한이 있는 리소스를 쉽게 검토할 수 있습니다.
권장:
pip3 install iamactionhunter
이 기능의 대부분은 https://github.com/RhinoSecurityLabs/pacu 의 모듈인 iam__enum_action_query로도 구현되어 있으므로, 원한다면 이를 사용할 수도 있습니다.
클론 및 Poetry 사용:
git clone https://github.com/RhinoSecurityLabs/IAMActionHunter.git
cd IAMActionHunter
# (필요한 경우: poetry env use python3.9)
poetry install
iamactionhunter --help
iamactionhunter --collect --profile <some-aws-profile>
클론 및 Pip 사용:
git clone https://github.com/RhinoSecurityLabs/IAMActionHunter.git
cd IAMActionHunter
pip install .
iamactionhunter --help
iamactionhunter --collect --profile <some-aws-profile>
도움말:
usage: iamactionhunter [-h] [--profile PROFILE] [--account ACCOUNT] [--query QUERY] [--role ROLE] [--user USER]
[--all-or-none] [--collect] [--list] [--csv CSV] [--config CONFIG]
Collect all policies for all users/roles in an AWS account and then query the policies for permissions.
optional arguments:
-h, --help show this help message and exit
--profile PROFILE The name of the AWS profile to use for authentication for user/role collection.
--account ACCOUNT Account number to query.
--query QUERY Permissions to query. A string like: s3:GetObject or s3:* or s3:GetObject,s3:PutObject
--role ROLE Filter role to query.
--user USER Filter user to query.
--all-or-none Check if all queried actions are allowed, not just some.
--collect Collect user and role policies for the account.
--list List accounts available to query.
--csv CSV File name for CSV report output.
--config CONFIG JSON config file for preset queries.
먼저 사용자와 역할에 대한 모든 IAM 정보를 다운로드합니다:
iamactionhunter --collect --profile my-aws-profile
데이터가 수집된 계정을 나열합니다:
iamactionhunter --list
그런 다음 쿼리를 실행합니다:
iamactionhunter --account <account_number_of_profile_above> --query iam:create*
더 많은 쿼리 실행:
iamactionhunter --account <account_number_of_profile_above> --query iam:create*,iam:put*
특정 역할 쿼리:
iamactionhunter --account <account_number_of_profile_above> --role some_role --query iam:*
특정 사용자 쿼리:
iamactionhunter --account <account_number_of_profile_above> --user some_user --query iam:*
CSV로 출력:
iamactionhunter --account <account_number_of_profile_above> --query iam:* --csv report.csv
사전 설정된 설정 실행:
iamactionhunter --account <account_number_of_profile_above> --config dangerous_iam
사용자나 역할이 쿼리한 모든 권한을 가지고 있는 경우에만 결과를 표시하는 쿼리 실행:
iamactionhunter --account <account_number_of_profile_above> --query s3:getobject,s3:listbucket --all-or-none
내장된 설정 옵션은 다음과 같습니다:
dangerous_iam
write_actions
privescs
iamactionhunter --account <account_number_of_profile> --config dangerous_iam
설정 파일은 특정 권한을 지정하는 JSON 파일입니다. 다음은 CodeBuild에서 쓰기 작업을 검색하는 예제 파일입니다.
[
{
"Description": "These are all actions which may allow some kind of write privilege in CodeBuild.",
"Name": "CodeBuildWriteActions",
"ActionsNeeded": [
"codebuild:Put*",
"codebuild:Create*",
"codebuild:Delete*",
"codebuild:Modify*",
"codebuild:Update*",
"codebuild:Attach*",
"codebuild:Detach*",
"codebuild:Associate*",
"codebuild:Disassociate*",
"codebuild:Add*",
"codebuild:Remove*",
"codebuild:Set*",
"codebuild:Enable*",
"codebuild:Disable*",
"codebuild:Reset*",
"codebuild:Stop*",
"codebuild:Terminate*",
"codebuild:Reboot*",
"codebuild:Start*"
],
"AllOrNone": false
}
]
그런 다음 --config 인수에 파일 이름을 지정하여 설정을 실행할 수 있습니다.
iamactionhunter --account <account_number_of_profile> --config write_code_build.json