当前位置: 首页>>代码示例>>Python>>正文


Python all.IPv6方法代码示例

本文整理汇总了Python中scapy.all.IPv6方法的典型用法代码示例。如果您正苦于以下问题:Python all.IPv6方法的具体用法?Python all.IPv6怎么用?Python all.IPv6使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.all的用法示例。


在下文中一共展示了all.IPv6方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: callback

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def callback(self, packet):
        flags = packet.sprintf("%TCP.flags%")
        proto = IP
        if IPv6 in packet:
            proto = IPv6
        if flags == "A" and not self.ignore_packet(packet, proto):
            src_mac = packet[Ether].src
            dst_mac = packet[Ether].dst
            src_ip = packet[proto].src
            dst_ip = packet[proto].dst
            src_port = packet[TCP].sport
            dst_port = packet[TCP].dport
            seq = packet[TCP].seq
            ack = packet[TCP].ack
            if self.verbose:
                print("RST from %s:%s (%s) --> %s:%s (%s) w/ %s" % (src_ip, src_port, src_mac, dst_ip, dst_port, dst_mac, ack))
            if self.noisy:
                self.send(self.build_packet(src_mac, dst_mac, src_ip, dst_ip, src_port, dst_port, seq, proto))
            self.send(self.build_packet(dst_mac, src_mac, dst_ip, src_ip, dst_port, src_port, ack, proto)) 
开发者ID:ecthros,项目名称:pina-colada,代码行数:21,代码来源:tcpkiller.py

示例2: visit_packet

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def visit_packet(self, time, packet):
        if (IP not in packet and IPv6 not in packet) or TCP not in packet:
            return

        iph = packet[IP] if IP in packet else packet[IPv6]
        tcph = packet[TCP]

        if iph.src == self._rcv_ip:
            return

        port = tcph.sport
        if port not in self._packet_size:
            return

        # TODO(arjunroy) IPv4 = total len, IPv6 = payload len. Is it important?
        packet_len = packet.len if IP in packet else packet.plen
        sizes = self._packet_size[port]
        if packet_len in sizes:
            sizes[packet_len] += 1
        else:
            sizes[packet_len] = 1 
开发者ID:google,项目名称:transperf,代码行数:23,代码来源:metric.py

示例3: send_dhcp_advertise

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def send_dhcp_advertise(p, basep, target):
    global ipv6noaddrc
    resp = Ether(dst=basep.src)/IPv6(src=config.selfaddr, dst=basep[IPv6].src)/UDP(sport=547, dport=546) #base packet
    resp /= DHCP6_Advertise(trid=p.trid)
    #resp /= DHCP6OptPref(prefval = 255)
    resp /= DHCP6OptClientId(duid=p[DHCP6OptClientId].duid)
    resp /= DHCP6OptServerId(duid=config.selfduid)
    resp /= DHCP6OptDNSServers(dnsservers=[config.selfaddr])
    if config.localdomain:
        resp /= DHCP6OptDNSDomains(dnsdomains=[config.localdomain])
    if target.ipv4 != '':
        addr = config.ipv6prefix + target.ipv4.replace('.', ':')
    else:
        addr = config.ipv6prefix + '%d:%d' % (config.ipv6noaddr, config.ipv6noaddrc)
        config.ipv6noaddrc += 1
    opt = DHCP6OptIAAddress(preflft=300, validlft=300, addr=addr)
    resp /= DHCP6OptIA_NA(ianaopts=[opt], T1=200, T2=250, iaid=p[DHCP6OptIA_NA].iaid)
    sendp(resp, iface=config.default_if, verbose=False) 
开发者ID:fox-it,项目名称:mitm6,代码行数:20,代码来源:mitm6.py

示例4: send_dhcp_reply

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def send_dhcp_reply(p, basep):
    resp = Ether(dst=basep.src)/IPv6(src=config.selfaddr, dst=basep[IPv6].src)/UDP(sport=547, dport=546) #base packet
    resp /= DHCP6_Reply(trid=p.trid)
    #resp /= DHCP6OptPref(prefval = 255)
    resp /= DHCP6OptClientId(duid=p[DHCP6OptClientId].duid)
    resp /= DHCP6OptServerId(duid=config.selfduid)
    resp /= DHCP6OptDNSServers(dnsservers=[config.selfaddr])
    if config.localdomain:
        resp /= DHCP6OptDNSDomains(dnsdomains=[config.localdomain])
    try:
        opt = p[DHCP6OptIAAddress]
        resp /= DHCP6OptIA_NA(ianaopts=[opt], T1=200, T2=250, iaid=p[DHCP6OptIA_NA].iaid)
        sendp(resp, iface=config.default_if, verbose=False)
    except IndexError:
        # Some hosts don't send back this layer for some reason, ignore those
        if config.debug or config.verbose:
            print('Ignoring DHCPv6 packet from %s: Missing DHCP6OptIAAddress layer' % basep.src) 
