@@ -831,6 +831,35 @@ static DIR* replaced___opendir2(const char* pathname, size_t bufsize) {
831
831
return NULL ;
832
832
}
833
833
834
+ // anti-antidebug
835
+ // Another way of figuring out if LLDB is attached. (Rednick16)
836
+ static int (*original_isatty)(int fd);
837
+ static int replaced_isatty (int fd) {
838
+ int result = original_isatty (fd);
839
+ if (result && fd == STDOUT_FILENO) {
840
+ errno = ENOENT;
841
+ return 0 ;
842
+ }
843
+ return result;
844
+ }
845
+
846
+ // Yet another way of figuring out if LLDB is attached. (Rednick16)
847
+ static int (*original_ioctl)(int fd, unsigned long request, ...);
848
+ static int replaced_ioctl (int fd, unsigned long request, ...) {
849
+ void * arg;
850
+ va_list args;
851
+ va_start (args, request);
852
+ arg = va_arg (args, void *);
853
+ va_end (args);
854
+
855
+ int result = original_ioctl (fd, request, arg);
856
+ if (!result && request == TIOCGWINSZ) {
857
+ errno = ENOTTY;
858
+ return -1 ;
859
+ }
860
+ return result;
861
+ }
862
+
834
863
void shadowhook_libc (HKSubstitutor* hooks) {
835
864
MSHookFunction (access , replaced_access, (void **) &original_access);
836
865
MSHookFunction (chdir , replaced_chdir, (void **) &original_chdir);
@@ -884,4 +913,6 @@ void shadowhook_libc_antidebugging(HKSubstitutor* hooks) {
884
913
MSHookFunction (ptrace, replaced_ptrace, (void **) &original_ptrace);
885
914
MSHookFunction (sysctl, replaced_sysctl, (void **) &original_sysctl);
886
915
MSHookFunction (getppid , replaced_getppid, NULL );
916
+ MSHookFunction (isatty , replaced_isatty,(void **) &original_isatty);
917
+ MSHookFunction (ioctl, replaced_ioctl, (void **) &original_ioctl);
887
918
}
0 commit comments