Skip to content

Instantly share code, notes, and snippets.

@gorillamoe
Created March 31, 2024 11:45
Show Gist options
  • Save gorillamoe/5922aa7b410ea6f03a57d25490492c02 to your computer and use it in GitHub Desktop.
Save gorillamoe/5922aa7b410ea6f03a57d25490492c02 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
VULNERABLE_MESSAGE="vulnerable"
SAFE_MESSAGE="safe"
if command -v apt-get &>/dev/null; then
PKG_MANAGER="apt-get"
elif command -v zypper &>/dev/null; then
PKG_MANAGER="zypper"
else
echo "unsupported system"
exit 1
fi
if [ "$PKG_MANAGER" = "zypper" ]; then
version=$(rpm -q xz)
if [[ $version =~ (5\.6\.(0|1)) ]]; then
echo "$VULNERABLE_MESSAGE"
else
echo "$SAFE_MESSAGE"
fi
elif [ "$PKG_MANAGER" = "apt-get" ]; then
version=$(dpkg -l | grep "xz-utils" | awk '{print $3}')
if [[ "$version" == *"5.6.0"* || "$version" == *"5.6.1"* ]]; then
echo "$VULNERABLE_MESSAGE"
else
echo "$SAFE_MESSAGE"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment