-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec2-enum.sh
More file actions
14 lines (14 loc) · 822 Bytes
/
ec2-enum.sh
File metadata and controls
14 lines (14 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#/bin/bash
trap exit INT
INSTANCES=$( aws --profile=%YOURPROFILEGOESHERE% ec2 describe-instances --query 'Reservations[].Instances[].InstanceId[]' | sed -e 's/\[//g' -e 's/\]//g')
SUM=0
echo $INSTANCES
for i in $( echo $INSTANCES | sed -e 's/"//g' -e 's/,//g' -e 's/\[//g' -e 's/\]//g' ) ;do
echo "---------------------------$i-------------------------------\n"
aws --profile=%YOURPROFILEGOESHERE% ec2 describe-instances --instance-ids $i --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value' --output text
aws --profile=%YOURPROFILEGOESHERE% ec2 describe-instance-attribute --instance-id $( echo $i | sed -e 's/"//g' -e 's/,//' -e 's/\[//g' -e 's/\]//g' ) --attribute userData \
| jq '.UserData.Value' | sed 's/"//g' | base64 --decode
((SUM += 1))
echo "\n"
done
echo "Total Number of Servers: $SUM"