计算机天才
cpuid01 判断是否存在虚拟机
#include<ntifs.h>
#include<ntddk.h>
#include<wdm.h>
#include<intrin.h>
#include "ia32.hpp"
template<typename... types>
void print(types... args)
{
DbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, args...);
}
void unload(PDRIVER_OBJECT DriverUnload) {
return;
}
extern "C" NTSTATUS DriverEntry(PDRIVER_OBJECT drv, PUNICODE_STRING reg) {
drv->DriverUnload = unload;
cpuid_eax_01 eax;
__cpuid(reinterpret_cast<int*>(&eax), 1);
if (eax.cpuid_feature_information_ecx.reserved2) {
print("[+] 存在虚拟机监控程序\n");
int t[4];
__cpuid(t, 0x40000001); //管理程序接口标识
print("[+] cpuid…
计算机天才
静态判断pe文件位数
.text:FFFFF802560B274B mov ecx, 8664h //64位一般是这个,32位一般是0x14C
.text:FFFFF802560B2750 cmp cx, [rax+_IMAGE_NT_HEADERS64.FileHeader.Machine]
.text:FFFFF802560B2754 jz short loc_FFFFF802560B2767
.text:FFFFF802560B2756 mov ecx, 200h
.text:FFFFF802560B275B cmp cx, [rax+_IMAGE_NT_HEADERS64.FileHeader.Machine]
.text:FFFFF802560B275F jz short loc_FFFFF802560B2767
.text:FFFFF802560B2761 add rax, 78h ; 'x'
.text:FFFFF802560B2765 jmp short loc_FFFFF802560B276D
.text:FFFFF802560B2767 ; ---------------------------------------------------------------------------
.text:FFFFF802560B2767
.text:FFFFF802560B2767 loc_FFFFF802560B2767: ; CODE XREF: sub_FFFFF802560B270C+48↑j
.text:FFFFF802560B2767 ; sub_FFFFF802560B270C+53↑j
.text:FFFFF802560B2767 add rax, 88h
计算机天才
windows内核LookasiddeList使用
#include<ntifs.h>
#include<ntddk.h>
#include<wdm.h>
#include<intrin.h>
#include"slist.h"
namespace dbg {
template<typename... types>
void print(types... args)
{
DbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, args...);
}
__inline void dbgbreak() {
if (*KdDebuggerNotPresent)
print("breakpoint trigger\n");
else
DbgBreakPoint();
}
}
//
//nonpaged pool 16byte align
//
#pragma(pack,16)
LOOKASIDE_LIST_EX lalist{};
struct test {
SLIST_ENTRY et;
int a;
int b;
int c;
};
void unload(PDRIVER_OBJECT DriverObject) {
return;
}
extern "C" NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegPath) {
NTSTATUS Status = STATUS_SUCCESS;
int t1 = 0…
计算机天才
windows 控制台实用代码
#include "general.h"
void ConsoleBase(enum ConsoleColor color, const char* prefix, const char* text, va_list args)
{
const HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(consoleHandle, White);
printf("[");
SetConsoleTextAttribute(consoleHandle, color);
printf("%s", prefix);
SetConsoleTextAttribute(consoleHandle, White);
printf("] ");
SetConsoleTextAttribute(consoleHandle, DarkWhite);
vprintf(text, args);
printf("\n");
}
void ConsoleInfo(const char* text, ...)
{
va_list args;
va_start(args, text);
ConsoleBase(Cyan, "i", text, args);
va_end(args);
}
void ConsoleWarning(const char* text, ...)
{
va_list args;
va_start(args, text);
ConsoleBase(Yellow, "w", text, args);
va_end(args);
}
void ConsoleError(const char* text, ...)
{
va_list args;
va_start(args, text);
ConsoleBase…
计算机天才
win32实用代码
main.cpp
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <filesystem>
#include "xtils.hpp"
int __cdecl main(int argc, const char** argv)
{
auto utils = xtils::um_t::get_instance();
const auto explorer_pid =
utils->get_pid(L"explorer.exe");
const auto explorer_module_base =
utils->get_process_base(utils->get_handle(explorer_pid).get());
std::printf("> explorer pid = 0x%x, module base = 0x%p\n",
explorer_pid, explorer_module_base);
std::map<std::wstring, std::uintptr_t> modules;
if (!utils->get_modules(explorer_pid…