Пример #1
0
 def send(self, x):
 
     pkt_src_mac_field,pkt_src_mac_val = x.getfield_and_val('src')
     if self.__use_iface and pkt_src_mac_val is None:
         iff = self.iface
         if iff:
             try:
                 src_mac = scapy.arch.get_if_hwaddr(iff)
             except:
                 pass
         if src_mac is None:
             src_mac = "00:00:00:00:00:00"
         x.src = scapy.fields.MACField.i2h(pkt_src_mac_field, x, src_mac)
     
     if x.haslayer('IP') :
         pkt_src_ip_field,pkt_src_ip_val = x['IP'].getfield_and_val('src')
         if isinstance(pkt_src_ip_field,scapy.fields.Emph):
             pkt_src_ip_field = pkt_src_ip_field.fld
         if self.__use_iface and pkt_src_ip_val is None:
             iff = self.iface
             if iff:
                 try:
                     src_ip = scapy.arch.get_if_addr(iff)
                 except:
                     pass
             x['IP'].src = scapy.fields.SourceIPField.i2h(pkt_src_ip_field, x, src_ip)
         
     SuperSocket.send(self, x)
Пример #2
0
 def send(self, x):
     try:
         return SuperSocket.send(self, x)
     except socket.error as msg:
         if msg.errno == 22 and len(x) < conf.min_pkt_size:
             padding = b"\x00" * (conf.min_pkt_size - len(x))
             if isinstance(x, Packet):
                 return SuperSocket.send(self, x / Padding(load=padding))
             else:
                 return SuperSocket.send(self, raw(x) + padding)
         raise
Пример #3
0
 def send(self, x):
     try:
         return SuperSocket.send(self, x)
     except socket.error as msg:
         if msg[0] == 22 and len(x) < conf.min_pkt_size:
             padding = b"\x00" * (conf.min_pkt_size - len(x))
             if isinstance(x, Packet):
                 return SuperSocket.send(self, x / Padding(load=padding))
             else:
                 return SuperSocket.send(self, raw(x) + padding)
         raise
Пример #4
0
    def send(self, x):
        try:
            if hasattr(x, "sent_time"):
                x.sent_time = time.time()

            # need to change the byteoder of the first four bytes,
            # required by the underlying Linux SocketCAN frame format
            bs = bytes(x)
            bs = bs + b'\x00' * (CAN_FRAME_SIZE - len(bs))
            bs = struct.pack("<I12s", *struct.unpack(">I12s", bs))
            return SuperSocket.send(self, bs)
        except socket.error as msg:
            raise msg
Пример #5
0
    def send(self, x):
        try:
            if hasattr(x, "sent_time"):
                x.sent_time = time.time()

            # need to change the byteoder of the first four bytes,
            # required by the underlying Linux SocketCAN frame format
            bs = bytes(x)
            bs = bs + b'\x00' * (CAN_FRAME_SIZE - len(bs))
            bs = struct.pack("<I12s", *struct.unpack(">I12s", bs))
            return SuperSocket.send(self, bs)
        except socket.error as msg:
            raise msg