Raw sockets and sendto in python

后端 未结 6 1926
余生分开走
余生分开走 2021-02-05 16:51

I am working on integrating scapy with twisted, but I ran into this very weird bug on OSX that I can\'t seem to figure out.

Basically I am unable to send a valid TCP pac

6条回答
  •  悲哀的现实
    2021-02-05 17:42

    Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
    [GCC 4.5.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import socket
    >>> from scapy.all import IP, TCP
    WARNING: No route found for IPv6 destination :: (no default route?)
    >>> pkt = IP(src='0.0.0.0', dst='127.0.0.1')/TCP()
    >>> spkt1 = str(pkt)
    >>> 
    >>> outs = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
    >>> outs.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1)
    >>> outs.sendto(spkt1, ('127.0.0.1', 0))
    40
    

    I don't seem to have any error writing that specific set of packets - I'm using x86_64 with a 2.6.38-* Gnu/Linux kernel.

    Perhaps your issue is related to some Mac OS X brain damage with raw sockets?

提交回复
热议问题