Skip to content

Instantly share code, notes, and snippets.

@b1tninja
Last active October 22, 2019 10:30
Show Gist options
  • Save b1tninja/35cb36f65be698dca14e745da46c7fb7 to your computer and use it in GitHub Desktop.
Save b1tninja/35cb36f65be698dca14e745da46c7fb7 to your computer and use it in GitHub Desktop.
kcrctab from /dev/mem
offsets=($(egrep "__kcrctab" /proc/kallsyms | cut -d " " -f 1 | sort -u));
for ((i=0; i<$((${#offsets[@]}-1)); i++)); do
start=$((0x${offsets[$i]}));
stop=$((0x${offsets[(($i+1))]}));
len=$(($stop-$start));
dd if=/dev/mem bs=${len} skip=${start} count=1 status=none;
done | od --endian little -t x4 -w4 -A
"${OBJCOPY}" -I binary -O elf32-littlearm --add-section '.modinfo'=<(sed -re "s/(vermagic=)[^\0]*/\1$(modinfo -F vermagic "${KNOWNGOOD}")/" <("${OBJCOPY}" -j '.modinfo' -I elf32-littlearm -O binary "${FIXUP}" /dev/stdout)) "${FIXUP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment