Suggest Help Change IP HMA by c#

offerdn

Junior
Joined
Mar 28, 2014
Messages
85
Reactions
40
MR
0.019
Chat with me via Skype
Như tiêu đề mình đang cần một đoạn code change ip HMA = c#.
Bác nào có thể hướng dẫn mình tý.
Cảm ơn và có hậu tạ. Có gì ib or pm yh mình với.
 
Joined
Jul 18, 2012
Messages
1,571
Reactions
2,454
MR
0.009
Chat with me via Skype
Nhận hàng:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.IO;
using Microsoft.Win32;

namespace VinaCaptcha
{
    public static class HideMyAssHandle
    {
        #region Windows API - user32.dll configs
        [DllImport("user32.dll")]
        private static extern int FindWindow(string lpClassName, String lpWindowName);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);

        [DllImport("user32.dll")]
        private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);

        private const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
        private const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)] //http://msdn.microsoft.com/en-us/library/windows/desktop/ms646291(v=vs.85).aspx
        private static extern bool EnableWindow(IntPtr hWnd, bool bEnable);

        [DllImport("user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);

        //const uint WM_KEYDOWN = 0x0100;
        //const uint WM_KEYUP = 0x0101;
        //const uint WM_CHAR = 0x0102;
        //const int VK_TAB = 0x09;
        //const int VK_ENTER = 0x0D;
        //const int VK_UP = 0x26;
        //const int VK_DOWN = 0x28;
        //const int VK_RIGHT = 0x27;
        //public const int WM_CLEAR = 0x0303;
        private const int BN_CLICKED = 245;
        private const int WM_LBUTTONDBLCLK = 0x0203;
        private const int WM_SETTEXT = 0x000C;
        private const int WM_PASTE = 0x0302;
        [DllImport("user32.dll", EntryPoint = "SendMessageA")]
        private static extern IntPtr SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, string lParam);
        //[DllImport("user32.dll")]
        //public static extern int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
        //[DllImport("user32.dll")]
        //[return: MarshalAs(UnmanagedType.Bool)]
        //static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
        #endregion

        private static string AppFolder { set; get; }
        private static string AppName { set; get; }
        private static string AppLogFile { set; get; }

        public static string FirefoxUsed = "";

        public static bool Connect()
        {
            bool Connected = false;

            //Detect App Folder
            AppName = "HMA! Pro VPN";
            AppFolder = @"C:\Program Files (x86)\HMA! Pro VPN\bin\";
            AppLogFile = AppFolder.Replace(@"\bin\", @"\log\ip_history.log");
            if (File.Exists(AppFolder + AppName + ".exe") == false)
            {
                AppFolder = @"C:\Program Files\HMA! Pro VPN\bin\";
                AppLogFile = AppFolder.Replace(@"\bin\", @"\log\ip_history.log");
                if (File.Exists(AppFolder + AppName + ".exe") == false)
                {
                    return Connected;
                }
            }

           
            StartHMA:

            // Delete log file before start new connect
            while (File.Exists(AppLogFile))
            {
                try
                {
                    File.Delete(AppLogFile);
                    Thread.Sleep(1000);
                }
                catch { }
            }

            // If HMA.exe exists then Disconnect
            Process[] prs = Process.GetProcessesByName(AppName);
            if (prs.Length > 0)
            {
                if (prs[0].Responding == false)
                {
                    while (prs.Length > 0)
                    {
                        try
                        {
                            prs[0].Kill();
                            prs[0].Close();
                        }
                        catch { }
                        prs = Process.GetProcessesByName(AppName);
                    }
                    Thread.Sleep(2000);

                    // Start HMA.exe & Connect
                    Process.Start(AppFolder + AppName + ".exe");
                    CheckWarningUpdate();
                }
            }
            // Update Registry before start HMA.exe
            else
            {
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LoginID", hmaAcc[0]);
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LoginKey", hmaAcc[1]);
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "ProtocolType2", "1");//1: OpenVPN, 2: PPTP
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "Region", hmaAcc[2]);
                Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LogIPHistory", "True");
           
                // Start HMA.exe & Connect
                Process.Start(AppFolder + AppName + ".exe");
                CheckWarningUpdate();
            }

          
            // Connect
            Process.Start(AppFolder + AppName + ".exe", "-disconnect");
            Thread.Sleep(3000);
            Process.Start(AppFolder + AppName + ".exe", "-connect");

            // Check Connected and Kill Error, Crash
            for (int i = 0; i < 120; i++)
            {
                Thread.Sleep(1000);

                if (i % 5 == 0)
                {
                    // Check CrashReport
                    if (FindWindow(default(string), "CrashReport") > 0)
                    {
                        prs = Process.GetProcessesByName(AppName);
                        while (prs.Length > 0)
                        {
                            try
                            {
                                prs[0].Kill();
                                prs[0].Close();
                            }
                            catch { }
                            prs = Process.GetProcessesByName(AppName);
                        }

                        goto StartHMA;
                    }
                }

                // Check new IP Address
                if ((i > 15) && (i % 3 == 0))
                {
                    if (File.Exists(AppLogFile))
                    {
                        Connected = true;
                        break;
                    }

                    //foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
                    //{
                    //    if ((nic.Description.Contains("TAP-Win32 Adapter V9") || nic.NetworkInterfaceType == NetworkInterfaceType.Ppp) && nic.OperationalStatus == OperationalStatus.Up)
                    //    {
                    //        Connected = true;
                    //        break;
                    //    }
                    //}
                    //if (Connected) break;
                }
            }

            if (Connected == false)
            {
                prs = Process.GetProcessesByName(AppName);
                while (prs.Length > 0)
                {
                    try
                    {
                        prs[0].Kill();
                        prs[0].Close();
                    }
                    catch { }
                    prs = Process.GetProcessesByName(AppName);
                }
            }


            return Connected;
        }

        public static void Disconnect()
        {
            try
            {
                Process.Start(AppFolder + AppName + ".exe", "-disconnect");
            }
            catch { }
        }


        private static void CheckWarningUpdate()
        {
            for (int i = 0; i < 15; i++)
            {
                Thread.Sleep(1000);

                if (i % 3 == 0)
                {
                    // Disable Warning Update new version
                    int WarningBox = FindWindow(default(string), "Warning");
                    if (WarningBox > 0)
                    {
                        try
                        {
                            IntPtr btnNoThanks = FindWindowEx((IntPtr)WarningBox, IntPtr.Zero, default(string), "No thanks");
                            SendMessage(btnNoThanks, BN_CLICKED, IntPtr.Zero, null);
                        }
                        catch { }
                    }
                }
            }
        }
    }
}
 
