Skip to content

Commit 37b4c6b

Browse files
[LAB5] 313554033:bypass ASan by unpoisoning redzone
1 parent c32547b commit 37b4c6b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lab5/antiasan.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
#include <string.h>
1+
// antiasan.c
2+
#include "antiasan.h"
3+
#include <sanitizer/asan_interface.h>
24

35
void antiasan(unsigned long addr)
46
{
7+
// addr 是 &gBadBuf,gS 緊接在它前面 0x18 bytes
8+
// 我們直接往前退 0x20 bytes,解毒整塊 gS + 之後很大一段,
9+
// 確保把中間那段紅區(redzone) 都 unpoison 掉
10+
void *start = (void*)(addr - 0x20);
11+
size_t len = 0x200; // 解毒 0x200 bytes(512 bytes),足夠覆蓋所有紅區
512

13+
__asan_unpoison_memory_region(start, len);
614
}

0 commit comments

Comments
 (0)