c++转换c# 窗体的无缝控制——————socketv5代理测试

来源:互联网 发布:无损音乐下载软件 编辑:程序博客网 时间:2024/04/27 19:34

     1.    对于外挂的程序一般的都很感兴趣,例如下面的一个小小的外挂,实现功能自动登录FTP :

                  IntPtr hwnd = IntPtr.Zero;


            //IntPtr FlashHwnd = FindWindow(null, "FlashFXP");
            IntPtr hwndParent = FindWindow(null, "快速连接");
            hwnd1 = FindWindowEx(hwndParent, hwnd1, "TpanelEx", null);
            //hwnd2 = FindWindowEx(hwndParent, hwnd2, "TButton", null);
            //hwnd = FindWindowEx(hwndParent, hwnd, "button4", null);
            do
            {
                //WindowsForms10.Window.8.app.0.b7ab7b
                hwnd = FindWindowEx(hwnd1, hwnd, "TEdit", null);
                if (hwnd != IntPtr.Zero)
                {
                    i++;
                    //ftp://hubenbjmyx:A75741F431A95F56@116.255.135.185
                    //intptr[nCount++] = hwnd;
                    GetWindowText(hwnd, sgb1, sgb1.Capacity);
                    if (i == 3)
                    {
                        SendMessage(hwnd, 0x000C, 0, "116.255.135.185");
                    }


                    if (i == 4)
                    {
                        SendMessage(hwnd, 0x000C, 0, "hubenbjmyx");
                    }


                    // MessageBox.Show(sgb1.ToString());
                    if (i == 5)//加上tostring 否则不执行
                    {
                        int id = GetDlgCtrlID(m_hWnd);
                        //PostMessage(hwnd, 0x0010, id, 0);
                        SendMessage(hwnd, 0x000C, 0, "A75741F431A95F56");
                        hwnd = IntPtr.Zero;
                        break;
                    }
                }
            } while (hwnd != IntPtr.Zero);
            // SendMessage(m_hGame, WM_LBUTTONDOWN, 0, lparam);
            //SendMessage(m_hGame, WM_LBUTTONUP, 0, lparam);


            do
            {
                hwnd2 = FindWindowEx(hwndParent, hwnd2, "TButton", null);//父窗体为hwndParent非hwnd1
                if (hwnd2 != IntPtr.Zero)
                {
                    GetWindowText(hwnd2, sgb1, sgb1.Capacity);
                    if (sgb1.ToString() == "连接(&C)")//单个的连接词语不行 有&C后缀
                    {
                        SendMessage(hwnd2, 0x201, 0, null);//sendMessage第一个参数句柄为hwnd2非hwnd
                        SendMessage(hwnd2, 0x202, 0, null);
                        break;
                    }
                }
            } while (hwnd2 != IntPtr.Zero);

 

         2.socketv5代理测试:

            代理顾名思义,通过代为传送的一种连接方式。当前最为可用的应该就是socketv5代理,他比socketv4的代理方式多了安全性的连接以及认证。

            socket代理软件内核:通过软件建立一个套接字客户端接收和返回程序,另一头构建套接字服务端接收与返回程序。

           

            string URL = " ";
            int port = 8000;
            string host = "10.168.1.72";
            IPAddress ip = IPAddress.Parse(host);
            IPEndPoint ipe = new IPEndPoint(ip, port);


            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);//创建一个Socket类
            s.Bind(ipe);//绑定2000端口
            s.Listen(0);//开始监听
            Console.WriteLine("Wait for connect\r\n"); 
                try
                {
                    Socket socket = s.Accept();
                    //并获取传送和接收数据的Scoket实例
                    Console.WriteLine("Get a connect\r\n");
                    Proxy proxy = new Proxy(socket);
                    //Proxy类实例化


                    
                    Thread thread = new Thread(new ThreadStart(proxy.Run));
                    thread.Start();
                    //创建线程
                    //启动线程 
                }


                catch (Exception ex)
                {


                }
                Console.ReadLine();
            }