• 目标:使calc程序输入的数自动加1

 (当别人使用时,总会得不到正确的结果,哈哈)

  • 编写注入程序

     

—————————————————————————————————
class Program中的方法,注入dll到目标进程
——————————————————————-——————————
static String ChannelName = null; static void Main(string[] args)
{
Int32.TryParse(args[], out TargetPID) ;
RemoteHooking.IpcCreateServer<FileMonInterface>(ref ChannelName, WellKnownObjectMode.SingleCall);
string injectionLibrary = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Inject.dll");
RemoteHooking.Inject(
TargetPID,
injectionLibrary,
injectionLibrary,
ChannelName);
Console.WriteLine("Injected to process {0}", TargetPID);
Console.WriteLine("<Press any key to exit>");
Console.ReadKey();
}
__________________________________________________
MarshalByRefObject的实现,供dll进行调用,判断是否正常
__________________________________________________
public class FileMonInterface : MarshalByRefObject
{
public void IsInstalled(Int32 InClientPID)
{
Console.WriteLine("FileMon has been installed in target {0}.\r\n", InClientPID);
}
}
  • 编写注入使用的dll程序

—————————————————————————————————
注入成功后,调用Run方法,钩取SetWindowTextW API,修改为DSetWindowText的委托
—————————————————————————————————
public void Run(
RemoteHooking.IContext InContext,
String InChannelName)
{
// install hook...
Hook = LocalHook.Create(
LocalHook.GetProcAddress("user32.dll", "SetWindowTextW"),
new DSetWindowText(SetWindowText_Hooked),
this); Hook.ThreadACL.SetExclusiveACL(new Int32[] { });
Interface.IsInstalled(RemoteHooking.GetCurrentProcessId());
RemoteHooking.WakeUpProcess();while (true)
{
Thread.Sleep();
}
} —————————————————————————————————
委托
—————————————————————————————————
[UnmanagedFunctionPointer(CallingConvention.StdCall,
CharSet = CharSet.Ansi,
SetLastError = true)]
delegate bool DSetWindowText(
IntPtr hWnd, //对于句柄采用IntPtr类型
string text
);
—————————————————————————————————
API
—————————————————————————————————
[DllImport("user32.dll",
CharSet = CharSet.Ansi,
SetLastError = true,
CallingConvention = CallingConvention.StdCall)]
static extern bool SetWindowText(
IntPtr hWnd, string text
);
—————————————————————————————————
傀儡API
—————————————————————————————————
static bool SetWindowText_Hooked(
IntPtr hWnd,
string text)
{
text = (int.Parse(text.Remove(text.Length-))+).ToString();//修改要显示的数据
return SetWindowText( hWnd, text);//调用API
}
  • 效果图

c#使用easyhook库进行API钩取的更多相关文章

  1. x64 下记事本WriteFile() API钩取

    <逆向工程核心原理>第30章 记事本WriteFile() API钩取 原文是在x86下,而在x64下函数调用方式为fastcall,前4个参数保存在寄存器中.在原代码基础上进行修改: 1 ...

  2. 高级全局API钩取 - IE连接控制

    @author: dlive @date: 2017/02/14 0x01 调试IE进程 常见网络连接库:ws2_32.dll(套接字),wininet.dll,winhttp.dll 使用Proce ...

  3. 调试钩取技术 - 记事本WriteFile() API钩取

    @author: dlive 0x01 简介 本章将讲解前面介绍过的调试钩取技术,钩取记事本的kernel32!WriteFile() API 调试钩取技术能进行与用户更具有交互性(interacti ...

  4. 通过注入DLL修改API代码实现钩取(一)

    通过注入DLL修改API代码实现钩取(一) Ox00 大致思路 通过CreateRemoteThread函数开辟新线程,并将DLL注入进去 通过GetProcessAddress函数找到需钩取的API ...

  5. 通过注入DLL后使用热补丁钩取API

    通过注入DLL后使用热补丁钩取API 0x00 对比修改API的前五个字节钩取API 对前一种方法钩取API的流程梳理如下: 注入相应的DLL 修改原始AI的函数的前五个字节跳往新函数(钩取API) ...

  6. 通过调试对WriteFile()API的钩取

    通过调试对WriteFile()API的钩取 0x00 目标与思路 目标:钩取指定的notepad.exe进程writeFile()API函数,对notepad.exe进程的写入的字符保存时保存为大写 ...

  7. EasyHook库系列使用教程之四钩子的启动与停止

    此文的产生花费了大量时间对EasyHook进行深入了解同一时候參考了大量文档 先来简单比較一下EasyHook与Detour钩取后程序流程 Detours:钩取API函数后.产生两个地址,一个地址相应 ...

  8. Java8新特性时间日期库DateTime API及示例

    Java8新特性的功能已经更新了不少篇幅了,今天重点讲解时间日期库中DateTime相关处理.同样的,如果你现在依旧在项目中使用传统Date.Calendar和SimpleDateFormat等API ...

  9. 《逆向工程核心原理》Windows消息钩取

    DLL注入--使用SetWindowsHookEx函数实现消息钩取 MSDN: SetWindowsHookEx Function The SetWindowsHookEx function inst ...

随机推荐

  1. leetcode 题解:Binary Tree Inorder Traversal (二叉树的中序遍历)

    题目: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary ...

  2. Android开发 SDK NDK下载

    2014.7版本 ADT Bundle http://dl.google.com/android/adt/adt-bundle-windows-x86-20140702.ziphttp://dl.go ...

  3. as3.0 [Embed]标签嵌入外部资源

    1.[Embed]嵌入资源 ActionScript代码的顺序非常重要.你必须在声明变量前添加[Embed]元数据标签,而且这个变量的类型会是Class; package { import flash ...

  4. Oracle基础 (十二)数学函数

    数学函数: ABS(n):求绝对值 ),) FROM DUAL; --获取15的绝对值 结果:, BITAND(X,Y):返回X,Y进行位与(AND)的运算结果 ,), BITAND(,), BITA ...

  5. iframe跨域自适应高度

    思路: 现有主界面main在域a下,被嵌套页面B在域b下,被嵌套页面B又嵌套一个在域a下的中介页面A. 当用户打开浏览器访问mail.html的时候载入B,触发B的onload事件获取其自身高度,然后 ...

  6. Unhandled Error in Silverlight Application “Syncfusion.Silverlight.Olap.Gauge.OlapGauge”的类型初始值设定项引发异常

    Silverlight 在运行时,如果出现如下错误: 检查生成的xap文件,解压出来,看是否里面包含该DLL:Syncfusion.Silverlight.Olap.Gauge.OlapGauge

  7. vijos 1426

    P1426兴奋剂检查 Accepted 标签:中学生论坛[显示标签]     背景 北京奥运会开幕了,这是中国人的骄傲和自豪,中国健儿在运动场上已经创造了一个又一个辉煌,super pig也不例外…… ...

  8. poj1330

    Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24762   Accept ...

  9. Evaluation

    precision是tp/(tp+fp),检索结果中正确的比例 recall是tp/(tp+fn),所有需要被检索出来的比例 1.真实情况:恶性,检查结果:恶性,这种情况就叫做:true positv ...

  10. 快速调试的VS设置

    这是2013年“惹”的“祸”. 自己一直使用着VS2012,以前的调试是相当方便的,或许是之前的同事设置好的VS,我一直不会去注意我停掉调试(停掉调试的意思是:将状态1正在调试的状态,变更为状态2待启 ...