OTUSの専門家であるAlexanderKolesnikovが、リバースエンジニアリングコースの学生向けに特別に書いた有益な記事を私たちと共有してくれました 。基本
私たちはすることを勧め のコースのデモデイ・ウォッチ私たちの教師はコースのプログラムと答えた質問について詳細に話しているが、。
アルゴリズムを取得するためのリバースエンジニアリングは常に魅力的ですが、新しいものを作成するためのリバースエンジニアリングはさらにクールです。この記事では、Fridaツールを使用して、脆弱なアプリケーションを分析するプロセスを少し簡単にし、このアプリケーションのエクスプロイトを少し簡単に作成しようとします。
この記事のすべての例は、Linuxオペレーティングシステムでのヒープ攻撃を扱っているため、忍耐とポップコーンを用意しています。
ヒープ
Heap — , . , malloc
. , . , .
. . , libc, . :
heap grooming attack
fastbin attack
tcache attack
unlink
largebin
unsortedbin attack
, . . — , . , — libc. — .
Frida
frida 2 : frida-trace MemoryMonitor. , . , , CTF.
Heap Grooming
, libc 2.23. , , , , . , . 7. :
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
unsigned long int *mem0, *mem1, *mem2;
mem0 = malloc(0x10);
mem1 = malloc(0x10);
mem2 = malloc(0x10);
printf("Allocated memory on:\nptr0: %p\nptr1: %p\nptr2: %p\n\n", mem0, mem1, mem2);
free(mem0);
free(mem1);
free(mem2);
printf("mem0 after free and alloc again: %p\n", malloc(0x10));
printf("mem1 after free and alloc again: %p\n", malloc(0x10));
printf("mem2 after free and alloc again: %p\n\n", malloc(0x10));
}
. :
, , , printf
? printf
frida-trace
. :
Frida-trace -f test -i “malloc”
handler
. “handlers” frida-trace. malloc.js OnLeave
, :
. pico CTF “Are you root”. frida-trace:
, , . , login;
Auth level
. ? malloc 0x10 0x7. , , 0x10, 2 - 0x1514eb0 0x1514ed0. .
TCACHE
, , tcache
, . , tcache
, tcache
:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
unsigned long int *mem0, *mem1;
int target;
mem0 = malloc(0x10);
mem1 = malloc(0x10);
target = 0xdead;
printf("mem0: %p\n", mem0);
printf("mem1: %p\n", mem1);
printf("int: %p\n\n", &target);
free(mem0);
free(mem1);
printf("Next pointer for mem1: %p\n\n", (unsigned long int *)mem1);
*mem1 = (unsigned long int)⌖
printf("Next pointer for mem1: %p\n\n", (unsigned long int )mem1);
printf("Malloc Allocated: %p\n\n", malloc(0x10));
printf("Malloc Allocated: %p\n\n", malloc(0x10));
}
, frida-trace , :
, , , . , malloc
. , Use-After-Free. Plaid CTF “cpp”. :
, malloc
. :
, .
. . , . .