Skip to content

Instantly share code, notes, and snippets.

@DamnedFacts
Created May 15, 2019 16:38
Show Gist options
  • Save DamnedFacts/2e1ba1001f6c20ba46f837089b602a0d to your computer and use it in GitHub Desktop.
Save DamnedFacts/2e1ba1001f6c20ba46f837089b602a0d to your computer and use it in GitHub Desktop.

Revisions

  1. DamnedFacts created this gist May 15, 2019.
    9 changes: 9 additions & 0 deletions mount_vdi.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/bin/sh

    TEMP="$1.$$.img"
    trap "rm -f $TEMP 2>/dev/null" 1 2 3 11 15
    offset=`hexdump -s 0x158 -n 4 "$1" | head -1 | awk '{print $5 $4 $3 $2}'`
    offset512=`echo "obase=16; ibase=16; $offset / 200" | bc`
    ln "$1" "$TEMP"
    hdiutil attach "$TEMP" -nomount -section "0x$offset512"
    rm -f "$TEMP"