开发者ID:fox-it,项目名称:mitm6,代码行数:19,代码来源:mitm6.py

示例5: parsepacket

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def parsepacket(p):
    if DHCP6_Solicit in p:
        target = get_target(p)
        if should_spoof_dhcpv6(target.host):
            send_dhcp_advertise(p[DHCP6_Solicit], p, target)
    if DHCP6_Request in p:
        target = get_target(p)
        if p[DHCP6OptServerId].duid == config.selfduid and should_spoof_dhcpv6(target.host):
            send_dhcp_reply(p[DHCP6_Request], p)
            print('IPv6 address %s is now assigned to %s' % (p[DHCP6OptIA_NA].ianaopts[0].addr, pcdict[p.src]))
    if DHCP6_Renew in p:
        target = get_target(p)
        if p[DHCP6OptServerId].duid == config.selfduid and should_spoof_dhcpv6(target.host):
            send_dhcp_reply(p[DHCP6_Renew],p)
            print('Renew reply sent to %s' % p[DHCP6OptIA_NA].ianaopts[0].addr)
    if ARP in p:
        arpp = p[ARP]
        if arpp.op is 2:
            #Arp is-at package, update internal arp table
            arptable[arpp.hwsrc] = arpp.psrc
    if DNS in p:
        if p.dst == config.selfmac:
            send_dns_reply(p) 
开发者ID:fox-it,项目名称:mitm6,代码行数:25,代码来源:mitm6.py

示例6: build_packet

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def build_packet(self, src_mac, dst_mac, src_ip, dst_ip, src_port, dst_port, seq, proto):
        eth = Ether(src=src_mac, dst=dst_mac, type=0x800)
        if proto == IP:
            ip = IP(src=src_ip, dst=dst_ip)
        elif proto == IPv6:
            ip = IPv6(src=src_ip, dst=dst_ip)
        else:
            return str(eth) #if unknown L2 protocol, send back dud ether packet
        tcp = TCP(sport=src_port, dport=dst_port, seq=seq, flags="R")
        return str(eth/ip/tcp) 
开发者ID:ecthros,项目名称:pina-colada,代码行数:12,代码来源:tcpkiller.py

示例7: get_dhcpv6_server_duid

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def get_dhcpv6_server_duid():
    if dhcpv6_server_duid is None:
        print(Base.c_info + 'Wait for receive DHCPv6 server DUID...')
        tm.add_task(recv_dhcpv6_reply)
        sleep(3)
        send_dhcpv6_solicit()
        sleep(10)

        count_solicit_reqeusts = 0
        while count_solicit_reqeusts < 2:
            if dhcpv6_server_duid is None:
                send_dhcpv6_solicit()
                count_solicit_reqeusts += 1
                sleep(5)
            else:
                break

        if dhcpv6_server_duid is None:
            print(Base.c_error + 'Can not get DHCPv6 server DUID!')
            return False
        else:
            print(Base.c_success + 'DHCPv6 server MAC:       ' + str(dhcpv6_server_mac))
            print(Base.c_success + 'DHCPv6 server IPv6 link: ' + str(dhcpv6_server_ipv6_link))
            print(Base.c_success + 'DHCPv6 server DUID:      ' + str(dhcpv6_server_duid).encode('hex'))
            return True
    else:
        return True 
开发者ID:raw-packet,项目名称:raw-packet,代码行数:29,代码来源:dnsmasploit.py

示例8: dhcpv6_callback

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def dhcpv6_callback(pkt):
    global dhcpv6_server_mac
    global dhcpv6_server_ipv6_link
    global dhcpv6_server_duid

    if pkt.haslayer(DHCP6_Advertise) or pkt.haslayer(DHCP6_Reply):
        if pkt[DHCP6OptServerId].duid is None:
            return False
        else:
            dhcpv6_server_mac = pkt[Ether].src
            dhcpv6_server_ipv6_link = pkt[IPv6].src
            dhcpv6_server_duid = pkt[DHCP6OptServerId].duid
            return True
    else:
        return False 
开发者ID:raw-packet,项目名称:raw-packet,代码行数:17,代码来源:dnsmasploit.py

示例9: postcondition2

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def postcondition2(packet):
        from scapy.all import IPv6
        pkt = IPv6(packet.get_payload())
        if pkt.haslayer('IPv6'):
            del pkt['IPv6'].plen
        if pkt.haslayer('TCP'):
            del pkt['TCP'].chksum
        if pkt.haslayer('ICMP'):
            del pkt['ICMP'].chksum
        pkt.show2()
        packet.raw = bytes(pkt)
        return packet 
开发者ID:shramos,项目名称:polymorph,代码行数:14,代码来源:cli.py

