LevelBlue Completes Acquisition of Cybereason. Learn more

LevelBlue Completes Acquisition of Cybereason. Learn more

Services
Cyber Advisory
Managed Cloud Security
Data Security
Manage Detection & Response
Email Security
Managed Network Infrastructure Security
Exposure Management
Security Operations Platforms
Incident Readiness & Response
SpiderLabs Threat Intelligence
Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Operational Technology
End-to-end OT security
Microsoft Security
Unlock the full power of Microsoft Security
Securing the IoT Landscape
Test, monitor and secure network objects
Why LevelBlue
About Us
Awards and Accolades
LevelBlue SpiderLabs
LevelBlue Security Operations Platforms
Security Colony
Partners
Microsoft
Unlock the full power of Microsoft Security
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings

JSON Crypto Helper a Ruby-based Burp Extension for JSON Encryption/Decryption - Part III

This is the third in a three-part series about how to write a simple Ruby extension that helps deal with encrypted JSON messages. So far we have covered how to decrypt and encrypt JSON messages using Burp Extender and JRuby (read the first and second parts). Now, let's do something awesome with it! The complete extension code is available here.

In this third and last post of the series, we will cover how to automatically encrypt the payloads used by the Intruder tool. You will be able to use any plaintext dictionary or any generated payload (using Burp payload generators) and encrypt the JSON values transparently before sending the requests.

 

Payload Processing with Intruder Tool

First, in order to process the payloads you will need to register and implement the IntruderPayloadProcessor interface:

class BurpExtender
include IBurpExtender
include IMessageEditorTabFactory
include IIntruderPayloadProcessor
include EncryptionHelper
attr_reader :callbacks

def registerExtenderCallbacks(callbacks)
@callbacks = callbacks
callbacks.setExtensionName("JSON Crypto Helper")
callbacks.registerMessageEditorTabFactory(self)
callbacks.registerIntruderPayloadProcessor(self)
end
...[SNIP]...

Note that you also need to include the EncryptionHelper module, as you will need to have access to the encryption routines later. Also, don't forget to include the related Java interface:

java_import 'burp.IIntruderPayloadProcessor'

This time, you just need to implement the two following methods in the BurpExtender class:

  • #getProcessorName: the payload processor name.
def getProcessorName
"JSON Crypto Helper"
end
  • #processPayload: the method that will take care of processing each payload.
def processPayload(currentPayload, originalPayload, baseValue)
return currentPayload if currentPayload.nil? or currentPayload.empty?
payload = encode_b64(encrypt(currentPayload.to_s))
return payload.to_java_bytes
end

This method provides 3 arguments:

  • currentPayload: the payload to be processed.
  • originalPayload: the payload before any previous processing. As you can chain the payload processors in Burp, the currentPayload could be the result of other processing. In some case, it could be useful to know the original value.
  • baseValue: the value of the original request, before being substituted by any payload.

The logic is pretty straightforward: retrieve the payload, encrypt it using the same routines you used before and base64-encode it.

Let's perform a basic fuzz:

11120_a9c456fe-4f1f-493c-9427-9634d6cf8cfc

The new payload processor appears on the available processor list: Payload Processor > Add > Invoke Burp Extension > Crypto Helper.

7620_00e3a8d6-d51f-42f8-a6bd-d4f3ae58dd1e

8240_1df21867-9bbc-40d6-96dc-069c1b7358d2

The result shows the values were successfully encrypted and the server replied with the correct decrypted values.

10645_92e77543-db78-4bed-a8bf-bc833d0f5eee

9233_4f6c2dd6-8dd2-4ff3-a954-e77fe71a5be6

Conclusion

The Extender tool and the rich API provided by Burp can be very useful during web application security assessments. This example is very basic, but I hope it will be a good introduction to Burp extension development. Don't hesitate to comment and share your ideas.

Also, I highly recommend having a look at the multiple extensions available in the Burp App Store.

Happy hacking!

ABOUT LEVELBLUE

LevelBlue is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo