Rk always use HOOK important functions to hide something , and some ARK first recover these hookers ( common by harddisk files) and then call the function.
And this is another way to HOOK in the kernel by DRX register. About the DRX register ,you can google it, there should be much info. So i only post some simple code next because of my poor english, if you know chinese, you can get the comment.
These code should be run in xp, and it simply act HOOK the ZwCreateFile and print the debug information.
/*
drxhook.h
Written By yykingking@126.com
*/
#ifndef _DRX_HOOK
#define _DRX_HOOK
#include <ntddk.h>
typedef unsigned long DWORD;
typedef unsigned char BOOL;
#pragma pack(push,1)
typedef struct _idtr
{
//定义中断描述符表的限制,长度两字节;
short IDTLimit;
//定义中断描述服表的基址,长度四字节;
unsigned int IDTBase;
}IDTR,*PIDTR;
typedef struct _IDTENTRY
{
unsigned short LowOffset;
unsigned short selector;
unsigned char unused_lo;
unsigned char segment_type:4; //0x0E is an interrupt gate
unsigned char system_segment_flag:1;
unsigned char DPL:2; // descriptor privilege level
unsigned char P:1; /* present */
unsigned short HiOffset;
} IDTENTRY,*PIDTENTRY;
#pragma pack(pop)
DWORD GetDBEntry();
void HookDBInt();
void UnHookDBInt();
#endif
/*
drxhook.cpp
Written By yykingking@126.com
*/
#include "drxhook.h"
DWORD g_OldDBEntry;
IDTR g_IDTR;
DWORD g_OldCreateFile;
DWORD g_HookNumber = 0;
DWORD g_CR0;
BOOL g_bExit;
void ReLoadCR0AndSti()
{
__asm
{
push eax
mov eax, g_CR0
mov cr0, eax
pop eax
sti
}
}
void CliAndDisableWPBit()
{
__asm
{
cli
push eax
mov eax, cr0
mov g_CR0, eax
and eax, 0xFFFEFFFF
mov cr0, eax
pop eax
}
}
void PrintHook()
{
DbgPrint(" Now Get In ZwCreateFile Hook: %d...Pid: %d.../n", g_HookNumber++, (DWORD)PsGetCurrentProcessId());
}
__declspec(naked) void NewZwCreateFile()
{
__asm
{
pushfd; // 仅仅适合于 XP 操作系统
call PrintHook;
popfd;
mov eax,0x25;
jmp g_OldCreateFile;
}
}
void SetHB() // set hardware breakpoint 设置硬件断点
{
__asm
{
mov eax, ZwCreateFile; // 想要挂接的函数或者地址
mov dr0, eax;
mov eax, dr7;
or eax, 0x2703; // 也要修改 dr7:GD 位,以免DrX被操作系统或其他程序修改
and eax, 0xfff0ffff;
mov dr7, eax;
}
}
__declspec(naked) void NewDBEntry()
{
__asm
{
pushfd;
push eax;
mov eax, dr6;
test eax, 0x2000;
jz NOT_EDIT_DRX;
// 以下是如果有对DRX的操作的简单处理,如有需要可以修改
// 我只是简单的跳过这些指令
and eax, 0xFFFFDFFF;
mov dr6, eax; // 清除DR6的标志
cmp g_bExit, 0;
jnz MY_DRV_EXIT; // 驱动 Unload
mov eax, [esp+8]; // 获取堆栈中的 EIP
add eax, 3; // 由于所有对 DRX 的操作全都是3个字节的
mov [esp+8], eax; // 修改 EIP ,跳过当前指令,返回时执行下条指令
jmp MY_INT_END;
NOT_EDIT_DRX:
mov eax, dr6;
test eax, 0x1;
jz SYS_INT; // 如果不是Dr0 产生的中断,则跳回原系统中断
mov eax, [esp+8];
cmp eax, ZwCreateFile; // 判断一下是不是 ZwCreateFile 的线性地址
jnz SYS_INT;
mov eax, NewZwCreateFile;
mov [esp+8],eax; // 修改堆栈中的 EIP ,实现返回时跳转
MY_INT_END:
mov eax, dr7;
or eax, 0x2000; // 恢复 GD 位
mov dr7, eax;
MY_DRV_EXIT: // 整个驱动 UnLoad 时,不恢复 Dr7
pop eax;
popfd;
iretd;
SYS_INT:
pop eax;
popfd;
jmp g_OldDBEntry;
}
}
DWORD GetDBEntry()
{
PIDTENTRY IdtEntry;
DWORD Entry;
__asm sidt g_IDTR;
IdtEntry = (PIDTENTRY)(g_IDTR.IDTBase + 8);
Entry = IdtEntry->HiOffset << 16;
Entry |= IdtEntry->LowOffset;
return Entry;
}
void HookDBInt()
{
DWORD NewEntry;
PIDTENTRY IdtEntry;
NewEntry = (DWORD)NewDBEntry;
g_OldCreateFile = (DWORD)ZwCreateFile + 5; // 新的要跳转过去的地址
g_OldDBEntry = GetDBEntry();
IdtEntry = (PIDTENTRY)(g_IDTR.IDTBase + 8);
CliAndDisableWPBit();
IdtEntry->LowOffset = (USHORT)NewEntry;
IdtEntry->HiOffset = (USHORT)( NewEntry >> 16 );
ReLoadCR0AndSti();
SetHB();
g_bExit = FALSE;
return;
}
void UnHookDBInt()
{
PIDTENTRY IdtEntry;
DWORD Entry;
__asm sidt g_IDTR;
IdtEntry = (PIDTENTRY)(g_IDTR.IDTBase + 8);
CliAndDisableWPBit();
g_bExit = TRUE;
__asm mov eax, dr7; // 产生一次例外并且清除Dr7:GD
if ( g_OldDBEntry != 0 )
{
IdtEntry->LowOffset = (USHORT)g_OldDBEntry;
IdtEntry->HiOffset = (USHORT)( g_OldDBEntry >> 16 );
}
ReLoadCR0AndSti();
DbgPrint(" UnLoad drx hook../n");
return;
}
NTSTATUS DriverUnload(IN PDRIVER_OBJECT DriverObject)
{
UnHookDBInt();
return STATUS_SUCCESS;
}
NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
HookDBInt();
DriverObject->DriverUnload = DriverUnload;
DbgPrint("Load drxhook Driver Ok.../n");
return STATUS_SUCCESS;
}
/***********************/
相关推荐
博途WinCC上位机避坑指南:从工控机选型到趋势图优化的完整流程
本文详细解析了博途WinCC上位机开发全流程,从工控机选型到趋势图优化的关键技巧。针对工业自动化场景,提供硬件配置指南、网络优化方案和性能提升策略,帮助工程师避开常见陷阱,实现稳定高效的HMI系统部署。特别强调PC Station与传统触摸屏的选型对比及SIMATIC NET配置优化。
Hooking the kernel directly
By Anton Bassov.IntroductionSometimes, we run into a situation when we badly need to hook some kernel function, but are unable to do it via conventional PE-based hooking. This article explains how
GIS分析-利用K-Means方法进行地震分析
通过“聚类”可以获得有关我们所拥有的数据的各种线索,这是数据挖掘技术之一。分析创建的组有助于决策过程。在这项研究中,我们将使用数据挖掘工具之一的K-Means方法研究安纳托利亚东部地区近100年发生的地震的空间分布,并试图获得有用的信息,以供未来的研究使用。我从局地震目录页面获得了研究所需的地震数据,并从获得了区域边界数据。
android内核hook定制,android kernel syscall table hook
I am using android 4.2.2(Jelly Been) with linux-kernel 3.0.31 source code. I am trying to hook open system call but i don't know that how to change a page from read-only to writable given an address b...
计量经济学——事件研究法/事件分析法
计量经济学——事件研究法/事件分析法
Simlink与PX4硬件在环仿真(HIL)实现
Simlink与PX4硬件在环仿真(HIL)实现 介于涉及的知识比较多,这里只是简单的介绍一下,更多内容可以参考阿木实验室《基于matlab模型开发》课程。 硬件在环HIL介绍 simlink与PX4通信实现 硬件在环HIL介绍 为来贯彻万物都可以用数学公式表示,我们以simlink的角度来看我们的无人机,那么UAV可以分为以下的几个模块: 传感器模型 滤波器模块 控制器模...
Linux 文件/文件夹隐藏(hook getdents)
前面讲的都是一些基础,比如说拿到sys_call_table地址,简单的hook某个函数,这一节做一个文件/文件夹隐藏,就是hook住文件枚举API --> getdents()&getdents64() fshid.c #include <linux/init.h> #include <linux/module.h> #include <linux/syscalls.h> #include <linux/kallsyms.h> #include
duilib入门基础一 容器之 BOX、VBOX、HBOX布局及其子控件align排列方式
序 容器 duilib有以下主要布局容器 Box(自由布局容器) VBox(垂直布局容器) HBox(水平布局容器) TabBox(多标签布局容器) TileBox(格子布局容器) ChildBox(子布局容器) ScrollableBox(可滚动容器) 一、Box容器布局 Box容器及其扩展VBox HBox是其中最常用的容器。 相对Box来说,HBox, VBox更好理解些 1.1 VBox HBox VBox下的各个控件垂...
Writing drivers to perform kernel-level SSDT hooking
Writing drivers to perform kernel-level SSDT hookingThe goal of the reader is to perform the the below points while following the tutorial. The tutorial describes how to do this step by step.Write
AI产品经理面试宝典第94天:RAG知识库构建与预处理策略面试指南
本文深入解析RAG知识库构建的核心挑战与预处理策略,涵盖文档格式转换、问答对生成及自动化测试全流程,为AI产品经理提供面试必备的实战方法论与避坑指南,助你精准应对技术深度类问题。
Keras神经网络可视化模块keras.utils.visualize_util的安装配置方法
本文介绍了如何安装和配置keras.utils.visualize_util模块,并提供了一个简单的示例演示如何使用该模块来可视化神经网络的结构。在上述代码中,我们首先定义了一个简单的神经网络模型,该模型具有一个输入层、一个隐藏层和一个输出层,其中隐藏层具有512个神经元,输出层具有10个神经元。运行上述代码后,我们将在当前工作目录下找到一个名为model.png的文件,它显示了神经网络的结构图。这种方式有效地展示了整个过程,让我们能够更好地理解神经网络的结构,方便对其进行改进和调试。
_黑客大神秘籍:Linux下Hook方式汇总
导语• Linux下的Hook方式,从ring3到ring0,姿势很多,但其实是互通的,这里总结自己实现的几个。/****** Ring3 ******/LD_PRELOAD劫持.soptrace API调试技术HookPLT劫持/******* Ring 0 *******/针对系统调用的hook--首先获得sys_call_table利用sys函数的嵌套实现hook调用的子函数修改系统调用的前...
uni-app - 解决 H5 微信公众号授权登录后,无法回退到 “上一页“ 的问题(微信登录后如何返回到触发它的那一页?无法通过 uni.navigateBack() 返回到前一页的问题?)详细教程
uniappH5微信登录重定向后无法返回到原来进入前的页面了,uni-appH5微信浏览器中授权微信登录后,无法正常回退问题,uniappH5微信登录后怎么返回上一页,uniapp公众号登陆后使用uni.navigateBack()回不去上一页,uniapp微信登录成功后返回页面后一直自动刷新页面,uniapph5授权成功后如何返回上一页,uniappH5微信登录后怎么返回到触发它的那一页去,公众号h5在授权后如何跳转回到刚进入时的页面,微信公众号H5网页返回上一页疑问,解决微信H5静默授
Linux x86架构内核Hook实现
Linux x86架构内核Hook实现 一、内核函数 text_poke()函数用于在内核动态替换opcode,从而达到Inline Hook的效果。 /** * text_poke - Update instructions on a live kernel * @addr: address to modify * @opcode: source of the copy * @len: length to copy * * Only atomic text poke/set should be
最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版
Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。
ET2012新版免狗免安装绿色软件
ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,
What Does __read_mostly In The Linux Kernel Do?
If you have spent any time looking at Linux kernel code you have undoubtedly come across the__read_mostly macro, in fact you have probably seen it within a structure definition reference or even at
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
kernel android,How to start Android Kernel programming?
If you are talking about platform level programming,i.e. framework extensions, native libraries and services there are a few places to start.The first one is the new and updated official open source p...
复分析 阿尔福斯(Ahlfors) 第三版答案 英文
答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案
Linux Kernel 2.6 Syscall Hooking via the Interrupt Descriptor Table
The symbol of sys_call_table is no longer exported since Linux 2.6.x, we have to HACK it http://www.elliotbradbury.com/linux-syscall-hooking-interrupt-descriptor-table/ Ever since the system cal
大模型推理引擎vLLM(21): vllm0.21.0中EP基类代码modular_kernel.py详细走读
大模型推理引擎vLLM(21): vllm0.21.0中EP基类代码modular_kernel.py详细走读
GG3M 国际规范商业计划书以 USDS 2.0 为认知宪法、以 Truth Kernel 为技术内核的高风险人工智能验证基础设施
本商业计划书提出GG3M以USDS 2.0为认知宪法,以KLA—LWEVSD—KCIT—TMM四层固定验证为核心,以Truth Kernel为技术内核,面向高风险AI应用提供逻辑审查、证据验证、知识审计与可信决策基础设施。项目定位为生成式模型之外的独立验证层,解决输出高置信度错误、来源不可追溯与责任链断裂等企业级痛点。本版BP将创始人理论与已验证产品严格区分,所有融资、客户、收入数字均标为待验证假设,并提出以付费试点、可复现基准与数据安全能力为融资证据,强调GG3M本身也须接受同样的逻辑、证据与纠错审查。
bitsandbytes 的 CI Lint 流水线:pre-commit 10 个 Hook、Ruff 规则集与 clang-format 完整实践
本篇以 [agents/linting_guide.md](https://link.gitcode.com/i/2e022a3b5693c205dc7b3c2ffdf18543) 为主体,系统讲解 bitsandbytes 仓库如何用一个 pre-commit 套件把 Python 风格检查(ruff/ruff format)、C/CUDA 格式化(clang-format)与文本卫生检查(ty
Detours within Windows kernel
By: izik I had to do an inline function hooking (aka. Detouring) to accomplish some task. When Ive started looking around for example in rootkits source codes, it turns out no rootkit is actual
279



被折叠的 条评论
为什么被折叠?



