Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- practicalmalwareanalysis
- string
- PMA
- writeup
- Bug
- format
- pico
- Leak
- shellcraft
- pwn
- ASM
- FSB
- CANARY
- Rookiss
- CTF
- Read
- Toddler's Bottle
- TUCTF
- reversing
- rev
- picoCTF
- shellcode
- anti
- BOF
- pwnable.kr
- 2018
- toddler
- Bottle
- Reverse
- pwnable
Archives
- Today
- Total
제리의 블로그
PMA Lab16-01.exe 안티디버깅 본문
Lab16-01.exe
if ( *(_BYTE *)(__readfsdword(0x30) + 2) )
del_file();
if ( *(_DWORD *)(*(_DWORD *)(__readfsdword(0x30) + 0x18) + 0x10) )
del_file();
if ( *(_DWORD *)(__readfsdword(0x30) + 0x68) == 0x70 )
del_file();
이 프로그램은 3가지 안티디버깅 기법이 적용된 Lab09 실습 프로그램입니다.
디버깅 중이라는 것이 판명되면 악성코드 스스로 삭제하게 됩니다. (sub_401000)
첫번째는 BeingDebugged 플래그
.text:00403554 mov eax, large fs:30h
.text:0040355A mov bl, [eax+2]
.text:0040355D mov [ebp+var_1820], bl
.text:00403563 movsx eax, [ebp+var_1820]
.text:0040356A test eax, eax
.text:0040356C jz short loc_403573
.text:0040356E call del_file
해당 플래그가 1이면 디버깅 중입니다.
두번째는 ProcessHeap 플래그
.text:00403573 mov eax, large fs:30h
.text:00403579 mov eax, [eax+18h]
.text:0040357C db 3Eh
.text:0040357C mov eax, [eax+10h]
.text:00403580 mov [ebp+var_1824], eax
.text:00403586 cmp [ebp+var_1824], 0
.text:0040358D jz short loc_403594
.text:0040358F call del_file
세번째는 NTGlobalFlag
.text:00403594 mov eax, large fs:30h
.text:0040359A db 3Eh
.text:0040359A mov eax, [eax+68h]
.text:0040359E sub eax, 70h
.text:004035A1 mov [ebp+var_1828], eax
.text:004035A7 cmp [ebp+var_1828], 0
.text:004035AE jnz short loc_4035B5
.text:004035B0 call del_file
이렇게 3가지의 플래그가 매 함수 프롤로그때마다 나옵니다.
stealth plugin을 사용하거나 메모리에있는 구조체쪽을 수정해주는 쪽으로 해야겠습니다.
void __noreturn del_file()
{
CHAR Filename; // [sp+Ch] [bp-208h]@1
CHAR Parameters; // [sp+110h] [bp-104h]@1
GetModuleFileNameA(0, &Filename, 0x104u);
GetShortPathNameA(&Filename, &Filename, 0x104u);
strcpy(&Parameters, "/c del");
strcat(&Parameters, &Filename);
strcat(&Parameters, ">> NUL");
ShellExecuteA(0, 0, "cmd.exe", &Parameters, 0, 0);
exit(0);
}
질문
1. 이 악성코드는 어떤 안티디버깅 기법을 이용하고 있는가?
BeingDebugged 플래그, ProcessHeap 플래그, NTGlobalFlag
2. 각 안티디버깅 기법을 성공했을 때 어떤 일이 발생하는가?
Lab16-01.exe 자기 자신을 삭제합니다.
3. 이 안티디버깅 기법을 어떻게 해결할 수 있는가?
OllyDbg 나 IDA 의 플러그인을 사용해서 해결할 수 있습다.
4. 실시간으로 검사하는 구조를 어떻게 수동으로 변경할 수 있는가?
직접 메모리에 접근해서 플래그를 바꿉니다.
5. 무슨 OllyDbg 플러그인으로 이 악성코드가 사용한 안티디버깅 기법으로부터 보호할 수 있는가?
OllyDbg의 hide-debug 플러그인으로 우회할 수 있습니다.
Comments