Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions util/scripts/lw_aws_exploit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ PROFILE=lacework
# Create a new IAM user
echo "${grn}Creating a new IAM user called ${mag}$USERNAME${end}"
echo ""
aws iam create-user --user-name $USERNAME | jq
aws iam create-access-key --user-name $USERNAME > creds.json
aws iam create-user --user-name $USERNAME --profile $PROFILE | jq
aws iam create-access-key --user-name $USERNAME --profile $PROFILE > creds.json
echo ""
echo "${grn}Granting PowerUser access to ${mag}$USERNAME${end}"
aws iam attach-user-policy --user-name $USERNAME --policy-arn arn:aws:iam::aws:policy/PowerUserAccess
aws iam attach-user-policy --user-name $USERNAME --profile $PROFILE --policy-arn arn:aws:iam::aws:policy/PowerUserAccess
export KEY=$(cat creds.json | jq -r .AccessKey.AccessKeyId)
export SECRET=$(cat creds.json | jq -r .AccessKey.SecretAccessKey)

Expand All @@ -39,9 +39,10 @@ bucket=${bucket#/}

aws s3api put-public-access-block \
--bucket $bucket \
--public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false"
--public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false" \
--profile $PROFILE

aws s3api put-bucket-acl --bucket $bucket --acl public-read
aws s3api put-bucket-acl --bucket $bucket --acl public-read --profile $PROFILE

curl -H "Accept: application/json" https://icanhazdadjoke.com/ > badfile.json
echo ""
Expand All @@ -58,9 +59,9 @@ aws s3api delete-bucket --bucket $bucket --profile $PROFILE

# Exit back out to our regular context
echo "${grn}Cleaning up..."
aws iam detach-user-policy --user-name $USERNAME --policy-arn arn:aws:iam::aws:policy/PowerUserAccess
aws iam delete-access-key --access-key-id $KEY --user-name $USERNAME
aws iam delete-user --user-name $USERNAME
aws iam detach-user-policy --user-name $USERNAME --profile $PROFILE --policy-arn arn:aws:iam::aws:policy/PowerUserAccess
aws iam delete-access-key --access-key-id $KEY --user-name $USERNAME --profile $PROFILE
aws iam delete-user --user-name $USERNAME --profile $PROFILE
rm creds.json

echo ""
Expand Down