Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- distrust() {
- echo "Rejecting local certificate trust chain"
- local config="/etc/ca-certificates.conf"
- local cert
- local found=0
- local changed=0
- if [ "$(id -u)" -ne 0 ]; then
- echo "Must run as root to update the system CA trust store" >&2
- return 1
- fi
- for cert in \
- "mozilla/Comodo_AAA_Services_root.crt" \
- "mozilla/emSign_ECC_Root_CA_-_G3.crt"
- do
- if [ ! -f "/usr/share/ca-certificates/$cert" ]; then
- echo "Certificate not found: $cert" >&2
- continue
- fi
- found=1
- if ! grep -Fxq "!$cert" "$config"; then
- if grep -Fxq "$cert" "$config"; then
- sed -i "s|^$cert\$|!$cert|" "$config" || return 1
- changed=1
- else
- echo "Certificate is not enabled in $config: $cert"
- fi
- fi
- done
- if [ "$found" -eq 0 ]; then
- echo "Neither certificate was found in the Debian CA store" >&2
- return 1
- fi
- if [ "$changed" -eq 0 ]; then
- echo "No enabled certificates needed disabling"
- return 1
- fi
- update-ca-certificates || return 1
- }
- if [ ! -f /etc/debian_version ]; then
- echo "Script designed for Debian-based systems" >&2
- exit 1
- fi
- if [ ! -x /usr/bin/curl ] || ! command -v update-ca-certificates >/dev/null 2>&1; then
- echo "Missing curl or update-ca-certificates" >&2
- exit 1
- fi
- urls="https://dv-g3b-emudhra.we-have-a-problem.com/
- https://dv-g3c-emudhra.we-have-a-problem.com/
- https://ov-g3b-emudhra.we-have-a-problem.com/
- https://ov-g3c-emudhra.we-have-a-problem.com/
- https://ev-g3b-emudhra.we-have-a-problem.com/
- https://ev-g3c-emudhra.we-have-a-problem.com/
- https://dv-g3b-aaa-emudhra.we-have-a-problem.com/
- https://dv-g3c-aaa-emudhra.we-have-a-problem.com/
- https://ov-g3b-aaa-emudhra.we-have-a-problem.com/
- https://ov-g3c-aaa-emudhra.we-have-a-problem.com/
- https://ev-g3b-aaa-emudhra.we-have-a-problem.com/
- https://ev-g3c-aaa-emudhra.we-have-a-problem.com/
- "
- vulnerable=0
- fixed=0
- fix_attempted=0
- for url in $urls; do
- echo "Trying $url"
- /usr/bin/curl "$url" -o /dev/null 2>/dev/null
- rc=$?
- if [ "$rc" -eq 0 ]; then
- vulnerable=1
- if [ "$fix_attempted" -eq 0 ]; then
- fix_attempted=1
- if distrust; then
- fixed=1
- fi
- fi
- elif [ "$rc" -eq 60 ]; then
- echo "Curl refused because of SSL - this is good."
- else
- echo "Some other network problem (curl exit $rc) - try again later."
- fi
- done
- if [ "$vulnerable" -eq 0 ]; then
- echo "Your system was not vulnerable"
- else
- echo "Your system was vulnerable"
- fi
- verified=0
- if [ "$fixed" -eq 1 ]; then
- verified=1
- for url in $urls; do
- echo "Verifying $url"
- /usr/bin/curl "$url" -o /dev/null 2>/dev/null
- rc=$?
- if [ "$rc" -ne 60 ]; then
- verified=0
- if [ "$rc" -eq 0 ]; then
- echo "Certificate verification still succeeds for $url"
- else
- echo "Could not verify $url (curl exit $rc)"
- fi
- fi
- done
- fi
- if [ "$fixed" -eq 0 ]; then
- echo "No fix was applied"
- elif [ "$verified" -eq 1 ]; then
- echo "System certificate fix was applied and verified"
- else
- echo "Trust-store update succeeded, but the certificate fix could not be verified"
- fi
Advertisement