Nhận hàng:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.IO;
using Microsoft.Win32;

namespace VinaCaptcha
{
    public static class HideMyAssHandle
    {
        #region Windows API - user32.dll configs
        [DllImport("user32.dll")]
        private static extern int FindWindow(string lpClassName, String lpWindowName);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);

        [DllImport("user32.dll")]
        private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);

        private const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
        private const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)] //http://msdn.microsoft.com/en-us/library/windows/desktop/ms646291(v=vs.85).aspx
        private static extern bool EnableWindow(IntPtr hWnd, bool bEnable);

        [DllImport("user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);

        //const uint WM_KEYDOWN = 0x0100;
        //const uint WM_KEYUP = 0x0101;
        //const uint WM_CHAR = 0x0102;
        //const int VK_TAB = 0x09;
        //const int VK_ENTER = 0x0D;
        //const int VK_UP = 0x26;
        //const int VK_DOWN = 0x28;
        //const int VK_RIGHT = 0x27;
        //public const int WM_CLEAR = 0x0303;
        private const int BN_CLICKED = 245;
        private const int WM_LBUTTONDBLCLK = 0x0203;
        private const int WM_SETTEXT = 0x000C;
        private const int WM_PASTE = 0x0302;
        [DllImport("user32.dll", EntryPoint = "SendMessageA")]
        private static extern IntPtr SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, string lParam);
        //[DllImport("user32.dll")]
        //public static extern int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
        //[DllImport("user32.dll")]
        //[return: MarshalAs(UnmanagedType.Bool)]
        //static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
        #endregion

        private static string AppFolder { set; get; }
        private static string AppName { set; get; }
        private static string AppLogFile { set; get; }

        public static string FirefoxUsed = "";

        public static bool Connect()
        {
            bool Connected = false;

            //Detect App Folder
            AppName = "HMA! Pro VPN";
            AppFolder = @"C:\Program Files (x86)\HMA! Pro VPN\bin\";
            AppLogFile = AppFolder.Replace(@"\bin\", @"\log\ip_history.log");
            if (File.Exists(AppFolder + AppName + ".exe") == false)
            {
                AppFolder = @"C:\Program Files\HMA! Pro VPN\bin\";
                AppLogFile = AppFolder.Replace(@"\bin\", @"\log\ip_history.log");
                if (File.Exists(AppFolder + AppName + ".exe") == false)
                {
                    return Connected;
                }
            }

          
            StartHMA:

            // Delete log file before start new connect
            while (File.Exists(AppLogFile))
            {
                try
                {
                    File.Delete(AppLogFile);
                    Thread.Sleep(1000);
                }
                catch { }
            }

            // If HMA.exe exists then Disconnect
            Process[] prs = Process.GetProcessesByName(AppName);
            if (prs.Length > 0)
            {
                if (prs[0].Responding == false)
                {
                    while (prs.Length > 0)
                    {
                        try
                        {
                            prs[0].Kill();
                            prs[0].Close();
                        }
                        catch { }
                        prs = Process.GetProcessesByName(AppName);
                    }
                    Thread.Sleep(2000);

                    // Start HMA.exe & Connect
                    Process.Start(AppFolder + AppName + ".exe");
                    CheckWarningUpdate();
                }
            }
            // Update Registry before start HMA.exe
            else
            {
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LoginID", hmaAcc[0]);
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LoginKey", hmaAcc[1]);
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "ProtocolType2", "1");//1: OpenVPN, 2: PPTP
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "Region", hmaAcc[2]);
                Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LogIPHistory", "True");
          
                // Start HMA.exe & Connect
                Process.Start(AppFolder + AppName + ".exe");
                CheckWarningUpdate();
            }

         
            // Connect
            Process.Start(AppFolder + AppName + ".exe", "-disconnect");
            Thread.Sleep(3000);
            Process.Start(AppFolder + AppName + ".exe", "-connect");

            // Check Connected and Kill Error, Crash
            for (int i = 0; i < 120; i++)
            {
                Thread.Sleep(1000);

                if (i % 5 == 0)
                {
                    // Check CrashReport
                    if (FindWindow(default(string), "CrashReport") > 0)
                    {
                        prs = Process.GetProcessesByName(AppName);
                        while (prs.Length > 0)
                        {
                            try
                            {
                                prs[0].Kill();
                                prs[0].Close();
                            }
                            catch { }
                            prs = Process.GetProcessesByName(AppName);
                        }

                        goto StartHMA;
                    }
                }

                // Check new IP Address
                if ((i > 15) && (i % 3 == 0))
                {
                    if (File.Exists(AppLogFile))
                    {
                        Connected = true;
                        break;
                    }

                    //foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
                    //{
                    //    if ((nic.Description.Contains("TAP-Win32 Adapter V9") || nic.NetworkInterfaceType == NetworkInterfaceType.Ppp) && nic.OperationalStatus == OperationalStatus.Up)
                    //    {
                    //        Connected = true;
                    //        break;
                    //    }
                    //}
                    //if (Connected) break;
                }
            }

            if (Connected == false)
            {
                prs = Process.GetProcessesByName(AppName);
                while (prs.Length > 0)
                {
                    try
                    {
                        prs[0].Kill();
                        prs[0].Close();
                    }
                    catch { }
                    prs = Process.GetProcessesByName(AppName);
                }
            }


            return Connected;
        }

        public static void Disconnect()
        {
            try
            {
                Process.Start(AppFolder + AppName + ".exe", "-disconnect");
            }
            catch { }
        }


        private static void CheckWarningUpdate()
        {
            for (int i = 0; i < 15; i++)
            {
                Thread.Sleep(1000);

                if (i % 3 == 0)
                {
                    // Disable Warning Update new version
                    int WarningBox = FindWindow(default(string), "Warning");
                    if (WarningBox > 0)
                    {
                        try
                        {
                            IntPtr btnNoThanks = FindWindowEx((IntPtr)WarningBox, IntPtr.Zero, default(string), "No thanks");
                            SendMessage(btnNoThanks, BN_CLICKED, IntPtr.Zero, null);
                        }
                        catch { }
                    }
                }
            }
        }
    }
}
Thanks a nhiều!
 
