> Frida 클라이언트 설치
1. 우선 프리다를 설치하려면 파이썬이 있어야 한다.
https://www.python.org/downloads/
Download Python
The official home of the Python Programming Language
www.python.org
2. 설치 후 파이썬 scripts 폴더에 들어간다.
내 컴퓨터에서는 (\PycharmProjects\untitled\venv\Scripts) 였음
(못 찾겠다면 everything이라는 프로그램 깔고 검색하면 찾을 수 있다.)
* 환경변수 설정해주었거나 아나콘다로 파이썬을 깐 경우 제외
3.
pip install frida
pip install frida-tools
* 회사 프록시 환경이라 다운로드가 안될 시! (https://mise.tistory.com/15)
* 혹시 버전이 안맞아 삭제하고 다시 받을시 명령어
pip uninstall frida-tools
pip uninstall frida
pip install frida==12.6.11
pip install frida-tools==2.2.0
> adb download
안드로이드 스튜디오가 안 깔려있는 pc에 경우 adb를 따로 설치해주어야 한다.
https://developer.android.com/studio/releases/platform-tools
다운로드하면 "platform-tools" 폴더가 생기는데 그 안에 adb.exe가 있다.
시스템 환경변수 path에 경로를 넣어주어서 사용하기 편하게 하자
nox에서 adb 연결할 시 nox 다운로드 경로 (C:\Program Files (x86)\Nox\bin)에 nox_adb.exe가 있다.
nox에서 진행 시를 위해 이 경로도 환경변수에 등록해 놓자
> Frida 서버 설치 (단말기)
1. Frida 서버 받기
실 단말기에 frida 서버를 설치 후 실행시켜야 하는데 bit를 알아보고 설치해야 한다.
- 단말기 확인법 : 단말기 연결 > *(윈도우)script폴더 접근 > adb shell getprop ro.product.cpu.abi => arm64
(* = 환경변수 설정 시 skip 가능)
아래 url에서 다운로드
https://github.com/frida/frida/releases
Releases · frida/frida
Clone this repo to build Frida. Contribute to frida/frida development by creating an account on GitHub.
github.com
나는 frida-server-14.2.18-android-arm64 을 받았다.
2. 서버에 전송
그다음 받은 서버를 단말기 /data/local/tmp에 전송해야 한다.
adb push frida-server-14.2.18-android-arm64 /data/local/tmp
3. 권한 변경 및 실행
adb shell
su -
cd /data/local/tmp
chmod 755 frida-server-14.2.18-android-arm64
chown root.root frida-server-14.2.18-android-arm64
./frida-server-14.2.18-android-arm64 &
* 다음에 접근할 땐 권한 변경 부분 제외하고 입력
> Frida 서버 설치 (nox)
1. Frida 서버 받기
nox도 똑같이 frida 서버를 설치 후 실행시켜야 한다.
- nox 확인법 : nox 실행 > *(윈도우)script폴더 접근 > nox_adb shell > getprop ro.product.cpu.abi => x86
(* = 환경변수 설정 시 skip 가능)
위에서 받은 frida-server-14.2.18-android-x86으로 사용할 거다.
2. 서버에 전송
nox_adb push frida-server-14.2.18-android-x86 /data/local/tmp
* nox는 명령어가 조금 다름
3. 권한 변경 및 실행
nox_adb shell
cd /data/local/tmp
chmod 777 frida-server-14.2.18-android-x86
./frida-server-14.2.18-android-x86 &
* 다음에 접근할 땐 권한 변경 부분 제외하고 입력
> Frida 서버 설치 (bluestack)
블루스택은 초기 세팅이 필요한데
a. 루트권한 설정 (설정 > 디바이스 설정)
b. Andriod 디버그 브릿지 on (설정 > 고급 기능 설정) 한 뒤에 진행하자
1. Frida 서버 받기
frida-server-14.2.18-android-x86 받았다.
2. 서버에 전송
adb connect 127.0.0.1:5555 // connected to 127.0.0.1:5555 문구뜨면 연결된거다.
adb -s 127.0.0.1:5555 shell // 연결 후에 전송
adb -s 127.0.0.1:5555 push frida-server-14.2.18-android-x86 /data/local/tmp //-s 옵션으로 연결을 알려줘야 함
3. 권한 변경 및 실행
adb connect 127.0.0.1:5555
adb -s 127.0.0.1:5555 shell
su
chmod 777 frida-server-14.2.18-android-x86
cd /data/local/tmp
./frida-server-14.2.18-android-x86 &
> 프리다 사용법
- 패키지 명 확인
frida-ps -Uia
- js 코드 프리다로 돌리기
frida -U -f [패키지명] -l [자바스크립트 파일] --no-pause
> 기본 틀
- js
Java.perform(function() {
console.log("[+] Hooking System.exit");
var exitClass = Java.use("java.lang.System"); //hooking 할 메소드의 class 명
exitClass.exit.implementation = function() { //class명.method명.implementation = funtion(argv[])
console.log("[+] System.exit called");
}
});
- py
import frida, sys
def on_message(message, data):
print(message)
# Hooking 할 어플리케이션의 package 명
PACKAGE_NAME = "owasp.mstg.uncrackable1"
jscode = """
console.log("[+] Start Script");
Java.perform(function() {
console.log("[+] Hooking System.exit");
var exitClass = Java.use("java.lang.System"); //hooking 할 메소드의 class 명
exitClass.exit.implementation = function() { //class명.method명.implementation = funtion(argv[])
console.log("[+] System.exit called");
}
});
"""
process = frida.get_usb_device(1).attach(PACKAGE_NAME)
script = process.create_script(jscode)
script.on('message', on_message)
print('[+] Running Hook')
script.load()
sys.stdin.read()'Mobile > Android' 카테고리의 다른 글
| [안드로이드] 내부 저장소 내 중요정보 확인 (0) | 2022.04.06 |
|---|---|
| [안드로이드] 다른 pc에서 burp 이용시 인증서 오류 뜰 때 (0) | 2021.11.21 |
| [안드로이드] 안드로이드 7.0이상 단말기에서 버프 연동하기 (0) | 2021.11.16 |
| [안드로이드] UnCrackable-Level1로 후킹 연습하기 (0) | 2021.10.21 |
| [안드로이드] RPS.apk로 후킹 연습하기 (0) | 2021.10.21 |