Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Created August 26, 2017 20:21
Show Gist options
  • Save salrashid123/b15d6bf826292deb90ebca10d160d1a5 to your computer and use it in GitHub Desktop.
Save salrashid123/b15d6bf826292deb90ebca10d160d1a5 to your computer and use it in GitHub Desktop.
$ python message_util.py read resp.bin
Got wire_message: 00000000120a1048656c6c6f2c206a6f686e20646f6521
Proto Decode: Hello, john doe!
def r(filename):
f = open(filename, "rb")
wire_msg = binascii.b2a_hex(f.read())
f.close()
print 'Got wire_message: ' + wire_msg
message_length = wire_msg[4:10]
msg = wire_msg[10:10+int(message_length, 16)*2]
r = echo_pb2.EchoReply()
r.ParseFromString(binascii.a2b_hex(msg))
print 'Proto Decode: ' + r.message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment