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 II

This is the second post in a three-part series about how to write a simple Ruby extension that helps deal with encrypted JSON messages (read part one here). The complete extension code is available here.

In the last post we saw how to automatically decrypt JSON messages and display the well-formatted plaintext in a custom tab. This enabled you to easily read encrypted JSON requests captured by the Proxy tool.

In this post I will explain how to automatically encrypt JSON request values before sending it to the remote server. You will be able to write or modify any plaintext JSON and send it encrypted to the remote server using the Repeater tool.

Encrypting JSON

Let's say now the server accepts an encrypted JSON, processes it and returns the result. To keep it simple here, the fake server will simply return the decrypted value:

8863_3e20f18b-70b5-4397-aca4-f9c6233ade63

As can be seen, sending the original encrypted JSON in a POST request will result in the same decrypted values you had before. Now you want to be able to modify the plaintext JSON and send it encrypted to the server. To do so, you will need to process the message in the #getMessage method:

def getMessage
is_request = @txt_input.text[0..3].to_s == "HTTP"
if is_request
info = @helper.analyze_request(@txt_input.text)
else
info = @helper.analyze_response(@txt_input.text)
end
headers = @txt_input.text[ 0..(info.get_body_offset - 1) ].to_s
body = @txt_input.text[ info.get_body_offset..-1 ].to_s
body = process_json(body, :encrypt) if json?(info, is_request)
return (headers + body).to_java_bytes
end

As you can see, the logic is quite similar to #setMessage. It encrypts instead of decrypting and it returns the encrypted message instead of filling the text editor. Note that it is mandatory to use #to_java_bytes to be accepted by Burp.

You can now modify the JSON in the "JSON Crypto Helper" tab, check the encrypted version in the Raw tab and send the request. The server successfully decrypts the JSON and returns the plain text:

7926_0f133e28-687c-4789-94e7-62b77e4d0f53

8557_2f0d0bec-5ed8-491d-985f-2640a13655dd

Parting Thoughts

With these first two posts we covered the basics of Burp Extender tool and learned how to write a simple ruby-based extension to decrypt a JSON, displaying it in the Burp interface and automatically encrypt plaintext values using the Repeater tool. This should be a good start for you to explore the Burp API and create your own extensions.

In the next post I will explain how to go further and do more awesome things with Burp Extender and the Intruder tools.

Stay tuned!

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