示例10: get_mac6

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def get_mac6(ip, interface):
    """Returns the according MAC address for the provided IPv6 address.

    Args:
        ip (str): IPv6 address used to get MAC address.
        interface (str): Interface used to send neighbor solicitation.

    Results:
        According MAC address as string (11:22:33:44:55:66)
        or None if no answer has been received.
    """
    ans, unans = srp(Ether(dst=ETHER_BROADCAST) / IPv6(dst=ip) / ICMPv6ND_NS(tgt=ip), timeout=2, iface=interface, inter=0.1, verbose=0)
    for snd, rcv in ans:
        return rcv.sprintf(r"%Ether.src%") 
开发者ID:usableprivacy,项目名称:upribox,代码行数:16,代码来源:util.py

示例11: is_spoof_dns

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def is_spoof_dns(ipv6):
    """Checks if it is necessary to additionally spoof the address of the DNS server.
    The DNS server needs to be spoofed if it is on the own network and if it is not
    the default gateway (this is already used for spoofing).

    Args:
        ipv6 (namedtuple): Contains various IPv6 information.
        ipv6.dns_servers (list): List containing the IP addresses of DNS servers as String.
        ipv6.network (netaddr.IPNetwork): IPNetwork object representing the IPv6 network.
        ipv6.gateway (str): IPv6 address of the default gateway.

    Results:
        True if configured DNS server uses a global address and is on own network
        or DNS server uses link-local address and is not also the gateway.
    """
    return ipv6.dns_servers[0] in ipv6.network or (IPAddress(ipv6.dns_servers[0]).is_link_local()
                                                   and ipv6.dns_servers[0] != ipv6.gateway)


# class IPInfo(object):
#
#     def __init__(self, ip, netmask, network, gateway, mac, gate_mac, dns_servers, redis):
#         self.ip = ip
#         self.netmask = netmask
#         self.mac = mac
#         self.network = network
#         self.gateway = gateway
#         self.gate_mac = gate_mac
#         self.dns_servers = dns_servers
#         self.redis = redis 
开发者ID:usableprivacy,项目名称:upribox,代码行数:32,代码来源:util.py

示例12: _return_to_normal

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def _return_to_normal(self):
        """This method is called when the daemon is stopping.
        First, sends a GARP broadcast request to all clients to tell them the real gateway.
        Then ARP replies for existing clients are sent to the gateway.
        If IPv6 is enabled, Apate tells the clients the real gateway via neighbor advertisements.
        """
        # spoof clients with GARP broadcast request

        with self.sleeper:
            sendp(
                Ether(dst=ETHER_BROADCAST) / ARP(op=1, psrc=self.ipv4.gateway, pdst=self.ipv4.gateway, hwdst=ETHER_BROADCAST,
                                                 hwsrc=self.ipv4.gate_mac)) 
开发者ID:usableprivacy,项目名称:upribox,代码行数:14,代码来源:daemon_process.py

示例13: run

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def run(self):
        """Sends ICMPv6 echo request packets marked with the data upribox to the
        IPv6 all nodes multicast address.
        Received echo replies are processed by a SniffThread.
        """
        while True:
            send(IPv6(dst=self._MULTICAST_DEST) / ICMPv6EchoRequest(data=self._DATA), iface=self.interface)
            time.sleep(self._SLEEP) 
开发者ID:usableprivacy,项目名称:upribox,代码行数:10,代码来源:misc_thread.py

示例14: get_local_ipv6_address

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def get_local_ipv6_address():
    """Return IPv6 address of local node."""
    sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
    sock.connect(("::1", 80))
    local_ip = sock.getsockname()[0]
    sock.close()
    return local_ip 
开发者ID:Samsung,项目名称:cotopaxi,代码行数:9,代码来源:common_utils.py

示例15: ssdp_send_query

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import IPv6 [as 别名]
def ssdp_send_query(test_params, query):
    """Send SSDP query to normal and multicast address."""
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
    if test_params.ip_version == 4:
        sock.sendto(
            query.encode(), (SSDP_MULTICAST_IPV4, test_params.dst_endpoint.port)
        )
        sent_time = test_params.report_sent_packet()
        sock.settimeout(test_params.timeout_sec)
        try:
            while True:
                data, addr = sock.recvfrom(INPUT_BUFFER_SIZE)
                print_verbose(
                    test_params,
                    "Received response from {} - content:\n{}\n-----".format(
                        addr, data
                    ),
                )
                if (
                    test_params.dst_endpoint.ip_addr,
                    test_params.dst_endpoint.port,
                ) == addr:
                    print_verbose(
                        test_params, "This is the response that we was waiting for!"
                    )
                    test_params.report_received_packet(sent_time)
                    return data
                else:
                    print_verbose(
                        test_params, "Received response from another host (not target)!"
                    )
        except socket.timeout:
            print_verbose(test_params, "Received no response!")

    elif test_params.ip_version == 6:
        print ("IPv6 is not supported for SSDP")
    return None 
开发者ID:Samsung,项目名称:cotopaxi,代码行数:39,代码来源:common_utils.py


注:本文中的scapy.all.IPv6方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。