mirror of
https://gist.github.com/3793a40dd0c7930f12b79ca1931a3296.git
synced 2025-06-19 06:05:39 -04:00
This commit is contained in:
parent
a4eb0307a7
commit
83aadd766a
@ -1,5 +1,6 @@
|
|||||||
# extract-updater-rofs
|
# extract-updater-rofs
|
||||||
# Extracts firmware CIAs from ROFS containers for some gigaleak SystemUpdaters.
|
# Extracts firmware CIAs from ROFS containers for some gigaleak SystemUpdaters.
|
||||||
|
# Place in same directory as ROFS named "romfs.bin"
|
||||||
|
|
||||||
echo "Finding CIA headers in file..."
|
echo "Finding CIA headers in file..."
|
||||||
od -t x -A d romfs.bin | grep "00002020 00000000 00000a00 00000350" | sed 's/ .*//' | sed 's/^0*//' > romfs-dir.txt
|
od -t x -A d romfs.bin | grep "00002020 00000000 00000a00 00000350" | sed 's/ .*//' | sed 's/^0*//' > romfs-dir.txt
|
||||||
@ -71,15 +72,14 @@ do
|
|||||||
i+=2
|
i+=2
|
||||||
done
|
done
|
||||||
|
|
||||||
i=$((i - 1))
|
|
||||||
START_HEADER=$( tail -n 1 romfs-dir.txt )
|
START_HEADER=$( tail -n 1 romfs-dir.txt )
|
||||||
NEXT_HEADER=$(xxd romfs.bin | grep "226e 6f6e 6522" | sed 's/: .*//' | sed 's/^0*//');
|
NEXT_HEADER=$((16#$(xxd romfs.bin | grep "226e 6f6e 6522" | sed 's/: .*//' | sed 's/^0*//')));
|
||||||
# Find "226e 6f6e 6522" as it is the last predictable data to mark the end of Contents.cnt and the last CIA.
|
# Find "226e 6f6e 6522" as it is the last predictable data to mark the end of Contents.cnt and the last CIA.
|
||||||
# Upsettingly I have to use xxd because od wouldn't turn up any results for this... I liked od's formatting more :despair:
|
# Upsettingly I have to use xxd because od wouldn't turn up any results for this... I liked od's formatting more :despair:
|
||||||
echo " Check CIA length"
|
echo " Check CIA length"
|
||||||
echo "CIA $i header at ${START_HEADER}"
|
echo "Final CIA header at ${START_HEADER}"
|
||||||
echo "Contents.cnt end at ${NEXT_HEADER}"
|
echo "Contents.cnt end at ${NEXT_HEADER}"
|
||||||
echo "Finding end of CIA $i from Contents.cnt end..."
|
echo "Finding end of final CIA from Contents.cnt end..."
|
||||||
y="00"
|
y="00"
|
||||||
x=16
|
x=16
|
||||||
# Start x as 16 to skip changing data and go right to padding
|
# Start x as 16 to skip changing data and go right to padding
|
||||||
@ -93,10 +93,10 @@ while [ "$y" = "00" ]; do
|
|||||||
done
|
done
|
||||||
echo "End found!"
|
echo "End found!"
|
||||||
echo "Non-zerobyte ($y) at $((NEXT_HEADER - x))"
|
echo "Non-zerobyte ($y) at $((NEXT_HEADER - x))"
|
||||||
echo "Padding from CIA $i to Content.cnt end is $((x - 1)) bytes."
|
echo "Padding from final CIA to Content.cnt end is $((x - 1)) bytes."
|
||||||
echo " Extract CIA"
|
echo " Extract CIA"
|
||||||
CIA_LENGTH=$(((NEXT_HEADER - START_HEADER) - x + 1))
|
CIA_LENGTH=$(((NEXT_HEADER - START_HEADER) - x + 1))
|
||||||
dd skip=${START_HEADER} count=${CIA_LENGTH} if=romfs.bin of="$i.cia" bs=1
|
dd skip=${START_HEADER} count=${CIA_LENGTH} if=romfs.bin of="0.cia" bs=1
|
||||||
echo "CIA $i output as '$i.cia', ${CIA_LENGTH} bytes."
|
echo "Final CIA output as '0.cia', ${CIA_LENGTH} bytes."
|
||||||
echo "================================================="
|
echo "================================================="
|
||||||
echo "All CIAs extracted from RomFS!"
|
echo "All CIAs extracted from RomFS!"
|
Loading…
Reference in New Issue
Block a user