阅读:1994回复:6
如何使用驱动释放一个exe并让它执行吶??
如何使用驱动释放一个exe并让它执行吶?? 通过将可执行文件的二进制写入文件当中,然后修改注册表,增加启动项可以么??
|
|
沙发#
发布于:2008-10-13 19:52
楼主想干嘛?
|
|
板凳#
发布于:2008-10-14 09:13
呵呵 看过一个将sys作为资源加到exe中,就逆向思维了一下。。。。sys可否释放exe
|
|
地板#
发布于:2008-10-21 13:31
驱动中怎么样执行进程呢?想知道
|
|
地下室#
发布于:2008-10-27 20:42
标 题: 【原创】修改“Starting a Process from KernelMode”
作 者: 火影 时 间: 2008-04-15,21:46 链 接: http://bbs.pediy.com/showthread.php?t=63179 这个例子就是从内核模式中启动一个用户进程,网上讲解的有很多了,不过源代码编译后不能正常启动用户进程,例子自带的ntifs.h中EPROCESS,_KPROCESS,ETHREAD,_KTHREAD结构中成员偏移位置有偏差。 查看上述结构方法很简单,用WinDbg的dt命令,如 dt EPROCESS 我的系统是windows sp2,其他系统需做相应调整 修改部分源代码见下: void RunProcess(LPSTR lpProcess) { //全部定义为ULONG类型 ULONG pTargetProcess; //self explanatory ULONG pTargetThread; //thread that can be either alerable or non-alertable ULONG pNotAlertableThread; //non-alertable thread ULONG pSystemProcess; //May not necessarily be the 'System' process ULONG pTempThread; ULONG pNextEntry, pListHead, pThNextEntry,pThListHead; if(strlen(lpProcess)>300) return; //name not longer than 300 characters //获得系统进程 pSystemProcess =(ULONG)PsGetCurrentProcess(); //make sure you are running at IRQL PASSIVE_LEVEL if(!pSystemProcess) { DbgPrint("KernelExec -> Cannot find 'System' process!"); return; } //获取进程列表头(+0x088 ActiveProcessLinks : _LIST_ENTRY) pListHead=pSystemProcess+0x88; //得到下一个EPROCESS结构的ActiveProcessLinks偏移地址 pNextEntry=*(ULONG*)pListHead; if(!pNextEntry) DbgPrint("KernelExec -> No processes found!"); else { while(pNextEntry != pListHead) //start looping through the available processes { //得到EPROCESS的首地址 pSystemProcess =pNextEntry-0x88; //进程名偏移 //+0x174 ImageFileName:[16] UChar DbgPrint("ProcessName %s \n",(char*)pSystemProcess+0x174); //Is this explorer.exe? if(_strnicmp((char*)pSystemProcess+0x174,"explorer.exe",12)==0) { //得到进程的EPROCESS结构的地址 pTargetProcess = pSystemProcess; //Yes,we have found it! DbgPrint("yes,we have found explorer.exe!"); pTargetThread = pNotAlertableThread = 0; //获取线程列表头 //+0x050 ThreadListHead : _LIST_ENTRY //也就是_KPROCESS(PCB)中ThreadListHead的偏移地址 pThListHead = pSystemProcess+0x50; //得到ETHREAD结构中_KTHREAD(Tcb)的+0x1b0 ThreadListEntry : _LIST_ENTRY地址 pThNextEntry=*(ULONG *)pThListHead; //Now we loop through it's threads, seeking an alertable thread while(pThNextEntry != pThListHead) { //所属ETHREAD的首地址 pTempThread =pThNextEntry-0x1b0; DbgPrint("ethread address is:0x%x\n",(ULONG *)pTempThread); //线程ID //ETHREAD+0x1ec Cid : _CLIENT_ID为进程ID //再向下+4为线程ID DbgPrint("thread Id is %d\n",*(ULONG *)(pTempThread+0x1f0)); //是否警告状态 //+0x164 Alertable : UChar DbgPrint("Alertable is:%x",*(char *)(pTempThread+0x164)); //tcb=*(PKTHREAD)pTempThread; if(*(char *)(pTempThread+0x164)) //Tcb is the KTHREAD of this ETHREAD and stands for 'Thread Control Block' { //Good, an alertable thread was found. //得到explorer.exe中符合条件的线程PKTHREAD(ETHREAD)结构的地址 pTargetThread =pTempThread; DbgPrint("KernelExec -> Found alertable thread"); //We will be using this one, so break now break; } else { //Didn't find an alertable thread yet, so we'll keep this one //just in case we won't find ANY alertable threads //至少需要一个非警告状态的线程 pNotAlertableThread =pTempThread; } //下一个线程块 pThNextEntry = *(ULONG *)pThNextEntry; //check next thread } break; } //下一个进程块 pNextEntry = *(ULONG *)pNextEntry; //get next process } } if(!pTargetProcess) { DbgPrint("KernelExec -> Couldn't find Explorer.exe!"); return; } if(!pTargetThread) { //No alertable thread was found, so let's hope we've at least got a non-alertable one (we'll set its alertable flag ON) //There's no problem with non-alertable threads, except for the fact that it takes //a little longer for them to return from KernelMode. (that means our process execution will be delayed) pTargetThread = pNotAlertableThread; } if(pTargetThread) { DbgPrint("KernelExec -> Targeted thread: 0x%p",pTargetThread); //We have one thread (alertable or n/a), now install the APC InstallUserModeApc(lpProcess,pTargetThread,pTargetProcess); } else DbgPrint("KernelExec -> No thread found!"); //Explorer exe with NO threads (???)*/ } 另外还需要修改WinExec函数的地址 顺便说一下遍历所有线程的方法,这里用的是第一种(详见JIURL玩玩Win2k进程线程篇) 1.一个链表是以 EPROCESS 结构的 KPROCESS Pcb 中的 ThreadListHead 为链表的链表头。链上的每一项是一个线程的 KTHREAD ETHREAD 结构的 Tcb 中的 ThreadListEntry 。 2.另一个链表是以 EPROCESS 结构中的 ThreadListHead 为链表的链表头。链上的每一项是一个线程的 ETHREAD 结构中的 ThreadListEntry 。 通过这两个链表中的任何一个,都可以找到一个进程的所有线程的 ETHREAD 结构,当然找到 ETHREAD 结构,就可以找到 ETHREAD 结构中的 KTHREAD。 |
|
5楼#
发布于:2008-10-30 18:13
赞..............
|
|
|
6楼#
发布于:2008-11-01 21:19
问题解决......将exe用二进制形式 保存到一个字符串数组中,写到磁盘中....加上注册表修改启动项....呵呵 或者直接写到启动文件夹中.....over
|
|