일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 플로이드와샬
- BFS
- sigmoid
- 부르트포스
- 백준
- DeepLearning
- Stack
- 탐색
- C++
- 풀이
- 문제풀이
- 알고리즘
- 캡스톤정리
- Docker
- Swift
- Algorithm
- Blockchain
- dp
- NeuralNetwork
- Greedy
- 백트래킹
- dfs
- 그리디
- 실버쥐
- ios
- ReLU
- 그래프
- 프로그래머스
- mysql
- Node.js
- Today
- Total
개발아 담하자
[iOS] Fridump3 를 사용한 메모리 덤프 본문
유저가 민감한 데이터(ID, password) 를 입력한 후 이 데이터가 메모리 상에 존재하는 경우 취약점이 발생할 수 있습니다.
이 취약성을 점검할 때 메모리 덤프를 통해 메모리 상에 중요한 정보가 있는지 확인할 수 있습니다.
이번 포스팅은 Frida(Fridump) 를 사용한 메모리 덤프에 대한 기초적인 수준의 내용을 작성했습니다.
기기 준비
1. 탈옥하기
탈옥된 아이폰 기기가 필요합니다.
탈옥 방법 : https://comdori.tistory.com/91
[iOS] 컴퓨터 없이 아이폰 아이패드 iOS14.3 이하 탈옥(해킹) 하기
내용 업데이트 2021년 8월 17일 - JBsite 웹사이트 주소 변경 (https://jbsite.kr/), A12(아이폰XS) 이상 탈옥 가능 확인 완료! 2021년 8월 22일 - 최신언커버 및 언커버6.1.1 다운로드 직링크 연결 컴퓨터 연결..
comdori.tistory.com
2. Frida 설치
탈옥된 기기에 frida 를 설치해야 합니다.
Cydia 앱에 들어가서 소스 > 편집 > 추가 > https://build.frida.re 소스를 추가한 후 알맞은 환경의 패키지를 다운받습니다. (frida 또는 frida for 32bits device)
PC 준비
1. pip 설치
아래 명령어를 입력해 pip을 설치합니다.
sudo easy_install pip
2. python3 설치
아래 명령어를 입력해 python3 을 설치하고 알맞게 설치가 되었는지 확인합니다.
brew install python3
python --version
python3 을 설치하더라도 버전 2.xx 이 뜨는 경우는 아래 명령어를 bash_profile 파일 에 입력한 후 저장합니다.
vi ~/.bash_profile // bash_profile 편집
alias python='python'
source ~/.bash_profile // bash_profile 저장
3. frida 설치
아래 명령어를 입력해 frida 를 설치합니다.
pip3 install frida-tools
이 때 urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> 와 같은 권한 오류가 발생해 설치가 안되는 경우가 있습니다.
pip install certifi
위 명령어를 실행해 certifi 패키지를 설치한 후
CERT_PATH=$(python -m certifi)
export SSL_CERT_FILE=${CERT_PATH}
export REQUESTS_CA_BUNDLE=${CERT_PATH}
~/.bash_profile 에 위 코드를 작성한 후 저장하면 해결됩니다.
4. fridump3 설치
https://github.com/rootbsd/fridump3
GitHub - rootbsd/fridump3: A universal memory dumper using Frida for Python 3
A universal memory dumper using Frida for Python 3 - GitHub - rootbsd/fridump3: A universal memory dumper using Frida for Python 3
github.com
원하는 디렉토리에 들어가 fridump3 깃 클론을 받습니다.
한글 앱 메모리 덤프를 위해 클론받은 fridump3.py 파일을 수정해야 합니다.
# Start a new Session
session = None
try:
if USB:
session = frida.get_usb_device().attach(APP_NAME)
elif NETWORK:
session = frida.get_device_manager().add_remote_device(IP).attach(APP_NAME)
else:
session = frida.attach(APP_NAME)
except Exception as e:
print(str(e))
sys.exit()
# Start a new Session
session = None
try:
if USB:
session = frida.get_usb_device().attach(int(APP_NAME)) # 수정!!
elif NETWORK:
session = frida.get_device_manager().add_remote_device(IP).attach(APP_NAME)
else:
session = frida.attach(APP_NAME)
except Exception as e:
print(str(e))
sys.exit()
한글 앱을 pid 로 인식시키기 위해 attach(APP_NAME) -> attach(int(APP_NAME)) 으로 수정합니다.
5. Fridump 실행하기
이제 fridump 를 실행하기 위한 준비가 끝났습니다. 탈옥된 기기를 USB 로 연결합니다.
클론받은 fridump3 디렉토리로 들어가 아래 명령어를 실행해 기기가 제대로 연결 되었는지 확인합니다.
frida-ls-devices
Id Type Name
---------------------------------------- ------ ------------
local local Local System
429e9ee46bb4b078677d39dd51a064a2ead11580 usb iPhone
socket remote Local Socket
아래 명령어를 입력해 메모리 덤프하고 싶은 어플의 pid를 확인합니다.
이 때 어플은 실행 상태 여야 합니다.
frida-ps -U | grep "원하는 어플 이름"
이제 메모리 덤프를 실행합니다.
python fridump3.py -u -r [PID]
Starting Memory dump...
Oops, memory access violation!-------------------------------] 14.52% Complete
Oops, memory access violation!-------------------------------] 17.42% Complete
Oops, memory access violation!-------------------------------] 17.53% Complete
Oops, memory access violation!-------------------------------] 20.0% Completee
Oops, memory access violation!-------------------------------] 20.86% Complete
Oops, memory access violation!-------------------------------] 20.97% Complete
Oops, memory access violation!-------------------------------] 29.57% Complete
Oops, memory access violation!-------------------------------] 29.78% Complete
Oops, memory access violation!-------------------------------] 34.84% Complete
Oops, memory access violation!############################---] 93.12% Complete
Oops, memory access violation!############################---] 93.33% Complete
Oops, memory access violation!###############################] 99.03% Complete
Oops, memory access violation!
Oops, memory access violation!
Finished!
해당 디렉토리 안에 덤프된 .data 메모리 파일들이 있음을 확인할 수 있습니다.
참고 자료https://cha3m.tistory.com/21
[iOS] frida 환경 구성
진행환경 iphone5s (10.3.3) Mac os (windows 에서도 가능) frida를 이용해서 iOS 앱을 분석하기 위한 환경구성 1. pip 설치 sudo easy_install pip 위 명령어가 안된다면 다음 두줄 실행 curl https://bootstrap...
cha3m.tistory.com
https://www.py4u.net/discuss/15704
How to make Python use CA certificates from Mac OS TrustStore?
Answer #5: As an update and datapoint, I ran into this issue running Python 3.7.0 on macOS 10.13.4: $ ipython Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) Type 'copyright', 'credits' or 'license' for more information IPython 7.0.1 -- An enhanced
www.py4u.net
https://stackoverflow.com/questions/18425379/how-to-set-pythons-default-version-to-3-x-on-os-x
How to set Python's default version to 3.x on OS X?
I'm running Mountain Lion and the basic default Python version is 2.7. I downloaded Python 3.3 and want to set it as default. Currently: $ python version 2.7.5 $ python3.3 version 3.3 Ho...
stackoverflow.com
'📱 iOS' 카테고리의 다른 글
[iOS] MLKit 를 사용한 사진 속 텍스트 인식하기 (0) | 2021.11.05 |
---|---|
[iOS] IDFA 적용하기 (0) | 2021.10.29 |
[iOS/Swift] storyboard 없이 UI 그리기 (iOS 13 버전 이하) (0) | 2021.09.12 |
[iOS/Swift] xcworkspace 파일 추가하기 (0) | 2021.09.12 |
[Swift] 의존성 주입 (DI) 이란? (3) | 2021.07.21 |