能力值:
( LV2,RANK:10 )
|
-
-
2 楼
刚解决了
目标程序的代码如下: /*****************************************************************************
To be the apostrophe which changed "Impossible" into "I'm possible"!
POC code of chapter 4 in book "Vulnerability Exploit and Analysis Technique"
file name : target_server.cpp
author : failwest
date : 2007.4.4
description : TCP server which got a stack overflow bug for exploit practice
Noticed : Complied with VC 6.0 and build into release version are recommend
version : 1.0
E-mail : failwest@gmail.com
Only for educational purposes enjoy the fun from exploiting :)
******************************************************************************/
#include<iostream.h>
#include<winsock2.h>
#pragma comment(lib, "ws2_32.lib")
void msg_display(char * buf)
{
char msg[200];
//strcpy(msg,buf);// overflow here, copy 0x200 to 200 程序原先使用字符串拷贝
memcpy(msg,buf,0x800); // 改为直接内存拷贝,避过了BADCHARS '/x00'
cout<<"********************"<<endl;
cout<<"received:"<<endl;
cout<<msg<<endl;
}
void main()
{
int sock,msgsock,lenth,receive_len;
struct sockaddr_in sock_server,sock_client;
char buf[0x800]; //noticed it is 0x200
WSADATA wsa;
WSAStartup(MAKEWORD(1,1),&wsa);
if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
{
cout<<sock<<"socket creating error!"<<endl;
exit(1);
}
sock_server.sin_family=AF_INET;
sock_server.sin_port=htons(7777);
sock_server.sin_addr.s_addr=htonl(INADDR_ANY);
if(bind(sock,(struct sockaddr*)&sock_server,sizeof(sock_server)))
{
cout<<"binging stream socket error!"<<endl;
}
cout<<"**************************************"<<endl;
cout<<" exploit target server 1.0 "<<endl;
cout<<"**************************************"<<endl;
listen(sock,4);
lenth=sizeof(struct sockaddr);
do{
msgsock=accept(sock,(struct sockaddr*)&sock_client,(int*)&lenth);
if(msgsock==-1)
{
cout<<"accept error!"<<endl;
break;
}
else
do
{
memset(buf,0,sizeof(buf));
if((receive_len=recv(msgsock,buf,sizeof(buf),0))<0)
{
cout<<"reading stream message erro!"<<endl;
receive_len=0;
}
msg_display(buf);//trigged the overflow
}while(receive_len);
closesocket(msgsock);
}while(1);
WSACleanup();
} //strcpy(msg,buf);// overflow here, copy 0x200 to 200 程序原先使用字符串拷贝
memcpy(msg,buf,0x800); // 改为直接内存拷贝,避过了BADCHARS '/x00' 目标测试用例里原先使用了 strcpy 来造成栈溢出,可由于现在MSF6里面无法对 windows/exec的payload进行避免‘/x00’编码,所以就改为采用memset来进行溢出,书里面的MSF3与MSF6相隔时间太久了
|
|
|