K_STREAM,0); //再次建立连接
if (sd<0) {return FALSE;}
if (connect(sd,(struct sockaddr *)&sad,sizeof(sad))<0)
{closesocket(sd); return true; }//连接失败,则发生拒绝服务
closesocket(sd); return FALSE;}
简要说明:Microsoft SQL Server通信端口为1433,
程序首先与SQL Server建立TCP连接并判断连接是否成功;然后向服务器发送连续字节的0并关闭连接,等待数秒后,再次试图与服务器建立连接,如果失败则表明服务器已发生拒绝服务故障。
(2)smtp problems简单邮件传输协议漏洞扫描
extern "C" __declspec( dllexport ) BOOL InitFunc(struct RECORD *record)
{ strcpy(record->advice,"升级NT Mail3系统。"); //建议
strcpy(record->classname,"SMTP problems"); //类型
strcpy(record->description," smtp存在非授权邮件收发,可能成为攻击跳板");
strcpy(record->filename,"nt_spam.nfs");
strcpy(record->ID,"7XX");
strcpy(record->membername,"nt_spam");
strcpy(record->risk,"中");
record->mark=true;
return true;}
extern "C" __declspec( dllexport ) BOOL ApplFunc(struct HOST *host)
{ struct sockaddr_in sad; //structure to hold server''s address
struct hostent *ptrh; //pointer to host entry
SOCKET sd; char buf[1024]; memset(buf,0,1024);
memset((char *)&sad,0,sizeof(sad)); //clear sockaddr structure
ptrh=NULL; sad.sin_port=htons(25); // 端口号25
sad.sin_addr.s_addr=inet_addr(host->ip);
sad.sin_family=AF_INET;
sd=socket(PF_INET,SOCK_STREAM,0);
if (sd<0) {return FALSE;}
if (connect(sd,(struct sockaddr *)&sad,sizeof(sad))<0)
{closesocket(sd); return FALSE;}
strcpy(buf,"HELO\n"); //第一步
send(sd,buf,sizeof(buf),0); //发送数据
fd_set rd; //超时控制
FD_ZERO(&rd); FD_SET(sd,&rd);
struct timeval tv={host->timeout,0};
select(sd,&rd,NULL,NULL,&tv);
int n=recv(sd,buf,1024,0); //接收数据
if (n<0) {closesocket(sd);return FALSE;} // 判断接收是否成功
strcpy(buf,"MAIL FROM:<>\n"); //第二步
send(sd,buf,sizeof(buf),0); //发送数据
FD_ZERO(&rd); //超时控制
FD_SET(sd,&rd); select(sd,&rd,NULL,NULL,&tv);
n=recv(sd,buf,1024,0); // 接收数据
if (n<0) {closesocket(sd);return FALSE;} // 判断接收是否成功
strcpy(buf,"RCPT TO: nobody@990.net\n"); //第三步
send(sd,buf,sizeof(buf),0); // 发送数据
FD_ZERO(&rd); // 超时控制
FD_SET(sd,&rd); select(sd,&rd,NULL,NULL,&tv);
n=recv(sd,buf,4,0); //接收4字节的字符串
if (n<0) {closesocket(sd);return FALSE;} // 判断接收是否成功
closesocket(sd); //在字符串中寻找执行成功代码“250”
if ((buf[0]==''2'')&&(buf==''5'')&&(buf==''0'')) return true;
if ((buf==''2'')&&(buf