I am trying to analyze HTTP traffic between an application and a server using Burp Suite. The traffic is routed through Burp, but the request and response bodies are obfuscated. Ideally I want to be able to inspect/modify the deobfuscated request/repsponse bodies in Burp's proxy history and Repeater.
For simplicity, assume the data in the bodies is base64 encoded for obfuscation and each obfuscated request/response has the string <!-- obfuscated
in them.
I modified the HTTP Handler Example Extension such that responses are intercepted and deobfuscated:
@Override
public ResponseReceivedAction handleHttpResponseReceived(HttpResponseReceived responseReceived) {
if (!responseReceived.bodyToString().contains("<!-- obfuscated")) {
return continueWith(responseReceived);
}
String body = deobfuscate(responseReceived.bodyToString());
return continueWith(responseReceived.withBody(body), annotations);
}
public static String deobfuscate(String encodedString) {
byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
return new String(decodedBytes);
}
The problem is that the application can't handle the deobfuscated response, which means I need to forward the obfuscated response to the application.
The same goes for requests to the server. The application obfuscates the data, I want Burp to deobfuscate it, be able to modify it and then Burp should obfuscate the data again and send it to the server.
Is there a practical way to work with the deobfuscated data in Burp while forwarding the obfuscated data?
Actually, Burp's Montoya API provides everything needed. One just has to implement the following methods of the 3 interfaces HttpHandler, ProxyRequestHandler, and ProxyResponseHandler: