Skip to content

Instantly share code, notes, and snippets.

@tuupola
Last active June 29, 2021 21:52
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuupola/4dd26664e52c2fffd5bede658e84cb3b to your computer and use it in GitHub Desktop.
Save tuupola/4dd26664e52c2fffd5bede658e84cb3b to your computer and use it in GitHub Desktop.
Extract protocol buffer messages from binary data
#!/bin/bash
#
# Try to decode hidden protocol buffers message from binary
size=$(wc -c < $1)
for ((i=1; i<=$size; i++))
do
# Skip $i bytes and decode
dd if=$1 bs=1 skip=$i | protoc --decode_raw
if [[ $? == 0 ]]
then
printf "\n"
read -p "Removed $i bytes, continue? [Yy] " -n 1 -r
printf "\n\n"
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 0
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment