PMapper:助你在AWS中實現IAM權限快速安全評估

關于PMapper

PMapper是一款功能強大的腳本工具,該工具本質上是一個基于Python開發的腳本/代碼庫,可以幫助廣大研究人員識別一個AWS賬號或AWS組織中存在安全風險的IAM配置,并對IAM權限執行快速評估。

PMapper可以將目標AWS帳戶中的不同IAM用戶和角色建模為有向圖,從而幫助廣大研究人員檢查權限提升以及攻擊者訪問AWS資源或操作所可能采取的替代路徑。PMapper還提供了一種查詢機制,該機制使用了AWS授權行為的本地模擬方法,當運行查詢以確定主體是否有權訪問某個操作/資源時,PMapper還會檢查該用戶或角色是否可以訪問其他有權訪問該操作/資源的用戶或角色。

工具要求

PMapper基于Python 3.5+開發,并使用了botocore庫構建項目功能。除此之外,PMapper還需要pydot和graphviz這兩個依賴組件,其中pydot可以通過pip安裝,graphviz可以訪問下列地址獲取Windows、macOS和Linux版本:

Graphviz

工具安裝

由于該工具基于Python 3.5開發,因此我們首先需要在本地設備上安裝并配置好Python 3.5+環境。接下來,廣大研究人員可以使用下列方法完成工具的下載和安裝。

Pip安裝

pip install principalmapper

源碼安裝

首先,使用下列命令將該項目源碼克隆至本地:

git clone git@github.com:nccgroup/PMapper.git

然后使用pip完成工具的安裝:

cd PMapperpip install .

Docker使用

將項目源碼克隆至本地之后,切換到項目目錄中,并執行下列命令:

cd PMapperdocker build -t $TAG .docker run -it $TAG

我們可以在調用docker run ...命令時,使用-e|--env或--env-file傳遞AWS_*環境變量,或使用-v加載你的~/.aws/目錄,并使用AWS_CONFIG_FILE和AWS_SHARED_CREDENTIALS_FILE環境變量。

工具使用

為目標賬號創建一個有向圖,并通過AWS CLI配置訪問:

$ pmapper --profile skywalker graph create# [... graph-creation output goes here ...]

運行一個查詢,并查看誰創建了IAM用戶:

$ pmapper --profile skywalker query 'who can do iam:CreateUser'# [... query output goes here ...]

運行一個查詢,并查看誰啟動了一個消耗大量資源的EC2實例(排除admin用戶):

$ pmapper --account 000000000000 argquery -s --action 'ec2:RunInstances' --condition 'ec2:InstanceType=c6gd.16xlarge'# [... query output goes here ...]

運行權限提升預設查詢,跳過報告當前“admin”用戶:

$ pmapper --account 000000000000 query -s 'preset privesc *'# [... privesc report goes here ...]

針對目標賬號為創建一個SVG格式的可視化訪問圖:

$ pmapper --account 000000000000 visualize --filetype svg# [... information output goes here, file created ...]

下面給出的是可視化有向圖的實例:

使用--only-privesc命令生成的結果如下:

輸出樣例

拉取一張圖:

