Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/src/main/java/com/xff/launch/detector/DebugDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public DetectionItem detectPtrace() {
// Native layer - read TracerPid via native
int nativeTracerPid = nativeDetector.getTracerPid();

// Set layer results (INVERTED: true = safe, false = detected)
item.setLayerResult(DetectionLayer.JAVA, javaTracerPid == 0);
item.setLayerResult(DetectionLayer.NATIVE, nativeTracerPid == 0);
item.setLayerResult(DetectionLayer.SYSCALL, syscallTracerPid == 0);
// Set layer results: true = detected (TracerPid > 0), false = safe
item.setLayerResult(DetectionLayer.JAVA, javaTracerPid != 0);
item.setLayerResult(DetectionLayer.NATIVE, nativeTracerPid != 0);
item.setLayerResult(DetectionLayer.SYSCALL, syscallTracerPid != 0);

// Check all threads
String allThreadsStatus = checkAllThreadsTracerPid();
Expand Down Expand Up @@ -232,10 +232,10 @@ public DetectionItem detectPtraceSelfProtection() {
detail = "TracerPid:0 (正常 - 无反调试保护)";
}

// Set layer results (true = safe/normal, false = risk)
item.setLayerResult(DetectionLayer.JAVA, tracerPid == 0 || isProtected);
item.setLayerResult(DetectionLayer.NATIVE, tracerPid == 0 || isProtected);
item.setLayerResult(DetectionLayer.SYSCALL, tracerPid == 0 || isProtected);
// Set layer results: true = detected risk (external debugger), false = safe/normal
item.setLayerResult(DetectionLayer.JAVA, tracerPid != 0 && !isProtected);
item.setLayerResult(DetectionLayer.NATIVE, tracerPid != 0 && !isProtected);
item.setLayerResult(DetectionLayer.SYSCALL, tracerPid != 0 && !isProtected);

item.setStatus(status);
item.setDetail(detail);
Expand Down
60 changes: 30 additions & 30 deletions app/src/main/java/com/xff/launch/detector/ReadlinkDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ private DetectionItem checkProcSelfExe() {
// Check consistency between layers
boolean consistent = nativeExePath.equals(syscallExePath);

item.setLayerResult(DetectionLayer.JAVA, !javaRisk && javaOk);
item.setLayerResult(DetectionLayer.NATIVE, !nativeRisk && nativeOk);
item.setLayerResult(DetectionLayer.SYSCALL, !syscallRisk && syscallOk);
item.setLayerResult(DetectionLayer.JAVA, javaRisk || !javaOk);
item.setLayerResult(DetectionLayer.NATIVE, nativeRisk || !nativeOk);
item.setLayerResult(DetectionLayer.SYSCALL, syscallRisk || !syscallOk);

if (javaRisk || nativeRisk || syscallRisk) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -174,9 +174,9 @@ private DetectionItem checkProcSelfMaps() {
// Check for hidden mappings (indication of hook framework)
boolean hasHiddenMaps = nativeDetector.checkHiddenMapsSyscall();

item.setLayerResult(DetectionLayer.JAVA, hasContent);
item.setLayerResult(DetectionLayer.NATIVE, !hasSuspicious);
item.setLayerResult(DetectionLayer.SYSCALL, !hasHiddenMaps);
item.setLayerResult(DetectionLayer.JAVA, !hasContent);
item.setLayerResult(DetectionLayer.NATIVE, hasSuspicious);
item.setLayerResult(DetectionLayer.SYSCALL, hasHiddenMaps);

if (hasHiddenMaps) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -216,9 +216,9 @@ private DetectionItem checkProcSelfMounts() {
boolean hasBindMount = mountContent.contains("magisk") ||
mountContent.contains("ksu") || mountContent.contains("apatch");

item.setLayerResult(DetectionLayer.JAVA, true);
item.setLayerResult(DetectionLayer.NATIVE, !hasOverlay);
item.setLayerResult(DetectionLayer.SYSCALL, !hasBindMount);
item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, hasOverlay);
item.setLayerResult(DetectionLayer.SYSCALL, hasBindMount);

if (hasBindMount) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -253,9 +253,9 @@ private DetectionItem checkProcSelfRoot() {
boolean syscallOk = "/".equals(syscallRoot);
boolean consistent = nativeRoot.equals(syscallRoot);

item.setLayerResult(DetectionLayer.JAVA, true);
item.setLayerResult(DetectionLayer.NATIVE, nativeOk);
item.setLayerResult(DetectionLayer.SYSCALL, syscallOk);
item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, !nativeOk);
item.setLayerResult(DetectionLayer.SYSCALL, !syscallOk);

if (!syscallOk) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -289,9 +289,9 @@ private DetectionItem checkProcSelfCwd() {
boolean hasSuspicious = containsSuspicious(syscallCwd);
boolean consistent = nativeCwd.equals(syscallCwd);

item.setLayerResult(DetectionLayer.JAVA, true);
item.setLayerResult(DetectionLayer.NATIVE, !containsSuspicious(nativeCwd));
item.setLayerResult(DetectionLayer.SYSCALL, !hasSuspicious);
item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, containsSuspicious(nativeCwd));
item.setLayerResult(DetectionLayer.SYSCALL, hasSuspicious);

if (hasSuspicious) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -325,9 +325,9 @@ private DetectionItem checkProcSelfFd() {
// Also check via native
int nativeFdCount = nativeDetector.checkSuspiciousFdsNative();

item.setLayerResult(DetectionLayer.JAVA, true);
item.setLayerResult(DetectionLayer.NATIVE, nativeFdCount == 0);
item.setLayerResult(DetectionLayer.SYSCALL, suspiciousFdCount == 0);
item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, nativeFdCount != 0);
item.setLayerResult(DetectionLayer.SYSCALL, suspiciousFdCount != 0);

if (suspiciousFdCount > 0) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -381,9 +381,9 @@ private DetectionItem checkSuSymlinks() {
}
}

item.setLayerResult(DetectionLayer.JAVA, true);
item.setLayerResult(DetectionLayer.NATIVE, nativeFound == 0);
item.setLayerResult(DetectionLayer.SYSCALL, syscallFound == 0);
item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, nativeFound > 0);
item.setLayerResult(DetectionLayer.SYSCALL, syscallFound > 0);

if (syscallFound > 0) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -453,9 +453,9 @@ private DetectionItem checkSystemBinaries() {
}
}

