Discover AWS Organization ID Via S3 Bucket
Welcome to my cybersecurity blog! i'm Basit Hassan, a student penetration tester passionate about ethical hacking. On this blog, i'll be sharing tutorials, walkthroughs, and real-world exploitation techniques that i've personally tested and can get you started in the penetration testing field.
Let The Hacking Begin!!!!
Step1: AWS cli Installation
In your browser, download the macOS
pkgfile: https://awscli.amazonaws.com/AWSCLIV2.pkgRun your downloaded file and follow the on-screen instructions. You can choose to install the AWS CLI in the following ways:
For all users on the computer (requires
sudo)You can install to any folder, or choose the recommended default folder of
/usr/local/aws-cli.The installer automatically creates a symlink at
/usr/local/bin/awsthat links to the main program in the installation folder you chose.
For only the current user (doesn't require
sudo)You can install to any folder to which you have write permission.
Due to standard user permissions, after the installer finishes, you must manually create a symlink file in your
$PATHthat points to theawsandaws_completerprograms by using the following commands at the command prompt. If your$PATHincludes a folder you can write to, you can run the following command withoutsudoif you specify that folder as the target's path. If you don't have a writable folder in your$PATH, you must usesudoin the commands to get permissions to write to the specified target folder. The default location for a symlink is/usr/local/bin/.$sudo ln -s /folder/installed/aws-cli/aws /usr/local/bin/aws$sudo ln -s /folder/installed/aws-cli/aws_completer /usr/local/bin/aws_completer
Note
You can view debug logs for the installation by pressing Cmd+L anywhere in the installer. This opens a log pane that enables you to filter and save the log. The log file is also automatically saved to
/var/log/install.log.To verify that the shell can find and run the
awscommand in your$PATH, use the following commands.$which aws/usr/local/bin/aws$aws --versionaws-cli/2.25.11 Python/3.11.6 Darwin/23.3.0If theawscommand cannot be found, you might need to restart your terminal or follow the troubleshooting in Troubleshooting errors for the AWS CLI.
Download and run the AWS CLI MSI installer for Windows (64-bit):
https://awscli.amazonaws.com/AWSCLIV2.msi
Alternatively, you can run the
msiexeccommand to run the MSI installer.C:\>msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msiFor various parameters that can be used with
msiexec, see msiexecon the Microsoft Docs website. For example, you can use the /qnflag for a silent installation.C:\>msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi/qnTo confirm the installation, open the Start menu, search for
cmdto open a command prompt window, and at the command prompt use theaws --versioncommand.C:\>aws --versionaws-cli/2.25.11 Python/3.11.6 Windows/10 exe/AMD64 prompt/offIf Windows is unable to find the program, you might need to close and reopen the command prompt window to refresh the path, or follow the troubleshooting in Troubleshooting errors for the AWS CLI.
Step2: Profile Configuration
Step3: Credentials Confirmation
Step4: Trying to check permissions the user have
Once pacu is installed let's go!!
After launching pacu you're asked to name the session so i named it "cybr". So we will be using pacu to check the permissions the user have.
The first thing we will be doing is to import the access key on pacu
once the keys are imported we try to brute force permissions to that account using pacu as seen below
after that run the "run iam__bruteforce_permissions --region us-east-1 " command to see permissions the account has, i added the tag --region to make the brute force fast by telling it my region .I found something interesting the permission to list roles there might be a role that might be interesting to us as a pentester that's why i highlighted it out now let's look it up.
After looking it up there is a whole bunch of role, to make it short i only choose the one i know i might find something interesting so the role i found is "S3AccessImages". It might seem overwhelming finding a role you can use as a leverage, you can just take your time and look for it. Here is the command i use to list the roles below ππ
┌──(p3lla㉿kali)-[~]
└─$ aws iam list-roles --profile cybr
when this is launched you will use the enter key to keep going down the bunch of roles in your CLI, so all i did is find a role i can use as a leverage to elevate my priviledge so this is the role i found below
we need to get the role policy to know what this role allow the user account we are authenticated to can do, by doing that we use this command belowNow that we have gotten the policy name which is "AccessS3Bucket0bjects", with the policy name we can get more information about what the policy allows so we will do that below
After launching the command we have two resources (which i highlighted) that are found in a S3 Bucket which allow whoever is in this role to checkout what is in this bucket, But this bucket belongs to a different AWS account but the account is not specified in the resources. SO this bucket doesn't belong to the organization ID of this account and remember the purpose of this lab is to figure out what's the organization ID of this bucket and you know once the organization ID can be gotten it can be use for different stuffs. so we will be using a tool called conditional-love.
Conditional love
How to install and use conditional-love for enumeration
so what this does is that it brute force (i.e it tries all possible combinations of letters and numbers) organization ID character by character, based on how AWS respond to the request. remember it's because of the resources we saw in the s3 Bucket ""arn:aws:s3:::img.cybrlabs.io/*" does not belong to the user organization ID we are authenticated with, Conditional Love uses this role which we use to access the resources to try and assume permissions and access the target resource.
s3:HeadObject" is an AWS action that checks metadata about an object in a bucket — like size, last modified date, etc. so what this does is it try all possible combination one character at a time in the request using the role we inputted AWS checks the request against the bucket’s policy.
-
If the partial Organization ID is completely wrong, AWS returns a generic AccessDenied error immediately.
-
But if your guess is partially correct, AWS might return a different error (or even let the request go deeper into policy evaluation).
With the help of Generative AI tools like ChatGPT, you’re never really stuck — when something confuses you, just ask. Whether it’s understanding a permission boundary or crafting a valid assume-role command, support is just a question away.
Consistency beats cramming. So keep breaking things (safely) and rebuilding — that’s how you truly master cloud pentesting.
Summary
In this lab, we demonstrated how a compromised IAM user's credentials can be used to:
-
Enumerate AWS Identity and Access Management (IAM) roles and permissions.
-
Exploit S3 bucket policies to discover the AWS Organization ID.
-
Use tools like Pacu and Conditional-Love to automate privilege escalation attempts.
-
Learn about real-world AWS misconfigurations in a safe, hands-on lab environment.
This blog post is for educational purposes only. All activities were performed in a controlled lab environment provided by CYBR's Assume Breach: AWS Edition.
Do not attempt these techniques on any systems or cloud accounts you do not own or have explicit permission to test. Unauthorized testing is illegal and unethical.








Comments
Post a Comment