Joined
Apr 13, 2010
Messages
2,687
Reactions
980
MR
0.000
Nhận hàng:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.IO;
using Microsoft.Win32;

namespace VinaCaptcha
{
    public static class HideMyAssHandle
    {
        #region Windows API - user32.dll configs
        [DllImport("user32.dll")]
        private static extern int FindWindow(string lpClassName, String lpWindowName);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);

        [DllImport("user32.dll")]
        private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);

        private const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
        private const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)] //http://msdn.microsoft.com/en-us/library/windows/desktop/ms646291(v=vs.85).aspx
        private static extern bool EnableWindow(IntPtr hWnd, bool bEnable);

        [DllImport("user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);

        //const uint WM_KEYDOWN = 0x0100;
        //const uint WM_KEYUP = 0x0101;
        //const uint WM_CHAR = 0x0102;
        //const int VK_TAB = 0x09;
        //const int VK_ENTER = 0x0D;
        //const int VK_UP = 0x26;
        //const int VK_DOWN = 0x28;
        //const int VK_RIGHT = 0x27;
        //public const int WM_CLEAR = 0x0303;
        private const int BN_CLICKED = 245;
        private const int WM_LBUTTONDBLCLK = 0x0203;
        private const int WM_SETTEXT = 0x000C;
        private const int WM_PASTE = 0x0302;
        [DllImport("user32.dll", EntryPoint = "SendMessageA")]
        private static extern IntPtr SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, string lParam);
        //[DllImport("user32.dll")]
        //public static extern int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
        //[DllImport("user32.dll")]
        //[return: MarshalAs(UnmanagedType.Bool)]
        //static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
        #endregion

        private static string AppFolder { set; get; }
        private static string AppName { set; get; }
        private static string AppLogFile { set; get; }

        public static string FirefoxUsed = "";

        public static bool Connect()
        {
            bool Connected = false;

            //Detect App Folder
            AppName = "HMA! Pro VPN";
            AppFolder = @"C:\Program Files (x86)\HMA! Pro VPN\bin\";
            AppLogFile = AppFolder.Replace(@"\bin\", @"\log\ip_history.log");
            if (File.Exists(AppFolder + AppName + ".exe") == false)
            {
                AppFolder = @"C:\Program Files\HMA! Pro VPN\bin\";
                AppLogFile = AppFolder.Replace(@"\bin\", @"\log\ip_history.log");
                if (File.Exists(AppFolder + AppName + ".exe") == false)
                {
                    return Connected;
                }
            }

          
            StartHMA:

            // Delete log file before start new connect
            while (File.Exists(AppLogFile))
            {
                try
                {
                    File.Delete(AppLogFile);
                    Thread.Sleep(1000);
                }
                catch { }
            }

            // If HMA.exe exists then Disconnect
            Process[] prs = Process.GetProcessesByName(AppName);
            if (prs.Length > 0)
            {
                if (prs[0].Responding == false)
                {
                    while (prs.Length > 0)
                    {
                        try
                        {
                            prs[0].Kill();
                            prs[0].Close();
                        }
                        catch { }
                        prs = Process.GetProcessesByName(AppName);
                    }
                    Thread.Sleep(2000);

                    // Start HMA.exe & Connect
                    Process.Start(AppFolder + AppName + ".exe");
                    CheckWarningUpdate();
                }
            }
            // Update Registry before start HMA.exe
            else
            {
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LoginID", hmaAcc[0]);
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LoginKey", hmaAcc[1]);
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "ProtocolType2", "1");//1: OpenVPN, 2: PPTP
                //Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "Region", hmaAcc[2]);
                Registry.SetValue(@"HKEY_CURRENT_USER\Software\Privax\HMA! Pro VPN\Settings", "LogIPHistory", "True");
          
                // Start HMA.exe & Connect
                Process.Start(AppFolder + AppName + ".exe");
                CheckWarningUpdate();
            }

         
            // Connect
            Process.Start(AppFolder + AppName + ".exe", "-disconnect");
            Thread.Sleep(3000);
            Process.Start(AppFolder + AppName + ".exe", "-connect");

            // Check Connected and Kill Error, Crash
            for (int i = 0; i < 120; i++)
            {
                Thread.Sleep(1000);

                if (i % 5 == 0)
                {
                    // Check CrashReport
                    if (FindWindow(default(string), "CrashReport") > 0)
                    {
                        prs = Process.GetProcessesByName(AppName);
                        while (prs.Length > 0)
                        {
                            try
                            {
                                prs[0].Kill();
                                prs[0].Close();
                            }
                            catch { }
                            prs = Process.GetProcessesByName(AppName);
                        }

                        goto StartHMA;
                    }
                }

                // Check new IP Address
                if ((i > 15) && (i % 3 == 0))
                {
                    if (File.Exists(AppLogFile))
                    {
                        Connected = true;
                        break;
                    }

                    //foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
                    //{
                    //    if ((nic.Description.Contains("TAP-Win32 Adapter V9") || nic.NetworkInterfaceType == NetworkInterfaceType.Ppp) && nic.OperationalStatus == OperationalStatus.Up)
                    //    {
                    //        Connected = true;
                    //        break;
                    //    }
                    //}
                    //if (Connected) break;
                }
            }

            if (Connected == false)
            {
                prs = Process.GetProcessesByName(AppName);
                while (prs.Length > 0)
                {
                    try
                    {
                        prs[0].Kill();
                        prs[0].Close();
                    }
                    catch { }
                    prs = Process.GetProcessesByName(AppName);
                }
            }


            return Connected;
        }

        public static void Disconnect()
        {
            try
            {
                Process.Start(AppFolder + AppName + ".exe", "-disconnect");
            }
            catch { }
        }


        private static void CheckWarningUpdate()
        {
            for (int i = 0; i < 15; i++)
            {
                Thread.Sleep(1000);

                if (i % 3 == 0)
                {
                    // Disable Warning Update new version
                    int WarningBox = FindWindow(default(string), "Warning");
                    if (WarningBox > 0)
                    {
                        try
                        {
                            IntPtr btnNoThanks = FindWindowEx((IntPtr)WarningBox, IntPtr.Zero, default(string), "No thanks");
                            SendMessage(btnNoThanks, BN_CLICKED, IntPtr.Zero, null);
                        }
                        catch { }
                    }
                }
            }
        }
    }
}

