Thread: Packet sending

  1. #1
    Registered User
    Join Date
    Sep 2008

    Packet sending

    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:
     bsock=socket(AF_INET, SOCK_STREAM, 0);
        connect( bsock, (SOCKADDR*) &sinb, sizeof(SOCKADDR_IN) );
    Any help or reference to a proper tutorial will be welcomed. Thanks
    Last edited by like_no_other; 02-19-2009 at 02:24 PM.

  2. #2
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    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.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Portland, OR
    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.
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);

  4. #4
    Registered User
    Join Date
    Sep 2008
    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 ( Is it the only way?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  2. Problem while constructing IP packet and sending using socket() system call
    By cavestine in forum Networking/Device Communication
    Replies: 10
    Last Post: 10-15-2007, 05:49 AM
  3. unable to recieve UDP packet
    By caroundw5h in forum Networking/Device Communication
    Replies: 15
    Last Post: 09-19-2007, 11:11 AM
  4. Raw Packet (sorry tripple weird Post)
    By Coder87C in forum Networking/Device Communication
    Replies: 6
    Last Post: 03-04-2006, 11:34 AM
  5. packet sending
    By Peaches in forum C Programming
    Replies: 2
    Last Post: 03-08-2002, 03:21 PM