
EMBA란?
EMBA : 오픈소스 펌웨어 분석 툴 // https://github.com/e-m-b-a
EMBA
The security analyzer for firmware of embedded devices. - EMBA
github.com
→ EMBA는 모의침투 전문가, PM 등을 위해 설계된 펌웨어 분석 및 SBOM 툴입니다. 이는 펌웨어 추출과 함께 정적, 동적 분석을 에뮬레이션을 통해 수행합니다. 그리고 그 결과 발견한 취약한 영역, 오래된 소프트웨어 요소 등을 정리하여 report를 생성합니다.
설치 & 실행 방법 // https://github.com/e-m-b-a/emba
GitHub - e-m-b-a/emba: EMBA - The firmware security analyzer
EMBA - The firmware security analyzer. Contribute to e-m-b-a/emba development by creating an account on GitHub.
github.com
● 설치 방법
git clone https://github.com/e-m-b-a/emba.git
cd emba
sudo ./installer.sh -d
● 실행 방법
sudo ./emba -l [output] -f [firmware] -p ./scan-profiles/[scan-profile]
EMBA는 여러 testing 방법을 제공합니다. 기본적으로 위의 -p 옵션 없이도 진행할 수 있지만, EMBA는 제공된 scan-profile을 사용하여 EMBA를 실행하는 것을 추천합니다.
biz-jeongwon@biz-jeongwon:~/emb/emba/scan-profiles$ ls
default-scan-emulation.emba default-scan-no-notify.emba full-scan.emba sbom-minimal.emba
default-scan-gpt.emba default-scan.emba quick-scan.emba
default-scan-long.emba example-disable-module.emba sbom-default.emba
`2024.11.14. 기준 EMBA는 위와 같이 다양한 scan-profile을 제공합니다. 각각의 profile에 따라 장단점이 있으며, 기능이 다릅니다. 그 중 자주 사용되는 profile은 default-scan, default-scan-emulation입니다.
default-scan은 EMBA가 제공하는 가장 기본적인 testing profile입니다.
https://github.com/e-m-b-a/emba/wiki/System-emulation
System emulation
EMBA - The firmware security analyzer. Contribute to e-m-b-a/emba development by creating an account on GitHub.
github.com
default-scan-emulation은 위의 단점을 개선한 버전입니다. 기존 EMBA는 알려진 취약점에 대해서만 분석을 수행합니다. 따라서 한계가 명확합니다. 그렇기 때문에 firmadyne, firmAE 등 system emulation을 사용하는 툴을 기존의 버전과 결부하여 개선을 수행하였습니다.
물론, 더 나은 버전이지만, 아직 개선 중이며, 기능을 추가하는 중이라는 단점이 있습니다. 그럼에도 위 버전을 확장하여 다양한 기능을 제공하여 주기 때문에 해당 profile을 사용하여 testing하는 것을 추천드립니다.
biz-jeongwon@biz-jeongwon:~/emb/emba$ ./emba -h
==> Imported 14 helper files
==> Imported 88 module/s
╔═══════════════════════════════════════════════════════════════╗
║ E M B A ║
║ EMBEDDED FIRMWARE ANALYZER ║
╚═══════════════════════════════════════════════════════════════╝
USAGE
Test firmware
-l [~/path] Log path
-f [~/path] Firmware path
-m [MODULE_NO.] Test only with set modules [e.g. -m p05 -m s10 ... or -m p to run all p modules]
(multiple usage possible, case insensitive)
-p [PROFILE] EMBA starts with a pre-defined profile (stored in ./scan-profiles)
-t Activate multi threading (destroys regular console output)
-P Overwrite auto MAX_MODS (maximum modules in parallel) configuration
-T Overwrite auto MAX_MOD_THREADS (maximum threads per module) configuration
Developer options
-D Developer mode - EMBA runs on the host without container protection
-S STRICT mode - developer option to improve code quality (not enabled by default)
-y Overwrite log directory automaticially, even if it is not empty
System check
-d [1/2] Only checks dependencies (1 - on host and in container, 2 - only container)
-F Checks dependencies but ignore errors
-U Check and apply available updates and exit
-V Show EMBA version
Special tests
-k [~/config] Kernel config path
-C [container id] Extract and analyze a local docker container via container id
-r Remove temporary firmware directory after testing
-b Just print a random banner and exit
-o [~/path] 2nd Firmware path to diff against the main firmware file - diff mode only (no other firmware analysis)
-c Enable extended binary analysis
-E Enables automated qemu user emulation tests (WARNING this module could harm your host!)
-Q Enables automated qemu system emulation tests (WARNING this module could harm your host!)
-a [MIPS] Architecture of the linux firmware [MIPS, ARM, x86, x64, PPC] (usually not needed)
-A [MIPS] Force Architecture of the linux firmware [MIPS, ARM, x86, x64, PPC] (disable architecture check - usually not needed)
-e [./path] Exclude paths from testing (multiple usage possible - usually not needed)
Reporter options
-W Activates web report creation in log path (overwrites -z)
-g Create grep-able log file in [log_path]/fw_grep.log
-s Prints only relative paths
-z Adds ANSI color codes to log
Firmware details
-X [version] Firmware version (versions aka 1.2.3-a:b only)
-Y [vendor] Firmware vendor (alphanummerical values only)
-Z [device] Device (alphanummerical values only)
-N [notes] Testing notes (alphanummerical values only)
Help
-h Prints this help message
추가로 ./emba -h 명령어를 통해 분석에 있어 사용할 수 있는 여러 option을 확인할 수 있습니다. 이를 통해 firmware diff 등 특수한 테스트나 분석의 여러 사항을 조정할 수 있습니다.
EMBA 실행 결과 분석
https://github.com/e-m-b-a/emba/wiki/Feature-overview
Feature overview
EMBA - The firmware security analyzer. Contribute to e-m-b-a/emba development by creating an account on GitHub.
github.com
EMBA의 분석 모듈은 크게 4가지로 나눌 수 있습니다.
(P) Pre modules : 사전 분석 모듈로, 펌웨어로부터 파일을 추출하고, 기본 정보들을 분석합니다.
(S) Core modules : 취약한 영역, 펌웨어의 특이한 부분 등을 분석합니다.
(L) Live testing modules : default-scan-emulation의 system emulation 동작을 수행합니다.
(F) Finishing modules : EMBA의 분석 결과를 정리함
당연히 각각의 모듈에서의 분석 결과물은 펌웨어 분석에 있어 가치있지만, 그 중 펌웨어 Zero-day 분석을 수행할 때 확인하면 좋다고 생각하는 부분에 대해서 소개하고자 합니다.
// `2024.11.14. 기준
Pre-modules (P)
→ EMBA 분석 이전 과정을 수행하는 모듈이므로 결과물에 있어 분석에 크게 의미있는 부분을 찾기는 어렵지만, 몇몇 기본 사항을 확인할 수 있습니다.
Core-modules (S)
● s07_bootloader_check
: bootloader나 부팅 시작 파일들을 확인할 수 있습니다. 이를 통해 부팅 과정을 파악하고, 서비스 관리, 시작 프로그램 등을 식별할 수 있으므로, 기기의 동작 과정을 분석하기 유용합니다. U-boot, OpenBSD configuration 파일을 식별하고, init.d, inittabn, rc.d 등의 파일을 찾습니다.
● s09_firmware_base_version_check
: 펌웨어에 존재하는 binary들의 정적 버전을 탐지하고, 해당 버전에 대해 알려진 CVE를 f20 파일에 정리합니다. 이를 통해 펌웨어가 취약한 버전의 binary를 사용하고 있다면, 해당 버전에 대해 알려진 CVE로 1-day 분석이 가능합니다.
※ 다만, 해당 모듈의 파일에서는 버전만 확인할 수 있고, 분석 결과는 f20파일에서 확인할 수 있습니다.
● s13_weak_func_check
: binary에 사용된 fprintf, mmap, printf, sprintf, strcat, strcpy, system함수를 찾습니다. 그리고 해당 함수가 많이 사용된 binary를 정리하며, 해당 binary가 리눅스 기본 파일인지 확인합니다. 이를 통해 Zero-day 분석을 위한 Attack Surface를 결정하는 것에 도움을 받을 수 있습니다.
● s25_kernel_check
: 커널의 버전 등 여러 정보를 확인합니다. 그리고 s09 모듈과 같이 해당 커널 버전에서 발생한 CVE를 분석하여 보여줍니다. 비록 kernel exploit과 관련된 사항이지만, Attack Surface를 선택할 때 도움을 받을 수 있습니다.
● s35_http_file_check
: http, webserver 관련 파일을 찾습니다. 그리고 해당 파일에서 취약한 함수나, 해당 파일의 버전에서 발생한 CVE를 정리하여 보여줍니다. 해당 파일은 User Interaction과 큰 연관성이 있는 만큼 Attack Vector가 발생할 수 있는 부분을 발견할 수 있습니다.
※ http 파일이 lighttpd인 경우 s36 파일에 분석 결과가 추가로 들어있습니다.
● s115_usermode_emulator
: QEMU를 사용해 펌웨어의 실행가능한 파일들을 에뮬레이트하여 해당 파일들의 버전에 대해 분석하여, s116 모듈에 저장합니다. 그리고 해당 파일들의 버전에서 발생한 CVE를 f20 파일에 정리합니다.
→ 제가 주로 사용하기 좋다고 생각한 Core module은 여러 binary에 대한 정적 분석을 통해 찾은 1-day CVE들을 분석하는 모듈들입니다. 다른 모듈에서도 Privilege Escalation, SSH password, Network, Shellcode 등 다양한 정보를 확인할 수 있으므로, 위 파일을 위주로 다른 모듈들의 분석 결과들을 확인하면 좋을 것 같습니다.
Live testing-modules (L)
→ default-scan-emulation profile을 사용할 때만 사용되는 모듈입니다.
● l10_system_emulation
: 해당 profile의 qemu 에뮬레이팅 과정을 수행할 때 사용한 파일과 에뮬레이팅을 실행한 run.sh 파일이 포함되어있으며, 여러 Init 파일 또한 포함되어있습니다.
● l25_web_checks
: system emulating 환경에서 ssl service 등에서 취약한 부분을 식별하며, web server에 대한 crawling을 통해 unique responses를 찾습니다.
● l35_metasploit_check
: system emulating 환경에서 metasploit framework를 사용해 간단한 BoF 취약점부터 웹 서버, DB, Wi-fi까지 다양한 범위의 보안 취약점을 찾습니다.
Finishing-modules (F)
● f20_vul_aggregator
: Core modules에서 분석한 binary들의 버전에 대해 알려진 CVE들이 정리되어 있습니다. CVE들은 csv 파일로도 정리가 되어 있고, CVSS score에 따라서도 나누어져 있습니다. 그리고 exploitDB의 PoC 존재 여부에 따라 해당 payload를 첨부합니다.
EMBA는 위 모듈들을 사용해 펌웨어의 보안 사항을 분석합니다. 이를 통해 침투 테스터에게는 Attack Surface를 제공해주고, PM에게는 취약한 영역, 소프트웨어 등을 보여주며 도와줌을 알 수 있습니다.
분석 결과를 활용한 Zero-day 분석 방향
저는 현재 EMBA를 사용해 임베디드 장비의 Zero-day 취약점을 찾아 CVE를 발급받고자 합니다. 따라서 위 결과를 통해 제가 분석중인 방향성에 대해 간략히 소개해드리겠습니다.
우선 default-scan으로 분석함에 있어 중요하게 살펴보고 있는 모듈은 s35_http_file_check에 의해 파생된 s36_lighttpd 입니다. 주로 Firmware에서 취약점을 찾는다고 한다면, 자주 분석할 파일은 User Interaction이 있는 http, CGI 혹은 System daemon 파일일 것입니다. 따라서 이를 우선적으로 분석중에 있습니다.
현재는 해당하는 http 버전에 따른 CVE를 실제 binary와 공개된 소스 코드와 비교하며 분석을 수행 중에 있습니다. 일단 해당하는 함수를 디스어셈블러를 통해 대조하여 찾는 과정을 거치고, 만약 발견한다면 CVE가 trigger 되는지를 확인할 예정입니다. 이는 다른 임베디드 장비에서 발생한 1-day 취약점이 분석 장비에서도 발견되는 사례와 유사하며, Zero-day 분석에 큰 도움이 될 것이라 생각합니다.
그리고 default-scan-emulation으로 분석을 진행중에 있는데, 까다로이 수행해야 하는 emulating 과정의 커널 이미지를 구하는 과정 등을 쉽게 제공해주어 매우 편리합니다. 또한, default-scan과 다른 여러 취약점과 Attack Vector를 찾을 수 있는 모듈들을 통해 더욱 다양한 분석이 가능합니다.
따라서 저는 이러한 EMBA를 적절히 사용한다면, 임베디드 장비의 펌웨어로부터 Zero-day 취약점을 찾는 것에 큰 도움이 될 것이라 확신합니다.
'석정원' 카테고리의 다른 글
| 공유기 파괴일지 (0) | 2025.01.29 |
|---|---|
| Debugging with MIPSel + Musl Env (0) | 2025.01.29 |
| squashFS 구조 (0) | 2024.12.09 |

stellarflare 님의 블로그 입니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!