xref: /openbsd/regress/sbin/isakmpd/msg/check.sh (revision 09467b48)
1#!/bin/sh
2#	$OpenBSD: check.sh,v 1.1 2005/04/08 17:12:50 cloder Exp $
3#	$EOM: check.sh,v 1.4 1998/07/17 21:33:13 niklas Exp $
4
5#
6# Copyright (c) 1998 Niklas Hallqvist.  All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29#
30# This code was written under funding by Ericsson.
31#
32
33PROGNAME=$0
34NC=/usr/bin/nc
35HOST=localhost
36ISAKMP_PORT=500
37
38set -- `getopt p: $*`
39if [ $? != 0 ]; then
40  echo 'usage: $PROGNAME [-p port] host' >&2
41  exit 2
42fi
43for i; do
44  case "$i" in
45  -p)
46    ISAKMP_PORT=$2; shift; shift;;
47  --)
48    shift; break;;
49  esac
50done
51
52if [ $# -gt 0 ]; then
53  HOST=$1
54fi
55
56send () {
57  ${NC} -u -w 1 ${HOST} ${ISAKMP_PORT}
58}
59
60# Short message
61printf "SHORT!" |send
62
63# (Most probably) invalid cookie
64printf "INVALID COOKIES!\0\x10\0\0\0\0\0\0\0\0\0\x1c" |send
65
66# Invalid next payload type
67printf "01234567\0\0\0\0\0\0\0\0!\x10\0\0\0\0\0\0\0\0\0\x1c" |send
68
69# Invalid major version
70printf "01234567\0\0\0\0\0\0\0\0\0\x20\0\0\0\0\0\0\0\0\0\x1c" |send
71
72# Invalid minor version
73printf "01234567\0\0\0\0\0\0\0\0\0\x11\0\0\0\0\0\0\0\0\0\x1c" |send
74
75# Invalid exchange type
76printf "01234567\0\0\0\0\0\0\0\0\0\x10!\0\0\0\0\0\0\0\0\x1c" |send
77
78# Invalid flags
79printf "01234567\0\0\0\0\0\0\0\0\0\x10\2\x80\0\0\0\0\0\0\0\x1c" |send
80
81# Invalid message ID
82printf "01234567\0\0\0\0\0\0\0\0\0\x10\2\0BAD!\0\0\0\x1c" |send
83
84# Short length
85printf "01234567\0\0\0\0\0\0\0\0\0\x10\2\0\0\0\0\0\0\0\0\x1b" |send
86
87# Long length
88printf "01234567\0\0\0\0\0\0\0\0\0\x10\2\0\0\0\0\0\0\0\0\x1d" |send
89