关于IAMActionHunter
IAMActionHunter是一款功能强大的AWS IAM策略声明解析和查询工具,旨在简化研究人员在 AWS IAM中收集和理解用户和角色权限策略语句的过程。
功能介绍
该工具的主要目的是通过查询可能被利用的各种 AWS IAM 操作来搜索 AWS 账户中潜在的安全风险,并以此来辅助安全管理人员提升AWS环境的安全性。
除此之外,该工具还提供了以 CSV 格式输出和保存查询结果的功能,这对于寻求 AWS 账户内主要权限和资源高级概览的安全团队非常有用。例如,你可能希望识别账户中具有iam:put*权限的用户和角色。通过执行查询并生成 CSV,你可以轻松查看具有这些权限的所有用户和角色,以及他们有权访问的资源。
工具要求
boto3==1.26.113
botocore==1.29.113
colorama==0.4.6
jmespath==1.0.1
numpy==1.24.2
pandas==2.0.0
policyuniverse==1.5.0.20220613
python-dateutil==2.8.2
pytz==2023.3
s3transfer==0.6.0
six==1.16.0
tzdata==2023.3
urllib3==1.26.15
工具安装
由于该工具基于Python 3开发,因此我们首先需要在本地设备上安装并配置好最新版本的Python 3环境。
源码获取
广大研究人员可以直接使用下列命令将该项目源码克隆至本地:
git clone https://github.com/RhinoSecurityLabs/IAMActionHunter.git
poetry使用
切换到项目目录中:
cd IAMActionHunter
运行下列命令启动poetry和IAMActionHunter:
# (potentially necessary: poetry env use python3.9) poetry install iamactionhunter --help iamactionhunter --collect --profile <some-aws-profile>
pip使用
切换到项目目录中,执行下列命令即可:
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 显示此帮助消息并退出 --profile PROFILE 用于用户/角色收集身份验证的AWS配置文件名称 --account ACCOUNT 要查询的账号 --query QUERY 查询权限。提供一个类似于:s3:GetObject或s3:*或s3:GetObjects、s3:PutObject的字符串 --role ROLE 筛选要查询的角色 --user USER 筛选要查询的用户 --all-or-none 检查是否允许所有查询的操作 --collect 收集帐户的用户和角色策略 --list 列出可查询的帐户 --csv CSV 报告输出的csv文件名 --config CONFIG JSON配置文件用于预设查询
工具配置
内置配置选项包括:
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
工具运行演示
下载用户和角色的所有 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
许可证协议
本项目的开发与发布遵循Apache-2.0开源许可协议。
项目地址
IAMActionHunter:【GitHub传送门】
参考资料
https://rhinosecuritylabs.com/aws/iamactionhunter-aws-iam-permissions/
4A评测 - 免责申明
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。
不得将上述内容用于商业或者非法用途,否则一切后果请用户自负。
本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
如果您喜欢该程序,请支持正版,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。敬请谅解!
程序来源网络,不确保不包含木马病毒等危险内容,请在确保安全的情况下或使用虚拟机使用。
侵权违规投诉邮箱:4ablog168#gmail.com(#换成@)