Questions tagged [raw-sockets]

An internet socket that allows direct sending and receiving of raw network packets that contain all headers. They differ from protocols like TCP/IP or UDP.

Raw sockets differ from standard sockets where the payload is encapsulated according to the transport layer protocol (TCP, UDP, HTTP, ..). Raw sockets can be used to implement completely new transport-layer protocols or to send messages through some less common protocol like ICMP.

Most socket APIs, especially those based on Berkeley sockets, support raw sockets. Support under Windows XP is intentionally limited due security concerns.

490 questions
5
votes
0 answers

Is it possible to make programs interpret $ORIGIN in loaded shared libraries with the CAP_NET_RAW capability?

I'm writing an application that has both Python and C++ libraries. The Python part needs to send and receive raw packets, so I'm giving the Python executable the CAP_NET_RAW capability. I also load C++ shared libraries with Cython in the same…
Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
5
votes
3 answers

How to write byte by byte to socket in PHP?

How to write byte by byte to socket in PHP? For example how can I do something like: socket_write($socket,$msg.14.56.255.11.7.89.152,strlen($msg)+7); The pseudo code concatenated digits are actually bytes in dec. Hope you understand me.
PatlaDJ
  • 1,226
  • 2
  • 17
  • 31
5
votes
2 answers

Unable to bind raw socket to interface

I'm struggling to bind raw socket to interface, my goal to implement simple packet sniffer. Already dedicated hours searching the web and went through references, part of them listed at bottom. I'm able to open socket, no error on bind, but when…
Vlad
  • 63
  • 1
  • 5
5
votes
2 answers

How do I parse a captured packet in python?

I have a capture packet raw packet using python's sockets: s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0003)) while True: message = s.recv(4096) test = [] print(len(message)) print(repr(message)) I assumed…
James Mertz
  • 8,459
  • 11
  • 60
  • 87
5
votes
1 answer

Use raw sockets in Go

I'm trying to write a program that receives DHCP discoveries (UDP) and forwards them on to a given IP address using a different source IP address depending on the content of a specific field (GIADDR) in the DHCP packet. I could get working the…
5
votes
2 answers

Is raw socket datagram socket or not?

For a non-blocking datagram socket, like UDP, when I call write()/send() on the socket, each call of write()/send() or read()/recv() deals with exactly 1 packet. I'm wondering if a raw socket, like the below, is a datagram socket or not? int on =…
user1944267
  • 1,557
  • 5
  • 20
  • 27
5
votes
2 answers

PHP and RAW SOCKETS on linux

Is it enough to do a sudo setcap cap_net_raw=eip /usr/bin/php5 to be able to use RAW SOCKETS in PHP (not CLI) in Linux ? If yes, well it is not working (but started to work in CLI but not using Apache) So I guess I have to give those permissions…
Rami Dabain
  • 4,709
  • 12
  • 62
  • 106
5
votes
1 answer

How can hping be so fast to send packets?

I have compared two tools for the speed of sending packets, hping and packETHcli. The command line options for packETHcli is ./packETHcli -i eth0 -m 2 -n 0 -d -1 -f icmpSample.pcap and for hping is hping --flood 192.168.0.1 But in iptraf, it…
longbowk
  • 219
  • 5
  • 14
5
votes
0 answers

Disable ICMP Host unreachable

I'm using a single raw socket to read UDP packets from local test network with 1024 ports. Each UDP src and dest port is unique and I need access to IP and UDP header fields. I can stream and process data (in and out) at 100 mbps in linux-rt kernel…
5
votes
3 answers

Will be a support of raw sockets in node.js, e.g. to create ping packets?

Will be a support of raw sockets in node.js, e.g. to create ping packets?
sauletasmiestas
  • 428
  • 2
  • 6
  • 17
5
votes
4 answers

Packet socket in promiscuous mode only receiving local traffic

I have a socket created with socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)), and I've set it into promiscuous mode using: struct ifreq ifr; strncpy((char*)ifr.ifr_name, interface, IF_NAMESIZE); if(ioctl(sock, SIOCGIFINDEX, &ifr)<0) fail(2); struct…
nonpolynomial237
  • 2,109
  • 4
  • 27
  • 35
5
votes
1 answer

Why are there differences between ETH_P_IP and ETH_P_ALL when doing a read()

I have the following setup: client(eth0) --- (eth2) linux bridge (eth1) --- (eth1) server When I open a RAW socket on the linux bridge using fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); I have the socket bound to eth2. When the client sends…
A G
  • 997
  • 2
  • 18
  • 36
5
votes
1 answer

Simple raw socket server in C/C++ on Linux

I am trying to build an Ethernet network with raw sockets. I cannot use TCP/IP, UDP, or any other protocol. This is because it will be communicating with very simple hardware that won't have the resources to handle all the different protocol…
NerdPirate
  • 139
  • 1
  • 2
  • 5
4
votes
2 answers

Raw socket with device bind using setsockopt() system is not working in Fedora core 6(2.6.18-1.2798.fc6)

Please any one could help on this issue. Please In the below sample code,we had bind raw sock with eth0. but while running the program the recvfrom of raw sock is receiving packets from eth0 & eth1 on same machine(xx_86). It is not clear to me…
viswanathan J
  • 119
  • 1
  • 1
  • 4
4
votes
2 answers

Establish direct peer-to-peer Wi-Fi communication between laptops

TL;DR available at the bottom I've been trying to figure out a way to get two laptops (both running Ubuntu) to be able to pass basic messages back and forth without the need for them to be connected via a wireless network,either by an AP or ad-hoc.…
Kaz
  • 143
  • 1
  • 9