| skipped 33 lines |
34 | 34 | | from ui import ParameterProcessingRulesTable |
35 | 35 | | |
36 | 36 | | |
37 | | - | CONTENT_PROTOBUF = ('application/x-protobuf', 'application/x-protobuffer', 'application/x-protobuffer; charset=utf-8', 'application/octet-stream') |
| 37 | + | CONTENT_PROTOBUF = ('application/grpc-web+proto') |
| 38 | + | |
38 | 39 | | PROTO_FILENAME_EXTENSION_FILTER = FileNameExtensionFilter("*.proto, *.py", |
39 | 40 | | ["proto", "py"]) |
40 | 41 | | CONTENT_GZIP = ('gzip') |
| skipped 36 lines |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | class BurpExtender(IBurpExtender, IMessageEditorTabFactory, ITab, IExtensionStateListener): |
80 | | - | EXTENSION_NAME = "Protobuf Decoder" |
| 81 | + | EXTENSION_NAME = "grpc-web-proto Decoder" |
81 | 82 | | |
82 | 83 | | def __init__(self): |
83 | 84 | | self.descriptors = OrderedDict() |
| skipped 6 lines |
90 | 91 | | def registerExtenderCallbacks(self, callbacks): |
91 | 92 | | self.callbacks = callbacks |
92 | 93 | | self.helpers = callbacks.getHelpers() |
93 | | - | |
94 | 94 | | self.enabled = False |
95 | 95 | | |
96 | 96 | | try: |
| skipped 62 lines |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | class ProtobufEditorTab(IMessageEditorTab): |
162 | | - | TAB_CAPTION = "Protobuf" |
| 162 | + | TAB_CAPTION = "grpc-web-proto" |
163 | 163 | | |
164 | 164 | | def __init__(self, extender, controller, editable): |
165 | 165 | | self.extender = extender |
| skipped 46 lines |
212 | 212 | | value = value.lower().strip() |
213 | 213 | | if value in CONTENT_PROTOBUF: |
214 | 214 | | return True |
215 | | - | |
216 | 215 | | return False |
217 | 216 | | |
218 | 217 | | def setMessage(self, content, isRequest): |
| skipped 23 lines |
242 | 241 | | else: |
243 | 242 | | body = content[info.getBodyOffset():].tostring() |
244 | 243 | | |
| 244 | + | #cut 5 bytes for grpc web |
| 245 | + | rawBytes = (content[info.getBodyOffset():]) |
| 246 | + | oldPadding = rawBytes[0:5] |
| 247 | + | rawBytes = rawBytes[5:] |
| 248 | + | body = rawBytes.tostring() |
| 249 | + | print(body) |
| 250 | + | |
| 251 | + | |
245 | 252 | | # process parameters via rules defined in Protobuf Decoder ui tab |
246 | 253 | | |
247 | 254 | | parameter = None |
| skipped 14 lines |
262 | 269 | | |
263 | 270 | | break |
264 | 271 | | |
| 272 | + | |
265 | 273 | | # Loop through all proto descriptors loaded |
266 | 274 | | |
267 | 275 | | for package, descriptors in self.descriptors.iteritems(): |
268 | 276 | | for name, descriptor in descriptors.iteritems(): |
269 | | - | |
| 277 | + | print(name,descriptor) |
270 | 278 | | try: |
271 | 279 | | print "Parsing message with proto descriptor %s (auto)." % (name) |
272 | 280 | | message = parse_message(descriptor, body) |
| skipped 61 lines |
334 | 342 | | |
335 | 343 | | try: |
336 | 344 | | merge_message(self.editor.getText().tostring(), message) |
| 345 | + | print(info.getHeaders()) |
337 | 346 | | headers = info.getHeaders() |
338 | 347 | | serialized = message.SerializeToString() |
339 | 348 | | |
| skipped 208 lines |
548 | 557 | | os.chdir(curdir) |
549 | 558 | | shutil.rmtree(tempdir) |
550 | 559 | | |
| 560 | + | |