Skip to content

Commit

Permalink
fix and document --linabins
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric Halbronn committed May 10, 2018
1 parent 7abac03 commit cb13411
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,52 @@ The remaining files for `asa981-smp-*` are there because of the failure. You can
use the idahunt scripts in [asadbg](https://github.com/nccgroup/asadbg) to
import the new `lina`. You can more specifically refer to the
`Importing additional symbols` section in the
[README](https://github.com/nccgroup/asadbg/README.md#Importing additional symbols).
[README](https://github.com/nccgroup/asadbg/blob/master/README.md#importing-additional-symbols).

## Retrieve lina and co files for future analysis

Because firmware files are quite big, and extracted files are even worse, it may be interesting
to extract each firmware, get the `lina`, `lina_monitor` files and then delete temporary
extracted files.

You can do it with the following command line:

```
$ unpack_repack_bin.sh -u -i /home/user/fw/ --linabins /home/user/linabins/ --delete-extracted
[unpack_repack_bin] Created /home/user/linabins/ directory
[unpack_repack_bin] Directory of firmware detected: /home/user/fw/
[unpack_repack_bin] extract_bin: asa924-25-k8.bin
[unpack_repack_bin] Extracted firmware to /home/user/fw/_asa924-25-k8.bin.extracted
[unpack_repack_bin] Firmware uses regular rootfs/ dir
[unpack_repack_bin] Extracting /home/user/fw/_asa924-25-k8.bin.extracted/rootfs/rootfs.img into /home/user/fw/_asa924-25-k8.bin.extracted/rootfs
[unpack_repack_bin] Deleting extracted files
[unpack_repack_bin] Deleting "/home/user/fw/_asa924-25-k8.bin.extracted"
[unpack_repack_bin] extract_bin: asa924-27-k8.bin
[unpack_repack_bin] Extracted firmware to /home/user/fw/_asa924-27-k8.bin.extracted
[unpack_repack_bin] Firmware uses regular rootfs/ dir
[unpack_repack_bin] Extracting /home/user/fw/_asa924-27-k8.bin.extracted/rootfs/rootfs.img into /home/user/fw/_asa924-27-k8.bin.extracted/rootfs
[unpack_repack_bin] Deleting extracted files
[unpack_repack_bin] Deleting "/home/user/fw/_asa924-27-k8.bin.extracted"
[unpack_repack_bin] extract_bin: asa924-k8.bin
[unpack_repack_bin] Extracted firmware to /home/user/fw/_asa924-k8.bin.extracted
[unpack_repack_bin] Firmware uses regular rootfs/ dir
[unpack_repack_bin] Extracting /home/user/fw/_asa924-k8.bin.extracted/rootfs/rootfs.img into /home/user/fw/_asa924-k8.bin.extracted/rootfs
[unpack_repack_bin] Deleting extracted files
[unpack_repack_bin] Deleting "/home/user/fw/_asa924-k8.bin.extracted"
$ tree /home/user/linabins/
/home/user/linabins/
├── asa924-25-k8.bin
│   ├── lina
│   └── lina_monitor
├── asa924-27-k8.bin
│   ├── lina
│   └── lina_monitor
└── asa924-k8.bin
├── lina
└── lina_monitor
3 directories, 6 files
```

# unpack_repack_qcow2.sh

Expand Down
10 changes: 8 additions & 2 deletions unpack_repack_bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ usage()
echo " # Repack an already unpacked firmware dir, freeing space and patching lina_monitor to bypass checksum validation"
echo " ./unpack_repack_bin.sh --repack-only -i _asa924-smp-k8.bin.extracted --output-bin asa924-smp-k8-repacked.bin --original-firmware /home/user/firmware/asa924-smp-k8.bin --free-space --replace-linamonitor /home/user/firmware/lina_monitor_patched"
echo " # Unpack and repack a firmware file, freeing space, enabling gdb, debug shell and linahook"
echo " ./unpack_repack_bin.sh -i asa924-smp-k8.bin -f -g -b -H"
echo " ./unpack_repack_bin.sh -i asa924-smp-k8.bin -f -g -b -H hat"
exit 1
}

Expand Down Expand Up @@ -942,12 +942,18 @@ then
usage
fi

if [[ -d $INPUTFW && -z $OUTDIR && -z $OUTBIN ]]
if [[ -d $INPUTFW && -z $OUTDIR && -z $OUTBIN && "${UNPACK_ONLY}" == "NO" ]]
then
log "ERROR: You must specify an output directory with --output (-o) when specifying a directory with --input (-i)"
usage
fi

if [[ ! -z $OUTDIR && "${UNPACK_ONLY}" == "YES" ]]
then
log "ERROR: --output (-o) is ignored if --unpack-only (-u) is specified"
usage
fi

if [[ -f $INPUTFW && ! -z $OUTDIR ]]
then
log "ERROR: --output (-o) is ignored if --input (-i) is a file"
Expand Down

0 comments on commit cb13411

Please sign in to comment.