File: check-error

package info (click to toggle)
arp-scan 1.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,128 kB
  • sloc: ansic: 3,256; sh: 1,767; perl: 523; makefile: 42
file content (187 lines) | stat: -rwxr-xr-x 5,492 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/sh
# arp-scan is Copyright (C) 2005-2022 Roy Hills
#
# This file is part of arp-scan.
#
# arp-scan is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# arp-scan is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with arp-scan.  If not, see <http://www.gnu.org/licenses/>.
#
# check-run1 -- Shell script to test arp-scan basic functionality
#
# Author: Roy Hills
# Date: 7 November 2022
#
# This shell script checks various error conditions.
#
ARPSCANOUTPUT=/tmp/arp-scan-output.$$.tmp
SAMPLE01="$srcdir/pkt-simple-response.pcap"

# Check invalid option - should have non-zero exit status
echo "Checking arp-scan --xyz (invalid option) ..."
./arp-scan --xyz > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^Use "arp-scan --help" for detailed information' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Check no target hosts - should have non-zero exit status
echo "Checking arp-scan without target hosts ..."
./arp-scan > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^ERROR: No target hosts on command line ' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Try to use a host input file that doesn't exist - should have non-zero exit status
echo "Checking arp-scan with non existent host file ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS -f xxxFUNNYxxx --readpktfromfile="$SAMPLE01" > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^Cannot open xxxFUNNYxxx:' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Try to use a non-existant mac/vendor mapping file - should warn and continue
echo "Checking arp-scan with non existent mac/vendor file ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS -O xxxFUNNYxxx --readpktfromfile="$SAMPLE01" 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^WARNING: Cannot open MAC/Vendor file xxxFUNNYxxx:' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Try to specify both --bandwidth and --interval - nonzero exit status.
echo "Checking arp-scan with both --bandwidth and --interval ..."
ARPARGS="--retry=1 --bandwidth=1 --interval=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^ERROR: You cannot specify both --bandwidth and --interval' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Try to specify targets with the --localnet option - nonzero exit
echo "Checking arp-scan with both targets and --localnet ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" --localnet 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^ERROR: You can not specify targets with the --localnet option' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Try to specify --file with --localnet option - nonzero exit
echo "Checking arp-scan with --file and --localnet ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" --localnet --file=- > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^ERROR: You can not specify both --file and --localnet options' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Try to specify invalid IP address - nonzero exit
echo "Checking arp-scan with invalid IP address ..."
ARPARGS="--retry=1 --numeric"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 333.333.333.333 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^WARNING: "333.333.333.333" is not a valid IPv4 address - target ignored' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"

# Try to specify invalid CIDR address - nonzero exit
echo "Checking arp-scan with invalid CIDR address ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 10.0.0.0/0 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
grep '^ERROR: Number of bits in 10.0.0.0/0 must be between 3 and 32' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
   rm -f "$ARPSCANOUTPUT"
   echo "FAILED"
   exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"