pmaports/device/testing/device-amazon-soho/amazon-omap-boot-hack.sh
kekzoz 08bdfccec7
amazon-soho: Fix postprocess script (MR 2602)
[ci:skip-build] already built successfully in CI
2021-10-13 16:52:03 -07:00

12 lines
483 B
Bash

#!/bin/sh
echo "==> Amending boot.img for Amazon signature verification exploit"
SOHO_HEADER_DATA='\x50\x03\x00\x00\x00\x25\xe4\x00'
SOHO_HEADER_SIZE=848
SOHO_HEADER_OFFSET=52
tempfile=$(mktemp)
bootimgfile=$(echo "${1}" | sed 's/initramfs/boot.img/g')
dd if=/dev/zero of="${tempfile}" bs=$SOHO_HEADER_SIZE count=1
printf "%b" $SOHO_HEADER_DATA | dd of="${tempfile}" bs=$SOHO_HEADER_OFFSET seek=1 conv=notrunc
cat "${bootimgfile}" >> "${tempfile}"
mv "${tempfile}" "${bootimgfile}"