From 3012684042381defce08f30320a4ab4fd5f4c774 Mon Sep 17 00:00:00 2001 From: Sergio de Miguel Date: Thu, 13 Feb 2020 14:39:59 +0100 Subject: [PATCH] Bug fix when re-serializing messages without padding --- protoburp.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/protoburp.py b/protoburp.py index 92759cb..c73b327 100755 --- a/protoburp.py +++ b/protoburp.py @@ -268,9 +268,12 @@ def setMessage(self, content, isRequest): #set message rawBytes = (content[info.getBodyOffset():]) global oldPadding + global hasPadding + hasPadding = False oldPadding= rawBytes[0:4] if rawBytes[0] == 0 and rawBytes[1] == 0 and rawBytes[2] == 0 and rawBytes[3] == 0: rawBytes = rawBytes[5:rawBytes[4]+5] + hasPadding = True body = rawBytes.tostring() # Loop through all proto descriptors loaded @@ -346,9 +349,10 @@ def getMessage(self): headers = info.getHeaders() serialized = message.SerializeToString() + if hasPadding: + oldPadding.append(len(serialized)) + serialized = oldPadding.tostring() + serialized - oldPadding.append(len(serialized)) - serialized = oldPadding.tostring() + serialized if parameter is not None: rules = self.extender.table.getParameterRules().get(parameter.getName(), {}) @@ -514,9 +518,12 @@ def actionPerformed(self, event): # cut 5 bytes for grpc web rawBytes = (content[info.getBodyOffset():]) global oldPadding + global hasPadding + hasPadding = False oldPadding= rawBytes[0:4] if rawBytes[0] == 0 and rawBytes[1] == 0 and rawBytes[2] == 0 and rawBytes[3] == 0: rawBytes = rawBytes[5:] + hasPadding = True body = rawBytes.tostring()