我成功地编写了一个半工作的EasyHook示例,该示例挂起recv函数。我编写了一个表单,添加了一个WebBrowser组件,并启动了应用程序。问题是,我得到了HTTP数据包,但是如果有套接字,那么recv似乎就停止了“挂钩”。问题是,使用外部应用程序Spystudio,我可以让他们连接recv。那我错过了什么?
using System;
using System.Collections.Generic;
using System.Data;
using System.Runtime.InteropServices;
using System.Threading;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Ipc;
using EasyHook;
namespace flashing
{
public partial class Form1 : Form,EasyHook.IEntryPoint
{
public LocalHook CreateRecvHook;
public Form1()
{
InitializeComponent();
}
[DllImport("Ws2_32.dll")]
static extern int recv(
IntPtr socketHandle,
IntPtr buf,
int count,
int socketFlags
);
[UnmanagedFunctionPointer(CallingConvention.StdCall,
CharSet = CharSet.Unicode,
SetLastError = true)]
delegate int Drecv(
IntPtr socketHandle,
IntPtr buf,
int count,
int socketFlags
);
static int recv_Hooked(
IntPtr socketHandle,
IntPtr buf,
int count,
int socketFlags)
{
int bytesCount = recv(socketHandle, buf, count, socketFlags);
if (bytesCount > 0)
{
byte[] newBuffer = new byte[bytesCount];
Marshal.Copy(buf, newBuffer, 0, bytesCount);
string s = System.Text.ASCIIEncoding.ASCII.GetString(newBuffer);
TextWriter tw = new StreamWriter("log.txt");
tw.Write(s);
tw.Close();
Debug.WriteLine("Hooked:>" + s);
}
return bytesCount;
}
private void bottonHook_Click(object sender, EventArgs e)
{
try
{
CreateRecvHook = LocalHook.Create(
LocalHook.GetProcAddress("Ws2_32.dll", "recv"),
new Drecv(recv_Hooked),
this);
CreateRecvHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
}
catch (Exception ExtInfo)
{
Debug.WriteLine("Error creating the Hook");
return;
}
RemoteHooking.WakeUpProcess();
}
private void buttonLoader_Click(object sender, EventArgs e)
{
axShockwaveFlash1.LoadMovie(0, "test.swf");
}
}
}编辑:我对recv毫不怀疑,这里是apimonitor告诉我的:
# TID Module API Return Error
5 2696 Flash10l.ocx recv ( 1992, 0x07080000, 65536, 0 ) 1有人能帮我吗?
发布于 2011-01-29 12:24:41
问题解决了。制造麻烦的那条线是
CreateRecvHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });我把它换成了
CreateRecvHook.ThreadACL.SetInclusiveACL(new Int32[] { 0 });现在一切都很好。谢谢大家:)
发布于 2011-01-03 23:39:50
套接字有很多不同的功能。也许插件没有使用名为recv的函数。从我的头顶,我可以想到recvfrom,recvmsg,WSARecv,WSARecvFrom,WSARecvMsg,ReadFile,ReadFileEx。
然后,插件可以使用重叠的I/O (可能因完成例程或完成端口而复杂)执行请求,在这种情况下,数据不是在例如ReadFile函数调用期间存储,而是在稍后的时间存储。把这些勾搭起来要困难得多。
发布于 2011-01-28 18:03:30
我在c#中编写了一个使用sharppcs转储http的工具。它用的是绞盘驱动器。我认为这是更可靠的褐色吊钩。
HTTPSaver (有源)
SharpPcap
温普卡普
https://stackoverflow.com/questions/4589328
复制相似问题