Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Filename: cve_2021_3156_sudo_buffer_overflow.sh
- # Version: 1.0.0
- # Author: Jeoi Reqi
- # Vulnerability Source: https://nvd.nist.gov/vuln/detail/CVE-2021-3156
- #
- # Description:
- # This script identifies systems vulnerable to CVE-2021-3156, the Sudo Buffer Overflow Vulnerability.
- # The vulnerability arises in Sudo versions prior to 1.9.5p2 due to an off-by-one error, potentially leading to privilege escalation.
- #
- # Usage:
- # Execute the script using `./cve_2021_3156_sudo_buffer_overflow.sh`.
- #
- # Functions:
- # - check_for_vulnerability(): Determines if the system is vulnerable.
- check_for_vulnerability() {
- echo "Checking for CVE-2021-3156 Sudo Buffer Overflow Vulnerability..."
- # Check if Sudo is installed and if the vulnerable version is present
- if command -v sudo >/dev/null 2>&1; then
- sudo_version=$(sudo -V | grep "Sudo version" | awk '{print $3}')
- vulnerable_version="1.9.5p2"
- if [[ "$sudo_version" == "$vulnerable_version" ]]; then
- echo "Your Sudo version ($sudo_version) is vulnerable to CVE-2021-3156."
- echo "Immediate action is recommended to mitigate the risk."
- else
- echo "Your Sudo version ($sudo_version) is not vulnerable to CVE-2021-3156."
- echo "No further action is required at this time."
- fi
- else
- echo "Sudo is not installed on your system."
- echo "Please install Sudo to check for this vulnerability."
- fi
- }
- check_for_vulnerability
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement