mirror of
https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite.git
synced 2026-02-09 14:16:33 +00:00
improved support az metadata
This commit is contained in:
@@ -16,10 +16,28 @@
|
||||
check_az_vm(){
|
||||
is_az_vm="No"
|
||||
|
||||
# 1. Check if the Azure log directory exists
|
||||
if [ -d "/var/log/azure/" ]; then
|
||||
is_az_vm="Yes"
|
||||
|
||||
elif cat /etc/resolv.conf 2>/dev/null | grep -q "search reddog.microsoft.com"; then
|
||||
|
||||
# 2. Check if 'reddog.microsoft.com' is found in /etc/resolv.conf
|
||||
elif grep -q "search reddog.microsoft.com" /etc/resolv.conf 2>/dev/null; then
|
||||
is_az_vm="Yes"
|
||||
|
||||
else
|
||||
# 3. Try querying the Azure Metadata Service for more wide support (e.g. Azure Container Registry tasks need this)
|
||||
if command -v curl &> /dev/null; then
|
||||
response=$(curl -s --max-time 2 \
|
||||
"http://169.254.169.254/metadata/identity/oauth2/token")
|
||||
if echo "$response" | grep -q "Missing"; then
|
||||
is_az_vm="Yes"
|
||||
fi
|
||||
elif command -v wget &> /dev/null; then
|
||||
response=$(wget -qO- --timeout=2 \
|
||||
"http://169.254.169.254/metadata/identity/oauth2/token")
|
||||
if echo "$response" | grep -q "Missing"; then
|
||||
is_az_vm="Yes"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user