how to execute Arm binary

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

이 명령어로 시스템에 대한 설정을 시작한다.

Python
(base) foxirain@foxirain:/home/amemoyoi/1day_2pwn$ ls /proc/sys/fs/binfmt_misc/
python3.12    qemu-alpha  qemu-armeb  qemu-hexagon  qemu-loongarch64  qemu-microblaze  qemu-mips64    qemu-mipsel   qemu-mipsn32el  qemu-ppc64    qemu-riscv32  qemu-s390x  qemu-sh4eb  qemu-sparc32plus  qemu-xtensa    register
qemu-aarch64  qemu-arm    qemu-cris   qemu-hppa     qemu-m68k         qemu-mips        qemu-mips64el  qemu-mipsn32  qemu-ppc        qemu-ppc64le  qemu-riscv64  qemu-sh4    qemu-sparc  qemu-sparc64      qemu-xtensaeb  status

해당 명령어 이후에 /proc/sys/fs/binfmt_misc/ 이 영역에 다음과 같이 qemu 관련 파일이 생기는데 이 디렉토리가 비표준 바이너리( elf X , 셀코드 X ) 에 대해 어떤 언어로 해석할지를 보여주는 디렉토리이다.

Python
(pwn) amemoyoi ~$ cat /proc/sys/fs/binfmt_misc/python3.12 
enabled
interpreter /usr/bin/python3.12
flags: 
offset 0
magic cb0d0d0a

예를 들어 다음과 같이 실행시킬 인터 프리터 위치와 매직이 다음과 같이 존재한다.

이후 Arm용 libc를 설치후

sudo apt install libc6-armel-cross

라이브러리 설치

다음과 같이 라이브러리 위치를 지정해준뒤 실행해주면 된다.

qemu-arm-static -L /usr/arm-linux-gnueabi ./arm_binary