ANh ơi có code change bằng ssh ko anh , tìm google hoài ko thấy anh ơi
 
bỉtvise bác nha , thanks bác nhiều lắm , cho hỏi là bác hay dùng sky hay yahoo có gì e pm học hỏi vài cái nếu thắc mắc
Nhận hàng:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.Sockets;
using ManagedWinapi.Windows;

namespace VinaCaptcha
{
    public static class BitviseHandle
    {
        #region Windows API - user32.dll configs
        private const int WM_CLOSE = 16;
        private const int BN_CLICKED = 245;
        private const int WM_LBUTTONDOWN = 0x0201;
        private const int WM_LBUTTONUP = 0x0202;

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam);
        //Click - Worked Perfect
        //SendMessage((int)hwnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
        //Thread.Sleep(100);
        //SendMessage((int)hwnd, WM_LBUTTONUP, 0, IntPtr.Zero);
        //---
        //Close Window
        //SendMessage((int)hwnd, WM_CLOSE ,0 , IntPtr.Zero);
        #endregion

        private static Hashtable BitviseList = new Hashtable();
        public static int TimeoutSeconds = 30;
       
        private static int PortIndex = 1079;
        public static int GetPortAvailable()
        {
            PortIndex++;
            if (PortIndex >= 1181) PortIndex = 1079;
            Process BitviseApp = new Process();
            BitviseList.Add(PortIndex, BitviseApp);
            return PortIndex;
        }

