Firmware-Mod-Kit(fmk) 사용하여 펌웨어 분석하기

 

Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다.
연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다.

Firmware-Mod-Kit(fmk) 사용하여 펌웨어 분석하기

1. 다운로드 및 설치
https://code.google.com/p/firmware-mod-kit 으로 가서 다운받는다.
별다를 설치의 과정은 없으며, 압축을 풀면된다.

2. 실행을 위한 라이브러리 설치.
fmk를 사용하기 위해서는 압축라이브러리(gzip, lzma)와 python magic 모듈이 필요하다.
우분투의 경우 아래와 같이 설치하면 쉽게 설치할 수 있다.

sudo apt-get install build-essential zlib1g-dev liblzma-dev python-magic

3. 실행

# ./extract-firmware.sh firmware.bin 
Firmware Mod Kit (extract) 0.99, (c)2011-2013 Craig Heffner, Jeremy Collake

Preparing tools ...
Scanning firmware...

Scan Time:     2014-06-12 16:41:19
Signatures:    193
Target File:   /root/apollo89/fmk/firmware.bin
MD5 Checksum:  217dd5********************e6596e

DECIMAL   	HEX       	DESCRIPTION
-------------------------------------------------------------------------------------------------------
16605     	0x40DD    	LZMA compressed data, properties: 0x04, dictionary size: 33554432 bytes, uncompressed size: 50331648 bytes
147460    	0x24004   	LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 264160 bytes
262144    	0x40000   	TRX firmware header, little endian, header size: 28 bytes,  image size: 7712768 bytes, CRC32: 0xAC1E337D flags/version: 0x10000
262172    	0x4001C   	LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 4477728 bytes
2089684   	0x1FE2D4  	Squashfs filesystem, little endian, version 4.0, compression:  size: 5880002 bytes,  520 inodes, blocksize: 131072 bytes, created: Thu May 22 11:09:56 2014 

Extracting 2089684 bytes of  header image at offset 0
Extracting squashfs file system at offset 2089684
Extracting 1024 byte footer from offset 7973944
Extracting squashfs files...
Firmware extraction successful!
Firmware parts can be found in '/root/apollo89/fmk/fmk/*'

위의 경우 LZMA압축을 사용하고, SquashFS 파일시스템을 사용하는 것을 볼수 있다.

* LZMA(Lempel–Ziv–Markov chain algorithm)는 데이터 압축에 쓰이는 알고리즘이다. 1998년 이후로 계속 개발 중이며 7-zip 압축 프로그램의 7z 형식에 쓰인다.
* SquashFS는 read-only 파일 시스템이며 사용자가 전체 파일시스템 혹은 single 디렉토리를 압축하고, 그것들이 다른 디바이스/파티션들 혹은 보통 파일에 쓰고(Write), 그리고 나서 그것들을 장치라면 직접 혹은 파일이라면 loopback 장치를 사용하여 마운트 시킨다.

압축이 풀린 펌웨어 파일시스템은 fmk 폴더 안에 존재한다.

# cd fmk/rootfs/
# ls -al
total 64
drwxr-xr-x. 16 root root 4096 2014-05-22 11:09 .
drwxr-xr-x   5 root root 4096 2014-06-12 16:41 ..
drwxr-xr-x.  5 root root 4096 2014-05-22 11:09 bin
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 cramfs
drwxr-xr-x.  4 root root 4096 2014-05-22 11:09 default
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 dev
lrwxrwxrwx.  1 root root    8 2014-06-12 16:41 etc -> /tmp/etc
drwxr-xr-x.  3 root root 4096 2014-05-22 11:09 home
drwxr-xr-x.  3 root root 4096 2014-05-22 11:09 lib
lrwxrwxrwx.  1 root root   11 2014-06-12 16:41 linuxrc -> bin/busybox
lrwxrwxrwx.  1 root root    8 2014-06-12 16:41 mnt -> /tmp/mnt
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 plugin
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 proc
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 save
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 sbin
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 sys
drwxr-xr-x.  2 root root 4096 2014-05-22 11:09 tmp
drwxr-xr-x.  4 root root 4096 2014-05-22 11:09 usr
lrwxrwxrwx.  1 root root    8 2014-06-12 16:41 var -> /tmp/var

파일 시스템을 확인할 수 있다..

이제 열심히 분석…

참고 : https://code.google.com/p/firmware-mod-kit
http://ko.wikipedia.org/wiki/LZMA
http://croky.tistory.com/229
 

This entry was posted in Security/Hacking and tagged , . Bookmark the permalink.

댓글 남기기