未加星标

I found a GCP service account token…now what?

字体大小 | |
[开发(python) 所属分类 开发(python) | 发布者 店小二04 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

Google Cloud Platform ( GCP ) is rapidly growing in popularity and i haven’t seen too many posts on f**king it up so I’m going to do at least one

Google has several ways to do authentication but most likely what you are going to come across shoved into code somewhere or in a dotfiles is a service account json file.

It’s going to look similar to this:


I found a GCP service account token…now what?

These service account files are similar to AWS tokens in that it can be difficult to determine what they have access to if you don’t already have console and/or IAM access. However with a little bit of scripting we can brute force at least some of the token’s functionality pretty quickly. The issue being service accounts for something like GCP compute looks the same as one you made to manage your calendar or one of the 100’s of other Google services.

You’ll need to install the gcloud tools for you OS. Info here: https://cloud.google.com/sdk/

Once you have the gcloud suite of tools installed you can auth with the json file with the following command:

gcloud auth activate-service-account key-file=KEY_FILE


If they key is invalid you’ll see something like the below:

gcloud auth activate-service-account key-file=21.json

ERROR: (gcloud.auth.activate-service-account) There was a problem refreshing your current auth tokens: invalid_grant: Not a valid email or user ID.

Otherwise it will look similar to below:


gcloud auth activate-service-account key-file=/Users/CG/Documents/pentest/gcp-weirdaal/gcp.json Activated service account credentials for: [python@removed.iam.gserviceaccount.com]

you can validate it worked by issuing gcloud auth list command:

gcloud auth list

Credentialed Accounts

ACTIVE ACCOUNT

* python@removed.iam.gserviceaccount.com

I put together a shell script that runs though a bunch of command to enumerate information. They only you info need to provide is the project name. This can be found in the json file in the project_id field or by issuing the gcloud project list command. Sometimes there are multiple projects associated with an account and you’d need to run the shell script with for each project.

The first time you run these api calls you might need to pass a “Y” to the cli to enable it. you can get around this manual shenanigans by doing a:

yes | ./gcp_enum.sh

This will answer Yes for you each time

本文开发(python)相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程

代码区博客精选文章
分页:12
转载请注明
本文标题:I found a GCP service account token…now what?
本站链接:https://www.codesec.net/view/628044.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(python) | 评论(0) | 阅读(126)