1d39d5ee2SKristof Provost#!/usr/bin/env python3 2d39d5ee2SKristof Provost# 3d39d5ee2SKristof Provost# SPDX-License-Identifier: BSD-2-Clause 4d39d5ee2SKristof Provost# 5d39d5ee2SKristof Provost# Copyright (c) 2021 Rubicon Communications, LLC (Netgate). All Rights Reserved. 6d39d5ee2SKristof Provost# 7d39d5ee2SKristof Provost# Redistribution and use in source and binary forms, with or without 8d39d5ee2SKristof Provost# modification, are permitted provided that the following conditions 9d39d5ee2SKristof Provost# are met: 10d39d5ee2SKristof Provost# 1. Redistributions of source code must retain the above copyright 11d39d5ee2SKristof Provost# notice, this list of conditions and the following disclaimer. 12d39d5ee2SKristof Provost# 2. Redistributions in binary form must reproduce the above copyright 13d39d5ee2SKristof Provost# notice, this list of conditions and the following disclaimer in the 14d39d5ee2SKristof Provost# documentation and/or other materials provided with the distribution. 15d39d5ee2SKristof Provost# 16d39d5ee2SKristof Provost# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17d39d5ee2SKristof Provost# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18d39d5ee2SKristof Provost# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19d39d5ee2SKristof Provost# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20d39d5ee2SKristof Provost# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21d39d5ee2SKristof Provost# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22d39d5ee2SKristof Provost# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23d39d5ee2SKristof Provost# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24d39d5ee2SKristof Provost# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25d39d5ee2SKristof Provost# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26d39d5ee2SKristof Provost# SUCH DAMAGE. 27d39d5ee2SKristof Provost 28d39d5ee2SKristof Provostimport argparse 29d39d5ee2SKristof Provostimport os 30*9d0bc96eSKristof Provostimport logging 31*9d0bc96eSKristof Provostlogging.getLogger("scapy").setLevel(logging.CRITICAL) 32d39d5ee2SKristof Provostimport scapy.all as sp 33d39d5ee2SKristof Provostimport sys 34d39d5ee2SKristof Provostimport time 35d39d5ee2SKristof Provost 36d39d5ee2SKristof Provostdef main(send): 37d39d5ee2SKristof Provost parser = argparse.ArgumentParser("frag-overindex.py", 38d39d5ee2SKristof Provost description="Fragmentation test tool") 39d39d5ee2SKristof Provost parser.add_argument('--to', nargs=1, 40d39d5ee2SKristof Provost required=True, 41d39d5ee2SKristof Provost help='The address to send the fragmented packets to') 42d39d5ee2SKristof Provost parser.add_argument('--fromaddr', nargs=1, 43d39d5ee2SKristof Provost required=True, 44d39d5ee2SKristof Provost help='The source address for the generated packets') 45d39d5ee2SKristof Provost parser.add_argument('--sendif', nargs=1, 46d39d5ee2SKristof Provost required=True, 47d39d5ee2SKristof Provost help='The interface through which the packet(s) will be sent') 48d39d5ee2SKristof Provost parser.add_argument('--recvif', nargs=1, 49d39d5ee2SKristof Provost required=True, 50d39d5ee2SKristof Provost help='The interface to expect the reply on') 51d39d5ee2SKristof Provost 52d39d5ee2SKristof Provost args = parser.parse_args() 53d39d5ee2SKristof Provost 54d39d5ee2SKristof Provost send(args.fromaddr[0], args.to[0], args.sendif[0], args.recvif[0]) 55