Debug Checks and Responses
PreEmptive Protection™ DashO™ for Android & Java can inject checks into Java and Android applications to detect if they are being run in a debuggable mode, or if they are being actively debugged. The Debugging Checks and Responses are configured on the Checks - Debug screen or by adding code annotations.
Debugging Check
To detect if an application is being debugged, place a DebuggingCheck on one or more methods in your application. DashO adds code that performs a runtime check that determines if it is being debugged. This check can be configured as described in the Overview.
An application can contain multiple uses of DebuggingCheck
with various configurations.
Using more than one Check or mixing the Responses will hamper attackers.
private static boolean debuggingFlag;
@DebuggingCheck(action="@debuggingFlag")
public void onCreate(Bundle check){
}
@DebuggingCheck(response=ResponseType.Hang)
private int computeResult(){
}
Note: On non-Android platforms, if a debugger is attached after the application has started, it will not be detected correctly.
Debugging Response
The DebuggingResponse annotation interacts with the DebuggingCheck. This Response can be configured as described in the Overview.
private static boolean debuggingFlag;
@DebuggingCheck(action="@debuggingFlag")
public void onCreate(Bundle state){
}
@DebuggingResponse(source="@debuggingFlag", response=ResponseType.Exit, probability=0.05f)
private int computeResult(){
}
@DebuggingResponse(source="@debuggingFlag", response=ResponseType.Error, probability=0.1f)
private FileInputStream readInput(){
}
Debug Enabled Check
To detect if an app appears to be debuggable, place a DebugEnabledCheck on one or more methods in your application. DashO adds code that performs a runtime check that determines if it appears to be debuggable. This Check can be configured as described in the Overview.
Note: A Debug Enabled Check for Android will trigger if USB debugging is enabled on the device or emulator. Many emulators have USB debugging enabled by default. USB debugging can be enabled or disabled via the Developer options screen.
An application can contain multiple uses of DebugEnabledCheck
with various configurations.
Using more than one Check or mixing the Responses will hamper attackers.
private static boolean debuggingFlag;
@DebugEnabledCheck(action="@debuggingFlag")
public void onCreate(Bundle check){
}
@DebugEnabledCheck(response=ResponseType.Hang)
private int computeResult(){
}
Note:
The Debug Enabled Check for Android requires access to the application's context; it expects agetApplicationContext()
method to exist on the class where it is being injected. Classes extendingandroid.context.Context
, likeandroid.app.Activity
,android.app.Application
,android.app.Service
, etc. will inheritgetApplicationContext()
, and require no additional changes. Otherwise, you will need to add agetApplicationContext()
method and make sure it returns a properContext
.
Debug Enabled Response
The DebugEnabledResponse annotation interacts with the DebugEnabledCheck. This Response can be configured as described in the Overview.
private static boolean debuggingFlag;
@DebugEnabledCheck(action="@debuggingFlag")
public void onCreate(Bundle state){
}
@DebugEnabledResponse(source="@debuggingFlag", response=ResponseType.Exit,
probability=0.05f)
private int computeResult(){
}
@DebugEnabledResponse(source="@debuggingFlag", response=ResponseType.Error,
probability=0.1f)
private FileInputStream readInput(){
}