Skip to content

Commit

Permalink
Fix no crash
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyesiqiu committed Dec 28, 2024
1 parent 70ef20b commit 4171599
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions shell/src/main/cpp/common/dpt_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define KEEP_SYMBOL __attribute__((visibility("default")))
#define INIT_ARRAY_SECTION __attribute__ ((constructor))
#define ALWAYS_INLINE static inline __attribute__((always_inline))
#define NO_INLINE __attribute__((noinline))
#define SYS_INLINE ALWAYS_INLINE
#define DPT_ENCRYPT SECTION(SECTION_NAME_BITCODE)
#define DPT_DATA_SECTION SECTION(SECTION_NAME_DATA)
Expand Down
2 changes: 1 addition & 1 deletion shell/src/main/cpp/dpt_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ DPT_ENCRYPT void patchClass(__unused const char* descriptor,
DLOGD("Attempt patch junk class %s ,char is '%c'",descriptor,ch);
if(isdigit(ch)) {
DLOGE("Find illegal call, desc: %s!", descriptor);
crash();
dpt_crash();
return;
}

Expand Down
16 changes: 8 additions & 8 deletions shell/src/main/cpp/dpt_risk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "dpt_risk.h"

void crash() {
DPT_ENCRYPT NO_INLINE void dpt_crash() {
#ifdef __aarch64__
asm volatile(
"mov x30,#0\t\n"
Expand All @@ -24,19 +24,19 @@ void crash() {
#endif
}

void junkCodeDexProtect(JNIEnv *env) {
DPT_ENCRYPT void junkCodeDexProtect(JNIEnv *env) {
jclass klass = dpt::jni::FindClass(env,JUNK_CLASS_FULL_NAME);
if(klass == nullptr) {
crash();
dpt_crash();
}
}

[[noreturn]] void *detectFridaOnThread(__unused void *args) {
[[noreturn]] DPT_ENCRYPT void *detectFridaOnThread(__unused void *args) {
while (true) {
int frida_so_count = find_in_maps(1,"frida-agent");
if(frida_so_count > 0) {
DLOGD("detectFridaOnThread found frida so");
crash();
dpt_crash();
}
int frida_thread_count = find_in_threads_list(4
,"pool-frida"
Expand All @@ -46,7 +46,7 @@ void junkCodeDexProtect(JNIEnv *env) {

if(frida_thread_count >= 2) {
DLOGD("detectFridaOnThread found frida threads");
crash();
dpt_crash();
}
sleep(10);
}
Expand All @@ -58,7 +58,7 @@ DPT_ENCRYPT void detectFrida() {
pthread_create(&t, nullptr,detectFridaOnThread,nullptr);
}

void doPtrace() {
DPT_ENCRYPT void doPtrace() {
__unused int ret = sys_ptrace(PTRACE_TRACEME,0,0,0);
DLOGD("doPtrace result: %d",ret);
}
Expand All @@ -73,7 +73,7 @@ DPT_ENCRYPT void *protectProcessOnThread(void *args) {
int pid = waitpid(child, nullptr, 0);
if(pid > 0) {
DLOGW("%s detect child process %d exited", __FUNCTION__, pid);
crash();
dpt_crash();
}
DLOGD("%s waitpid %d end", __FUNCTION__ ,child);

Expand Down
2 changes: 1 addition & 1 deletion shell/src/main/cpp/dpt_risk.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "dpt_jni.h"
#include "linux_syscall_support.h"

void crash();
void dpt_crash();
void detectFrida();
void doPtrace();
void protectChildProcess(pid_t pid);
Expand Down

0 comments on commit 4171599

Please sign in to comment.