        public static bool Connect(string Host, string User, string Pass, int ForwardPort)
        {
            bool Connected = false;
           
            //Start Bitvise - Auto Login
            ProcessStartInfo sinfo = new ProcessStartInfo();
            sinfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient\\BvSsh.exe";
            sinfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient";
            sinfo.Arguments = "-profile=\"" + AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient\\" + ForwardPort + ".bscp\" -host=" + Host + " -user=" + User + " -password=" + Pass + " -loginOnStartup -hide=trayIcon";
            Process BitviseApp = Process.Start(sinfo);

            BitviseList[ForwardPort] = BitviseApp;
           
            Thread.Sleep(2000);

            //Bitvise Login Checking...
            for (int i = 0; i < TimeoutSeconds; i++)
            {
                //Detect Host Key Verification
                SystemWindow[] wins = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return w.Title == "Host Key Verification"; });
                if (wins.Length > 0)
                {
                    SystemWindow[] wins2 = wins[0].FilterDescendantWindows(false, (SystemWindow w) => { return w.Title == "&Accept for This Session"; }); //Accept and &Save
                    if (wins2.Length > 0)
                    {
                        //Click 4 times to effected !
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);

                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);
                    }
                }

                //Detect Connected
                SystemWindow[] wins3 = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return w.Title == "Bitvise SSH Client - " + ForwardPort + ".bscp - " + Host + ":22"; });
                if (wins3.Length > 0)
                {
                    Connected = true;
                    break;
                }

                Thread.Sleep(1000);
            }

            if (Connected == false)
            {
                try
                {
                    BitviseApp.Kill();
                    BitviseApp.Dispose();
                }
                catch { }
            }

           
            return Connected;
        }

        public static void Disconnect(int ForwardPort)
        {
            if (BitviseList[ForwardPort] == null) return;

            try
            {
                Process BitviseApp = BitviseList[ForwardPort] as Process;
                BitviseApp.Kill();
                BitviseApp.Dispose();
            }
            catch { }
        }

        private static bool GetPort(string Host, int Port)
        {
            return true;

            //using (TcpClient tcpClient = new TcpClient())
            //{
            //    IAsyncResult result = tcpClient.BeginConnect(Host, Port, null, null);
            //    WaitHandle timeoutHandler = result.AsyncWaitHandle;
            //    try
            //    {
            //        if (!result.AsyncWaitHandle.WaitOne(200, false))
            //        {
            //            tcpClient.Close();
            //            return false;
            //        }

            //        tcpClient.EndConnect(result);
            //    }
            //    catch
            //    {
            //        return false;
            //    }
            //    finally
            //    {
            //        timeoutHandler.Close();
            //    }
            //    return true;
            //}
        }
    }
}

