IAMActionHunter:一款AWS IAM策略声明解析和查询工具

admin 2025年2月9日01:42:39评论10 views字数 3355阅读11分11秒阅读模式
IAMActionHunter:一款AWS IAM策略声明解析和查询工具
关于IAMActionHunter

IAMActionHunter是一款功能强大的AWS IAM策略声明解析和查询工具,旨在简化研究人员在 AWS IAM中收集和理解用户和角色权限策略语句的过程。

IAMActionHunter:一款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 installiamactionhunter --helpiamactionhunter --collect --profile <some-aws-profile>

pip使用

切换到项目目录中,执行下列命令即可:

cd IAMActionHunterpip install .iamactionhunter --helpiamactionhunter --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_iamwrite_actionsprivescsiamactionhunter --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

https://github.com/RhinoSecurityLabs/IAMActionHunter

原文始发于微信公众号(FreeBuf):IAMActionHunter:一款AWS IAM策略声明解析和查询工具

 

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年2月9日01:42:39
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   IAMActionHunter:一款AWS IAM策略声明解析和查询工具https://cn-sec.com/archives/3690790.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息