Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Services
Capture
Managed Detection & Response

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

twi-managed-portal-color
Co-Managed SOC (SIEM)

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

twi-briefcase-color-svg
Advisory & Diagnostics

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

tw-laptop-data
Penetration Testing

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

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

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

tw-officer
Digital Forensics & Incident Response

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

tw-network
Firewall & Technology Management

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

Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
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
SpiderLabs Blog

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!

Latest SpiderLabs Blogs

Clockwork Blue: Automating Security Defenses with SOAR and AI

It’s impractical to operate security operations alone, using manual human processes. Finding opportunities to automate SecOps is an underlying foundation of Zero Trust and an essential architecture...

Read More

Professional Services Sector Under Attack - Trustwave SpiderLabs Report 2024

Recent research by Trustwave SpiderLabs, detailed in their newly published report "2024 Professional Services Threat Landscape: Trustwave Threat Intelligence Briefing and Mitigation Strategies,"...

Read More

Atlas Oil: The Consequences of a Ransomware Attack

Overview Atlas Oil, a major player in the oil and fuel distribution industry, fell victim to a ransomware attack orchestrated by the Black Basta group. This attack not only compromised sensitive...

Read More