ManagedWinapi thì download từ đây: http://mwinapi.sourceforge.net/

Profile của Bitvise thì từ tạo ra rồi save lại thôi nhé.
 
Nhận hàng:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.Sockets;
using ManagedWinapi.Windows;

namespace VinaCaptcha
{
    public static class BitviseHandle
    {
        #region Windows API - user32.dll configs
        private const int WM_CLOSE = 16;
        private const int BN_CLICKED = 245;
        private const int WM_LBUTTONDOWN = 0x0201;
        private const int WM_LBUTTONUP = 0x0202;

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam);
        //Click - Worked Perfect
        //SendMessage((int)hwnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
        //Thread.Sleep(100);
        //SendMessage((int)hwnd, WM_LBUTTONUP, 0, IntPtr.Zero);
        //---
        //Close Window
        //SendMessage((int)hwnd, WM_CLOSE ,0 , IntPtr.Zero);
        #endregion

        private static Hashtable BitviseList = new Hashtable();
        public static int TimeoutSeconds = 30;
      
        private static int PortIndex = 1079;
        public static int GetPortAvailable()
        {
            PortIndex++;
            if (PortIndex >= 1181) PortIndex = 1079;
            Process BitviseApp = new Process();
            BitviseList.Add(PortIndex, BitviseApp);
            return PortIndex;
        }

