Raw Packets

This is a discussion on Raw Packets within the Networking/Device Communication forums, part of the General Programming Boards category; Code: #include <stdio.h> #include "winsock2.h" int main() { WSADATA wsa; SOCKET sock; sockaddr_in RecvAddr; char sendbuf[40] = "lalalala"; WSAStartup(MAKEWORD(2,2),&wsa); if((sock ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    20

    Raw Packets

    Code:
    #include <stdio.h>
    #include "winsock2.h"
    
    int main() {
    
    	WSADATA wsa;
    	SOCKET sock;
    	sockaddr_in RecvAddr;
    	char sendbuf[40] = "lalalala";
    
    	WSAStartup(MAKEWORD(2,2),&wsa);
    
    	if((sock = socket(AF_INET,
    	SOCK_RAW,
    	IPPROTO_RAW)) == -1)
    	{
    	printf("socket(:()\n");
    	exit(0);
    	}
    
    	DWORD bOpt = true;
    	if (setsockopt( sock,
    	IPPROTO_IP,
    	2,
    	(char *)&bOpt,
    	sizeof(bOpt)) == SOCKET_ERROR)
    	{
    	printf("setsockopt(IP_HDRINCL) failed: %d\n", WSAGetLastError());
    	return -1;
    	}
    
      RecvAddr.sin_family = AF_INET;
      RecvAddr.sin_port = htons(80);
      RecvAddr.sin_addr.s_addr = inet_addr("62.80.248.65");
    
      if( sendto( sock,
    	sendbuf,
    	40,
    	0,
    	(sockaddr *)&RecvAddr,
    	sizeof(RecvAddr)) == -1)
    	{
    	printf("sendto failed: %d\n", WSAGetLastError());
    	exit(0);
    	}
      closesocket(sock);
    
      WSACleanup();
      return 0;
    }
    Hello. Here is my problem, I wanna to send raw packet, but when I execute that program, and sniffing my packets, I can`t capture that packet which is sent by that program, what`s wrong here? THNX. C ya.
    Butterfly sweep can make torando in another side of world

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    OS information would be nice, as if my memory serves me correctly Microsoft cut raw socket usage in SP2, the stuff is still there I guess, but just won't work IIRC.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  3. #3
    Registered User crepincdotcom's Avatar
    Join Date
    Oct 2003
    Posts
    94
    OS, sniffer, and the command you executed is what we need
    -Jack C
    jack {at} crepinc.com
    http://www.crepinc.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Raw Sockets problem.
    By Mad_guy in forum C Programming
    Replies: 3
    Last Post: 07-03-2005, 03:14 PM
  2. Want to start learning raw packets in C
    By Lateralus in forum Networking/Device Communication
    Replies: 1
    Last Post: 06-08-2005, 12:55 PM
  3. Raw Sockets, Filter Packets?
    By ew16301 in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-28-2005, 07:52 AM
  4. Sending Raw Packets?
    By Coder87C in forum Networking/Device Communication
    Replies: 7
    Last Post: 12-03-2003, 12:27 PM
  5. Sending raw packets.
    By Denethor2000 in forum C++ Programming
    Replies: 3
    Last Post: 06-04-2002, 02:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21