Android-studio - SDK Manager
NDK(Side by side)
CMake
두가지 필수 인스톨
jni환경 구축하시고
cpp파일에 아래코드 구현하시면 됩니다.
void be_attached_check() {
try {
const int bufsize = 1024;
char filename[bufsize];
char line[bufsize];
int pid = getpid();
sprintf(filename, "/proc/%d/status", pid);
FILE *fd = fopen(filename, "r");
if (fd != nullptr) {
while (fgets(line, bufsize, fd)) {
if (strncmp(line, "TracerPid", 9) == 0) {
int statue = atoi(&line[10]);
// LOGD("%s", line);
if (statue != 0) {
fclose(fd);
int ret = kill(pid, SIGKILL);
}
break;
}
}
fclose(fd);
} else {
}
} catch (...) {
}
}
void thread_task(int n) {
while (true) {
be_attached_check();
std::this_thread::sleep_for(std::chrono::seconds(n));
}
}
void anti_process_status () {
auto checkThread = std::thread(thread_task, 1);
checkThread.detach();
}
extern "C"
JNIEXPORT void JNICALL
Java_kr_com_testapp_main_MainActivity_antiDebug(JNIEnv *env, jobject thiz) {
// TODO: implement antiDebug()
anti_process_status();
}