        public static bool Connect(string Host, string User, string Pass, int ForwardPort)
        {
            bool Connected = false;
          
            //Start Bitvise - Auto Login
            ProcessStartInfo sinfo = new ProcessStartInfo();
            sinfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient\\BvSsh.exe";
            sinfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient";
            sinfo.Arguments = "-profile=\"" + AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient\\" + ForwardPort + ".bscp\" -host=" + Host + " -user=" + User + " -password=" + Pass + " -loginOnStartup -hide=trayIcon";
            Process BitviseApp = Process.Start(sinfo);

            BitviseList[ForwardPort] = BitviseApp;
          
            Thread.Sleep(2000);

            //Bitvise Login Checking...
            for (int i = 0; i < TimeoutSeconds; i++)
            {
                //Detect Host Key Verification
                SystemWindow[] wins = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return w.Title == "Host Key Verification"; });
                if (wins.Length > 0)
                {
                    SystemWindow[] wins2 = wins[0].FilterDescendantWindows(false, (SystemWindow w) => { return w.Title == "&Accept for This Session"; }); //Accept and &Save
                    if (wins2.Length > 0)
                    {
                        //Click 4 times to effected !
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);

                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);
                    }
                }

                //Detect Connected
                SystemWindow[] wins3 = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return w.Title == "Bitvise SSH Client - " + ForwardPort + ".bscp - " + Host + ":22"; });
                if (wins3.Length > 0)
                {
                    Connected = true;
                    break;
                }

                Thread.Sleep(1000);
            }

            if (Connected == false)
            {
                try
                {
                    BitviseApp.Kill();
                    BitviseApp.Dispose();
                }
                catch { }
            }

          
            return Connected;
        }

        public static void Disconnect(int ForwardPort)
        {
            if (BitviseList[ForwardPort] == null) return;

            try
            {
                Process BitviseApp = BitviseList[ForwardPort] as Process;
                BitviseApp.Kill();
                BitviseApp.Dispose();
            }
            catch { }
        }

        private static bool GetPort(string Host, int Port)
        {
            return true;

            //using (TcpClient tcpClient = new TcpClient())
            //{
            //    IAsyncResult result = tcpClient.BeginConnect(Host, Port, null, null);
            //    WaitHandle timeoutHandler = result.AsyncWaitHandle;
            //    try
            //    {
            //        if (!result.AsyncWaitHandle.WaitOne(200, false))
            //        {
            //            tcpClient.Close();
            //            return false;
            //        }

            //        tcpClient.EndConnect(result);
            //    }
            //    catch
            //    {
            //        return false;
            //    }
            //    finally
            //    {
            //        timeoutHandler.Close();
            //    }
            //    return true;
            //}
        }
    }
}

ManagedWinapi thì download từ đây: http://mwinapi.sourceforge.net/

Profile của Bitvise thì từ tạo ra rồi save lại thôi nhé.

Hay quá bác nha thanks bác nhiều
 

hainam121991

Newbie
Joined
Jun 4, 2014
Messages
17
Reactions
4
MR
0.000
Nhận hàng:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.Sockets;
using ManagedWinapi.Windows;

namespace VinaCaptcha
{
    public static class BitviseHandle
    {
        #region Windows API - user32.dll configs
        private const int WM_CLOSE = 16;
        private const int BN_CLICKED = 245;
        private const int WM_LBUTTONDOWN = 0x0201;
        private const int WM_LBUTTONUP = 0x0202;

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam);
        //Click - Worked Perfect
        //SendMessage((int)hwnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
        //Thread.Sleep(100);
        //SendMessage((int)hwnd, WM_LBUTTONUP, 0, IntPtr.Zero);
        //---
        //Close Window
        //SendMessage((int)hwnd, WM_CLOSE ,0 , IntPtr.Zero);
        #endregion

