Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Services
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats

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 TRUSTWAVE

Trustwave 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