Hello, I've discovered that using an application called scapy i can send network packets to any address,port, subnet. The thing that caught my attention was the option to modify the source of the packet in the packet that was sent. I want to do that in c++. So far, all i can do is something like this:
Any help or reference to a proper tutorial will be welcomed. Thanks
bsock=socket(AF_INET, SOCK_STREAM, 0);
connect( bsock, (SOCKADDR*) &sinb, sizeof(SOCKADDR_IN) );
Well, seeing you called WSAStartup, I am assuming you are on windows.
This has great documentation and examples.
This is also a good reference as well. The examples here are for a unix type environment, but most of it is similar. It also shows some good techniques on how to do some advanced topics.
Source spoofing is usually considered evil. Moreover, it doesn't work unless you are within the core routing network.
You can set the source IP to something that's not your real IP, but firstly, the socket layer will not allow you to bind to an IP which isn't configured on an interface, and secondly, even if you send a raw packet, your ISP's routers will detect the lie and drop the packet on the floor.
You might be able to source spoof within a LAN, if the routers are configured stupidly. Anyway, don't do it.
i've googled a bit and found out that i can send raw packets by registering a new protocol driver to which i later write to through a handle (http://www.codeproject.com/KB/IP/sendrawpacket.aspx). Is it the only way?