        private static Hashtable BitviseList = new Hashtable();
        public static int TimeoutSeconds = 30;
      
        private static int PortIndex = 1079;
        public static int GetPortAvailable()
        {
            PortIndex++;
            if (PortIndex >= 1181) PortIndex = 1079;
            Process BitviseApp = new Process();
            BitviseList.Add(PortIndex, BitviseApp);
            return PortIndex;
        }

        public static bool Connect(string Host, string User, string Pass, int ForwardPort)
        {
            bool Connected = false;
          
            //Start Bitvise - Auto Login
            ProcessStartInfo sinfo = new ProcessStartInfo();
            sinfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient\\BvSsh.exe";
            sinfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient";
            sinfo.Arguments = "-profile=\"" + AppDomain.CurrentDomain.BaseDirectory + "BitviseSSHClient\\" + ForwardPort + ".bscp\" -host=" + Host + " -user=" + User + " -password=" + Pass + " -loginOnStartup -hide=trayIcon";
            Process BitviseApp = Process.Start(sinfo);

            BitviseList[ForwardPort] = BitviseApp;
          
            Thread.Sleep(2000);

            //Bitvise Login Checking...
            for (int i = 0; i < TimeoutSeconds; i++)
            {
                //Detect Host Key Verification
                SystemWindow[] wins = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return w.Title == "Host Key Verification"; });
                if (wins.Length > 0)
                {
                    SystemWindow[] wins2 = wins[0].FilterDescendantWindows(false, (SystemWindow w) => { return w.Title == "&Accept for This Session"; }); //Accept and &Save
                    if (wins2.Length > 0)
                    {
                        //Click 4 times to effected !
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);

                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);
                    }
                }

                //Detect Connected
                SystemWindow[] wins3 = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return w.Title == "Bitvise SSH Client - " + ForwardPort + ".bscp - " + Host + ":22"; });
                if (wins3.Length > 0)
                {
                    Connected = true;
                    break;
                }

                Thread.Sleep(1000);
            }

            if (Connected == false)
            {
                try
                {
                    BitviseApp.Kill();
                    BitviseApp.Dispose();
                }
                catch { }
            }

          
            return Connected;
        }

        public static void Disconnect(int ForwardPort)
        {
            if (BitviseList[ForwardPort] == null) return;

            try
            {
                Process BitviseApp = BitviseList[ForwardPort] as Process;
                BitviseApp.Kill();
                BitviseApp.Dispose();
            }
            catch { }
        }

        private static bool GetPort(string Host, int Port)
        {
            return true;

            //using (TcpClient tcpClient = new TcpClient())
            //{
            //    IAsyncResult result = tcpClient.BeginConnect(Host, Port, null, null);
            //    WaitHandle timeoutHandler = result.AsyncWaitHandle;
            //    try
            //    {
            //        if (!result.AsyncWaitHandle.WaitOne(200, false))
            //        {
            //            tcpClient.Close();
            //            return false;
            //        }

            //        tcpClient.EndConnect(result);
            //    }
            //    catch
            //    {
            //        return false;
            //    }
            //    finally
            //    {
            //        timeoutHandler.Close();
            //    }
            //    return true;
            //}
        }
    }
}

ManagedWinapi thì download từ đây: http://mwinapi.sourceforge.net/

Profile của Bitvise thì từ tạo ra rồi save lại thôi nhé.
Hình như cái BitviseHandle không disable được hay sao ấy bác, bật soft thì bật được
 

huytt117

Junior
Joined
Jul 4, 2020
Messages
285
Reactions
29
MR
0.981
code này cũ rồi ạ
giờ app nó đổi qua C:\Program Files\Privax\HMA VPN>
dùng các tham số -connect, -disconnect, -changeip..
không được ạ
bác nào có code mới không ạ. em cảm ơn ạ
 

Announcements

Today's birthdays

Forum statistics

Threads
426,414
Messages
7,176,748
Members
178,855
Latest member
j88hospital

Most viewed of week

Most viewed of week

Back
Top Bottom