当前位置:编程学习 > C#/ASP.NET >>

高手进 Hook,DLL 注入

--------------------编程问答-------------------- 听说过,没有用过Dll注入, 不过Hook到时用到一下, 屏蔽键盘,鼠标的钩子。 --------------------编程问答-------------------- 1.注入是为了隐藏自己(木马、病毒),另外为了获取自己取得不到的数据需要注入其他进程
  
2.注入和Hook没有必然的关系,不过你注入后可以Hook目标的回调函数

3.想改IP包,Hook API吧。 --------------------编程问答-------------------- 第一:
C# Hook不了WinSocket?该怎么办?
第二:
DLL注入了除了隐藏自己之外 还有什么用 关键是 我能不能 把注入代码 注入到比如:

C++的非托管DLL中一函数 名为: 

public int Send(byte[] data)
{
   //处理操作
}


我能不能 这样

public int Send(byte[] data)
{
   //把我的代码注入在这里 对参数 data 进行自己的处理 再交给下文进行原来的处理

   // 处理操作
}
--------------------编程问答--------------------
加到一百分了 


希望有懂这方面的达人 回答一下。。。 --------------------编程问答-------------------- 基础知识,是一个长期积累的过程 --------------------编程问答-------------------- --------------------编程问答-------------------- 继续问 有谁知道 

EasyHook库怎么使用的啊。。。

比如:如何Hook 一个Window 的消息呢? --------------------编程问答-------------------- http://topic.csdn.net/u/20110613/19/feb74217-62bc-4560-89ae-d760266c4d85.html

这是一个hook winproc消息的。

第一:
C# Hook不了WinSocket?该怎么办?
这个c#可以。
昨天试别的东西时。试过这个是可以的。 --------------------编程问答--------------------
引用 8 楼 zanfeng 的回复:
http://topic.csdn.net/u/20110613/19/feb74217-62bc-4560-89ae-d760266c4d85.html

这是一个hook winproc消息的。

第一:
C# Hook不了WinSocket?该怎么办?
这个c#可以。
昨天试别的东西时。试过这个是可以的。




namespace NetHook
{
    public class Win32
    {
        /// <summary>
        /// Windows消息
        /// </summary>
        public enum WinMsg:int
        {
            /// <summary>
            /// 刷新消息
            /// </summary>
            WM_PAINT = 0x000F
        }
        [DllImport("user32.dll")]
        public static extern IntPtr GetWindowLong(IntPtr hwindow, int unindex);

        [DllImport("user32.dll")]
        public static extern int CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll")]
        public static extern int SetWindowLong(IntPtr hwindow, int unindex, WndProc lnewvalue);

        public const int GWL_WNDPROC = -4;
        public delegate int WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

}
 public class WinProcHook : IDisposable
    {
        //Win32 w32 = new Win32();
        Graphics g;
        Font DefaultFont = new Font("宋体", 9);
        Font Main = null;
        SolidBrush SB = new SolidBrush(Color.Yellow);

        const string WindowTitle = "abctitle", WindowClassName = "abc;

        public WinProcHook()
        {

            WindowHandle = Win32.FindWindow(WindowClassName, WindowTitle);
            if (WindowHandle != IntPtr.Zero)
            {
                g = Graphics.FromHwnd(WindowHandle);
                OldWindProc = Win32.GetWindowLong(WindowHandle, Win32.GWL_WNDPROC);
                MyProc = new Win32.WndProc(WndProc);
                Win32.SetWindowLong(WindowHandle, Win32.GWL_WNDPROC, MyProc);
            }
            else
            {
                throw new Exception("窗口未找到!");
            }
        }

        IntPtr OldWindProc;
        public IntPtr WindowHandle;
        public Win32.WndProc MyProc;


        public void DrawStr(string str,int x,int y)
        {
            if(g!=null)
            g.DrawString(str, DefaultFont, SB, new PointF(x, y));
        }

        public int WndProc(IntPtr hWnd, int Msg, IntPtr WParam, IntPtr LParam)
        {
            switch (Msg)
            {
                case (int)Win32.WinMsg.WM_PAINT:
                    DrawStr("asdskdskdslds 偶看 我知道了  呵呵 O(∩_∩)O~", 50, 50);
                    break;
            }

            //const int WM_ERASEBKGND = 0x14;

            //if (Msg == WM_ERASEBKGND)
            //{
            //    return 1;
            //}

            return Win32.CallWindowProc(OldWindProc, hWnd, Msg, WParam, LParam);
        }

        #region IDisposable 成员

        public void Dispose()
        {

        }

        #endregion
    }


不行啊,根本接收不到任何消息
难道是因为操作系统是Win7 的缘故吗?
即使开了 管理员运行 也无济于事。。。。
这可该怎么办是好啊。。。

莫非Win7下面 消息 钩子就用不了了。。??? --------------------编程问答-------------------- 此贴为感兴趣的人而留,日后希望,有强人可以在挖矿是找到并回答。。。


不要畏惧挖坟!因为很可能此贴等的就是你呢!
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,