raw-sockets

how to embed C code in python program?

谁说我不能喝 提交于 2019-12-10 16:33:12
问题 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 回答1: Please check out Cython. It makes it very easy to wrap C code. This is adapted from the documentation on calling external C functions: cdef extern from "math.h": double sin(double) def pysin(x): return sin(x) You could then call pysin from the compiled module like a normal

Prevent kernel from processing TCP segments bound to a raw socket

喜你入骨 提交于 2019-12-10 14:13:43
问题 According to http://linux.die.net/man/7/raw , raw_socket = socket(AF_INET, SOCK_RAW, int protocol); is the way to create a raw socket. I assume that raw-sockets are created on layer-3 and so protocol shouldn't be IPPROTO_TCP / IPPROTO_UDP but it should be IPPROTO_IP . Is this understanding correct? But when I create the raw socket with protocol as IPPROTO_IP ( *socketFd = socket(AF_INET, SOCK_RAW, IPPROTO_IP); ), socket creation fails with the error Protocol not supported When I create the

PHP and RAW SOCKETS on linux

我是研究僧i 提交于 2019-12-10 14:06:28
问题 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 to Apache as well, but I couldn't find out how. Can you help me? errors from the PHP script : Warning: socket_create(): Unable to create socket [1]: Operation not permitted in the php script : $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost";

How to write byte by byte to socket in PHP?

蹲街弑〆低调 提交于 2019-12-10 13:54:45
问题 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. 回答1: You can use the pack function to pack the data into any datatype you wish. Then send it with any of the socket functions. $strLen = strlen($msg); $packet = pack("a{$strLen}C7", $msg, 14, 56, 255, 11, 7, 89, 152); $pckLen = strlen($packet); socket_write(

rawsocket sendto() some of the packet are dropped and not seen in the network

懵懂的女人 提交于 2019-12-10 10:38:23
问题 socketFd_ = socket(AF_INET, SOCK_RAW, protoType); sentBytes = sendto(socketFd_, buf, len, 0, (struct sockaddr *)&sa,sizeof(structsockaddr_in)); protoType = GRE I am sending the 1000 packets in the network. If my tx packet rate is 40, i am able to see all the packet in wireshark. however when i will try to send at the rate of 100 some of the packet(3-4) will not reach in the network however sendto did not return any error. i know sendto will just put the txpacket into the queue and will not

How to use Golang to compose raw TCP packet (using gopacket) and send it via raw socket

别说谁变了你拦得住时间么 提交于 2019-12-09 05:52:46
问题 I would like to craft custome TCP packets using gopacket and then send them using raw sockets. Here is a short and readable example go program that demonstrates what I'd like to do: package main import ( "code.google.com/p/gopacket" "code.google.com/p/gopacket/examples/util" "code.google.com/p/gopacket/layers" "log" "net" ) func main() { defer util.Run()() // XXX create tcp/ip packet srcIP := net.ParseIP("127.0.0.1") dstIP := net.ParseIP("192.168.0.1") //srcIPaddr := net.IPAddr{ // IP: srcIP,

How I can grant permission for Pcap library in Windows 10 from C#?

雨燕双飞 提交于 2019-12-08 14:07:07
问题 I use SharpPcap library for realise GOOSE protocol listener (EtherType = 0x88B8). It works well, but only if I run Wireshark in parallel, otherwise my program does not catch GOOSE packets. SharpPcap examples also don't capture GOOSE packets while Wireshark is not running. But SharpPcap library captures my broadcast UDP packets. 回答1: I had to open my SharpPCap device in promiscuous mode: winPcap.Open(SharpPcap.WinPcap.OpenFlags.Promiscuous | SharpPcap.WinPcap.OpenFlags.NoCaptureLocal,

Can't send Scapy packet over a raw socket in python

我是研究僧i 提交于 2019-12-08 11:50:31
问题 A simple client-server raw socket where the client send a custom packet and it will be received from the server. Here's my code. Client.py #!/usr/bin/env python import socket import sys from scapy.all import * sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) try: a=Ether(dst="90:**:**:**:**:75", src="90:**:**:**:**:96")/IP(src="192.168.240.5", dst="192.168.240.1")/TCP(sport=10000,dport=10000)/"HELLO" a.show() sendp(a) finally: print >>sys.stderr, 'closing socket' sock.close() Output: #

How to send both 802.11 management frames and data frames using RAW sockets in linux

别说谁变了你拦得住时间么 提交于 2019-12-08 05:40:07
问题 I am trying to build an application that will send 802.11 management frames and data frames together from the userspace using raw sockets. I am being able to send data frames using the the sendto() function, but I need to send management frames as well, where I am mostly stuck. Is there any possible way of doing it? 回答1: In order to send management, data or any type of pure raw packet from a wireless interface you have to do the following: Make sure the wireless interface hardware supports

Connecting a Docker container to a network interface / device instead of an IP address

不问归期 提交于 2019-12-05 23:44:59
问题 After careful research, testing, and fiddling, I've only been able to find away to connect a Docker container to a given interface by forwarding from an IP/port. This can be accomplished by adding -p Host-IP:Host-Port:Container-Port to a docker run command. I have an app that listens for UDP broadcasts (255.255.255.255), and have been unable to configure forwarding in such a way that my container will receive those broadcasts without forwarding all network traffic on the port I care about (no