From 26038a03d155e58f6396b0deef26171f1ef90a39 Mon Sep 17 00:00:00 2001 From: neru Date: Sun, 12 Apr 2026 13:12:42 -0300 Subject: [PATCH] feat: make body editable on proxy client req listeners --- src/unlocker/proxy.cpp | 5 +++++ src/unlocker/proxy.h | 2 +- src/unlocker/spoofing.cpp | 2 +- src/unlocker/spoofing.h | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/unlocker/proxy.cpp b/src/unlocker/proxy.cpp index 99899e4..c78018e 100644 --- a/src/unlocker/proxy.cpp +++ b/src/unlocker/proxy.cpp @@ -526,6 +526,11 @@ void Proxy::handleClient(SOCKET clientSocket) OnClientRequest.run(url, fullBody, headers); + removeHeader(headers, "Transfer-Encoding"); + removeHeader(headers, "Content-Length"); + headers.insert(headers.size() - 2, + "Content-Length: " + std::to_string(fullBody.size()) + "\r\n"); + SSL_write(remoteSSL.get(), headers.data(), (int)headers.size()); SSL_write(remoteSSL.get(), fullBody.data(), (int)fullBody.size()); diff --git a/src/unlocker/proxy.h b/src/unlocker/proxy.h index e1846da..a7e92c4 100644 --- a/src/unlocker/proxy.h +++ b/src/unlocker/proxy.h @@ -30,7 +30,7 @@ class Proxy bool init(); void shutdown(); - CallbackEvent OnClientRequest; + CallbackEvent OnClientRequest; CallbackEvent OnServerResponse; void addWhitelistDomain(const std::string& domain); diff --git a/src/unlocker/spoofing.cpp b/src/unlocker/spoofing.cpp index 5c74178..ab417b3 100644 --- a/src/unlocker/spoofing.cpp +++ b/src/unlocker/spoofing.cpp @@ -51,7 +51,7 @@ void Spoofer::registerListeners(Proxy* proxy) this->serverResponseHandler(url, body, respHeaders); }); - proxy->OnClientRequest.addListener([this](std::string& url, const std::string& body, std::string& reqHeaders) { + proxy->OnClientRequest.addListener([this](const std::string& url, std::string& body, std::string& reqHeaders) { this->clientRequestHandler(url, body, reqHeaders); }); } diff --git a/src/unlocker/spoofing.h b/src/unlocker/spoofing.h index 5b62c46..9180eb1 100644 --- a/src/unlocker/spoofing.h +++ b/src/unlocker/spoofing.h @@ -43,7 +43,7 @@ class Spoofer void onBloodweb(std::string& body, std::string& respHeaders); void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders); - void clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders); + void clientRequestHandler(const std::string& url, std::string& body, std::string& reqHeaders); SpooferConfig _config;