Skip to content

[REQ] - If online checksum check fails fallback to using offline checksum check #593

Description

@Razor221

According to merlin's recent post and i quote

"My hosting provider regularly gets flooded with bots, in which case they end up blocking multiple IP ranges (sometimes entire countries). Nothing I can do about.

I'm just surprised that despite the site being behind Cloudflare, the provider can still end up blocking visitors even tho these shouldn't be going through Cloudflare, not directly accessing the website. I suspect they might be looking at the IP of origin header that Cloudflare publishes."

Problem is Turkish ip addresses are usually first ones to get to the chopping block. I tried to update fw 3006.102.8_4 on my asus rt-88u-pro but merlin au script kept failing in online checksum checking because of 403 error on https://www.asuswrt-merlin.net/download.

So, I modified your script and changed the online checksum verification code to fallback to offline checksum verification if online verification fails.

Here is my modified online checksum check with offline fallback.

`CheckOnlineFirmwareSHA256()
{
# Fetch the latest SHA256 checksums from ASUSWRT-Merlin website #
checksums="$(curl -Ls --retry 4 --retry-delay 5 --retry-connrefused
https://www.asuswrt-merlin.net/download |
sed -n '/<.>SHA256 signatures:</.>/,/</pre>/p' |
sed -n '/<pre[^>].>/,/</pre>/p' |
sed -e 's/<[^>].
>//g; s/^[[:space:]]//; s/[[:space:]]$//')"

if [ -z "$checksums" ]
then
    Say "${YELLOWct}**WARNING**${NOct}: Could not fetch signatures online (HTTP 403/Block)."
    Say "Falling back to offline SHA256 verification..."
    _CheckOfflineFirmwareSHA256_
    return $?
fi

if [ -f "$firmware_file" ]
then
    fw_sig="$(openssl sha256 "$firmware_file" | awk -F ' ' '{print $2}')"
    dl_sig="$(echo "$checksums" | grep "$(basename "$firmware_file")" | awk -F ' ' '{print $1}')"
    if [ "$fw_sig" != "$dl_sig" ]
    then
        Say "${REDct}**ERROR**${NOct}: SHA256 signature from extracted firmware file does not match the SHA256 signature from the website."
        _DoCleanUp_ 1
        _SendEMailNotification_ FAILED_FW_CHECKSUM_STATUS
        return 1
    else
        Say "SHA256 signature check for firmware image file passed successfully."
        return 0
    fi
else
    Say "${REDct}**ERROR**${NOct}: Firmware image file NOT found!"
    _DoCleanUp_ 1
    return 1
fi

}`

I also share my full MerlinAU.sh for troubleshooting as well.

MerlinAU.sh

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions