raw-sockets

What should I use as a buffer in C++ for receiving data from network sockets?

I'm using sockets with C++. The program simply requests an HTTP page, reads it into a buffer buf[512], and then displays the buffer. However pages can contain more data than the buffer, so it will cut off if there is no more space left. I can make the buffer size bigger, but that doesn't seem like a good solution. This is the code that I...

How to set the Don't Fragment (IP_DF) flag in C

I want to set the Don't Fragment flag on a IP packet. Is there a way to do so via the setsockopt() function or via the flags of the sendto() function? Can I do this with "normal" sockets or do i have to use raw sockets and build the entire IP header myself, setting it's offset-field to IP_DF (which is defined in ip.h)? ...

Low level networking in assembler (x86 compatible)

Hello. I wish to write a bootable program in assembler that would be capable of sending and receiving network packets. I do not wish to use any libraries, I'd like to create it all by myself (and also learn while doing so). Unfortunately, I was unable to find any information regarding communication with the network card on the lowest lev...

python socket.PF_PACKET

I am trying to send out an ARP request with python, working with dpkt, and I found some sample code that uses: socket.socket(socket.PF_PACKET, socket.SOCK_RAW) I understand that you need to use raw sockets to send this, but it says that socket.PF_PACKET doesn't exist. And there is nothing in the python docs about it that I have seen. ...

how to embed C code in python program?

i want to write a program using multi-threading, raw sockets, to scan the ports in python i have a C code for injection of raw socket. i want to perform a ACK scan so need a raw socket. So please help me. thank you ...

How to write a raw socket for tcp packet injection in python?

I want inject a tcp raw packet for port scanning using ACK scan, need some help in writing the code in python. Thank you ...

Python raw IPv6 socket errors

I am having some problems using raw IPv6 sockets in python. I connect via: if self._socket != None: # Close out old socket first self._socket.close() self._socket = socket.socket(socket.AF_INET6, socket.SOCK_RAW) self._socket.bind((self._interface,0)) self._socket.sendall(data) where self._interface is...

How to determine start of data payload in TCP packet?

Hi, I'm writing program for monitoring FTP traffic using raw sockets. Now, I am able to determine start of data in TCP packet using this code: // char * packet; // struct * iphdr; // struct * tcphdr; // ... // check, whether sniffed ethernet frame contains IP and TCP char * data; data = (packet + sizeof (struct ethhdr) + sizeof (str...

how to bind raw socket to specific interface

Hello, My application is running on CentOS 5.5. I'm using raw socket to send data: sd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); if (sd < 0) { // Error } const int opt_on = 1; rc = setsockopt(m_SocketDescriptor, IPPROTO_IP, IP_HDRINCL, &opt_on, sizeof(opt_on)); if (rc < 0) { close(sd); // Error } struct sockaddr_in sin; memset(&si...