-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script which extracts blobs from romdump.
- Loading branch information
Your Name
committed
May 30, 2020
1 parent
04b6557
commit 6e19100
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
|
||
function printusage { | ||
echo "Usage: $0 -f <romdump> -m <me_cleaner> -i <ifdtool>" | ||
exit 0 | ||
} | ||
|
||
BLOBDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
MECLEAN="$BLOBDIR/me_cleaner/me_cleaner.py" | ||
IFDTOOL="$BLOBDIR/ifdtool/ifdtool" | ||
|
||
if [ "$#" -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; | ||
then printusage; fi | ||
|
||
while getopts ":f:m:i:" opt; do | ||
case $opt in | ||
f) | ||
FILE="$OPTARG" | ||
;; | ||
m) | ||
if [ -x "$OPTARG" ]; then | ||
MECLEAN="$OPTARG" | ||
fi | ||
;; | ||
i) | ||
if [ -x "$OPTARG" ]; then | ||
IFDTOOL="$OPTARG" | ||
fi | ||
;; | ||
esac | ||
done | ||
|
||
if [ ! -f "$FILE" ]; then | ||
echo "romdump required but not found. Aborting." | ||
exit 1; | ||
fi | ||
|
||
if [ ! -f "$MECLEAN" ]; then | ||
echo "me_cleaner.py required but not found. Aborting." | ||
exit 1; | ||
fi | ||
MECLEAN=$(realpath $MECLEAN) | ||
|
||
if [ ! -f "$IFDTOOL" ]; then | ||
echo "ifdtool required but not found. Aborting." | ||
exit 1; | ||
fi | ||
IFDTOOL=$(realpath $IFDTOOL) | ||
|
||
echo "FILE: $FILE" | ||
echo "ME: $MECLEAN" | ||
echo "IFD: $IFDTOOL" | ||
|
||
bioscopy=$(mktemp) | ||
extractdir=$(mktemp -d) | ||
|
||
cp "$FILE" $bioscopy | ||
|
||
cd "$extractdir" | ||
$IFDTOOL -x $bioscopy | ||
cp "$extractdir/flashregion_3_gbe.bin" "$BLOBDIR/gbe.bin" | ||
$MECLEAN -O "$BLOBDIR/me.bin" -r -t "$extractdir/flashregion_2_intel_me.bin" | ||
$IFDTOOL -n "$BLOBDIR/layout.txt" $bioscopy | ||
$IFDTOOL -x $bioscopy.new | ||
cp "$extractdir/flashregion_0_flashdescriptor.bin" "$BLOBDIR/ifd.bin" | ||
|
||
rm "$bioscopy" | ||
rm "$bioscopy.new" | ||
rm -r "$extractdir" |