해킹공주의 일상
Android 기기에 Frida 설치하기(+ERROR 처리) 본문
Nox 에서 모든것을 해결하려고 하였으나 일부 앱이 녹스에서 염병하게 안되는 바람에 어쩔수없이 기기로 넘어오게되었다 빡센 프로젝트가 들어오면 나는 힘들지만 암튼 성장하니까... 그래.. 한번만 봐준다
Ready
- 루팅된 단말기
- Python(설치방법 생략. 그냥 다운받아서 설치하면 됨)
- adb
Step by Step
Install ADB & Connect Device
1) 단말기 USB 드라이버 설치(삼성 통합드라이버,LG USB Driver,Google USB Driver)
2) ADB Tool 다운로드(Android SDK platform tool 설치)
https://developer.android.com/studio/releases/platform-tools?hl=ko
SDK 플랫폼 도구 출시 노트 | Android 개발자 | Android Developers
Android SDK 플랫폼 도구는 Android SDK의 구성요소입니다.
developer.android.com
3) 환경변수에 ADB 설치 Path 추가해야하는데, 나는 귀찮아서 그냥 adb.exe 있는 폴더에서 했음. 근데 환경변수에 추가하는게 정신건강에 좋음
4) 단말기 설정 > 개발자 메뉴 > USB 디버깅 연결 활성화
5) 단말기와 PC 연결 후 다음 명령어 입력해서 연결 확인
adb device
Install Frida
python -m pip install --upgrade pip
pip install frida
pip install frida-tools
하고나서 아래와 같이 버전 정보가 뜨면 성공이야~
C:\Users>frida --version
16.0.9
Install Frida-Server
1) 안드로이드 운영체제 비트 확인
: 아래와 같이 명령어 입력해서 운영체제 비트 확인.
C:\Users\platform-tools_r34.0.0-windows\platform-tools> adb shell getprop ro.product.cpu.abi
arm64-v8a
2) frida-server 파일 다운로드 (https://github.com/frida/frida/releases)
: 위 링크에서 본인 운영체제에 맞는 frida-server 파일 다운로드 후, 압축해제(확장자 없음)
여기서 다운받은 프리다 서버버전과 python 에서 설치하는 버전이 안맞으면 다음과 같은에러가 나므로 버전을 잘맞춰주자.
Failed to spawn: unable to communicate with remote frida-server; please ensure that major versions match and that the remote Frida has the feature you are trying to use
3) frida-server 파일 서버에 넣기
: 확장자가 없는 frida-server 파일을 adb.exe 와 같은 폴더 안에 넣고, cmd를 열어 다음과 같이 단말기에 넣기.
C:\Users>adb push ./frida-server-16.0.9-android-x86_64 /data/local/tmp
./frida-server-16.0.9-android-x86_64: 1 file pushed, 0 skipped. 17.7 MB/s (112167064 bytes in 6.035s)
4) frida-server 파일 실행
:adb.exe 가 있는 폴더에서 cmd를 열어 shell을 실행시킨후, 다음과 같이 서버를 실행
C:\>adb shell
beyond1q:/ # cd /data/local/tmp // 서버 집어넣은 곳으로 이동
beyond1q:/data/local/tmp # ls
frida-server-16.0.2-android-x86 // 파일이 잘 push 됨을 확인
beyond1q:/data/local/tmp # chmod 777 frida-server-16.0.2-android-x86 // 실행시키기 위해 권한 변경
beyond1q:/data/local/tmp # ./frida-server-16.0.2-android-x86 & // 백그라운드에서 실행
[1] 5153
1|beyond1q:/data/local/tmp # ps | grep "frida*"
root 5153 5146 58712 47584 d4686cc0 S ./frida-server-16.0.2-android-x86
// 잘 실행되고 있음을 확인
ERROR
Permission denied
Unable to load SELinux policy from the kernel: Failed to open file ?/sys/fs/selinux/policy?: Permission denied
: su 명령어로 해당 경로 chmod 777 해주면 댐.!
$ su chmod 777 /sys/fs/selinux/policy
Address already in use
Unable to start: Error binding to address 127.0.0.1:27042: Address already in use
: ps로 조회하면 안나오고 netstat 로 잡았을때 나오는 경우가 있다. 그냥 잡아서 아래와 같이 kill 하고 새로 시작하면 된다
dream2lteks:/data/local/tmp # netstat -antp | grep fri
tcp 0 0 127.0.0.1:27042 0.0.0.0:* LISTEN 27754/frida-server-16.0.9-android-arm64
dream2lteks:/data/local/tmp # ps | grep fri
1|dream2lteks:/data/local/tmp #
1|dream2lteks:/data/local/tmp # kill -9 27754
dream2lteks:/data/local/tmp # ./frida-server-16.0.9-android-arm64 &
[1] 27890
{"type":"error","descrption":"Error: Unable to perform state transition; ...
: 이렇게 실행 에러가 나면 서버 실행에 에러가 난거라 frida-ps 하더라도 출력값이 없다.
a32:/data/local/tmp # ./frida-server-16.5.1-android-arm64 &
[1] 22045
a32:/data/local/tmp # {"type":"error","description":"Error: Unable to perform state transition;
please file a bug","stack":"Error: Unable to perform state transition; please file a bug\n
at bt (frida/node_modules/frida-java-bridge/lib/android.js:578:1)\n at frida/node_modules/
frida-java-bridge/lib/class-model.js:112:1\n at Function.build (frida/node_modules/frida-
java-bridge/lib/class-model.js:7:1)\n at k._make (frida/node_modules/frida-java-bridge/lib/
class-factory.js:168:1)\n at k.use (frida/node_modules/frida-java-bridge/lib/class-factory
.js:62:1)\n at frida/node_modules/frida-java-bridge/index.js:224:1\n at c.perform (frid
a/node_modules/frida-java-bridge/lib/vm.js:12:1)\n at _performPendingVmOpsWhenReady (frida/n
ode_modules/frida-java-bridge/index.js:223:1)\n at _.perform (frida/node_modules/frida-ja
va-bridge/index.js:204:1)\n at /internal-agent.js:490:6","fileName":"frida/node_modules/fri
da-java-bridge/lib/android.js","lineNumber":578,"columnNumber":1}
adb shell 에서 아래 명령어를 입력하고 재부팅 해주자.
pm uninstall com.google.android.art
Failed to spawn: need Gadget to attach on jailed Android; its default location is:
Failed to spawn: need Gadget to attach on jailed Android; its default location is:
C:\Users\70752\AppData\Local\Microsoft\Windows\INetCache\frida\gadget-android-arm64.so
: 요것은 이제.. 서버를 재실행 시켜주면 된다.
'모의해킹 > MOBILE' 카테고리의 다른 글
Frida를 활용한 SSL Pinning 우회(안드로이드) (0) | 2023.02.25 |
---|---|
adb shell error: more than one device/emulator (0) | 2023.02.16 |
iOS에 Frida 설치 (0) | 2023.02.14 |
안드로이드 Nox 프록시(BurpSuite) 환경 구성하기 (0) | 2023.02.13 |
[Fridump] Fridump IOS 앱 복호화 추출하기 (0) | 2022.12.05 |