A fix would be to monitor the threads for termination
and not suspended state but it is possible to just set
the thread to be suspended indefinitely without
terminating it. A possible solution for this would be
to check the suspended time on each thread and
determine whether they have been suspended for an
unusual amount of time, but the implementation of
this solution would have to be specific since
suspension times can vary due to various reasons
from the operating system as well. In the current
implementation, the only thread that would produce a
detection vector when suspended would be the
heartbeat thread since both the driver and the user
mode application operates upon it. Another defect is
present in the driver. Both the user mode application
and the protected process utilize API functions and
subroutines from the driver to enable their self-
defence mechanisms but the driver does not
implement such features. Due to this fact it is possible
to simply unregister the callbacks registered by the
driver if an attacker is able to map a driver of their
own. The only method preventing rogue mapping of
drivers is checking for test signing policy through the
user mode application. However, it is possible to
manual map drivers into kernel space without a valid
certificate using methods such as through vulnerable
drivers. The implemented heartbeat system is vague
and could be improved upon. This is due to the fact
that only the heartbeat thread is responsible for
carrying out the communication between the driver.
This means that the heartbeat thread could be
terminated or simply suspended in order to bypass the
entire implementation. A solution for this would be to
create a system thread of its own through the driver
and synchronize the heartbeat process through them.
Another major weakness would be the fact that the
monitoring system does not perform any integrity
checks on itself and the files. An attacker would be
able to patch system routines and monitoring system
files in order to circumvent most of the detection
mechanisms. The files include system files as well.
Obtaining hash values for all system modules in each
distribution of Windows would be a tedious and long
task that would not be fruitful when achieving the
ultimate goal of developing this system, which is to
introduce a new method of approach to anti-
debugging and anti-disassembly.
4 TESTING THE SYSTEM
In these scenarios, we will attempt to cloak the
x32dbg debugger using various methods and attempt
to debug a protected application. The effectiveness of
the monitoring application will be decided on the
following criteria.
1. Detection
2. Traceback
3. Termination – Not carried out
Detection refers to the ability of the monitoring
application to detect any debugging attempts done to
the protected application. Detection criteria will be
triggered if Hooks, Suspicious handles to the process,
presence of a dormant (installed but not running)
debugger within the system, injected modules,
manually mapped modules are discovered.
Suspicious handles are handles to the application
created by untrusted processes. Untrusted processes
refer to processes without a valid digital signature or
forged signatures and processes containing
(Microsoft, Debug Privilege, 2017) SE_DEBUG
privileges. System processes are excluded from this
detection vector since most of the system processes
contain this privilege in latest Windows builds.
Furthermore, registry values will be observed in order
to determine whether certain analysis tools and
processes are installed within a system. If a detection
has occurred, the monitoring application would try to
traceback to the process responsible. In the
termination phase, the monitoring application would
try to determine if the process obtained through the
traceback is eligible to be terminated. The termination
would occur in two separate ways by either
terminating the process that triggered the detection or
terminating the protected process itself. The latter
method is used in case the monitoring application is
unable to terminate the debugger. The monitoring
program should only protect the protected
application. It should not prevent debugging attempts
done to other applications which are not protected by
the monitoring system. Therefore, traceback and
termination should not happen in the case of a
debugger debugging another application which is not
protected. The monitoring system is designed to
traceback and log the triggered detection vector and
the actual termination of the responsible process or
tool is not carried out since it will be difficult to
monitor the effectiveness of the system and log the
required details. Therefore, a traceback is determined
as a successful termination. One major issue during
testing was the fact that since thread hiding is enabled
it is difficult to attach a debugger to any application
without it crashing since there are no visible threads
in the process. A way to bypass this would be to byte
patch the executable (timb3r, 2019). However, this
would be impractical in most test scenarios therefore