-
Notifications
You must be signed in to change notification settings - Fork 154
/
check-decode
executable file
·538 lines (506 loc) · 18.9 KB
/
check-decode
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
#!/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-decode - Shell script to test arp-scan packet decoding
#
# Author: Roy Hills
# Date: 30 January 2011
#
# This script checks that arp-scan decodes and displays ARP response packets
# correctly. It uses the undocumented arp-scan option --readpktfromfile to
# read the packet from a file rather than from the network.
#
ARPSCANOUTPUT=/tmp/arp-scan-output.$$.tmp
EXAMPLEOUTPUT=/tmp/example-output.$$.tmp
#
SAMPLE01="$srcdir/testdata/pkt-simple-response.pcap"
SAMPLE02="$srcdir/testdata/pkt-padding-response.pcap"
SAMPLE03="$srcdir/testdata/pkt-vlan-response.pcap"
SAMPLE04="$srcdir/testdata/pkt-llc-response.pcap"
SAMPLE05="$srcdir/testdata/pkt-net1921681-response.pcap"
SAMPLE06="$srcdir/testdata/pkt-trailer-response.pcap"
SAMPLE07="$srcdir/testdata/pkt-vlan-llc-response.pcap"
SAMPLE08="$srcdir/testdata/pkt-dup-response.pcap"
SAMPLE09="$srcdir/testdata/pkt-diff-frame-addr.pcap"
SAMPLE10="$srcdir/testdata/pkt-local-admin.pcap"
# Simple ARP response packet
echo "Checking simple ARP response packet decode using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response packet with non zero padding
echo "Checking padded ARP response packet decode using $SAMPLE02 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION Padding=55aa55aa55aa55aa55aa55aa55aa55aa55aa
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt --verbose"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE02" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# ARP response packet with 802.1Q VLAN tag
echo "Checking 802.1Q ARP response packet decode using $SAMPLE03 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION (802.1Q VLAN=4095)
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE03" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# ARP response packet with 802.2 LLC/SNAP encapsulation
echo "Checking LLC/SNAP ARP response packet decode using $SAMPLE04 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION (802.2 LLC/SNAP)
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE04" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# 56 ARP responses from a Class-C sized network with various vendors
echo "Checking 192.168.1.0/24 ARP response packet decode using $SAMPLE05 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
192.168.1.3 00:0b:cd:26:aa:78 Hewlett Packard
192.168.1.4 00:08:02:e2:e3:2b Hewlett Packard
192.168.1.7 00:0b:cd:3d:4f:2a Hewlett Packard
192.168.1.5 00:02:a5:90:c3:e6 Hewlett Packard
192.168.1.6 00:c0:9f:3f:3d:70 Quanta Computer Inc.
192.168.1.8 00:02:a5:a9:27:29 Hewlett Packard
192.168.1.9 00:02:a5:f9:33:8d Hewlett Packard
192.168.1.10 00:08:02:89:b3:cb Hewlett Packard
192.168.1.11 00:0f:1f:5c:d1:13 Dell Inc.
192.168.1.12 00:02:a5:de:c2:17 Hewlett Packard
192.168.1.14 00:c0:9f:0b:91:d1 Quanta Computer Inc.
192.168.1.13 00:08:02:1f:0e:42 Hewlett Packard
192.168.1.16 00:18:8b:7a:fe:28 Dell Inc.
192.168.1.17 00:12:3f:d4:41:86 Dell Inc.
192.168.1.18 00:21:9b:18:bd:e2 Dell Inc.
192.168.1.20 00:21:70:0a:5d:42 Dell Inc.
192.168.1.22 00:12:3f:27:bb:ae Dell Inc.
192.168.1.21 00:25:64:e7:ad:e2 Dell Inc.
192.168.1.23 00:21:70:0b:34:c8 Dell Inc.
192.168.1.24 00:1a:a0:9e:fd:06 Dell Inc.
192.168.1.26 00:08:74:bb:2a:33 Dell Inc.
192.168.1.25 00:25:64:e7:b3:d6 Dell Inc.
192.168.1.28 00:18:8b:7a:fe:82 Dell Inc.
192.168.1.31 00:12:3f:d4:41:85 Dell Inc.
192.168.1.35 00:12:3f:26:72:eb Dell Inc.
192.168.1.37 00:18:8b:7a:fe:10 Dell Inc.
192.168.1.43 00:12:3f:d4:40:ae Dell Inc.
192.168.1.41 00:12:3f:ae:bd:02 Dell Inc.
192.168.1.48 00:12:3f:ae:a3:c5 Dell Inc.
192.168.1.51 00:08:74:c0:40:ce Dell Inc.
192.168.1.49 00:0f:1f:5c:c2:ae Dell Inc.
192.168.1.68 f0:4d:a2:84:7c:07 Dell Inc.
192.168.1.73 00:11:25:83:92:e9 IBM Corp
192.168.1.89 00:21:9b:18:a4:84 Dell Inc.
192.168.1.102 00:25:64:3d:98:5a Dell Inc.
192.168.1.104 00:0c:29:ec:85:39 VMware, Inc.
192.168.1.105 00:13:72:09:ad:76 Dell Inc.
192.168.1.148 00:90:27:9d:2a:0b Intel Corporation
192.168.1.154 00:0c:30:85:58:9d Cisco Systems, Inc
192.168.1.155 00:10:db:74:d0:52 Juniper Networks
192.168.1.187 00:00:aa:a1:b3:60 XEROX CORPORATION
192.168.1.189 00:14:38:93:93:7e Hewlett Packard Enterprise
192.168.1.196 00:15:99:5d:d5:26 Samsung Electronics Co.,Ltd
192.168.1.195 00:15:99:61:08:30 Samsung Electronics Co.,Ltd
192.168.1.202 00:d0:b7:25:61:6c Intel Corporation
192.168.1.204 00:11:43:0f:f2:dd Dell Inc.
192.168.1.205 00:02:b3:91:20:2a Intel Corporation
192.168.1.207 00:12:3f:ec:cf:a0 Dell Inc.
192.168.1.206 00:c0:9f:39:f7:f2 Quanta Computer Inc.
192.168.1.222 00:90:27:9d:48:90 Intel Corporation
192.168.1.192 00:01:e6:27:27:6e Hewlett Packard
192.168.1.234 00:c0:9f:0d:00:9a Quanta Computer Inc.
192.168.1.245 00:0b:5f:d2:34:21 Cisco Systems, Inc
192.168.1.246 00:13:80:53:cd:79 Cisco Systems, Inc
192.168.1.250 00:12:00:2f:18:c0 Cisco Systems, Inc
192.168.1.251 00:04:27:6a:5d:a1 Cisco Systems, Inc
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE05" 192.168.1.0/24 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response packet using IPstart-IPend target syntax
echo "Checking IP range ARP response packet decode using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.1-127.0.0.9 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response packet using network:mask target syntax
# We use a /22 (255.255.252.0) because this gives more than 1000 hosts, which
# causes the list allocation code to call realloc().
echo "Checking IP net:mask ARP response packet decode using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.0:255.255.252.0 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response packet with trailer ARP reply.
echo "Checking trailer ARP response packet decode using $SAMPLE06 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:12:34:56 DIGITAL EQUIPMENT CORPORATION
127.0.0.1 08:00:2b:12:34:56 DIGITAL EQUIPMENT CORPORATION (ARP Proto=0x1000) (DUP: 2)
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE06" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# 802.1Q LLC ARP response packet
echo "Checking 802.1Q LLC ARP response packet decode using $SAMPLE07 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION (802.2 LLC/SNAP) (802.1Q VLAN=100)
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE07" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# ARP response packets with duplicates
echo "Checking ARP responses packets with duplicates using $SAMPLE08 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
192.168.14.2 00:50:56:e4:9a:83 VMware, Inc.
192.168.14.1 00:50:56:c0:00:08 VMware, Inc.
192.168.14.1 00:50:56:c0:00:08 VMware, Inc. (DUP: 2)
192.168.14.135 00:0c:29:54:fc:75 VMware, Inc.
192.168.14.135 00:0c:29:54:fc:75 VMware, Inc. (DUP: 2)
192.168.14.135 00:0c:29:54:fc:75 VMware, Inc. (DUP: 3)
192.168.14.136 00:0c:29:80:62:77 VMware, Inc.
192.168.14.136 00:0c:29:80:62:77 VMware, Inc. (DUP: 2)
192.168.14.136 00:0c:29:80:62:77 VMware, Inc. (DUP: 3)
192.168.14.136 00:0c:29:80:62:77 VMware, Inc. (DUP: 4)
192.168.14.254 00:50:56:ed:35:d5 VMware, Inc.
192.168.14.254 00:50:56:ed:35:d5 VMware, Inc. (DUP: 2)
192.168.14.254 00:50:56:ed:35:d5 VMware, Inc. (DUP: 3)
192.168.14.254 00:50:56:ed:35:d5 VMware, Inc. (DUP: 4)
192.168.14.254 00:50:56:ed:35:d5 VMware, Inc. (DUP: 5)
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE08" 192.168.14.1 192.168.14.2 192.168.14.135 192.168.14.136 192.168.14.254 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# ARP response packets with ignored duplicates
echo "Checking ARP response packets with ignored duplicates using $SAMPLE08 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
192.168.14.2 00:50:56:e4:9a:83 VMware, Inc.
192.168.14.1 00:50:56:c0:00:08 VMware, Inc.
192.168.14.135 00:0c:29:54:fc:75 VMware, Inc.
192.168.14.136 00:0c:29:80:62:77 VMware, Inc.
192.168.14.254 00:50:56:ed:35:d5 VMware, Inc.
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt --ignoredups"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE08" 192.168.14.1 192.168.14.2 192.168.14.135 192.168.14.136 192.168.14.254 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response with rount-trip time (RTT).
# We cannot predict the RTT number so we use sed to change it to a fixed number.
echo "Checking simple ARP response with round-trip time (RTT) display using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 DIGITAL EQUIPMENT CORPORATION RTT=999.999 ms
_EOF_
ARPARGS="--retry=1 --ignoredups --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt --rtt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' | sed 's/RTT=[0-9]*\.[0-9]* ms/RTT=999.999 ms/' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response packet with --resolve
echo "Checking simple ARP response with --resolve using $SAMPLE01 ..."
echo "(this test will fail if 127.0.0.1 does not resolve to a hostname)"
echo "(typically localhost but it does not matter what name it resolves to)"
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt --resolve --plain --quiet"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
grep -v '^127\.0\.0\.1' "$ARPSCANOUTPUT" >/dev/null
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
# ARP response with Ethernet frame source address != ar$sha in the ARP packet
echo "Checking ARP response with Ethernet frame source address != ar\$sha using $SAMPLE09 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08 (08:00:2b:08:07:06) DIGITAL EQUIPMENT CORPORATION
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE09" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# ARP response from locally administered address
echo "Checking ARP response with locally administered MAC address using $SAMPLE09 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 02:00:00:00:00:00 (Unknown: locally administered)
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE10" 127.0.0.1 | grep -v '^Starting arp-scan ' | grep -v '^Interface: ' | grep -v '^Ending arp-scan ' | grep -v '^[0-9]* packets received ' > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response with custom formatting
echo "Checking custom formatting using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
WARNING: Field \${xyz} unknown or not available
127.0.0.1|08:00:2b:06:07:08\ DIGITAL EQUIPMENT CORPORATION,
XXXX
_EOF_
ARPARGS="--plain --retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt --format=\${ip;15}|\${mac}\\\\\t\${vendor},\${xyz}\nXXXX"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
# Simple ARP response with --quiet option
echo "Checking --quiet formatting using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
127.0.0.1 08:00:2b:06:07:08
_EOF_
ARPARGS="--plain --retry=1 --quiet"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 127.0.0.1 > "$ARPSCANOUTPUT" 2>&1
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
cmp -s "$ARPSCANOUTPUT" "$EXAMPLEOUTPUT"
if test $? -ne 0; then
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"
echo "FAILED"
exit 1
fi
echo "ok"
rm -f "$ARPSCANOUTPUT"
rm -f "$EXAMPLEOUTPUT"