Implement a SYN flooding for mounting a DoS attack in a comp
Implement a SYN flooding for mounting a DoS attack in a computer using c++. You may use any scanner( like nmap) to figure out the open ports at the destination machine.
Solution
Lets begin with creating a raw socket. To do this your program must be running with effective user id == 0 (root). We can easily check this:
Once we\'ve got that out of the way we can procede to creating our socket.
We set our protocol to IPPROTO_TCP because we will be using TCP/IP with our socket. Next we indicate that we would like IP headers sent with our packets.
It\'s now time to craft our packets. We will need to calculate checksums for our packets, so we define a structure for holding pseudo headers. Lets also look at the IP and TCP headers. We only need to do this if we are running Windows. When using Linux, just #include <netinet/ip.h> and <netinet/tcp.h>
Next we will have to fill our headers according to the rules of TCP/IP networking. First we allocate memory for our packet.
And next we fill the allocated memory to look like a legitimate SYN packet. In the code below saddr, daddr, sport, dport are variables holding the source IP address, destination IP address, source port, and destination port respectively.
TCP/IP uses a simple checksum function to check for any errors that might have occurred during transmission. This function\'s implementation in C looks like this:
Now we can calculate the checksum for our TCP/IP headers.
Finally we create and fill a sockaddr_in structure and sent out our packet using the sendto() function.

