Skip to content

Commit 1d3fbb2

Browse files
authored
Merge pull request #4 from Jisll/main
Many improvements, bug fixes and new functions.
2 parents 23d6b04 + 2719f78 commit 1d3fbb2

File tree

7 files changed

+233
-101
lines changed

7 files changed

+233
-101
lines changed

AntiCrack-DotNet/AntiDebug.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Diagnostics;
77
using System.IO;
88
using System.Threading;
9-
using static System.Net.WebRequestMethods;
109
using System.Windows.Forms;
1110
using System.ServiceProcess;
1211
using System.Runtime.CompilerServices;
@@ -91,7 +90,7 @@ class AntiDebug
9190
private static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect);
9291

9392
[DllImport("kernelbase.dll", SetLastError = true)]
94-
private static extern bool VirtualFree(IntPtr lpAddress, uint dwSize,uint dwFreeType);
93+
private static extern bool VirtualFree(IntPtr lpAddress, uint dwSize, uint dwFreeType);
9594

9695
public static bool NtCloseAntiDebug_InvalidHandle()
9796
{
@@ -345,7 +344,7 @@ public static bool ParentProcessAntiDebug()
345344
}
346345
}
347346
}
348-
catch{};
347+
catch { }
349348
return false;
350349
}
351350

@@ -371,7 +370,7 @@ public static bool PageGuardAntiDebug()
371370
{
372371
memset(AllocatedSpace, 1, 0xC3);
373372
uint OldProtect = 0;
374-
if(VirtualProtect(AllocatedSpace, SysInfo.PageSize, PAGE_EXECUTE_READWRITE | PAGE_GUARD, out OldProtect))
373+
if (VirtualProtect(AllocatedSpace, SysInfo.PageSize, PAGE_EXECUTE_READWRITE | PAGE_GUARD, out OldProtect))
375374
{
376375
try
377376
{
@@ -390,4 +389,4 @@ public static bool PageGuardAntiDebug()
390389
return false;
391390
}
392391
}
393-
}
392+
}

AntiCrack-DotNet/AntiDllInjection.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,20 @@ public static bool IsInjectedLibrary()
6666
if (!FileName.StartsWith(Windows) && !FileName.StartsWith(ProgramData))
6767
IsMalicious = true;
6868

69-
if (FileName.StartsWith(Environment.CurrentDirectory.ToLower())) //for compatibility
69+
if (FileName.StartsWith(Environment.CurrentDirectory.ToLower()))
7070
IsMalicious = false;
7171
}
7272
return IsMalicious;
7373
}
74+
public static string SetDllLoadPolicy()
75+
{
76+
Structs.PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY policy = new Structs.PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY
77+
{
78+
MicrosoftSignedOnly = 1
79+
};
80+
if (SetProcessMitigationPolicy(0x10, ref policy, Marshal.SizeOf(policy)))
81+
return "Success";
82+
return "Failed";
83+
}
7484
}
75-
}
85+
}

AntiCrack-DotNet/AntiVirtualization.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public static bool PortConnectionAntiVM()
213213
return false;
214214
}
215215

216-
public static void CrashingSandboxie() //Only use if running as x86
216+
public static void CrashingSandboxie()
217217
{
218218
if (!Environment.Is64BitProcess)
219219
{
@@ -265,5 +265,38 @@ public static bool CheckDevices()
265265
}
266266
return false;
267267
}
268+
public static bool CheckForParallels()
269+
{
270+
string[] BadDriversList = { "prl_sf", "prl_tg", "prl_eth" };
271+
foreach (string Drivers in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.System), "*"))
272+
{
273+
foreach (string BadDrivers in BadDriversList)
274+
{
275+
if (Drivers.Contains(BadDrivers))
276+
{
277+
return true;
278+
}
279+
}
280+
}
281+
282+
return false;
283+
}
284+
285+
public static bool CheckForQemu()
286+
{
287+
string[] BadDriversList = { "qemu-ga", "qemuwmi" };
288+
foreach (string Drivers in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.System), "*"))
289+
{
290+
foreach (string BadDrivers in BadDriversList)
291+
{
292+
if (Drivers.Contains(BadDrivers))
293+
{
294+
return true;
295+
}
296+
}
297+
}
298+
299+
return false;
300+
}
268301
}
269-
}
302+
}

