Skip to content

Commit 94da9fb

Browse files
Improved SHA256 Signature Extraction
Code improvements for extracting SHA256 signatures.
1 parent 5296f3b commit 94da9fb

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

MerlinAU.sh

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Original Creation Date: 2023-Oct-01 by @ExtremeFiretop.
66
# Official Co-Author: @Martinski W. - Date: 2023-Nov-01
7-
# Last Modified: 2025-Feb-16
7+
# Last Modified: 2025-Feb-17
88
###################################################################
99
set -u
1010

@@ -3574,22 +3574,17 @@ _CopyGnutonFiles_()
35743574
return 0
35753575
}
35763576

3577-
##------------------------------------------##
3578-
## Modified by ExtremeFiretop [2024-Jul-24] ##
3579-
##------------------------------------------##
3577+
##----------------------------------------##
3578+
## Modified by Martinski W. [2025-Feb-17] ##
3579+
##----------------------------------------##
35803580
_CheckOnlineFirmwareSHA256_()
35813581
{
35823582
# Fetch the latest SHA256 checksums from ASUSWRT-Merlin website #
3583-
checksums="$(
3584-
curl -Ls --retry 4 --retry-delay 5 --retry-connrefused \
3585-
https://www.asuswrt-merlin.net/download |
3586-
sed -n '/<.*>SHA256 signatures:<\/.*>/,/<\/pre>/p' |
3587-
sed -n '/<pre[^>]*>/,/<\/pre>/p' |
3588-
sed -e 's/<[^>]*>//g' |
3589-
tr -d '\r' |
3590-
sed -e 's/^[[:space:]]*//; s/[[:space:]]*$//' |
3591-
sed -e 's/SHA256 signatures:Latest release://'
3592-
)"
3583+
checksums="$(curl -Ls --retry 4 --retry-delay 5 --retry-connrefused \
3584+
https://www.asuswrt-merlin.net/download |
3585+
sed -n '/<.*>SHA256 signatures:<\/.*>/,/<\/pre>/p' |
3586+
sed -n '/<pre[^>].*>/,/<\/pre>/p' |
3587+
sed -e 's/<[^>].*>//g; s/^[[:space:]]*//; s/[[:space:]]*$//')"
35933588

35943589
if [ -z "$checksums" ]
35953590
then
@@ -3600,9 +3595,9 @@ _CheckOnlineFirmwareSHA256_()
36003595

36013596
if [ -f "$firmware_file" ]
36023597
then
3603-
fw_sig="$(openssl sha256 "$firmware_file" | cut -d' ' -f2)"
3598+
fw_sig="$(openssl sha256 "$firmware_file" | awk -F ' ' '{print $2}')"
36043599
# Extract the corresponding signature for the firmware file from the fetched checksums #
3605-
dl_sig="$(echo "$checksums" | grep "$(basename "$firmware_file")" | cut -d' ' -f1)"
3600+
dl_sig="$(echo "$checksums" | grep "$(basename "$firmware_file")" | awk -F ' ' '{print $1}')"
36063601
if [ "$fw_sig" != "$dl_sig" ]
36073602
then
36083603
Say "${REDct}**ERROR**${NOct}: SHA256 signature from extracted firmware file does not match the SHA256 signature from the website."
@@ -3621,14 +3616,14 @@ _CheckOnlineFirmwareSHA256_()
36213616
}
36223617

36233618
##----------------------------------------##
3624-
## Modified by Martinski W. [2024-Jul-31] ##
3619+
## Modified by Martinski W. [2025-Feb-17] ##
36253620
##----------------------------------------##
36263621
_CheckOfflineFirmwareSHA256_()
36273622
{
36283623
if [ -f "sha256sum.sha256" ] && [ -f "$firmware_file" ]
36293624
then
3630-
fw_sig="$(openssl sha256 "$firmware_file" | cut -d' ' -f2)"
3631-
dl_sig="$(grep "$firmware_file" sha256sum.sha256 | cut -d' ' -f1)"
3625+
fw_sig="$(openssl sha256 "$firmware_file" | awk -F ' ' '{print $2}')"
3626+
dl_sig="$(grep "$firmware_file" sha256sum.sha256 | awk -F ' ' '{print $1}')"
36323627
if [ "$fw_sig" != "$dl_sig" ]
36333628
then
36343629
echo

0 commit comments

Comments
 (0)