esteringer@ubuntu:~/Documents/projects/Skywalker$ python pmapper.py graph
Using profile: skywalker
Pulling data for account [REDACTED]
Using principal with ARN arn:aws:iam::[REDACTED]:user/TestingSkywalker
[+] Starting EC2 checks.
[+] Starting IAM checks.
[+] Starting Lambda checks.
[+] Starting CloudFormation checks.
[+] Completed CloudFormation checks.
[+] Completed EC2 checks.
[+] Completed Lambda checks.
[+] Completed IAM checks.
Created an AWS Graph with 16 nodes and 53 edges
[NODES]
AWSNode("arn:aws:iam::[REDACTED]:user/AdminUser", properties={u'is_admin': True, u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:user/EC2Manager", properties={u'is_admin': False, u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:user/LambdaDeveloper", properties={u'is_admin': False, u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:user/LambdaFullAccess", properties={u'is_admin': False, u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:user/PowerUser", properties={u'is_admin': False, u'rootstr': u'arn:aws:iam::[REDACTED]:root', u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:user/S3ManagementUser", properties={u'is_admin': False, u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:user/S3ReadOnly", properties={u'is_admin': False, u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:user/TestingSkywalker", properties={u'is_admin': False, u'type': u'user'})
AWSNode("arn:aws:iam::[REDACTED]:role/AssumableRole", properties={u'is_admin': False, u'type': u'role', u'name': u'AssumableRole'})
AWSNode("arn:aws:iam::[REDACTED]:role/EC2-Fleet-Manager", properties={u'is_admin': False, u'type': u'role', u'name': u'EC2-Fleet-Manager'})
AWSNode("arn:aws:iam::[REDACTED]:role/EC2Role-Admin", properties={u'is_admin': True, u'type': u'role', u'name': u'EC2Role-Admin'})
AWSNode("arn:aws:iam::[REDACTED]:role/EC2WithS3ReadOnly", properties={u'is_admin': False, u'type': u'role', u'name': u'EC2WithS3ReadOnly'})
AWSNode("arn:aws:iam::[REDACTED]:role/EMR-Service-Role", properties={u'is_admin': False, u'type': u'role', u'name': u'EMR-Service-Role'})
AWSNode("arn:aws:iam::[REDACTED]:role/LambdaRole-S3ReadOnly", properties={u'is_admin': False, u'type': u'role', u'name': u'LambdaRole-S3ReadOnly'})
AWSNode("arn:aws:iam::[REDACTED]:role/ReadOnlyWithLambda", properties={u'is_admin': False, u'type': u'role', u'name': u'ReadOnlyWithLambda'})
AWSNode("arn:aws:iam::[REDACTED]:role/UpdateCredentials", properties={u'is_admin': False, u'type': u'role', u'name': u'UpdateCredentials'})
[EDGES]
(0,1,'ADMIN','can use existing administrative privileges to access')
(0,2,'ADMIN','can use existing administrative privileges to access')
(0,3,'ADMIN','can use existing administrative privileges to access')
(0,4,'ADMIN','can use existing administrative privileges to access')
(0,5,'ADMIN','can use existing administrative privileges to access')
(0,6,'ADMIN','can use existing administrative privileges to access')
(0,7,'ADMIN','can use existing administrative privileges to access')
(0,8,'ADMIN','can use existing administrative privileges to access')
(0,9,'ADMIN','can use existing administrative privileges to access')
(0,10,'ADMIN','can use existing administrative privileges to access')
(0,11,'ADMIN','can use existing administrative privileges to access')
(0,12,'ADMIN','can use existing administrative privileges to access')
(0,13,'ADMIN','can use existing administrative privileges to access')
(0,14,'ADMIN','can use existing administrative privileges to access')
(0,15,'ADMIN','can use existing administrative privileges to access')
(10,0,'ADMIN','can use existing administrative privileges to access')
(10,1,'ADMIN','can use existing administrative privileges to access')
(10,2,'ADMIN','can use existing administrative privileges to access')
(10,3,'ADMIN','can use existing administrative privileges to access')
(10,4,'ADMIN','can use existing administrative privileges to access')
(10,5,'ADMIN','can use existing administrative privileges to access')
(10,6,'ADMIN','can use existing administrative privileges to access')
(10,7,'ADMIN','can use existing administrative privileges to access')
(10,8,'ADMIN','can use existing administrative privileges to access')
(10,9,'ADMIN','can use existing administrative privileges to access')
(10,11,'ADMIN','can use existing administrative privileges to access')
(10,12,'ADMIN','can use existing administrative privileges to access')
(10,13,'ADMIN','can use existing administrative privileges to access')
(10,14,'ADMIN','can use existing administrative privileges to access')
(10,15,'ADMIN','can use existing administrative privileges to access')
(1,9,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(1,10,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(1,11,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(4,9,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(4,10,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(4,11,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(3,13,'LAMBDA_CREATEFUNCTION','can create a Lambda function and pass an execution role to access')
(3,14,'LAMBDA_CREATEFUNCTION','can create a Lambda function and pass an execution role to access')
(3,15,'LAMBDA_CREATEFUNCTION','can create a Lambda function and pass an execution role to access')
(9,10,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(4,13,'LAMBDA_CREATEFUNCTION','can create a Lambda function and pass an execution role to access')
(9,11,'EC2_USEPROFILE','can create an EC2 instance and use an existing instance profile to access')
(4,8,'STS_ASSUMEROLE','can use STS to assume the role')
(4,14,'LAMBDA_CREATEFUNCTION','can create a Lambda function and pass an execution role to access')
(4,15,'LAMBDA_CREATEFUNCTION','can create a Lambda function and pass an execution role to access')
(15,0,'IAM_CREATEKEY','can create access keys with IAM to access')
(15,1,'IAM_CREATEKEY','can create access keys with IAM to access')
(15,2,'IAM_CREATEKEY','can create access keys with IAM to access')
(15,3,'IAM_CREATEKEY','can create access keys with IAM to access')
(15,4,'IAM_CREATEKEY','can create access keys with IAM to access')
(15,5,'IAM_CREATEKEY','can create access keys with IAM to access')
(15,6,'IAM_CREATEKEY','can create access keys with IAM to access')
(15,7,'IAM_CREATEKEY','can create access keys with IAM to access')

查詢圖信息:

esteringer@ubuntu:~/Documents/projects/Skywalker$ ./pmapper.py --profile skywalker query "who can do s3:GetObject with *"
user/AdminUser can do s3:GetObject with *
user/EC2Manager can do s3:GetObject with * through role/EC2Role-Adminuser/EC2Manager can create an EC2 instance and use an existing instance profile to access role/EC2Role-Admin
role/EC2Role-Admin can do s3:GetObject with *
user/LambdaFullAccess can do s3:GetObject with *
user/PowerUser can do s3:GetObject with *
user/S3ManagementUser can do s3:GetObject with *
user/S3ReadOnly can do s3:GetObject with *
user/TestingSkywalker can do s3:GetObject with *
role/EC2-Fleet-Manager can do s3:GetObject with * through role/EC2Role-Adminrole/EC2-Fleet-Manager can create an EC2 instance and use an existing instance profile to access role/EC2Role-Admin
role/EC2Role-Admin can do s3:GetObject with *
role/EC2Role-Admin can do s3:GetObject with *
role/EC2WithS3ReadOnly can do s3:GetObject with *
role/EMR-Service-Role can do s3:GetObject with *
role/LambdaRole-S3ReadOnly can do s3:GetObject with *
role/UpdateCredentials can do s3:GetObject with * through user/AdminUserrole/UpdateCredentials can create access keys with IAM to access user/AdminUser
user/AdminUser can do s3:GetObject with *

識別潛在的權限提升:

esteringer@ubuntu:~/Documents/projects/Skywalker$ ./pmapper.py --profile skywalker query "preset priv_esc user/PowerUser"
Discovered a potential path to change privileges:
user/PowerUser can change privileges because:user/PowerUser can access role/EC2Role-Admin because: user/PowerUser can create an EC2 instance and use an existing instance profile to access role/EC2Role-Adminand role/EC2Role-Admin can change its own privileges.

許可證協議

本項目的開發與發布遵循AGPL-3.0開源許可協議。

項目地址

PMapper:【GitHub傳送門】

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/14742.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/14742.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/14742.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Hive環境搭建

1 安裝Hive 下載文件 # wget -P /opt/ https://mirrors.huaweicloud.com/apache/hive/hive-2.3.8/apache-hive-2.3.8-bin.tar.gz 解壓縮 # tar -zxvf /opt/apache-hive-2.3.8-bin.tar.gz -C /opt/ 修改hive文件夾名字 # mv /opt/apache-hive-2.3.8-bin /opt/hive 配置環境變量 …

torch Embedding 學習筆記

文本向量化(Text Embedding):將文本數據(詞、句子、文檔)表示成向量的方法。 詞向量化將詞轉為二進制或高維實數向量,句子和文檔向量化則將句子或文檔轉為數值向量,通過平均、神經網絡或主題模…

幀動畫播放出現oom異常分析及解決

問題描述 需要播放序列幀,幀數特別多的時候會oom 問題分析 源代碼每一幀都創建一次bitmap,極度消耗內存 bitmap.recycle并不會立刻回收內存,內存還是會很緊張 問題解決 利用inbitmap,每一幀復用同一片內存區域 //設置Bitmap…

【大模型部署】在C# Winform中使用文心一言ERNIE-3.5 4K 聊天模型

【大模型部署】在C# Winform中使用文心一言ERNIE-3.5 4K 聊天模型 前言 今天來寫一個簡單的ernie-c#的例子,主要參考了百度智能云的例子,然后自己改了改,學習了ERNIE模型的鑒權方式,數據流的格式和簡單的數據解析,實…

軟件安裝:Linux安裝Nginx

軟件安裝:Linux如何安裝軟件,程序。 源碼安裝 類似于.exe 源碼包就是一堆源代碼程序組成的。 linux tar.gz 這個就是源碼包 源碼包--------二進制包,源碼包里面的代碼經過編譯之后形成的包。 優點:1、開源,可以二次…

面試八股之MySQL篇1——慢查詢定位篇

🌈hello,你好鴨,我是Ethan,一名不斷學習的碼農,很高興你能來閱讀。 ??目前博客主要更新Java系列、項目案例、計算機必學四件套等。 🏃人生之義,在于追求,不在成敗,勤通…

JavaScript 數組方法總結

JavaScript 數組方法總結 創建數組訪問和修改數組(長度 & 元素)添加和刪除元素數組遍歷元素查找過濾和映射歸并和縮減數組的連接數組的扁平化數組的排序數組的反轉數組的復制數組的測試數組的填充 創建數組 Array.of(...elements): 創建一個…

Singer模型與CT模型狀態轉移矩陣的求解

Singer模型與CT模型狀態轉移矩陣的求解 文章目錄 Singer模型與CT模型狀態轉移矩陣的求解前言狀態方程矩陣指數函數泰勒展開拉普拉斯變換 Singer模型CT模型 前言 回想起來,第一次接觸Singer模型與CT模型時的狀態轉移矩陣時,對求解過程一知半解。現在&…

linux 上除了shell、python腳本以外,還有什么腳本語言用得比較多?

在開始前我有一些資料,是我根據網友給的問題精心整理了一份「 Linux的資料從專業入門到高級教程」, 點個關注在評論區回復“888”之后私信回復“888”,全部無償共享給大家!!!說到在 Linux下的編程&#xf…

柯橋成人商務英語“?cold”是“冷”,“shoulder”是“肩膀”,?cold shoulder可不是冷肩膀!

英文中有很多俚語(idioms)都與身體部位有關,非常有趣。 今天,英語君就為大家介紹一些和身體部位有關的俚語,一起來看看吧! cold shoulder “cold shoulder”不能用字面意思理解為“冷肩膀”,我們…

學習毛概思想(自用)

一、單項選擇題 毛澤東思想的主要創立者是( A ) A、毛澤東 B、劉少奇 C、周恩來 D、朱德中國共產黨內第一個提出“毛澤東思想”科學概念的是( D  )    A、周恩來   B、劉少奇   C、朱德…

CommonJS 和 ESM 在模塊加載和處理依賴關系的方式上的不同點理解

模塊加載: CommonJS:當執行到 require() 函數時,Node.js 會同步地加載模塊文件,即立即讀取模塊文件并執行其中的代碼,然后返回模塊的導出值。這就意味著,直到運行時我們才知道具體導入了哪些模塊&#xff0…

智慧校園學工管理系統的部署

學工體系思政服務該怎么規劃建造?思政作為高校育人的中心使命,在做到讓學生健康高興生長的一起,也應滿意學生生長成才的各類需求。使用技術為學生供給優質的信息化服務,是其間的有效途徑。大數據讓個性化教育成為可能,…

【題解】AB33 相差不超過k的最多數(排序 + 滑動窗口)

https://www.nowcoder.com/practice/562630ca90ac40ce89443c91060574c6?tpId308&tqId40490&ru/exam/oj 排序 滑動窗口 #include <iostream> #include <vector> #include <algorithm> using namespace std;int main() {int n, k;cin >> n &…

css中彈性布局使用方法

最近寫企業家用到許多彈性&#xff0c;感覺到彈性的重要性&#xff0c;今天給大家總結一下 彈性布局&#xff08;Flexbox&#xff09;是一種在 CSS 中用來實現靈活的布局方式&#xff0c;它能夠方便地調整容器中子元素的尺寸、順序和對齊方式。以下是一些常見的彈性布局屬性及…

【探索數據結構】線性表之順序表

&#x1f389;&#x1f389;&#x1f389;歡迎蒞臨我的博客空間&#xff0c;我是池央&#xff0c;一個對C和數據結構懷有無限熱忱的探索者。&#x1f64c; &#x1f338;&#x1f338;&#x1f338;這里是我分享C/C編程、數據結構應用的樂園? &#x1f388;&#x1f388;&…

Vue3按順序調用新增和查詢接口

Vue3按順序調用新增和查詢接口 一、前言1、代碼 一、前言 如果你想將兩個調用接口的操作封裝在不同的方法中&#xff0c;你可以考慮將這兩個方法分別定義為異步函數&#xff0c;并在需要時依次調用它們。以下是一個示例代碼&#xff1a; 1、代碼 <template><div>…

豐田精益生產的模板

豐田精益生產&#xff0c;也被稱為豐田生產方式&#xff08;Toyota Production System, TPS&#xff09;&#xff0c;是一套完整的生產和管理系統&#xff0c;其核心目標是最大化效率、消除浪費&#xff0c;并通過持續改進來提升產品質量。 學習優秀企業 學習福特 豐田精益生產…

C語言之函數指針(持續更新)

C語言精髓是指針&#xff0c;指針知識深似海&#xff0c;遇到一些學習一些~ 文章目錄 1. typedef 定義函數指針類型2. void* 空指針的解引用 1. typedef 定義函數指針類型 函數參數化是指通過函數指針將函數的某些行為參數化。這樣&#xff0c;我們可以在調用函數時動態地指定…