AntiCrack-DotNet/HooksDetection.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private static IntPtr LowLevelGetModuleHandle(string Library)
3737
LdrGetDllHandleEx(0, null, null, UnicodeString, ref hModule);
3838
return hModule;
3939
}
40-
40+
4141
private static IntPtr LowLevelGetProcAddress(IntPtr hModule, string Function)
4242
{
4343
if (IntPtr.Size == 4)
@@ -195,5 +195,29 @@ public static bool DetectHooksOnCommonWinAPIFunctions(string ModuleName, string[
195195
}
196196
return false;
197197
}
198+
199+
// Additional detection method
200+
public static bool DetectInlineHooks(string moduleName, string[] functions)
201+
{
202+
if (moduleName != null && functions != null)
203+
{
204+
try
205+
{
206+
foreach (string function in functions)
207+
{
208+
IntPtr moduleHandle = LowLevelGetModuleHandle(moduleName);
209+
IntPtr functionHandle = LowLevelGetProcAddress(moduleHandle, function);
210+
byte[] functionBytes = new byte[1];
211+
Marshal.Copy(functionHandle, functionBytes, 0, 1);
212+
if (functionBytes[0] == 0xCC || functionBytes[0] == 0xE9)
213+
{
214+
return true;
215+
}
216+
}
217+
}
218+
catch { }
219+
}
220+
return false;
221+
}
198222
}
199-
}
223+
}

AntiCrack-DotNet/OtherChecks.cs

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62
using System.Runtime.InteropServices;
3+
using Microsoft.Win32;
74

85
namespace AntiCrack_DotNet
96
{
@@ -41,7 +38,7 @@ public static bool IsTestSignedDriversAllowed()
4138
Structs.SYSTEM_CODEINTEGRITY_INFORMATION CodeIntegrityInfo = new Structs.SYSTEM_CODEINTEGRITY_INFORMATION();
4239
CodeIntegrityInfo.Length = (uint)Marshal.SizeOf(typeof(Structs.SYSTEM_CODEINTEGRITY_INFORMATION));
4340
uint ReturnLength = 0;
44-
if(NtQuerySystemInformation(SystemCodeIntegrityInformation, ref CodeIntegrityInfo, (uint)Marshal.SizeOf(CodeIntegrityInfo), out ReturnLength) >= 0 && ReturnLength == (uint)Marshal.SizeOf(CodeIntegrityInfo))
41+
if (NtQuerySystemInformation(SystemCodeIntegrityInformation, ref CodeIntegrityInfo, (uint)Marshal.SizeOf(CodeIntegrityInfo), out ReturnLength) >= 0 && ReturnLength == (uint)Marshal.SizeOf(CodeIntegrityInfo))
4542
{
4643
uint CODEINTEGRITY_OPTION_TESTSIGN = 0x02;
4744
if ((CodeIntegrityInfo.CodeIntegrityOptions & CODEINTEGRITY_OPTION_TESTSIGN) == CODEINTEGRITY_OPTION_TESTSIGN)
@@ -85,5 +82,50 @@ public static bool IsSecureBootEnabled()
8582
}
8683
return false;
8784
}
85+
public static bool IsVirtualizationBasedSecurityEnabled()
86+
{
87+
try
88+
{
89+
using (var searcher = new System.Management.ManagementObjectSearcher(@"root\cimv2\Security\MicrosoftVolumeEncryption", "SELECT * FROM Win32_EncryptableVolume WHERE DriveLetter = C:"))
90+
{
91+
foreach (var obj in searcher.Get())
92+
{
93+
var protectionStatus = (uint)obj["ProtectionStatus"];
94+
if (protectionStatus == 1)
95+
{
96+
return true;
97+
}
98+
}
99+
}
100+
}
101+
catch
102+
{
103+
return false;
104+
}
105+
return false;
106+
}
107+
108+
public static bool IsMemoryIntegrityEnabled()
109+
{
110+
try
111+
{
112+
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity"))
113+
{
114+
if (key != null)
115+
{
116+
object value = key.GetValue("Enabled");
117+
if (value != null && (int)value == 1)
118+
{
119+
return true;
120+
}
121+
}
122+
}
123+
}
124+
catch
125+
{
126+
return false;
127+
}
128+
return false;
129+
}
88130
}
89-
}
131+
}

0 commit comments

Comments
 (0)