security/리버싱핵심원리

UPX 압축

민사민서 2023. 3. 11. 20:10

upx -o notepad_upx.exe notepad.exe

 

이렇게 하면 안 열림

 

This has to do with resource compression; the "MUI" resource somehow does not get uncompressed correctly which causes LoadStringW to fail, regardless of .mui files being present or not. This in turn causes notepad to bail (nice error handling...). If you compress with upx --compress-resources=0 you'll see that it works.

 

upx --compress-resources=0 -o notepad_upx.exe notepad.exe

 

이래야 실행 압축 제대로 됨 (압축률은 감소)

 

[UPX OEP 찾기]

1) EP code가 PUSHAD/POPAD로 둘러쌓여있음 => tracing => POPAD 뒤의 JMP 명령어에 bp

 

2) Hardware Breakpoint 이용 (Debug - Hardware breakpoint 에서 확인 가능)

PUSHAD 직후 스택 ESP 주소 파악 => dump 창에서 해당 주소로 jump(Ctrl+G) => 해당 주소 우클릭 => Breakpoint - Hardware, on access => byte/word/dword 암거나 선택 => F9(실행) => POPAD 다음 명령어에서 멈춤

'security > 리버싱핵심원리' 카테고리의 다른 글

UPack 파일 분석 - HXD, Ollydbg  (0) 2023.03.12
PE 재배치  (0) 2023.03.11
tiny PE 분석  (0) 2023.03.11
PE File Format 정리  (0) 2023.03.09
Ollydbg 단축키 정리  (0) 2023.03.08