반응형

1. 환경

  • host: macOS
  • target: ELF 32-bit LSB executable, Atmel AVR 8-bit,

2. QEMU 설치

  • brew 를 사용한 install
    • brew install qemue
  • apt 를 사용한 install
    • apt install qemu

3. AVR 바이너리(ELF) 파일 실행

4. avr-gdb 설치

  • First, make sure you have xcode command line developer tools installed with
    $ xcode-select --install
  • Then, just run the following to install the latest version of avr-gcc:
    $ brew tap osx-cross/avr
    $ brew install avr-gcc
    $ brew install avr-gdb

5. avr-gdb 를 이용한 디버깅 실행

  • avr-gdb 명령어 실행
  • user@bk-mac:~/ctf $ avr-gdb ./atme.elf GNU gdb (GDB) 10.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-apple-darwin20.6.0 --target=avr". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"...
  • qemu에 실행되어 있는 ELF 파일에 원격 연결
  • (gdb) target remote :1234 Remote debugging using :1234 warning: Target-supplied registers are not supported by the current architecture 0x00000000 in __vectors ()
  • 디버깅 예제

'Security > [리얼] IoT' 카테고리의 다른 글

iptime 공유기에서 펌웨어 추출하는 방법  (2) 2016.05.13
반응형

1. binwalk명령어를 사용하여 파일시스템 오프셋 확인

  • 명령어 : binwalk [binary]
  • 아래의 사진을 보면 " Squashfs filesystem, little endian, version 4.0, c"라는 파일시스템이 offset 1345582에 위치한 것을 확인할 수 있다.

2. dd 명령어로 파일시스템 추출

  • 명령어 : dd if=binary of=output bs=1 skip=[filesystem offset]
  • file명령어로 output파일을 확인한 결과 Squashfs 파일이 정상적으로 추출된 것을 확인할 수 있다.

3. 파일시스템 mount

  • 명령어 : unsquashfs output
  • squashfs-root디렉토리가 생성되었고 내부에 각 파일들이 존재한다.

# Download 'unsquashfs 
sudo apt-get install lzma-dev 
sudo apt-get install liblzma-dev 
tar -zxvf squashfs4.2.tar.gz 
cd squashfs4.2/squashfs-tools
: Edit Makefile and uncomment this line "LZMA_XZ_SUPPORT = 1" 

make
sudo make install 
sudo unsquashfs <path/lzma_filename_to_unsquash>

'Security > [리얼] IoT' 카테고리의 다른 글

QEMU 를 이용한 AVR 바이너리 분석하는 방법  (0) 2022.01.23

+ Recent posts