Skip to content

Commit 7f4fef2

Browse files
Merge pull request #409 from Martinski4GitHub/WebFun
Improved SHA256 Signature Extraction
2 parents 7e7a49e + cfaedff commit 7f4fef2

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

@@ -4547,22 +4547,17 @@ _CopyGnutonFiles_()
45474547
return 0
45484548
}
45494549

4550-
##------------------------------------------##
4551-
## Modified by ExtremeFiretop [2024-Jul-24] ##
4552-
##------------------------------------------##
4550+
##----------------------------------------##
4551+
## Modified by Martinski W. [2025-Feb-17] ##
4552+
##----------------------------------------##
45534553
_CheckOnlineFirmwareSHA256_()
45544554
{
45554555
# Fetch the latest SHA256 checksums from ASUSWRT-Merlin website #
4556-
checksums="$(
4557-
curl -Ls --retry 4 --retry-delay 5 --retry-connrefused \
4558-
https://www.asuswrt-merlin.net/download |
4559-
sed -n '/<.*>SHA256 signatures:<\/.*>/,/<\/pre>/p' |
4560-
sed -n '/<pre[^>]*>/,/<\/pre>/p' |
4561-
sed -e 's/<[^>]*>//g' |
4562-
tr -d '\r' |
4563-
sed -e 's/^[[:space:]]*//; s/[[:space:]]*$//' |
4564-
sed -e 's/SHA256 signatures:Latest release://'
4565-
)"
4556+
checksums="$(curl -Ls --retry 4 --retry-delay 5 --retry-connrefused \
4557+
https://www.asuswrt-merlin.net/download |
4558+
sed -n '/<.*>SHA256 signatures:<\/.*>/,/<\/pre>/p' |
4559+
sed -n '/<pre[^>].*>/,/<\/pre>/p' |
4560+
sed -e 's/<[^>].*>//g; s/^[[:space:]]*//; s/[[:space:]]*$//')"
45664561

45674562
if [ -z "$checksums" ]
45684563
then
@@ -4573,9 +4568,9 @@ _CheckOnlineFirmwareSHA256_()
45734568

45744569
if [ -f "$firmware_file" ]
45754570
then
4576-
fw_sig="$(openssl sha256 "$firmware_file" | cut -d' ' -f2)"
4571+
fw_sig="$(openssl sha256 "$firmware_file" | awk -F ' ' '{print $2}')"
45774572
# Extract the corresponding signature for the firmware file from the fetched checksums #
4578-
dl_sig="$(echo "$checksums" | grep "$(basename "$firmware_file")" | cut -d' ' -f1)"
4573+
dl_sig="$(echo "$checksums" | grep "$(basename "$firmware_file")" | awk -F ' ' '{print $1}')"
45794574
if [ "$fw_sig" != "$dl_sig" ]
45804575
then
45814576
Say "${REDct}**ERROR**${NOct}: SHA256 signature from extracted firmware file does not match the SHA256 signature from the website."
@@ -4594,14 +4589,14 @@ _CheckOnlineFirmwareSHA256_()
45944589
}
45954590

45964591
##----------------------------------------##
4597-
## Modified by Martinski W. [2024-Jul-31] ##
4592+
## Modified by Martinski W. [2025-Feb-17] ##
45984593
##----------------------------------------##
45994594
_CheckOfflineFirmwareSHA256_()
46004595
{
46014596
if [ -f "sha256sum.sha256" ] && [ -f "$firmware_file" ]
46024597
then
4603-
fw_sig="$(openssl sha256 "$firmware_file" | cut -d' ' -f2)"
4604-
dl_sig="$(grep "$firmware_file" sha256sum.sha256 | cut -d' ' -f1)"
4598+
fw_sig="$(openssl sha256 "$firmware_file" | awk -F ' ' '{print $2}')"
4599+
dl_sig="$(grep "$firmware_file" sha256sum.sha256 | awk -F ' ' '{print $1}')"
46054600
if [ "$fw_sig" != "$dl_sig" ]
46064601
then
46074602
echo

0 commit comments

Comments
 (0)