Skip to content

Commit e6e55de

Browse files
committed
finds root differently
1 parent 80553be commit e6e55de

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

entrypoint.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,30 @@ else
3737
fi
3838

3939
# find the squashfs root within each extracted firmware sample
40-
OLD_ROOT=$(find "$OUTDIR/$OLD_FW" -type d \( -name squashfs-root -o -name cpio-root \) | head -n 1)
41-
NEW_ROOT=$(find "$OUTDIR/$NEW_FW" -type d \( -name squashfs-root -o -name cpio-root \) | head -n 1)
40+
find_rootfs() {
41+
SEARCH_DIR="$1"
42+
# search for any directory that contains typical rootfs directories
43+
while IFS= read -r dir; do
44+
if [[ -d "$dir/etc" || -d "$dir/bin" || -d "$dir/sbin" ]]; then
45+
echo "$dir"
46+
return 0
47+
fi
48+
done < <(find "$SEARCH_DIR" -type d)
49+
50+
return 1
51+
}
52+
53+
OLD_ROOT=$(find_rootfs "$OUTDIR/$OLD_FW")
54+
NEW_ROOT=$(find_rootfs "$OUTDIR/$NEW_FW")
55+
4256
if [[ -z "$OLD_ROOT" || -z "$NEW_ROOT" ]]; then
43-
echo "[!] Could not find squashfs-root in one of the firmwares!"
57+
echo "[!] Could not detect root filesystem in one of the firmware images!"
4458
exit 1
4559
fi
4660

61+
echo "[+] OLD ROOTFS: $OLD_ROOT"
62+
echo "[+] NEW ROOTFS: $NEW_ROOT"
63+
4764
# run recursive diff and only report differing files, comparing the old to new
4865
echo "[*] Comparing filesystem trees..."
4966
DIFF_OUT=/outputs/firmware_diff_flat.json

0 commit comments

Comments
 (0)