feat: add spoofer base
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
#include "spoofer.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "log-sink.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <tinymitm/proxy.h>
|
||||||
|
|
||||||
|
#include <seallib/assert.h>
|
||||||
|
#include <seallib/log.h>
|
||||||
|
|
||||||
|
#include <ixwebsocket/IXWebSocketServer.h>
|
||||||
|
|
||||||
|
#include <glaze/glaze.hpp>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
Spoofer::Spoofer()
|
||||||
|
{
|
||||||
|
_log = new seallib::Logger("Spoofer");
|
||||||
|
_log->addSink(std::make_shared<ConOutSink>());
|
||||||
|
|
||||||
|
_log->info("Spoofer init");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Spoofer::~Spoofer()
|
||||||
|
{
|
||||||
|
_log->info("Stopping WebSocket server");
|
||||||
|
delete _log;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spoofer::registerListeners(TinyMITMProxy* proxy)
|
||||||
|
{
|
||||||
|
proxy->onClientRequest.addListener(
|
||||||
|
[this](const std::string& url, std::string& body, std::string& headers, bool& blockOutgoing) {
|
||||||
|
this->clientRequestHandler(url, body, headers, blockOutgoing);
|
||||||
|
});
|
||||||
|
|
||||||
|
proxy->onServerResponse.addListener(
|
||||||
|
[this](const std::string& url, std::string& body, std::string& headers, bool wasBlocked) {
|
||||||
|
this->serverResponseHandler(url, body, headers, wasBlocked);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
proxy handlers
|
||||||
|
*/
|
||||||
|
void Spoofer::serverResponseHandler(const std::string& url, std::string& body, std::string& headers,
|
||||||
|
bool& /*blockOutgoing*/)
|
||||||
|
{
|
||||||
|
if (url.find("bhvrdbd.com") == std::string::npos) return;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spoofer::clientRequestHandler(const std::string& url, std::string& body, std::string& /*headers*/, bool /*wasBlocked*/)
|
||||||
|
{
|
||||||
|
if (url.find("bhvrdbd.com") == std::string::npos) return;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <utility>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace seallib
|
||||||
|
{
|
||||||
|
class Logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Spoofer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Spoofer();
|
||||||
|
~Spoofer();
|
||||||
|
|
||||||
|
void registerListeners(TinyMITMProxy* proxy);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
proxy handlers
|
||||||
|
*/
|
||||||
|
void serverResponseHandler(const std::string& url, std::string& body, std::string& headers,
|
||||||
|
bool& blockOutgoing);
|
||||||
|
void clientRequestHandler(const std::string& url, std::string& body, std::string& headers, bool wasBlocked);
|
||||||
|
seallib::Logger* _log = nullptr;
|
||||||
|
std::mutex _mutex;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user