﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-逆向分析专栏-随笔分类-Hack</title><link>http://www.cppblog.com/xunbu7/category/20252.html</link><description>内心的平静是一种修为，容易激动不是件好事。</description><language>zh-cn</language><lastBuildDate>Tue, 22 Jan 2013 18:06:01 GMT</lastBuildDate><pubDate>Tue, 22 Jan 2013 18:06:01 GMT</pubDate><ttl>60</ttl><item><title>反调试技巧总结-原理和实现</title><link>http://www.cppblog.com/xunbu7/archive/2013/01/05/196963.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Sat, 05 Jan 2013 02:59:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2013/01/05/196963.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196963.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2013/01/05/196963.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196963.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196963.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 摘自：http://www.cnblogs.com/huhu0013/archive/2011/07/05/2098358.html一、 前言&nbsp;&nbsp;&nbsp; 前段学习反调试和vc，写了antidebug-tester，经常会收到message希望交流或索要实现代码，我都没有回复。其实代码已经在编程版提供了1个版本，另其多是vc内嵌asm写的，对cracker而言，只要反下就知...&nbsp;&nbsp;<a href='http://www.cppblog.com/xunbu7/archive/2013/01/05/196963.html'>阅读全文</a><img src ="http://www.cppblog.com/xunbu7/aggbug/196963.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2013-01-05 10:59 <a href="http://www.cppblog.com/xunbu7/archive/2013/01/05/196963.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>找基址的整体思路</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/26/196648.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Wed, 26 Dec 2012 02:09:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/26/196648.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196648.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/26/196648.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196648.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196648.html</trackback:ping><description><![CDATA[<p>游戏里&#8220;人物&#8221;是以对象形式存在。<br />对象有很多&#8220;属性&#8221;，和&#8220;方法&#8221;，<br />&#8220;人物&#8220;可以有血，蓝，坐标x,坐标y。等等属性。<br />可以有&#8220;攻击&#8221;，&#8220;选怪&#8221;，&#8220;走路&#8221;等方法。<br />在游戏编程的时候，定义了一个对象。<br />他的属性是按照线性的地址排列。<br />&#8220;对象&#8221;在内存中的地址，就是基址。<br />&#8220;属性&#8221;和&#8220;方法&#8221;相对于对象的内存排列，就是偏移。<br />比如刚开始，游戏定义了&#8220;人物&#8221;对象具有，1.血2.蓝3.坐标x.4.坐标y<br />这时候，血值相当于&#8220;对象&#8221;基址的偏移就是4，蓝的偏移就是8，坐标x就是12，坐标y就是16<br />然后大更新了一次，游戏给&#8220;人物&#8221;对象添加了一个属性&#8220;经验&#8221;。且插入在在"2.蓝"这个属性之后，这时候，其他属性的&#8220;相对于对象基址的偏移&#8221;就发生了改变。<br />1.血2.蓝3.经验4.坐标x.5.坐标y</p>
<p>血偏移4，蓝8，经验12，坐标x16，坐标y20。。依次类推。<br /><br />游戏一般会维护一个&#8220;对象列表&#8221;，就是把&#8220;对象&#8220;在内存中的地址存放在特定的数据结构之中，这个数据结构可以是&#8221;数组&#8220;，&#8221;链表&#8220;，&#8221;树&#8220;之类的。</p><img src ="http://www.cppblog.com/xunbu7/aggbug/196648.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-26 10:09 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/26/196648.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>游戏中的各种Call</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/24/196576.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Mon, 24 Dec 2012 12:12:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/24/196576.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196576.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/24/196576.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196576.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196576.html</trackback:ping><description><![CDATA[<p>无参Call：<br />打坐CALL<br /><br />有参Call:<br />普通攻击CALL</p>
<p>走路CALL</p>
<p>技能CALL</p>
<p>捡物CALL</p>
<p>选怪CALL</p>
<p>喊话CALL</p>
<p>死亡回程CALL</p>
<p>等</p><img src ="http://www.cppblog.com/xunbu7/aggbug/196576.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-24 20:12 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/24/196576.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WH_GETMESSAGE Hook</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/24/196565.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Mon, 24 Dec 2012 07:17:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/24/196565.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196565.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/24/196565.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196565.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196565.html</trackback:ping><description><![CDATA[Windows消息分为队列消息和非队列消息，WH_GETMESSAGE不能取到非队列消息，用SendMessage发送的消息<span style="color: red"><strong>不经过队列</strong></span>，用PostMessage发送的消息被放入队列，<br />即，WH_GETMESSAGE&nbsp;Hook只拦截由GetMessage&nbsp;or&nbsp;PostMessage PeekMessage的队列消息。<img src ="http://www.cppblog.com/xunbu7/aggbug/196565.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-24 15:17 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/24/196565.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Dll注入的2种方法</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/09/196136.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Sun, 09 Dec 2012 14:42:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/09/196136.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196136.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/09/196136.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196136.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196136.html</trackback:ping><description><![CDATA[<div style="color: #000" id="Content">
<p>后卫大师教你过程注入<br />起首提一下，因为文章美满是我手写，所以打不了太多，请包含，因为我已经供给了源代码，所以我在这里具体讲一下理论，至于想看代码的下载代码就可以了。代码中关于注入的项目组做了具体的注释。MFC界面项目组的注释没有写，（毕竟成果太肤浅了。）<br />&nbsp;&nbsp;&nbsp;&nbsp; 好，言归正传。<br />&nbsp;&nbsp;&nbsp;&nbsp; 所谓DLL注入，既把一个DLL文件放到目标过程中。<br />&nbsp;&nbsp;&nbsp;&nbsp; 下面介绍2种注入体式格式：<br />&nbsp;&nbsp;&nbsp;&nbsp; 1.长途线程注入。<br />&nbsp;&nbsp;&nbsp;&nbsp; 2.哄骗hook注入。（可以过卡巴斯基）<br />因为本文篇幅限制，不写如何编写DLL。<br />一.起首讲一下长途线程注入的办法：<br />1.假设我们已经写好了一个DLL文件。<br />2.设置本过程权限为debug权限，既调试权限，可以打开其他过程。代码如下：</p><br />
<p>BOOL SetToken（void）<br />{<br />&nbsp;HANDLE hToken;<br />&nbsp;TOKEN_PRIVILEGES Privileges;<br />&nbsp;LUID luid;<br />&nbsp;OpenProcessToken（GetCurrentProcess（），TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY | TOKEN_READ，&amp;hToken）;<br />&nbsp;Privileges.PrivilegeCount=1;<br />&nbsp;LookupPrivilegeValue（NULL，SE_DEBUG_NAME，&amp;luid）;<br />&nbsp;Privileges.Privileges[0].Luid=luid;<br />&nbsp;Privileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;<br />&nbsp;if（!AdjustTokenPrivileges（hToken，FALSE，&amp;Privileges，NULL，NULL，NULL）!=0）<br />&nbsp;&nbsp;return FALSE;<br />&nbsp;CloseHandle（hToken）;<br />&nbsp;return （GetLastError（） == ERROR_SUCCESS）;<br />}<br />3.获得目标过程的句柄。<br />OpenProcess（权限类型，是否可被持续，过程ID）功能:返回目标过程句柄.<br />4.在长途过程平分派内存，用来存储，我们要注入的dll的路径<br />VirtualAllocEx（hProcess， NULL， cb， MEM_COMMIT， PAGE_READWRITE）;</p><br />
<p>//VirtualAllocEx（）函数功能：为制订的过程分派虚拟地址<br />//参1：要分派的过程句柄<br />//参2：要分派的虚拟地址的地位，0默示，主动分派地位<br />//参3：分派的大小<br />//参4：MEM_COMMIT默示，分派物理内存或者页面内存，并且初始化内存为0<br />//参5：存储选项：PAGE_READWRITE默示可以在页面内存中 &#8220;读写&#8221;<br />//返回值：若是分派内存成功，则返回分派内存的地址，若是分派失败则返回NULL，调用GetLastError（）查看错误原因</p><br />
<p>5.在长途过程中刚才分派的内存处，写入目标DLL路径：<br />WriteProcessMemory（hProcess， pszLibFileRemote，PVOID） pszLibFile， cb， NULL）<br />//WriteProcessMemory（）函数功能：在制订过程中写入内存<br />//参1：写入过程的句柄<br />//参2：写入内存的肇端地址，必须是已经创建的地址，比如上方用VirtualAllocEx（）在过程中创建的内存地址<br />//参3：写入内存中的数据内容的缓存<br />//参4：写入数据大小<br />//参5：一个选项，0默示忽视<br />//返回值： 非0值默示成功， 返回0则默示写入错误。调用GetLastError（）查看错误原因</p><br />
<p>6.获取LoadLibrary（）函数地址，因为要用他来动态加载DLL，该函数在kernel32.dll文件中<br />PROC AdrMyDllDir=（PROC）::GetProcAddress（::GetModuleHandle（TEXT（"kernel32.dll"）），"LoadLibraryW"）;//W代表UNICODE版本，说实话，A代表多字节字符集，本人喜好UNICODE版本</p><br />
<p>GetProcAddress（）<br />FARPROC GetProcAddress（HMODULE hModule，LPCWSTR lpProcName）;<span class="Apple-converted-space">&nbsp;</span><br />//功能：返回指定的DLL输出函数的函数地址<br />//参数1：DLL模块句柄<br />//参数2：DLL输出函数的函数名<br />这个函数的返回值，就是LoadLibraryW的地址了</p><br />
<p>7.创建长途线程，既在目标过程中创建一个线程，这里的线程跟通俗的线程不合，通俗线程有线程处理惩罚函数ProcThread（）<br />CreateRemoteThread（）<br />HANDLE CreateRemoteThread（<br />&nbsp; HANDLE hProcess，<br />&nbsp; LPSECURITY_ATTRIBUTES lpThreadAttributes，<br />&nbsp; SIZE_T dwStackSize，<br />&nbsp; LPTHREAD_START_ROUTINE lpStartAddress，<br />&nbsp; LPVOID lpParameter，<br />&nbsp; DWORD dwCreationFlags，<br />&nbsp; LPDWORD lpThreadId<br />）;<br />//函数功能：在制订过程中的虚拟地址中创建一个线程<br />//参数1：过程句柄，线程被创建在这个过程中<br />//参数2：安然等级，0默示默认安然等级<br />//参数3：创建线程的大小，0默示体系主动分派线程实际须要的大小<br />//参数4：线程肇端地址，应用LPTHREAD_START_ROUTINE 定义的线程，并且线程是在长途过程中已经存在。<br />//参数5: 给线程函数传递的参数<br />//参数6：创建标记，若是参数是0，则线程创建后立即运行<br />//参数7：线程ID，若是 ID给0 ，则不返回创建线程的ID</p><br />
<p>::CreateRemoteThread（hProcess，0，0，（LPTHREAD_START_ROUTINE）AdrMyDllDir，bufRemote，0，0）；<br />这里的AdrMyDllDir存放LoadLibraryW ，也就是说把LoadLibraryW当做线程处理惩罚函数，传入的参数bufRemote存放的是目标DLL文件的地址。</p><br />
<p><br />二。下面讲解一下如何用hook既钩子注入DLL文件。<br />起首给不懂钩子的人简单介绍一下道理：所谓hook，既钩子。hook会在应用法度接到消息之前，阻碍应用法度的信息，比如鼠标键盘钩子会阻碍一个应用法度的鼠标键盘信息。要做盗号木马？用WH_KEYBOARD类型的hook<br />1.我们要跨过程应用钩子，要把hook函数写在DLL文件中，这是微软明白规定的。也有其他办法，这里不久不多论述<br />2.在DLL文件中 设置钩子.<br />这里须要调用线程ID，threadId，我们会鄙人面调用DLL的调用端中写入<br />hhookGetMsg=::SetWindowsHookEx（WH_GETMESSAGE，GetMessageHookProc，::GetModuleHandle（TEXT（"dll.dll"）），threadId）;<br />//参数1：钩子类型<br />//参数2：钩子处理惩罚函数<br />//参数3：钩子地点的模块<br />//参数4：钩子要阻碍的线程ID，若是要设置全局钩子，这里给0。<br />把这个SetWindowsHookEx（）函数写在一个导出函数中，容许调用dll文件的法度调用<br />_declspec（dllexport） void SetHook（DWORD threadId）<br />{<br />&nbsp;hhookGetMsg=::SetWindowsHookEx（WH_GETMESSAGE，GetMessageHookProc，::GetModuleHandle（TEXT（"dll.dll"）），threadId）;<br />}<br />SetHook（）就是本dll的导出函数<br />3.在钩子处理惩罚函数中写入功能，当钩子截取到WM_NULL消息的时辰，注入DLL文件。因为WM_NULL消息，是个没用的消息，应用法度一般不会收到这个消息，除非我们本身发送一个这个消息，所以我们在注入DLL的时辰，只要给要注入的应用法度发一个WM_NULL消息，当钩子截取到WM_NULL的时辰就注入钩子，就可以了。<br />LRESULT CALLBACK GetMessageHookProc（int nCode，WPARAM wParam，LPARAM lParam）<br />{<br />MSG* pMsg=（MSG*）lParam;<br />if（WM_NULL==pMsg-&gt;message）<br />&nbsp;::LoadLibraryW（TEXT（"D://MyDLL.dll"））；<br />}<br />好了，编译DLL项目，产生DLL文件。</p><br />
<p>4.编写调用端，调用钩子<br />起首获取窗口句柄<br />HWND FindWindow（&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpClassName，<br />&nbsp;&nbsp;&nbsp; LPCTSTR lpWindowName<br />）;<br />返回窗体句柄。hWnd.<br />hWnd=FindWindow（0，要注入dll的窗体的名称（例如：千千静听））<br />哄骗hWnd，查找窗体线程ID<br />threadId=GetWindowThreadProcessId（hWnd，0）；<br />好了，我们有了线程ID了，可以调用钩子了。<br />SetHook（threadId）;<br />这时钩子已经加载到目标线程中了。<br />向目标窗体发送WM_NULL消息<br />SendMessage（hWnd，WM_NULL，0，0）;<br />钩子会在目标窗体受到消息前受到WM_NULL消息。因为钩子处理惩罚函数中做了断定，当受到WM_NULL消息时，加载DLL文件。所以DLL文件就注入到目标线程中了。</p><br />
<p>你可以把你的DLL文件中写入很多功能，并且DLL已经被目标法度加载了，也就是说，你的DLL法度已经打入到目标法度内部了，所以如今你可以随心所欲了</p></div><img src ="http://www.cppblog.com/xunbu7/aggbug/196136.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-09 22:42 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/09/196136.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Dll注入和代码注入</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/09/196135.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Sun, 09 Dec 2012 14:20:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/09/196135.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196135.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/09/196135.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196135.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196135.html</trackback:ping><description><![CDATA[今天无意之中在网上看到关于DLL注入的文章，感觉写的真的很好，代码很实用！！<br />所以Ctrl+C,Ctrl+V！给大家学习学习~~~~ 
<p>&nbsp;</p>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;InjectDLL(DWORD&nbsp;PID,</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">Path)&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img id="Codehighlighter1_39_659_Open_Image" onclick="this.style.display='none'; Codehighlighter1_39_659_Open_Text.style.display='none'; Codehighlighter1_39_659_Closed_Image.style.display='inline'; Codehighlighter1_39_659_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_39_659_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_39_659_Closed_Text.style.display='none'; Codehighlighter1_39_659_Open_Image.style.display='inline'; Codehighlighter1_39_659_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_39_659_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_39_659_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;DWORD&nbsp;dwSize;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;HANDLE&nbsp;hProcess</span><span style="color: #000000">=</span><span style="color: #000000">OpenProcess(PROCESS_ALL_ACCESS,</span><span style="color: #0000ff">false</span><span style="color: #000000">,PID);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;dwSize</span><span style="color: #000000">=</span><span style="color: #000000">strlen(Path)</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;LPVOID&nbsp;lpParamAddress</span><span style="color: #000000">=</span><span style="color: #000000">VirtualAllocEx(hProcess,</span><span style="color: #000000">0</span><span style="color: #000000">,dwSize,PARITY_SPACE,PAGE_EXECUTE_READWRITE);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;WriteProcessMemory(hProcess,lpParamAddress,(PVOID)Path,dwSize,NULL);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;HMODULE&nbsp;hModule</span><span style="color: #000000">=</span><span style="color: #000000">GetModuleHandleA(</span><span style="color: #000000">"</span><span style="color: #000000">kernel32.dll</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;LPTHREAD_START_ROUTINE&nbsp;lpStartAddress</span><span style="color: #000000">=</span><span style="color: #000000">(LPTHREAD_START_ROUTINE)GetProcAddress(hModule,</span><span style="color: #000000">"</span><span style="color: #000000">LoadLibraryA</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;HANDLE&nbsp;hThread</span><span style="color: #000000">=</span><span style="color: #000000">CreateRemoteThread(hProcess,NULL,</span><span style="color: #000000">0</span><span style="color: #000000">,lpStartAddress,lpParamAddress,</span><span style="color: #000000">0</span><span style="color: #000000">,NULL);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;WaitForSingleObject(hThread,</span><span style="color: #000000">1000</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;CloseHandle(hThread);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div>
<p><br />另一种是直接注入代码，代码如下：<br />//函数名：InjectCode</p>
<p>//功能：封装远程注入的函数</p>
<p>//参数：进程ID </p>
<p>//参数：被注入函数指针&lt;函数名&gt; </p>
<p>//参数：参数</p>
<p>//参数：参数长度</p>
<p>&nbsp;</p>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;InjectCode(DWORD&nbsp;dwProcId,LPVOID&nbsp;mFunc,&nbsp;LPVOID&nbsp;Param,&nbsp;DWORD&nbsp;ParamSize)&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /><img id="Codehighlighter1_78_1043_Open_Image" onclick="this.style.display='none'; Codehighlighter1_78_1043_Open_Text.style.display='none'; Codehighlighter1_78_1043_Closed_Image.style.display='inline'; Codehighlighter1_78_1043_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_78_1043_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_78_1043_Closed_Text.style.display='none'; Codehighlighter1_78_1043_Open_Image.style.display='inline'; Codehighlighter1_78_1043_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_78_1043_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_78_1043_Open_Text"><span style="color: #000000">{&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;HANDLE&nbsp;hProcess;</span><span style="color: #008000">//</span><span style="color: #008000">远程句柄</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;LPVOID&nbsp;mFuncAddr;</span><span style="color: #008000">//</span><span style="color: #008000">申请函数内存地址&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;LPVOID&nbsp;ParamAddr;</span><span style="color: #008000">//</span><span style="color: #008000">申请参数内存地址</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;HANDLE&nbsp;hThread;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">线程句柄</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;DWORD&nbsp;NumberOfByte;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">辅助返回值</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;CString&nbsp;str;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">打开被注入的进程句柄&nbsp;</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;hProcess&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwProcId);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">申请内存</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;mFuncAddr&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;VirtualAllocEx(hProcess,NULL,</span><span style="color: #000000">128</span><span style="color: #000000">,MEM_COMMIT,PAGE_EXECUTE_READWRITE);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;ParamAddr&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;VirtualAllocEx(hProcess,NULL,ParamSize,MEM_COMMIT,PAGE_EXECUTE_READWRITE);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">写内存</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;WriteProcessMemory(hProcess,mFuncAddr,mFunc,</span><span style="color: #000000">128</span><span style="color: #000000">,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">NumberOfByte);&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;WriteProcessMemory(hProcess,ParamAddr,Param,ParamSize,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">NumberOfByte);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">创建远程线程</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;hThread&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;CreateRemoteThread(hProcess,NULL,</span><span style="color: #000000">0</span><span style="color: #000000">,(LPTHREAD_START_ROUTINE)mFuncAddr,<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;ParamAddr,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #000000">&amp;</span><span style="color: #000000">NumberOfByte);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;WaitForSingleObject(hThread,&nbsp;INFINITE);&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">等待线程结束<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">释放申请有内存</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;VirtualFreeEx(hProcess,mFuncAddr,</span><span style="color: #000000">128</span><span style="color: #000000">,MEM_RELEASE);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;VirtualFreeEx(hProcess,ParamAddr,ParamSize,MEM_RELEASE);&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">释放远程句柄</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;CloseHandle(hThread);&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;CloseHandle(hProcess);&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000">&nbsp;</span></div>
<p>&nbsp;</p><img src ="http://www.cppblog.com/xunbu7/aggbug/196135.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-09 22:20 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/09/196135.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个完整的DLL远程注入函数</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/09/196134.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Sun, 09 Dec 2012 14:14:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/09/196134.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196134.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/09/196134.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196134.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196134.html</trackback:ping><description><![CDATA[<div style="border-bottom: rgb(128,128,128) 1px solid; text-align: left; border-left: rgb(128,128,128) 1px solid; padding-bottom: 10px; widows: 2; text-transform: none; background-color: rgb(245,250,255); text-indent: 0px; margin: 5px 20px; padding-left: 10px; padding-right: 10px; font: 13px/21px Arial, Helvetica, 宋体; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(68,68,68); border-top: rgb(128,128,128) 1px solid; border-right: rgb(128,128,128) 1px solid; word-spacing: 0px; padding-top: 10px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-image: initial" class="introduce">函数名称: CreateRemoteDll() 返加类型:BOOL 接受参数: DLL路径,注入进程ID 其完整代码如下: BOOL CreateRemoteDll(const char *DllFullPath, const DWORD dwRemoteProcessId)...{ HANDLE hToken; ...</div>
<div style="text-align: left; padding-bottom: 20px; border-right-width: 0px; widows: 2; text-transform: none; background-color: rgb(245,250,255); text-indent: 0px; margin: 0px; padding-left: 20px; padding-right: 20px; font: 14px/24px Arial, Helvetica, 宋体; white-space: normal; orphans: 2; border-top-width: 0px; border-bottom-width: 0px; letter-spacing: normal; color: rgb(68,68,68); border-left-width: 0px; word-spacing: 0px; padding-top: 20px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-image: initial" class="content_text">
<p style="padding-bottom: 10px; line-height: 1.6em; margin: 0px; padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, 宋体; font-size: 14px; padding-top: 10px">函数名称: CreateRemoteDll()</p>
<p style="padding-bottom: 10px; line-height: 1.6em; margin: 0px; padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, 宋体; font-size: 14px; padding-top: 10px">返加类型:BOOL</p>
<p style="padding-bottom: 10px; line-height: 1.6em; margin: 0px; padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, 宋体; font-size: 14px; padding-top: 10px">接受参数:&nbsp;DLL路径,注入进程ID</p>
<p style="padding-bottom: 10px; line-height: 1.6em; margin: 0px; padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, 宋体; font-size: 14px; padding-top: 10px">其完整代码如下:</p>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000">BOOL&nbsp;CreateRemoteDll(</span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">DllFullPath,&nbsp;</span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;DWORD&nbsp;dwRemoteProcessId)<br /><img id="Codehighlighter1_77_2042_Open_Image" onclick="this.style.display='none'; Codehighlighter1_77_2042_Open_Text.style.display='none'; Codehighlighter1_77_2042_Closed_Image.style.display='inline'; Codehighlighter1_77_2042_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_77_2042_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_77_2042_Closed_Text.style.display='none'; Codehighlighter1_77_2042_Open_Image.style.display='inline'; Codehighlighter1_77_2042_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_77_2042_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_77_2042_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;HANDLE&nbsp;hToken;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(&nbsp;OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,</span><span style="color: #000000">&amp;</span><span style="color: #000000">hToken)&nbsp;)<br /><img id="Codehighlighter1_185_497_Open_Image" onclick="this.style.display='none'; Codehighlighter1_185_497_Open_Text.style.display='none'; Codehighlighter1_185_497_Closed_Image.style.display='inline'; Codehighlighter1_185_497_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_185_497_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_185_497_Closed_Text.style.display='none'; Codehighlighter1_185_497_Open_Image.style.display='inline'; Codehighlighter1_185_497_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_185_497_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_185_497_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TOKEN_PRIVILEGES&nbsp;tkp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LookupPrivilegeValue(&nbsp;NULL,SE_DEBUG_NAME,</span><span style="color: #000000">&amp;</span><span style="color: #000000">tkp.Privileges[</span><span style="color: #000000">0</span><span style="color: #000000">].Luid&nbsp;);</span><span style="color: #008000">//</span><span style="color: #008000">修改进程权限</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tkp.PrivilegeCount</span><span style="color: #000000">=</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tkp.Privileges[</span><span style="color: #000000">0</span><span style="color: #000000">].Attributes</span><span style="color: #000000">=</span><span style="color: #000000">SE_PRIVILEGE_ENABLED;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AdjustTokenPrivileges(&nbsp;hToken,FALSE,</span><span style="color: #000000">&amp;</span><span style="color: #000000">tkp,</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">&nbsp;tkp,NULL,NULL&nbsp;);</span><span style="color: #008000">//</span><span style="color: #008000">通知系统修改进程权限</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;HANDLE&nbsp;hRemoteProcess;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">打开远程线程</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;(hRemoteProcess&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;OpenProcess(&nbsp;PROCESS_CREATE_THREAD&nbsp;</span><span style="color: #000000">|</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">允许远程创建线程</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PROCESS_VM_OPERATION&nbsp;</span><span style="color: #000000">|</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">允许远程VM操作</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PROCESS_VM_WRITE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">允许远程VM写</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FALSE,&nbsp;dwRemoteProcessId&nbsp;)&nbsp;)</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;NULL&nbsp;)<br /><img id="Codehighlighter1_841_914_Open_Image" onclick="this.style.display='none'; Codehighlighter1_841_914_Open_Text.style.display='none'; Codehighlighter1_841_914_Closed_Image.style.display='inline'; Codehighlighter1_841_914_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_841_914_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_841_914_Closed_Text.style.display='none'; Codehighlighter1_841_914_Open_Image.style.display='inline'; Codehighlighter1_841_914_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_841_914_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_841_914_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(</span><span style="color: #000000">"</span><span style="color: #000000">OpenProcess&nbsp;Error!</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;FALSE;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">pszLibFileRemote;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">在远程进程的内存地址空间分配DLL文件名缓冲区</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;pszLibFileRemote&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">char</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">)&nbsp;VirtualAllocEx(&nbsp;hRemoteProcess,&nbsp;NULL,&nbsp;lstrlen(DllFullPath)</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">,&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MEM_COMMIT,&nbsp;PAGE_READWRITE);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(pszLibFileRemote&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;NULL)<br /><img id="Codehighlighter1_1164_1241_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1164_1241_Open_Text.style.display='none'; Codehighlighter1_1164_1241_Closed_Image.style.display='inline'; Codehighlighter1_1164_1241_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1164_1241_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1164_1241_Closed_Text.style.display='none'; Codehighlighter1_1164_1241_Open_Image.style.display='inline'; Codehighlighter1_1164_1241_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1164_1241_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1164_1241_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(</span><span style="color: #000000">"</span><span style="color: #000000">VirtualAllocEx&nbsp;error!&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;FALSE;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">将DLL的路径名复制到远程进程的内存空间</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;WriteProcessMemory(hRemoteProcess,<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pszLibFileRemote,&nbsp;(</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">)&nbsp;DllFullPath,&nbsp;lstrlen(DllFullPath)</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">,&nbsp;NULL)&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">)<br /><img id="Codehighlighter1_1410_1489_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1410_1489_Open_Text.style.display='none'; Codehighlighter1_1410_1489_Closed_Image.style.display='inline'; Codehighlighter1_1410_1489_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1410_1489_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1410_1489_Closed_Text.style.display='none'; Codehighlighter1_1410_1489_Open_Image.style.display='inline'; Codehighlighter1_1410_1489_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1410_1489_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1410_1489_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(</span><span style="color: #000000">"</span><span style="color: #000000">WriteProcessMemory&nbsp;Error</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;FALSE;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">计算LoadLibraryA的入口地址</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;PTHREAD_START_ROUTINE&nbsp;pfnStartAddr&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(PTHREAD_START_ROUTINE)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetProcAddress(GetModuleHandle(TEXT(</span><span style="color: #000000">"</span><span style="color: #000000">Kernel32</span><span style="color: #000000">"</span><span style="color: #000000">)),&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">LoadLibraryA</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(pfnStartAddr&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;NULL)<br /><img id="Codehighlighter1_1696_1771_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1696_1771_Open_Text.style.display='none'; Codehighlighter1_1696_1771_Closed_Image.style.display='inline'; Codehighlighter1_1696_1771_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1696_1771_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1696_1771_Closed_Text.style.display='none'; Codehighlighter1_1696_1771_Open_Image.style.display='inline'; Codehighlighter1_1696_1771_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1696_1771_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1696_1771_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(</span><span style="color: #000000">"</span><span style="color: #000000">GetProcAddress&nbsp;Error</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;FALSE;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;HANDLE&nbsp;hRemoteThread;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;(hRemoteThread&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;CreateRemoteThread(&nbsp;hRemoteProcess,&nbsp;NULL,&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">,&nbsp;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pfnStartAddr,&nbsp;pszLibFileRemote,&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">,&nbsp;NULL)&nbsp;)&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;NULL)<br /><img id="Codehighlighter1_1943_2022_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1943_2022_Open_Text.style.display='none'; Codehighlighter1_1943_2022_Closed_Image.style.display='inline'; Codehighlighter1_1943_2022_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1943_2022_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1943_2022_Closed_Text.style.display='none'; Codehighlighter1_1943_2022_Open_Image.style.display='inline'; Codehighlighter1_1943_2022_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1943_2022_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1943_2022_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(</span><span style="color: #000000">"</span><span style="color: #000000">CreateRemoteThread&nbsp;Error</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;FALSE;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;TRUE;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div>
<p style="padding-bottom: 10px; line-height: 1.6em; margin: 0px; padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, 宋体; font-size: 14px; padding-top: 10px"></p><br /></div><img src ="http://www.cppblog.com/xunbu7/aggbug/196134.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-09 22:14 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/09/196134.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>鼠标模拟</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/07/196068.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Fri, 07 Dec 2012 01:58:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/07/196068.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196068.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/07/196068.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196068.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196068.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;2</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;GameStart()<br /></span><span style="color: #008080">&nbsp;3</span><span style="color: #000000"><img id="Codehighlighter1_18_399_Open_Image" onclick="this.style.display='none'; Codehighlighter1_18_399_Open_Text.style.display='none'; Codehighlighter1_18_399_Closed_Image.style.display='inline'; Codehighlighter1_18_399_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_18_399_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_18_399_Closed_Text.style.display='none'; Codehighlighter1_18_399_Open_Image.style.display='inline'; Codehighlighter1_18_399_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_18_399_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_18_399_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">&nbsp;4</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;HWND&nbsp;hGame</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;::FindWindow(NULL,_T(</span><span style="color: #000000">"</span><span style="color: #000000">超级玛丽专用辅助</span><span style="color: #000000">"</span><span style="color: #000000">));<br /></span><span style="color: #008080">&nbsp;5</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;CRect&nbsp;rect;<br /></span><span style="color: #008080">&nbsp;6</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;GetWindowRect(hGame,</span><span style="color: #000000">&amp;</span><span style="color: #000000">rect);<br /></span><span style="color: #008080">&nbsp;7</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /><br /></span><span style="color: #008080">&nbsp;8</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;POINT&nbsp;ptNow</span><span style="color: #008000">//</span><span style="color: #008000">模拟之前鼠标的位置</span><span style="color: #008000"><br /></span><span style="color: #008080">&nbsp;9</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,pt;</span><span style="color: #008000">//</span><span style="color: #008000">要模拟的位置</span><span style="color: #008000"><br /></span><span style="color: #008080">10</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000"><br /></span><span style="color: #008080">11</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;GetCursorPos(</span><span style="color: #000000">&amp;</span><span style="color: #000000">ptNow);</span><span style="color: #008000">//</span><span style="color: #008000">保存模拟之前的鼠标位置</span><span style="color: #008000"><br /></span><span style="color: #008080">12</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;pt.x&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;rect.left&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">213</span><span style="color: #000000">;<br /></span><span style="color: #008080">13</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;pt.y&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;rect.top&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">370</span><span style="color: #000000">;<br /></span><span style="color: #008080">14</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;SetCursorPos(pt.x,pt.y);</span><span style="color: #008000">//</span><span style="color: #008000">新的位置</span><span style="color: #008000"><br /></span><span style="color: #008080">15</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;mouse_event(MOUSEEVENTF_LEFTDOWN,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #000000">0</span><span style="color: #000000">);<br /></span><span style="color: #008080">16</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;mouse_event(MOUSEEVENTF_LEFTUP,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #000000">0</span><span style="color: #000000">,</span><span style="color: #000000">0</span><span style="color: #000000">);<br /></span><span style="color: #008080">17</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;SetCursorPos(ptNow.x,ptNow.y);</span><span style="color: #008000">//</span><span style="color: #008000">恢复模拟之前的鼠标位置</span><span style="color: #008000"><br /></span><span style="color: #008080">18</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" /></span><span style="color: #000000">}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">19</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span></div><img src ="http://www.cppblog.com/xunbu7/aggbug/196068.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-07 09:58 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/07/196068.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>外挂方式的简单总结</title><link>http://www.cppblog.com/xunbu7/archive/2012/12/05/196004.html</link><dc:creator>寻步</dc:creator><author>寻步</author><pubDate>Wed, 05 Dec 2012 06:44:00 GMT</pubDate><guid>http://www.cppblog.com/xunbu7/archive/2012/12/05/196004.html</guid><wfw:comment>http://www.cppblog.com/xunbu7/comments/196004.html</wfw:comment><comments>http://www.cppblog.com/xunbu7/archive/2012/12/05/196004.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xunbu7/comments/commentRss/196004.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xunbu7/services/trackbacks/196004.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt">&nbsp;</span><span style="font-size: 20pt"><span style="font-family: Wingdings; font-size: 10pt">&#216;</span></span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">游戏外挂以</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">Dll</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">注入方式居多，</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">修改方式为：</span> 
<p style="text-align: left; margin-top: 3.84pt; text-indent: 0in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">&nbsp;&nbsp;&nbsp;&nbsp; 1.</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">修改游戏代码</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">(</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">改变游戏的流程，使跳转的外挂自己的代码中</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">)</span></p>
<p style="text-align: left; margin-top: 3.84pt; text-indent: 0in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">&nbsp;&nbsp;&nbsp;&nbsp; 2.</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">修改游戏</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">IAT</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">（</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">IAT Hook</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">的方式挂钩游戏的</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">Send()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">和</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">Recv</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">函数，实现修改数据处理&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: Arial; color: black; font-size: 16pt; language: en-US">&nbsp;</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">的&nbsp;目的）</span></p>
<p style="text-align: left; margin-top: 3.84pt; text-indent: 0in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">&nbsp;&nbsp;&nbsp;&nbsp; 3.</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">安装消息钩子（当有特定消息发生时，外挂函数来处理）</span></p>
<div style="text-align: left; margin-top: 4.8pt; text-indent: -0.38in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0.38in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-size: 20pt"><span style="font-family: Wingdings; font-size: 10pt">&#216;</span></span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">其次是</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">Process，</span><span style="font-family: Arial; color: black; font-size: 10pt; language: zh-CN">&nbsp;方式一般为：</span></div>
<p style="text-align: left; margin-top: 3.84pt; text-indent: 0in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-family: Arial; color: black; font-size: 16pt; language: en-US">&nbsp;</span><span style="font-family: Arial; color: black; font-size: 16pt; language: en-US">&nbsp;&nbsp;</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">1.</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">通过调用</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">CreateProcessW</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">、</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">OpenProcess</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">、</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">ReadProcessMemory</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()<span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">、</span></span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">WriteProcessMemory</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">等</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">API</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">函数</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">使游戏作为外挂的子进程被打开以</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">实现辅助和</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">游戏之间的通信，从而对游戏数据进行恶意修改，以达到其相应的辅助功能</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">。</span></p>
<p style="text-align: left; margin-top: 5.76pt; text-indent: 0in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">&nbsp;&nbsp;&nbsp;&nbsp; 2.FindWindow</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">、</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">GetWindowThreadProcessId</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">、</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">OpenProcess</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">、</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">ReadProcessMemory</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">、</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">WriteProcessMemory</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">()</span></p>
<div style="text-align: left; margin-top: 7.2pt; text-indent: -0.38in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0.38in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-size: 20pt"><span style="font-family: Wingdings; font-size: 10pt">&#216;</span></span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">最后是</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">Allocate</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">方式</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">一般为：</span></div>
<p style="text-align: left; margin-top: 5.76pt; text-indent: 0in; unicode-bidi: embed; direction: ltr; margin-bottom: 0pt; margin-left: 0in; vertical-align: baseline; language: zh-CN; punctuation-wrap: simple"><span style="font-family: Arial; color: black; font-size: 10pt; language: zh-CN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 有</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">一个类似</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">Process</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">的客户端，成功打开游戏后退出，不写单独的</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">dll</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">，或者将写好的</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">dll</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">文件</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">拷贝到游戏进程</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">--</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">通过</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">WriteProcessMemory</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">--</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">并</span><span style="font-family: Arial; color: black; font-size: 10pt; language: en-US">CreateRemoteThread</span><span style="font-family: 微软雅黑; color: black; font-size: 10pt; language: zh-CN">启动它的执行。</span></p><img src ="http://www.cppblog.com/xunbu7/aggbug/196004.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xunbu7/" target="_blank">寻步</a> 2012-12-05 14:44 <a href="http://www.cppblog.com/xunbu7/archive/2012/12/05/196004.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>