原创作者:Unicorn(白色猎人)
信息来源:邪恶八进制安全团队(E.S.T)
最近没事在邪八溜达,看到个sunlion发的老帖子,evilsun匿名信使发送器, 就是模仿windows中的net send命令在局域网中发送消息,接收消息的计算机必须开启了Messenger服务才能正确收到消息,开启messenger的命令是net start messenger。由于当时sunlion没给出代码,反正我也闲着无聊,就随便写了个玩玩,代码很简单,用到的核心函数是NetMessageBufferSend函数。
以下代码在Windows Xp / Windows 2000 + VC6.0下测试成功。
CODE:
/*
* 功能:模仿Net Send 命令发消息
*
* 文件:SendMsg.cpp
*
* 编码:Unicorn
*
* 日期:2006年7月4日
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <windows.h>
#include <Lm.h>
#pragma comment(lib, "Netapi32.lib") // 加载Netapi32.lib库
void Usage(wchar_t *AppName)
{
char szInformation[] = "欢迎使用UNI匿名消息发送器 V1.0 Coding By Unicorn 2006/7/4";
char szParam[] = "参数说明:\r\n\t<DesIP>参数不可省略,是目的机器的IP地址.\r\n\t<SouIP>参数不可省略,是发送端的名称,这里可以随便填写.\r\n\t<Message>参数不可省略,要发送的信息.\r\n\t[Count]参数可以省略,发送消息的次数,默认为1次.";
printf("=========================================================\n");
printf("%s\n", szInformation);
printf("=========================================================\n");
printf("Usage: %s <DesIP> <SouIP> <Message> [Count]\n", AppName);
printf("%s\n", szParam);
}
void wmain(int argc, wchar_t *argv[])
{
// 参数不满4个或者5个的话就出现帮助信息
if ((argc<4) || (argc>5))
{
Usage(argv[0]);
return;
}
wchar_t *DesIp = argv[1];
wchar_t *SouIp = argv[2];
wchar_t *Msg = argv[3];
const wchar_t *wCount = argv[4];
int count = _wtoi(wCount);
if (count == 0)
{
count = 1;
}
int nCount = count;
printf("Sending\n");
while (count--)
{
// 发送函数
int nRet = NetMessageBufferSend(NULL, DesIp, SouIp, (LPBYTE)Msg, sizeof(Msg));
if (nRet != NERR_Success)
{
switch(nRet)
{
case ERROR_ACCESS_DENIED:
printf("\rThe user does not have access to the requested information.\n");
break;
case ERROR_INVALID_PARAMETER:
printf("\rThe specified parameter is invalid.\n");
break;
case ERROR_NOT_SUPPORTED:
printf("\rThis network request is not supported.\n");
break;
case NERR_NameNotFound:
printf("\rThe user name could not be found.\n");
break;
case NERR_NetworkError:
printf("\rA general failure occurred in the network hardware.\n");
break;
default:
break;
}
break;
}
printf("...");
}
printf("\r\r\n总共发送了%d次\n", nCount);
}
[Copy to clipboard]
[ 此贴被白色猎人在2006-07-05 12:41重新编辑 ]
青铜的钝剑:我是没有眼泪的人 为了保护自己 今后我可以对任何人残忍
巫师的披风:我不怕死 因为我一直对它充满着无尽的好奇 想亲眼看一下死之后会是什么←目前状态
耀眼的强光:我最擅长从零开始创造世界 所以从来不怕失败 它最多也就让我一无所有