-
Notifications
You must be signed in to change notification settings - Fork 154
/
check-error
executable file
·602 lines (570 loc) · 16.7 KB
/
check-error
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
#!/bin/sh
# arp-scan is Copyright (C) 2005-2024 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/testdata/pkt-simple-response.pcap"
SAMPLE02="$srcdir/testdata/pkt-too-short.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-existent 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"
# Specify invalid IP address - warning followed by 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"
# Specify invalid IP network in CIDR notation - nonzero exit
echo "Checking arp-scan with invalid IP network in CIDR notation ..."
ARPARGS="--retry=1 --numeric"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 333.0.0.0/24 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^ERROR: 333.0.0.0 is not a valid IPv4 network' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Specify invalid CIDR mask - 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"
# Specify CIDR address with non-zero host part: warning
echo "Checking arp-scan with nonzero host in CIDR address ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 10.0.0.1/30 > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^WARNING: host part of 10.0.0.1/30 is non-zero' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Specify invalid IP network in net:mask notation - nonzero exit
echo "Checking arp-scan with invalid IP network in net:mask notation ..."
ARPARGS="--retry=1 --numeric"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 333.0.0.0:255.255.255.0 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^ERROR: 333.0.0.0 is not a valid IPv4 network' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Specify invalid netmask - nonzero exit
echo "Checking arp-scan with invalid netmask ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 10.0.0.0:333.0.0.0 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^ERROR: 333.0.0.0 is not a valid netmask' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Specify net:mask address with non-zero host part: warning
echo "Checking arp-scan with nonzero host in net:mask address ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 10.0.0.1:255.255.255.252 > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^WARNING: host part of 10.0.0.1:255.255.255.252 is non-zero' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Specify invalid starting IP address in range notation - nonzero exit
echo "Checking arp-scan with invalid starting IP network in range notation ..."
ARPARGS="--retry=1 --numeric"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 333.0.0.0-10.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^ERROR: Invalid range specification: 333.0.0.0 is not a valid IPv4 address' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Specify invalid ending IP address in range notation - nonzero exit
echo "Checking arp-scan with invalid ending IP network in range notation ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 10.0.0.1-333.0.0.0 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^ERROR: Invalid range specification: 333.0.0.0 is not a valid IPv4 address' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid signed long int input - nonzero exit
echo "Checking arp-scan with invalid CIDR address ..."
ARPARGS="--retry=1 --retry-send=xyz"
./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: "xyz" is not a valid numeric value' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid unsigned long int input - nonzero exit
echo "Checking arp-scan with invalid CIDR address ..."
ARPARGS="--retry=1 --snap=xyz"
./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: "xyz" is not a valid numeric value' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid bandwidth multiplier - nonzero exit
echo "Checking arp-scan with invalid bandwidth multiple ..."
ARPARGS="--retry=1 --bandwidth=1x"
./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: Unknown bandwidth multiplier character: "x"' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid interval multiplier - nonzero exit
echo "Checking arp-scan with invalid interval multiple ..."
ARPARGS="--retry=1 --interval=1x"
./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: Unknown interval multiplier character: "x"' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid --format string: invalid field width
echo "Checking arp-scan with invalid --format field width ..."
ARPARGS="--retry=1 --format=\${ip;X}"
./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: incorrect format string: invalid character \"X\" in field width' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid --format string: field width out of range
echo "Checking arp-scan with --format field width out of range ..."
ARPARGS="--retry=1 --format=\${ip;5000000000}"
./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: incorrect format string: field width out of range' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid format string: missing closing brace
echo "Checking arp-scan with --format field missing closing brace ..."
ARPARGS="--retry=1 --format=\${ip"
./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: incorrect format string: missing closing brace' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid format string: empty string
echo "Checking arp-scan with --format field empty string ..."
ARPARGS="--retry=1 --format="
./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: output format may not be empty string' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# --destaddr invalid MAC address
echo "Checking arp-scan with --destaddr invalid MAC address ..."
ARPARGS="--retry=1 --destaddr=XX"
./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 '^Invalid MAC address: XX' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# --arpsha invalid MAC address
echo "Checking arp-scan with --arpsha invalid MAC address ..."
ARPARGS="--retry=1 --arpsha=XX"
./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 '^Invalid MAC address: XX' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# --arptha invalid MAC address
echo "Checking arp-scan with --arptha invalid MAC address ..."
ARPARGS="--retry=1 --arptha=XX"
./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 '^Invalid MAC address: XX' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# --srcaddr invalid MAC address
echo "Checking arp-scan with --srcaddr invalid MAC address ..."
ARPARGS="--retry=1 --srcaddr=XX"
./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 '^Invalid MAC address: XX' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Non-existent pcap file for --readpktfromfile
echo "Checking arp-scan with nonexistent --readpktfromfile file ..."
ARPARGS="--retry=1 --readpktfromfile=xxxFUNNYxxx"
./arp-scan $ARPARGS 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^pcap_open_offline: xxxFUNNYxxx: No such file or directory' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Invalid IP address for --arpspa option
echo "Checking arp-scan with invalid --arpspa option ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --arpspa=333.0.0.1 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^ERROR: Invalid IPv4 address: 333.0.0.1' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Odd --padding length
echo "Checking arp-scan with odd --padding length ..."
ARPARGS="--retry=1"
./arp-scan $ARPARGS --padding=a 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -eq 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^ERROR: Length of --padding argument must be even (multiple of 2).' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# Packet too short to decode
echo "Checking arp-scan with packet too short to decode ..."
ARPARGS="--retry=1 --plain --quiet"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE02" 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep '^WARNING: 22 byte packet too short to decode.' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"