Last active
June 29, 2021 21:52
-
-
Save tuupola/4dd26664e52c2fffd5bede658e84cb3b to your computer and use it in GitHub Desktop.
Extract protocol buffer messages from binary data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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