小编duk*_*two的帖子

C#Easyhook Winsock WS2_32.dll,连接挂钩Socks5

我试图钩住winsock连接功能,并通过socks5代理/ w auth路由TCP连接。

如果套接字是阻塞套接字,则此方法有效,但是在使用firefox(非阻塞套接字)时,我收到很多10035、10022 winsock错误。

我如何确定它是否是非阻塞/阻塞插座?

我真的很感激任何提示或想法,以实现钩住wsock连接功能并通过socks5服务器路由TCP通信的功能。

如果有人要测试它,我可以将其放在github上。(适用于任何版本的firefox)

编辑1:https : //github.com/duketwo/WinsockConnectHookSocks5/

(您必须在WSockConnectHook / HookManager.cs中编辑代理信息,并在Injector / MainForm.cs中编辑firefox的路径)

Edit2:这很容易引起麻烦,原始函数调用后的所有操作均无法正常进行。

Edit3:似乎我使它具有许多缺陷,实际上需要区分非阻塞套接字和阻塞套接字。任何想法如何实现这一目标?

Edit4:Windows没有提供任何方法来检索套接字的阻塞属性,因此我可能必须钩挂ioctlsocket函数以跟踪套接字的阻塞状态。

谢谢

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using EasyHook;
using System.IO;
using System.Windows.Forms;

namespace WSockConnectHook
{
    public class WinSockConnectController : IDisposable, IHook
    {
        [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet =     CharSet.Ansi, SetLastError = true)]
        private delegate int WinsockConnectDelegate(IntPtr s, IntPtr     addr, int addrsize);

    [DllImport("WS2_32.dll", SetLastError = true)]
    public static extern int connect(IntPtr s, IntPtr addr, int addrsize);

    [StructLayout(LayoutKind.Sequential, …
Run Code Online (Sandbox Code Playgroud)

c# winsock easyhook

5
推荐指数
0
解决办法
3814
查看次数

标签 统计

c# ×1

easyhook ×1

winsock ×1