Changeset 887:0986d0178351

Show
Ignore:
Timestamp:
08/28/08 13:26:31 (4 months ago)
Author:
Phil <phil@secdev.org>
Message:

Added repr() to supersockets

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • scapy/arch/linux.py

    r885 r887  
    211211 
    212212class L3PacketSocket(SuperSocket): 
     213    desc = "read/write packets at layer 3 using Linux PF_PACKET sockets" 
    213214    def __init__(self, type = ETH_P_ALL, filter=None, promisc=None, iface=None, nofilter=0): 
    214215        self.type = type 
     
    308309 
    309310class L2Socket(SuperSocket): 
     311    desc = "read/write packets at layer 2 using Linux PF_PACKET sockets" 
    310312    def __init__(self, iface = None, type = ETH_P_ALL, filter=None, nofilter=0): 
    311313        if iface is None: 
     
    352354 
    353355class L2ListenSocket(SuperSocket): 
     356    desc = "read packets at layer 2 using Linux PF_PACKET sockets" 
    354357    def __init__(self, iface = None, type = ETH_P_ALL, promisc=None, filter=None, nofilter=0): 
    355358        self.type = type 
  • scapy/arch/pcapdnet.py

    r885 r887  
    7272     
    7373        class L2pcapListenSocket(SuperSocket): 
     74            desc = "read packets at layer 2 using libpcap" 
    7475            def __init__(self, iface = None, type = ETH_P_ALL, promisc=None, filter=None): 
    7576                self.type = type 
     
    159160if conf.use_pcap and conf.use_dnet: 
    160161    class L3dnetSocket(SuperSocket): 
     162        desc = "read/write packets at layer 3 using libdnet and libpcap" 
    161163        def __init__(self, type = ETH_P_ALL, filter=None, promisc=None, iface=None, nofilter=0): 
    162164            self.iflist = {} 
     
    235237     
    236238    class L2dnetSocket(SuperSocket): 
     239        desc = "read/write packets at layer 2 using libdnet and libpcap" 
    237240        def __init__(self, iface = None, type = ETH_P_ALL, filter=None, nofilter=0): 
    238241            if iface is None: 
  • scapy/layers/bluetooth.py

    r862 r887  
    156156         
    157157class BluetoothL2CAPSocket(SuperSocket): 
     158    desc = "read/write packets on a connected L2CAP socket" 
    158159    def __init__(self, peer): 
    159160        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, 
     
    168169 
    169170class BluetoothHCISocket(SuperSocket): 
     171    desc = "read/write on a BlueTooth HCI socket" 
    170172    def __init__(self, iface=0x10000, type=None): 
    171173        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI) 
  • scapy/supersocket.py

    r885 r887  
    1010from data import * 
    1111 
     12class _SuperSocket_metaclass(type): 
     13    def __repr__(self): 
     14        if self.desc is not None: 
     15            return "<%s: %s>" % (self.__name__,self.desc) 
     16        else: 
     17            return "<%s>" % self.__name__ 
     18 
    1219 
    1320class SuperSocket: 
     21    __metaclass__ = _SuperSocket_metaclass 
     22    desc = None 
    1423    closed=0 
    1524    def __init__(self, family=socket.AF_INET,type=socket.SOCK_STREAM, proto=0): 
     
    3948        self.outs.bind(addr) 
    4049 
    41  
    4250class L3RawSocket(SuperSocket): 
     51    desc = "Layer 3 using Raw sockets (PF_INET/SOCK_RAW)" 
    4352    def __init__(self, type = ETH_P_IP, filter=None, iface=None, promisc=None, nofilter=0): 
    4453        self.outs = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) 
     
    5665 
    5766class SimpleSocket(SuperSocket): 
     67    desc = "wrapper arround a classic socket" 
    5868    def __init__(self, sock): 
    5969        self.ins = sock 
     
    6272 
    6373class StreamSocket(SimpleSocket): 
     74    desc = "transforms a stream socket into a layer 2" 
    6475    def __init__(self, sock, basecls=Raw): 
    6576        SimpleSocket.__init__(self, sock)