@@ -22,6 +22,7 @@ BOOL ENABLE_TIMING_ATTACKS = FALSE;
2222BOOL ENABLE_DUMPING_CHECK = FALSE ;
2323BOOL ENABLE_ANALYSIS_TOOLS_CHECK = FALSE ;
2424BOOL ENABLE_ANTI_DISASSM_CHECKS = FALSE ;
25+ const char * PROGRAM_NAME = " al-khaser.exe" ;
2526
2627
2728void EnableDefaultChecks () {
@@ -66,20 +67,84 @@ void EnableChecks(std::string checkType) {
6667 else if (checkType == " ANTI_DISASSM" ) ENABLE_ANTI_DISASSM_CHECKS = TRUE ;
6768}
6869
70+ void print_help (const char * prog_name){
71+ printf (
72+ " Usage: %s [OPTIONS]\n "
73+ " Options:\n "
74+ " --check <type> Enable specific check(s). Can be used multiple times. Valid types are:\n "
75+ " TLS (Thread Local Storage callback checks)\n "
76+ " DEBUG (Anti-debugging checks)\n "
77+ " INJECTION (Code injection checks)\n "
78+ " GEN_SANDBOX (Generic sandbox checks)\n "
79+ " VBOX (VirtualBox detection)\n "
80+ " VMWARE (VMware detection)\n "
81+ " VPC (Virtual PC detection)\n "
82+ " QEMU (QEMU detection)\n "
83+ " KVM (KVM detection)\n "
84+ " XEN (Xen detection)\n "
85+ " WINE (Wine detection)\n "
86+ " PARALLELS (Parallels detection)\n "
87+ " HYPERV (Hyper-V detection)\n "
88+ " CODE_INJECTIONS (Additional code injection techniques)\n "
89+ " TIMING_ATTACKS (Timing/sleep-based sandbox evasion)\n "
90+ " DUMPING_CHECK (Dumping memory/process checks)\n "
91+ " ANALYSIS_TOOLS (Analysis tools detection)\n "
92+ " ANTI_DISASSM (Anti-disassembly checks)\n "
93+ " --sleep <seconds> Set sleep/delay duration in seconds (default: 600).\n "
94+ " --delay <seconds> Alias for --sleep.\n "
95+ " -h, --help Show this help message and exit.\n "
96+ " \n "
97+ " Examples:\n "
98+ " %s --check DEBUG --check TIMING_ATTACKS --sleep 30\n "
99+ " %s --check VMWARE --check QEMU\n "
100+ " %s --sleep 30\n "
101+ " \n "
102+ " If no --check options are given, all checks are executed by default.\n "
103+ " If no other options are given, the default delay is 600 seconds.\n " ,
104+ prog_name, prog_name, prog_name, prog_name
105+ );
106+ }
69107
70- int main (int argc, char * argv[])
71- {
108+ int main (int argc, char * argv[]){
72109 /* enable functions */
110+ UINT delayInSeconds = 600U ; // default value
111+ int enabled_checks = 0 ;
112+
73113 if (argc > 1 ) {
74- for (int i = 1 ; i < argc; i += 2 ) {
75- if (strcmp (argv[i], " --check" ) == 0 && (i + 1 < argc)) {
114+ for (int i = 1 ; i < argc; ++i) {
115+ if (strcmp (argv[i], " -h" ) == 0 || strcmp (argv[i], " --help" ) == 0 ) {
116+ // print_help(argv[0]);
117+ print_help (PROGRAM_NAME);
118+ return 0 ;
119+ } else if ((strcmp (argv[i], " --sleep" ) == 0 || strcmp (argv[i], " --delay" ) == 0 ) && i + 1 < argc) {
120+ char * endptr;
121+ errno = 0 ;
122+ long val = strtol (argv[i + 1 ], &endptr, 10 );
123+
124+ if (errno == ERANGE || val > UINT_MAX || val <= 0 ) {
125+ printf (" [!] Invalid delay value: %s. Using default %u seconds.\n " , argv[i + 1 ], delayInSeconds);
126+ }
127+ else if (endptr == argv[i + 1 ] || *endptr != ' \0 ' ) {
128+ printf (" [!] Non-numeric delay value: %s. Using default %u seconds.\n " , argv[i + 1 ], delayInSeconds);
129+ }
130+ else {
131+ delayInSeconds = (UINT)val;
132+ }
133+ i++; // skip the value
134+ } else if ((strcmp (argv[i], " --check" ) == 0 ) && i + 1 < argc) {
76135 EnableChecks (argv[i + 1 ]);
136+ enabled_checks++;
137+ i++; // skip the value
77138 }
139+ // Add more flags here as needed
140+ // else if (strcmp(argv[i], "--otherflag") == 0) { ... }
78141 }
79142 }
80- else {
143+
144+ if (!enabled_checks) {
81145 EnableDefaultChecks ();
82146 }
147+
83148
84149 /* Resize the console window for better visibility */
85150 resize_console_window ();
@@ -326,9 +391,9 @@ int main(int argc, char* argv[])
326391 /* Timing Attacks */
327392 if (ENABLE_TIMING_ATTACKS) {
328393 print_category (TEXT (" Timing-attacks" ));
329- UINT delayInSeconds = 600U ;
394+
330395 UINT delayInMillis = delayInSeconds * 1000U ;
331- printf (" \n [*] Delay value is set to %u minutes ...\n " , delayInSeconds / 60 );
396+ printf (" \n [*] Delay value is set to %u seconds (%u minutes) ...\n " , delayInSeconds , delayInSeconds / 60 );
332397
333398 exec_check (timing_NtDelayexecution, delayInMillis, TEXT (" Performing a sleep using NtDelayExecution ..." ));
334399 exec_check (timing_sleep_loop, delayInMillis, TEXT (" Performing a sleep() in a loop ..." ));
0 commit comments