Skip to content

Commit adbaa74

Browse files
authored
Merge pull request #467 from saw-your-packet/main
update(article): creds from cloudshell with boto3
2 parents 53028a3 + 5aeb4ef commit adbaa74

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

content/aws/post_exploitation/get_iam_creds_from_console_session.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ Alternatively, you can run the following command, which returns credentials with
3636
```
3737
[user@cloudshell]$ aws configure export-credentials --format env
3838
```
39+
40+
## Using boto3 to Retrieve Credentials
41+
42+
Alternatively, you can use Python's boto3 library directly within CloudShell to programmatically retrieve the credentials. This method can be useful when you need to integrate credential extraction into a Python script or automation workflow.
43+
44+
```python
45+
import boto3
46+
47+
session = boto3.Session()
48+
creds = session.get_credentials()
49+
print({
50+
'AccessKey': creds.access_key,
51+
'SecretKey': creds.secret_key,
52+
'Token': creds.token
53+
})
54+
```
55+
56+
![POC Credentials Retrieval using boto3](../../images/aws/post_exploitation/get_iam_creds_from_console_session/poc_boto3_creds_retrieval.png)
57+
58+
This approach leverages boto3's automatic credential detection within the CloudShell environment, providing the same temporary credentials that are available through the metadata service endpoint. The credentials obtained this way will have the same TTL limitations as other methods described above.

0 commit comments

Comments
 (0)