carstein / burp-extensions

Automatically exported from code.google.com/p/burp-extensions
30 stars 19 forks source link

Extension fails to parse JSON array element #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Get a server to respond with a JSON array (i.e. 
[{"key":"val"},{"key":"val"}])
2. View the extension logging (it shows an error)

What is the expected output? What do you see instead?
I expect the extension to properly parse and pretty print the array.

What version of the product are you using? On what operating system?
Latest (1.1)

Please provide any additional information below.
The problem is with the garbage removal code. It will remove anything 
(including the '[') before the first '{'.
This issue can be resolved by changing some code in setMessage:

      if msg[len(msg)-1:] == "]":
        garbageChr = "["
      else:
        garbageChr = "{"

      garbage = msg[:msg.find(garbageChr)]
      clean = msg[msg.find(garbageChr):]

Also, the getMessage function should be changed:

        if pre_data[len(pre_data)-1:] == "]":
            garbageChr = "["
        else:
            garbageChr = "{"

        garbage = pre_data[:pre_data.find(garbageChr)]
        clean = pre_data[pre_data.find(garbageChr):]

I attached the new file. I'm not very good with Python but it all seems to be 
working for me.

PS I also fixed an issue in the getMessage method where the extension tried to 
do an array.find() which doesn't work. Fix:

  def getMessage(self): 
    if self._txtInput.isTextModified():
      try:
        pre_data = self._txtInput.getText().tostring()

Original issue reported on code.google.com by ni...@vrijbuiters.nl on 22 Jul 2015 at 2:57

Attachments:

carstein commented 9 years ago

Fixed now, should work correctly.