Пример #1
0
        public static bool fake_proxy(string countryName, string ipforward, string portforward, ref Process refproc)
        {
            bool isValid = false;

            //check if configuration file is existed or not


            DateTime now                    = DateTime.Now;
            int      maxwait                = 120;
            string   pathToCcProxyIni       = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "CCProxy\\", "CCProxy", ".ini");
            string   pathToCcProxyDesignIni = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "CCProxyProfile\\", "CCProxy_design", ".ini");

            while (true)
            {
                if ((DateTime.Now - now).TotalSeconds <= (double)maxwait)
                {
                    var countryCode = Lumi.GetCountryCodeFromName(countryName);

                    if (countryCode != null)
                    {
                        try
                        {
                            var configCopyLines = File.ReadAllLines(pathToCcProxyIni);

                            // check if password for luminatio is fill

                            string lumiPass = null;
                            string lumiUser = null;


                            foreach (var configLine in configCopyLines)
                            {
                                if (configLine.StartsWith("Password="******"UserName="******"[StringEx]"))
                                {
                                    break;
                                }
                            }

                            if ((lumiPass == "Password="******"UserName="******"Please Open CCProxy and Fill Luminatio Username and Password!", Application.ProductName, MessageBoxButtons.OK,
                                                MessageBoxIcon.Hand);
                                break;
                            }


                            //allready filled password.


                            //change username to with CountryCode.

                            if (lumiUser.Contains("country-"))
                            {
                                lumiUser = lumiUser.Substring(0, lumiUser.Length - 2) + countryCode.ToLower();
                            }
                            else
                            {
                                MessageBox.Show("Luminati Username Must Contain '-country-'!", Application.ProductName, MessageBoxButtons.OK,
                                                MessageBoxIcon.Hand);
                                break;
                            }


                            //replace

                            File.Copy(pathToCcProxyDesignIni, pathToCcProxyIni, true);

                            // fill value to new ini file.

                            var originalLines = File.ReadAllLines(pathToCcProxyIni);

                            var updatedLines = new List <string>();
                            foreach (var line in originalLines)
                            {
                                var copyLine = line;

                                if (line.Contains("#SOCK_FORWARD_IP#"))
                                {
                                    copyLine = "SOCKS=" + ipforward;
                                }

                                if (line.Contains("#SOCK_FORWARD_PORT#"))
                                {
                                    copyLine = "SOCKS=" + portforward;
                                }

                                if (line.Contains("#LUMI_USER#"))
                                {
                                    copyLine = lumiUser;
                                }

                                if (line.Contains("#LUMI_PASS#"))
                                {
                                    copyLine = lumiPass;
                                }

                                updatedLines.Add(copyLine);
                            }

                            File.WriteAllLines(pathToCcProxyIni, updatedLines);


                            string  str2    = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "CCProxy\\CCProxy.exe");
                            Process process = Process.Start(str2);
                            refproc = process;
                            while ((DateTime.Now - process.StartTime).Seconds < 1)
                            {
                                Thread.Sleep(100);
                            }
                            IntPtr intPtr = Lumi.FindWindowInProcess(process, (string s) => s.StartsWith("CCProxy"));
                            while (intPtr == IntPtr.Zero)
                            {
                                intPtr = Lumi.FindWindowInProcess(process, (string s) => s.StartsWith("CCProxy"));
                                Thread.Sleep(100);
                            }
                            if (intPtr != IntPtr.Zero)
                            {
                                refproc = process;
                                isValid = true;
                            }
                            else
                            {
                                process.Kill();
                                isValid = false;
                            }
                        }
                        catch (Exception e)
                        {
                        }
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            return(isValid);
        }
Пример #2
0
        public static bool fake_proxy_lumi(string countryName, string portforward, string zone, string password, string username)
        {
            bool isValid = false;

            //check if configuration file is existed or not


            DateTime now     = DateTime.Now;
            int      maxwait = 30;

            while (true)
            {
                if ((DateTime.Now - now).TotalSeconds <= (double)maxwait)
                {
                    var countryCode = Lumi.GetCountryCodeFromName(countryName);

                    if (countryCode != null)
                    {
                        //check if port is exited.
                        if (!Lumi.sendCheck())
                        {
                            MessageBox.Show("Luminatio Proxy Manager is not running!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                        else
                        {
                            //create port with country.
                            try
                            {
                                bool isPortExisted = Lumi.checkIfPortExisted(portforward);

                                if (isPortExisted)
                                {
                                    bool isSame = Lumi.CheckIfHaveProxySameInfo(portforward, username, zone, password, countryCode);

                                    if (isSame == true)
                                    {
                                        isValid = true;
                                    }
                                    else
                                    {
                                        isValid = CreateOrUpdateProxy(portforward, username, password, zone, countryCode, true);
                                    }
                                }
                                else
                                {
                                    isValid = CreateOrUpdateProxy(portforward, username, password, zone, countryCode, false);
                                }
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show("Luminatio Proxy set country port with error" + e.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                        }
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Timeout when finding country Code For Country" + countryName, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);

                    break;
                }
            }

            return(isValid);
        }