일반적으로 release 앱 권한에서는 fork & open /proc/child_pid/maps 시 권한이 없어서 "No such file or directory" 에러가 발생한다.

이를 해결하기 위해 아래와 같이 코딩한다.

prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); // enable
.. fork() 수행
.. open("/proc/child_pid/maps", ) 수행
.. ptrace() 수행
prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); // disable

https://android.googlesource.com/platform/frameworks/base/+/master/core/jni/com_android_internal_os_Zygote.cpp 의 EnableDebugger()를 참조하였음

또한,  EnableDebugger()을 앱에 인젝션 하면 앱 디버깅 시 manifest를 수정하지 않아도 될 것 같다. (참고 : https://codetronik.tistory.com/165?category=1096665) 

 

(안드로이드) IDA 동적 디버깅

1. 리패키징 혹은 개발 과정에서 아래 코드를 추가 // build.gradle에 추가 buildTypes { release { debuggable true } // AndroidManifest.xml에 추가 2. adb forward tcp:23946 tcp:23946 3. adb push c:\ida\db..

codetronik.tistory.com

 

1. 리패키징 혹은 개발 과정에서 아래 코드를 추가

// build.gradle에 추가
buildTypes {
	release {
		debuggable true
	}
    
// AndroidManifest.xml에 추가
<application
	android:debuggable="true"     
	tools:ignore="HardcodedDebugMode">

2. adb forward tcp:23946 tcp:23946

3. adb push c:\ida\dbgsrv\android_server64 /data/local/tmp

4. 안드로이드에서 /android_server64 &

5. IDA->Debugger->Attach->Remote ARM Linux/Android debugger

6. Hostname 127.0.0.1 Port 23946

7. Run!

8. 앱 선택 후 attach 되면 F9

9. got SIGCHLD signal 창이 뜨면 F9클릭 후 Yes 클릭

 

 

	var access = Module.findExportByName(null, "access");
	Interceptor.attach(access, {
		onEnter: function(args) {			
			console.log("path : " + Memory.readUtf8String(args[0]));
		}
	});

+ Recent posts