File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737fi
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+
4256if [[ -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
4559fi
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
4865echo " [*] Comparing filesystem trees..."
4966DIFF_OUT=/outputs/firmware_diff_flat.json
You can’t perform that action at this time.
0 commit comments