Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Created August 6, 2018 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vgmoose/a6d820dc58c01180ce42e3ea85943320 to your computer and use it in GitHub Desktop.
Save vgmoose/a6d820dc58c01180ce42e3ea85943320 to your computer and use it in GitHub Desktop.
URL="https://dl.google.com/dl/android/aosp/ryu-opm4.171019.021.n1-factory-1f31fdce.zip"
TMP="tmp.zip"
OUT="output.zip"
# fetch the important "PK" region from the remote zip by specifying offsets*
curl --header "Range: bytes=1842-3820027" -k $URL > $TMP
# restore "corrupted" zip data (answer yes to question it prompts)
echo y | zip -FF $TMP --out $OUT
# extract from fixed zip
unzip $OUT
# to find this "PK" region, it will have to be discovered ahead of time, but it corresponds to
# the region of the zip file between two stretches of "PK" headers (0x504B01) that contain the
# filename of the target file to be extracted (in this case, they surround the first instance
# the string "bootloader-dragon-google_smaug.7900.126.0.img" appears in the HEX)
# to understand this better, you can look at the region from the curl command in a hex
# editor for the above URL, as they are hardcoded for that zip (in hex, offsets: 0x732 - 0x3a49fb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment