132af08ecSBjoern A. Zeeb#!/usr/bin/env python 232af08ecSBjoern A. Zeeb#- 332af08ecSBjoern A. Zeeb# SPDX-License-Identifier: BSD-2-Clause 432af08ecSBjoern A. Zeeb# 532af08ecSBjoern A. Zeeb# Copyright (c) 2019 Netflix, Inc. 632af08ecSBjoern A. Zeeb# 732af08ecSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without 832af08ecSBjoern A. Zeeb# modification, are permitted provided that the following conditions 932af08ecSBjoern A. Zeeb# are met: 1032af08ecSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright 1132af08ecSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer. 1232af08ecSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright 1332af08ecSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer in the 1432af08ecSBjoern A. Zeeb# documentation and/or other materials provided with the distribution. 1532af08ecSBjoern A. Zeeb# 1632af08ecSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1732af08ecSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1832af08ecSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1932af08ecSBjoern A. Zeeb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2032af08ecSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2132af08ecSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2232af08ecSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2332af08ecSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2432af08ecSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2532af08ecSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2632af08ecSBjoern A. Zeeb# SUCH DAMAGE. 2732af08ecSBjoern A. Zeeb# 2832af08ecSBjoern A. Zeeb# 2932af08ecSBjoern A. Zeeb 3032af08ecSBjoern A. Zeebimport argparse 31*a26e895fSKristof Provostimport logging 32*a26e895fSKristof Provostlogging.getLogger("scapy").setLevel(logging.CRITICAL) 3332af08ecSBjoern A. Zeebimport scapy.all as sp 3432af08ecSBjoern A. Zeebimport socket 3532af08ecSBjoern A. Zeebimport sys 3632af08ecSBjoern A. Zeebimport binascii 3732af08ecSBjoern A. Zeeb 3832af08ecSBjoern A. Zeebdef main(): 3932af08ecSBjoern A. Zeeb parser = argparse.ArgumentParser("scapyi386.py", 4032af08ecSBjoern A. Zeeb description="IPv6 Ethernet Dest MAC test") 4132af08ecSBjoern A. Zeeb parser.add_argument('--sendif', nargs=1, 4232af08ecSBjoern A. Zeeb required=True, 4332af08ecSBjoern A. Zeeb help='The interface through which the packet will be sent') 4432af08ecSBjoern A. Zeeb parser.add_argument('--recvif', nargs=1, 4532af08ecSBjoern A. Zeeb required=True, 4632af08ecSBjoern A. Zeeb help='The interface on which to check for the packet') 4732af08ecSBjoern A. Zeeb parser.add_argument('--src', nargs=1, 4832af08ecSBjoern A. Zeeb required=True, 4932af08ecSBjoern A. Zeeb help='The source IP address') 5032af08ecSBjoern A. Zeeb parser.add_argument('--to', nargs=1, 5132af08ecSBjoern A. Zeeb required=True, 5232af08ecSBjoern A. Zeeb help='The destination IP address') 5332af08ecSBjoern A. Zeeb parser.add_argument('--debug', 5432af08ecSBjoern A. Zeeb required=False, action='store_true', 5532af08ecSBjoern A. Zeeb help='Enable test debugging') 5632af08ecSBjoern A. Zeeb parser.add_argument('--mldraw01', 5732af08ecSBjoern A. Zeeb required=False, action='store_true', 5832af08ecSBjoern A. Zeeb help='Multicast Listener Query Raw01') 5932af08ecSBjoern A. Zeeb 6032af08ecSBjoern A. Zeeb args = parser.parse_args() 6132af08ecSBjoern A. Zeeb 6232af08ecSBjoern A. Zeeb pkt = None 6332af08ecSBjoern A. Zeeb if args.mldraw01: 6432af08ecSBjoern A. Zeeb pkt = sp.Ether() / \ 6532af08ecSBjoern A. Zeeb sp.IPv6(dst="ff02::1", hlim=1, nh=0) / \ 6632af08ecSBjoern A. Zeeb sp.IPv6ExtHdrHopByHop(options = sp.RouterAlert(value=0)) / \ 6732af08ecSBjoern A. Zeeb sp.ICMPv6MLQuery() 6832af08ecSBjoern A. Zeeb if pkt is None: 6932af08ecSBjoern A. Zeeb sys.exit(1) 7032af08ecSBjoern A. Zeeb if args.debug: 7132af08ecSBjoern A. Zeeb pkt.display() 7232af08ecSBjoern A. Zeeb sp.sendp(pkt, iface=args.sendif[0], verbose=False) 7332af08ecSBjoern A. Zeeb 7432af08ecSBjoern A. Zeeb sys.exit(0) 7532af08ecSBjoern A. Zeeb 7632af08ecSBjoern A. Zeebif __name__ == '__main__': 7732af08ecSBjoern A. Zeeb main() 78