item.setLayerResult(DetectionLayer.JAVA, true);
item.setLayerResult(DetectionLayer.NATIVE, nativeSuspicious == 0);
item.setLayerResult(DetectionLayer.SYSCALL, syscallSuspicious == 0);
item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, nativeSuspicious > 0);
item.setLayerResult(DetectionLayer.SYSCALL, syscallSuspicious > 0);

if (syscallSuspicious > 0) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -524,9 +524,9 @@ private DetectionItem checkAppPath() {
boolean consistent = nativeReal.equals(syscallReal);
boolean hasSuspicious = containsSuspicious(nativeReal) || containsSuspicious(syscallReal);

item.setLayerResult(DetectionLayer.JAVA, !hasSuspicious);
item.setLayerResult(DetectionLayer.NATIVE, !nativeIsLink || !hasSuspicious);
item.setLayerResult(DetectionLayer.SYSCALL, !syscallIsLink || !hasSuspicious);
item.setLayerResult(DetectionLayer.JAVA, hasSuspicious);
item.setLayerResult(DetectionLayer.NATIVE, nativeIsLink && hasSuspicious);
item.setLayerResult(DetectionLayer.SYSCALL, syscallIsLink && hasSuspicious);

if (hasSuspicious) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -565,9 +565,9 @@ private DetectionItem checkMountNamespace() {
boolean nativeCheck = nativeDetector.checkMountNamespaceNative();
boolean syscallCheck = nativeDetector.checkMountNamespaceSyscall();

item.setLayerResult(DetectionLayer.JAVA, true);
item.setLayerResult(DetectionLayer.NATIVE, nativeCheck);
item.setLayerResult(DetectionLayer.SYSCALL, syscallCheck);
item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, !nativeCheck);
item.setLayerResult(DetectionLayer.SYSCALL, !syscallCheck);

if (!syscallCheck) {
item.setStatus(DetectionStatus.RISK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private DetectionItem checkSyscallTimingOpenat() {
// Set layer results
item.setLayerResult(DetectionLayer.JAVA, false); // Java layer N/A
item.setLayerResult(DetectionLayer.NATIVE, isHooked);
item.setLayerResult(DetectionLayer.SYSCALL, !isHooked);
item.setLayerResult(DetectionLayer.SYSCALL, isHooked);

if (isHooked) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -157,7 +157,7 @@ private DetectionItem checkSyscallTimingAccess() {

item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, isHooked);
item.setLayerResult(DetectionLayer.SYSCALL, !isHooked);
item.setLayerResult(DetectionLayer.SYSCALL, isHooked);

if (isHooked) {
item.setStatus(DetectionStatus.RISK);
Expand Down Expand Up @@ -193,7 +193,7 @@ private DetectionItem checkSyscallTimingStat() {

item.setLayerResult(DetectionLayer.JAVA, false);
item.setLayerResult(DetectionLayer.NATIVE, isHooked);
item.setLayerResult(DetectionLayer.SYSCALL, !isHooked);
item.setLayerResult(DetectionLayer.SYSCALL, isHooked);

if (isHooked) {
item.setStatus(DetectionStatus.RISK);
Expand Down
Loading