Files
bintec-w2044ax-firmware-qemu/extract.sh
T

51 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Phase 2: Firmware extrahieren + Inventur. Aufruf: extract.sh <pfad-zum-img>
set -euo pipefail
IMG="$1"
WORK="${WORK:-/build/work}"
LOGS="${LOGS:-/build/logs}"
export WORK
mkdir -p "$WORK" "$LOGS"
echo "== carve.py =="
python3 /build/carve.py "$IMG" | tee "$LOGS/carve.log"
echo "== unsquashfs =="
unsquashfs -no-progress -f -d "$WORK/rootfs" "$WORK/rootfs.squashfs" \
> "$LOGS/unsquashfs.log" 2>&1
echo "RootFS entpackt: $(du -sh "$WORK/rootfs" | cut -f1)"
echo "== Inventur =="
R="$WORK/rootfs"
set +e
{
echo "### RootFS-Baum (Tiefe 2)"
find "$R" -maxdepth 2 | sort | head -200
echo; echo "### os-release / openwrt / banner"
cat "$R"/etc/os-release 2>/dev/null
cat "$R"/etc/openwrt_release 2>/dev/null
cat "$R"/etc/banner* 2>/dev/null
echo; echo "### init"
ls -l "$R/sbin/init" 2>/dev/null
ls "$R/etc/init.d" 2>/dev/null | head -60
echo; echo "### systemd?"
ls "$R/lib/systemd/systemd" 2>/dev/null
file "$R/sbin/init" "$R/lib/systemd/systemd" 2>/dev/null
echo; echo "### libc"
file "$R/lib/aarch64-linux-gnu/libc.so.6" 2>/dev/null
file "$R/usr/bin/python3" 2>/dev/null
echo; echo "### osdx / vyatta / frr"
ls "$R/etc/osdx" 2>/dev/null | head -30
ls "$R/opt/vyatta" 2>/dev/null | head -30
ls "$R/opt/qsdk" 2>/dev/null | head -20
echo; echo "### webserver-kandidaten"
find "$R" -maxdepth 4 -type f \( -iname '*http*' -o -iname '*nginx*' -o -iname '*lighttpd*' -o -iname '*uhttpd*' \) 2>/dev/null | head -20
echo; echo "### kernel-Module"
ls "$R/lib/modules" 2>/dev/null || echo "keine /lib/modules"
echo; echo "### groesste Verzeichnisse"
du -x -d1 "$R" 2>/dev/null | sort -h | tail -15
} > "$LOGS/inventory.txt" 2>&1
set -e
echo "Inventur: $LOGS/inventory.txt"
file "$WORK/kernel.img" || true