Forensics/Iphone Forensics

[ios Forensics] 아이폰 메모리 포렌식 - fridump 사용

pental 2019. 12. 17. 13:36

필자는 1주일 동안 해매다 드디어 아이폰 메모리 덤프를 성공했다.

[ Requirement  / 요구사항 ]

1. python 3.x ( python2.7 보다 python3.x 버전을 추천한다 ) ( https://python.org // 여기서 다운로드 가능하다)

2. iphone ( 필자는 iphone6 / 12.3.1 을 사용했으며 물론 탈옥이 되어있는 상태이다.)

3. frida

다시 본론으로.

python3 버전을 설치하면 자동으로 환경변수가 등록된다. + pip 도 가능하다.

먼저 pip 로 frida 를 설치해준다.

C:\Users\pental>pip install frida

frida를 설치 했다면, 본인의 아이폰을 컴퓨터에 연결후

C:\Users\pental>frida-ps -U

입력해주면 현재 본인의 탈옥된 아이폰의 프로세스를 보여줍니다.

C:\Users\pental>frida-ps -U
Waiting for USB device to appear...
 PID  Name
----  -------------------------------------------------
2773  Mail
2793  메모
2807  설정
2777  AppleCredentialManagerDaemon
2769  AssetCacheLocatorService
2761  CMFSyncAgent
2735  CloudKeychainProxy
 147  CommCenter
----- 이하생략 -----​

 

 

여기서 문제가 발생할수 있는데, 필자는 itunes 를 설치 하지 않고 frida-ps -U 를 해봤지만, 장치를 찾을수 없다는 

Waiting for USB device to appear... 이구문만 계속해서 반복되었다.

혹시라도 frida를 사용했을때 위와 같은 구문이 나온다면 itunes 를 설치하자. ( 참고 : https://blog.do9.kr/337 ) 

 

프로세스가 정상적으로 보여지면 70%는 성공한 것이다.

https://github.com/Nightbringer21/fridump

 

Nightbringer21/fridump

A universal memory dumper using Frida. Contribute to Nightbringer21/fridump development by creating an account on GitHub.

github.com

위 사이트를 들어가서 아이폰 메모리 덤프에 필요한 파일을 다운 받자.

파일은 간단하게 3개의 파일로 이뤄져 있다. (필자는 python 3.7 을 사용했다. )

C:\Users\pental\Desktop\fridump-master>python fridump.py -h

        ______    _     _
        |  ___|  (_)   | |
        | |_ _ __ _  __| |_   _ _ __ ___  _ __
        |  _| '__| |/ _` | | | | '_ ` _ \| '_ \
        | | | |  | | (_| | |_| | | | | | | |_) |
        \_| |_|  |_|\__,_|\__,_|_| |_| |_| .__/
                                         | |
                                         |_|

usage: fridump [-h] [-o dir] [-U] [-v] [-r] [-s] [--max-size bytes] process

positional arguments:
  process            the process that you will be injecting to

optional arguments:
  -h, --help         show this help message and exit
  -o dir, --out dir  provide full output directory path. (def: 'dump')
  -U, --usb          device connected over usb
  -v, --verbose      verbose
  -r, --read-only    dump read-only parts of memory. More data, more errors
  -s, --strings      run strings on all dump files. Saved in output dir.
  --max-size bytes   maximum size of dump file in bytes (def: 20971520)

사용 방법은 위와 같이 -h 옵션을 붙여주면 파악 가능하다.

아까 frida-ps -U 구문을 쳤지 않았나? 필자는 메모 앱을 덤프해 보도록 하겠다.

PID 가 2793이지 않는가? 우리는 2793을 기억하고 덤프한다. (물론 메모로 진행하지 않아도 좋다.)

fridump의 사용방법은 python fridump.py -U -r [PID] 이다.

C:\Users\pental\Desktop\fridump-master>python fridump.py -U -r 2793

        ______    _     _
        |  ___|  (_)   | |
        | |_ _ __ _  __| |_   _ _ __ ___  _ __
        |  _| '__| |/ _` | | | | '_ ` _ \| '_ \
        | | | |  | | (_| | |_| | | | | | | |_) |
        \_| |_|  |_|\__,_|\__,_|_| |_| |_| .__/
                                         | |
                                         |_|

Can't connect to App. Have you connected the device?

하지만 필자의 기대와는 달리 Can't connect to App. Have you connected the device? 라는 구문을 뿜어낸다.

이 문제로 인해서 몇일을 고생했다. StackoverFlow에서는 3.7말고 더 하위버전을 써라, 어디서는 3.8을 써라 등등 다양한 의견이 맞았지만 필자에게는 해결방법이 맞지 않았다. (도움을 준 pdm0205와 RT께 감사의 말을 전한다.)

https://github.com/rootbsd/fridump3

 

rootbsd/fridump3

A universal memory dumper using Frida for Python 3 - rootbsd/fridump3

github.com

fridump3 버전 전용을 사용하면 정상적으로 덤프를 할수 있다. (다운 받는 방법은 당연히 알거라 서술 하지 않는다.)

C:\Users\pental\Desktop\fridump3-master>python fridump3.py -u -r 2852

        ______    _     _
        |  ___|  (_)   | |
        | |_ _ __ _  __| |_   _ _ __ ___  _ __
        |  _| '__| |/ _` | | | | '_ ` _ \| '_ \
        | | | |  | | (_| | |_| | | | | | | |_) |
        \_| |_|  |_|\__,_|\__,_|_| |_| |_| .__/
                                         | |
                                         |_|

Current Directory: C:\Users\pental\Desktop\fridump3-master
Output directory is set to: C:\Users\pental\Desktop\fridump3-master\dump
Starting Memory dump...
Progress: [###############-----------------------------------] 29.9% Completee

( 덤프 과정에서 폰이 꺼지는 바람에 pid가 변경되었다. // 무시해도 좋다.)

여러 오류가 뜨지만 무시해도 좋다.

Oops, memory access violation!#############################--] 96.13% Complete
Oops, memory access violation!#############################--] 96.39% Complete
Oops, memory access violation!#############################--] 96.65% Complete
Oops, memory access violation!#############################--] 96.91% Complete
Oops, memory access violation!##############################-] 97.16% Complete
Oops, memory access violation!##############################-] 97.42% Complete
Finished!

완료가 되면, 해당폴더 내 dump 폴더가 생성되서 거기에 저장이 되었을 것이다.

필자는 총 778개의 data 파일이 생성되었다.

이렇게 fridump 사용법이 끝났다.

다른 추가적인 문의나 오탈자는 pental@kakao.com 로 보내주시면 감사하겠습니다. :)