-
Notifications
You must be signed in to change notification settings - Fork 154
/
check-host-list
executable file
·599 lines (593 loc) · 11.2 KB
/
check-host-list
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
#!/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-host-list - Shell script to test arp-scan host list creation
#
# Author: Roy Hills
# Date: 4 February 2011
#
# This script checks that arp-scan creates the host list correctly.
# It uses the undocumented arp-scan option --readpktfromfile to
# read the packets from a pcap file rather than from the network.
#
ARPSCANOUTPUT=/tmp/arp-scan-output.$$.tmp
EXAMPLEOUTPUT=/tmp/example-output.$$.tmp
#
SAMPLE01="$srcdir/testdata/pkt-net1921681-response.pcap"
# 56 ARP responses from a Class-C sized network with various vendors
echo "Checking host list creation using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
Host List:
Entry IP Address
1 192.168.1.0
2 192.168.1.1
3 192.168.1.2
4 192.168.1.3
5 192.168.1.4
6 192.168.1.5
7 192.168.1.6
8 192.168.1.7
9 192.168.1.8
10 192.168.1.9
11 192.168.1.10
12 192.168.1.11
13 192.168.1.12
14 192.168.1.13
15 192.168.1.14
16 192.168.1.15
17 192.168.1.16
18 192.168.1.17
19 192.168.1.18
20 192.168.1.19
21 192.168.1.20
22 192.168.1.21
23 192.168.1.22
24 192.168.1.23
25 192.168.1.24
26 192.168.1.25
27 192.168.1.26
28 192.168.1.27
29 192.168.1.28
30 192.168.1.29
31 192.168.1.30
32 192.168.1.31
33 192.168.1.32
34 192.168.1.33
35 192.168.1.34
36 192.168.1.35
37 192.168.1.36
38 192.168.1.37
39 192.168.1.38
40 192.168.1.39
41 192.168.1.40
42 192.168.1.41
43 192.168.1.42
44 192.168.1.43
45 192.168.1.44
46 192.168.1.45
47 192.168.1.46
48 192.168.1.47
49 192.168.1.48
50 192.168.1.49
51 192.168.1.50
52 192.168.1.51
53 192.168.1.52
54 192.168.1.53
55 192.168.1.54
56 192.168.1.55
57 192.168.1.56
58 192.168.1.57
59 192.168.1.58
60 192.168.1.59
61 192.168.1.60
62 192.168.1.61
63 192.168.1.62
64 192.168.1.63
65 192.168.1.64
66 192.168.1.65
67 192.168.1.66
68 192.168.1.67
69 192.168.1.68
70 192.168.1.69
71 192.168.1.70
72 192.168.1.71
73 192.168.1.72
74 192.168.1.73
75 192.168.1.74
76 192.168.1.75
77 192.168.1.76
78 192.168.1.77
79 192.168.1.78
80 192.168.1.79
81 192.168.1.80
82 192.168.1.81
83 192.168.1.82
84 192.168.1.83
85 192.168.1.84
86 192.168.1.85
87 192.168.1.86
88 192.168.1.87
89 192.168.1.88
90 192.168.1.89
91 192.168.1.90
92 192.168.1.91
93 192.168.1.92
94 192.168.1.93
95 192.168.1.94
96 192.168.1.95
97 192.168.1.96
98 192.168.1.97
99 192.168.1.98
100 192.168.1.99
101 192.168.1.100
102 192.168.1.101
103 192.168.1.102
104 192.168.1.103
105 192.168.1.104
106 192.168.1.105
107 192.168.1.106
108 192.168.1.107
109 192.168.1.108
110 192.168.1.109
111 192.168.1.110
112 192.168.1.111
113 192.168.1.112
114 192.168.1.113
115 192.168.1.114
116 192.168.1.115
117 192.168.1.116
118 192.168.1.117
119 192.168.1.118
120 192.168.1.119
121 192.168.1.120
122 192.168.1.121
123 192.168.1.122
124 192.168.1.123
125 192.168.1.124
126 192.168.1.125
127 192.168.1.126
128 192.168.1.127
129 192.168.1.128
130 192.168.1.129
131 192.168.1.130
132 192.168.1.131
133 192.168.1.132
134 192.168.1.133
135 192.168.1.134
136 192.168.1.135
137 192.168.1.136
138 192.168.1.137
139 192.168.1.138
140 192.168.1.139
141 192.168.1.140
142 192.168.1.141
143 192.168.1.142
144 192.168.1.143
145 192.168.1.144
146 192.168.1.145
147 192.168.1.146
148 192.168.1.147
149 192.168.1.148
150 192.168.1.149
151 192.168.1.150
152 192.168.1.151
153 192.168.1.152
154 192.168.1.153
155 192.168.1.154
156 192.168.1.155
157 192.168.1.156
158 192.168.1.157
159 192.168.1.158
160 192.168.1.159
161 192.168.1.160
162 192.168.1.161
163 192.168.1.162
164 192.168.1.163
165 192.168.1.164
166 192.168.1.165
167 192.168.1.166
168 192.168.1.167
169 192.168.1.168
170 192.168.1.169
171 192.168.1.170
172 192.168.1.171
173 192.168.1.172
174 192.168.1.173
175 192.168.1.174
176 192.168.1.175
177 192.168.1.176
178 192.168.1.177
179 192.168.1.178
180 192.168.1.179
181 192.168.1.180
182 192.168.1.181
183 192.168.1.182
184 192.168.1.183
185 192.168.1.184
186 192.168.1.185
187 192.168.1.186
188 192.168.1.187
189 192.168.1.188
190 192.168.1.189
191 192.168.1.190
192 192.168.1.191
193 192.168.1.192
194 192.168.1.193
195 192.168.1.194
196 192.168.1.195
197 192.168.1.196
198 192.168.1.197
199 192.168.1.198
200 192.168.1.199
201 192.168.1.200
202 192.168.1.201
203 192.168.1.202
204 192.168.1.203
205 192.168.1.204
206 192.168.1.205
207 192.168.1.206
208 192.168.1.207
209 192.168.1.208
210 192.168.1.209
211 192.168.1.210
212 192.168.1.211
213 192.168.1.212
214 192.168.1.213
215 192.168.1.214
216 192.168.1.215
217 192.168.1.216
218 192.168.1.217
219 192.168.1.218
220 192.168.1.219
221 192.168.1.220
222 192.168.1.221
223 192.168.1.222
224 192.168.1.223
225 192.168.1.224
226 192.168.1.225
227 192.168.1.226
228 192.168.1.227
229 192.168.1.228
230 192.168.1.229
231 192.168.1.230
232 192.168.1.231
233 192.168.1.232
234 192.168.1.233
235 192.168.1.234
236 192.168.1.235
237 192.168.1.236
238 192.168.1.237
239 192.168.1.238
240 192.168.1.239
241 192.168.1.240
242 192.168.1.241
243 192.168.1.242
244 192.168.1.243
245 192.168.1.244
246 192.168.1.245
247 192.168.1.246
248 192.168.1.247
249 192.168.1.248
250 192.168.1.249
251 192.168.1.250
252 192.168.1.251
253 192.168.1.252
254 192.168.1.253
255 192.168.1.254
256 192.168.1.255
Total of 256 host entries.
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt -v -v -v"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 192.168.1.0/24 2>&1 | sed -n -e '/^Host List:/,/^Total of /p' > "$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"
#
echo "Checking random host list creation using $SAMPLE01 ..."
cat >"$EXAMPLEOUTPUT" <<_EOF_
Host List:
Entry IP Address
1 192.168.1.149
2 192.168.1.211
3 192.168.1.122
4 192.168.1.254
5 192.168.1.45
6 192.168.1.15
7 192.168.1.226
8 192.168.1.84
9 192.168.1.47
10 192.168.1.80
11 192.168.1.113
12 192.168.1.247
13 192.168.1.118
14 192.168.1.191
15 192.168.1.196
16 192.168.1.210
17 192.168.1.206
18 192.168.1.184
19 192.168.1.245
20 192.168.1.237
21 192.168.1.2
22 192.168.1.240
23 192.168.1.63
24 192.168.1.153
25 192.168.1.223
26 192.168.1.4
27 192.168.1.133
28 192.168.1.16
29 192.168.1.58
30 192.168.1.103
31 192.168.1.169
32 192.168.1.179
33 192.168.1.19
34 192.168.1.37
35 192.168.1.64
36 192.168.1.44
37 192.168.1.151
38 192.168.1.163
39 192.168.1.111
40 192.168.1.93
41 192.168.1.152
42 192.168.1.203
43 192.168.1.14
44 192.168.1.67
45 192.168.1.135
46 192.168.1.215
47 192.168.1.38
48 192.168.1.86
49 192.168.1.52
50 192.168.1.74
51 192.168.1.218
52 192.168.1.65
53 192.168.1.30
54 192.168.1.197
55 192.168.1.134
56 192.168.1.147
57 192.168.1.123
58 192.168.1.174
59 192.168.1.126
60 192.168.1.6
61 192.168.1.143
62 192.168.1.144
63 192.168.1.251
64 192.168.1.241
65 192.168.1.168
66 192.168.1.159
67 192.168.1.120
68 192.168.1.109
69 192.168.1.204
70 192.168.1.39
71 192.168.1.35
72 192.168.1.177
73 192.168.1.157
74 192.168.1.231
75 192.168.1.234
76 192.168.1.239
77 192.168.1.25
78 192.168.1.171
79 192.168.1.51
80 192.168.1.187
81 192.168.1.72
82 192.168.1.69
83 192.168.1.232
84 192.168.1.181
85 192.168.1.150
86 192.168.1.100
87 192.168.1.24
88 192.168.1.1
89 192.168.1.130
90 192.168.1.33
91 192.168.1.136
92 192.168.1.50
93 192.168.1.175
94 192.168.1.95
95 192.168.1.131
96 192.168.1.61
97 192.168.1.209
98 192.168.1.249
99 192.168.1.236
100 192.168.1.225
101 192.168.1.139
102 192.168.1.18
103 192.168.1.49
104 192.168.1.208
105 192.168.1.119
106 192.168.1.92
107 192.168.1.190
108 192.168.1.161
109 192.168.1.201
110 192.168.1.183
111 192.168.1.216
112 192.168.1.248
113 192.168.1.162
114 192.168.1.219
115 192.168.1.17
116 192.168.1.10
117 192.168.1.62
118 192.168.1.3
119 192.168.1.224
120 192.168.1.182
121 192.168.1.242
122 192.168.1.138
123 192.168.1.217
124 192.168.1.90
125 192.168.1.40
126 192.168.1.22
127 192.168.1.48
128 192.168.1.102
129 192.168.1.73
130 192.168.1.76
131 192.168.1.202
132 192.168.1.255
133 192.168.1.97
134 192.168.1.88
135 192.168.1.9
136 192.168.1.243
137 192.168.1.165
138 192.168.1.105
139 192.168.1.132
140 192.168.1.205
141 192.168.1.176
142 192.168.1.253
143 192.168.1.194
144 192.168.1.229
145 192.168.1.79
146 192.168.1.230
147 192.168.1.98
148 192.168.1.173
149 192.168.1.55
150 192.168.1.222
151 192.168.1.101
152 192.168.1.99
153 192.168.1.207
154 192.168.1.212
155 192.168.1.166
156 192.168.1.154
157 192.168.1.78
158 192.168.1.5
159 192.168.1.42
160 192.168.1.13
161 192.168.1.91
162 192.168.1.23
163 192.168.1.193
164 192.168.1.7
165 192.168.1.66
166 192.168.1.124
167 192.168.1.114
168 192.168.1.41
169 192.168.1.28
170 192.168.1.0
171 192.168.1.235
172 192.168.1.146
173 192.168.1.238
174 192.168.1.178
175 192.168.1.71
176 192.168.1.60
177 192.168.1.117
178 192.168.1.12
179 192.168.1.57
180 192.168.1.192
181 192.168.1.29
182 192.168.1.164
183 192.168.1.116
184 192.168.1.121
185 192.168.1.167
186 192.168.1.125
187 192.168.1.32
188 192.168.1.228
189 192.168.1.59
190 192.168.1.85
191 192.168.1.20
192 192.168.1.110
193 192.168.1.156
194 192.168.1.200
195 192.168.1.77
196 192.168.1.233
197 192.168.1.106
198 192.168.1.8
199 192.168.1.148
200 192.168.1.11
201 192.168.1.82
202 192.168.1.213
203 192.168.1.81
204 192.168.1.75
205 192.168.1.246
206 192.168.1.188
207 192.168.1.107
208 192.168.1.172
209 192.168.1.214
210 192.168.1.94
211 192.168.1.140
212 192.168.1.26
213 192.168.1.127
214 192.168.1.115
215 192.168.1.87
216 192.168.1.199
217 192.168.1.36
218 192.168.1.250
219 192.168.1.189
220 192.168.1.129
221 192.168.1.170
222 192.168.1.180
223 192.168.1.27
224 192.168.1.128
225 192.168.1.112
226 192.168.1.46
227 192.168.1.186
228 192.168.1.21
229 192.168.1.68
230 192.168.1.53
231 192.168.1.70
232 192.168.1.221
233 192.168.1.160
234 192.168.1.83
235 192.168.1.198
236 192.168.1.252
237 192.168.1.31
238 192.168.1.145
239 192.168.1.244
240 192.168.1.142
241 192.168.1.220
242 192.168.1.155
243 192.168.1.89
244 192.168.1.43
245 192.168.1.141
246 192.168.1.137
247 192.168.1.104
248 192.168.1.185
249 192.168.1.96
250 192.168.1.54
251 192.168.1.34
252 192.168.1.158
253 192.168.1.108
254 192.168.1.195
255 192.168.1.227
256 192.168.1.56
Total of 256 host entries.
_EOF_
ARPARGS="--retry=1 --ouifile=$srcdir/ieee-oui.txt --macfile=$srcdir/mac-vendor.txt -v -v -v --random --randomseed=0xdeadbeef"
./arp-scan $ARPARGS --readpktfromfile="$SAMPLE01" 192.168.1.0/24 2>&1 | sed -n -e '/^Host List:/,/^Total of /p' > "$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"