From 6c79aef01419f34171a8fdd6dcab88aabc33fcac Mon Sep 17 00:00:00 2001 From: Guillaume Valadon <guillaume.valadon@ssi.gouv.fr> Date: Tue, 17 Jan 2017 11:21:50 +0100 Subject: [PATCH] Pierre comments --- scapy/arch/bpf/core.py | 2 +- scapy/route6.py | 2 +- scapy/utils6.py | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scapy/arch/bpf/core.py b/scapy/arch/bpf/core.py index 7360506d..5d84f233 100644 --- a/scapy/arch/bpf/core.py +++ b/scapy/arch/bpf/core.py @@ -57,7 +57,7 @@ def get_if_raw_addr(ifname): return "\0\0\0\0" # Get IPv4 addresses - addresses = [l for l in fd.readlines() if l.find("netmask") >= 0] + addresses = [l for l in fd if l.find("netmask") >= 0] if not addresses: warning("No IPv4 address found on %s !" % ifname) return "\0\0\0\0" diff --git a/scapy/route6.py b/scapy/route6.py index bbc61a60..58f64c2b 100644 --- a/scapy/route6.py +++ b/scapy/route6.py @@ -105,7 +105,7 @@ class Route6: l = filter(lambda x: in6_ptop(x[0]) == dst and x[1] == plen, self.routes) if gw: gw = in6_ptop(gw) - l = filter(lambda x: in6_ptop(x[2]) == gw, self.routes) + l = [x for x in self.routes if in6_ptop(x[2]) == gw] if len(l) == 0: warning("No matching route found") elif len(l) > 1: diff --git a/scapy/utils6.py b/scapy/utils6.py index 19306afe..30ee6ba5 100644 --- a/scapy/utils6.py +++ b/scapy/utils6.py @@ -17,6 +17,7 @@ from scapy.config import conf from scapy.data import * from scapy.utils import * from scapy.pton_ntop import * +from scapy.volatile import RandMAC def construct_source_candidate_set(addr, plen, laddr, loname): @@ -357,10 +358,7 @@ def in6_getLocalUniquePrefix(): i = int(tod) j = int((tod - i)*(2**32)) tod = struct.pack("!II", i,j) - # TODO: Add some check regarding system address gathering - from scapy.arch import get_if_raw_hwaddr - rawmac = get_if_raw_hwaddr(conf.iface6)[1] - mac = ":".join(map(lambda x: "%.02x" % ord(x), list(rawmac))) + mac = RandMAC() # construct modified EUI-64 ID eui64 = inet_pton(socket.AF_INET6, '::' + in6_mactoifaceid(mac))[8:] import sha -- GitLab