-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemory.cs
More file actions
232 lines (219 loc) · 9.54 KB
/
Memory.cs
File metadata and controls
232 lines (219 loc) · 9.54 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Management;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ProxyPooler
{
internal class Memory
{
[DllImport("kernel32.dll")]
private static extern bool IsDebuggerPresent();
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool CheckRemoteDebuggerPresent(IntPtr hProcess, ref bool isDebuggerPresent);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern int NtQueryInformationProcess(IntPtr hProcess, int processInformationClass, ref uint processInformation, int processInformationLength, ref uint returnLength);
private static bool isBackgroundCheckRunning = false;
public static async void AntiTamper()
{
try
{
// 1. Basic Debugger Detection
if (IsDebuggerPresent())
{
LogAndExit("Access Denied. Debugger Detected!");
return;
}
// 2. Remote Debugger Detection
bool remoteDebugger = false;
CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref remoteDebugger);
if (remoteDebugger)
{
LogAndExit("Access Denied. Remote Debugger Detected!");
return;
}
// 2. Debugger on Port Detection
uint debugPort = 0;
uint returnLength = 0;
if (NtQueryInformationProcess(Process.GetCurrentProcess().Handle, 7, ref debugPort, sizeof(uint), ref returnLength) == 0 && debugPort != 0)
{
LogAndExit("Access Denied. Debugger on Port Detected!");
return;
}
// 3. Process Monitoring
string[] suspiciousProcesses = { "ollydbg", "x64dbg", "cheatengine", "ida", "wireshark", "fiddler", "processhacker", "dnSpy", "ILSpy", "Ghidra", "ModHog", "de4dot", "deobfuscator", "decrypter" };
foreach (var process in Process.GetProcesses())
{
try
{
if (suspiciousProcesses.Any(sp => process.ProcessName.ToLower().Contains(sp)))
{
LogAndExit($"Access Denied. Suspicious Process Detected!");
return;
}
}
catch { }
}
// 6. Virtual Machine/Sandbox Detection
if (IsRunningInVirtualMachine())
{
LogAndExit("Access Denied. Virtual Machine or Sandbox Detected!");
return;
}
// 7. Periodic Background Checks
if (isBackgroundCheckRunning == false)
{
Task.Run(async () =>
{
isBackgroundCheckRunning = true;
Random r = new Random();
while (true)
{
isBackgroundCheckRunning = true;
await Task.Delay(r.Next(3000, 5000));
// 1. Basic Debugger Detection
if (IsDebuggerPresent())
{
LogAndExit("Access Denied. Debugger Detected!");
}
// 2. Remote Debugger Detection
bool remoteDebugger2 = false;
CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref remoteDebugger2);
if (remoteDebugger2)
{
LogAndExit("Access Denied. Remote Debugger Detected!");
}
// 2. Debugger on Port Detection
uint debugPort2 = 0;
uint returnLength2 = 0;
if (NtQueryInformationProcess(Process.GetCurrentProcess().Handle, 7, ref debugPort2, sizeof(uint), ref returnLength2) == 0 && debugPort2 != 0)
{
LogAndExit("Access Denied. Debugger on Port Detected!");
return;
}
// 3. Process Monitoring
string[] suspiciousProcesses2 = { "ollydbg", "x64dbg", "cheatengine", "ida", "wireshark", "fiddler", "processhacker", "dnSpy", "ILSpy", "Ghidra", "ModHog", "de4dot", "deobfuscator", "decrypter" };
foreach (var process2 in Process.GetProcesses())
{
try
{
if (suspiciousProcesses2.Any(sp => process2.ProcessName.ToLower().Contains(sp)))
{
LogAndExit($"Access Denied. Suspicious Process Detected!");
return;
}
}
catch { }
}
// 6. Virtual Machine/Sandbox Detection
if (IsRunningInVirtualMachine())
{
LogAndExit("Access Denied. Virtual Machine or Sandbox Detected!");
return;
}
}
});
}
}
catch (Exception ex)
{
LogAndExit($"Access Denied. Anti-Tamper Error!");
}
}
private static void LogAndExit(string message)
{
lock (Program.consoleLock)
{
Colorful.Console.Title = "Safeguarding your virtual vessel is the key to a secure voyage.";
Colorful.Console.Clear();
Program.Logo();
Colorful.Console.WriteLine($" {message}", Color.White);
}
Task.Delay(3000).Wait();
Environment.Exit(0);
}
private static bool IsRunningInVirtualMachine()
{
try
{
// Check for common VM indicators
string[] vmIndicators = { "virtualbox", "vmware", "qemu", "hyper-v", "parallels" };
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem"))
{
foreach (ManagementObject obj in searcher.Get())
{
string manufacturer = obj["Manufacturer"]?.ToString().ToLower();
string model = obj["Model"]?.ToString().ToLower();
if (vmIndicators.Any(vm => manufacturer.Contains(vm) || model.Contains(vm)))
{
return true;
}
}
}
// Check for virtual disk signatures
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"))
{
foreach (ManagementObject obj in searcher.Get())
{
string model = obj["Model"]?.ToString().ToLower();
if (vmIndicators.Any(vm => model.Contains(vm)))
{
return true;
}
}
}
// Check CPUID for hypervisor presence
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"))
{
foreach (ManagementObject obj in searcher.Get())
{
string cpuName = obj["Name"]?.ToString().ToLower();
if (cpuName.Contains("virtual") || cpuName.Contains("kvm"))
{
return true;
}
}
}
}
catch { }
return false;
}
public static async Task<string> GetIP()
{
return null; // REDACTED
}
public static async Task SendLog(string content)
{
// REDACTED
}
public static string ComputeHmac(string data, string secret)
{
return null; // REDACTED
}
public static string GetHWID()
{
return null; // REDACTED
}
private static string GetWMI(string wmiClass, string wmiProperty)
{
return null; // REDACTED
}
private static string GetMAC()
{
return null; // REDACTED
}
public static string[] links = new string[]
{
"" // REDACTED
};
}
}