-
Notifications
You must be signed in to change notification settings - Fork 49
/
passer.py
executable file
·2502 lines (2235 loc) · 164 KB
/
passer.py
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
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
"""Passer learns, by watching network traffic, about the servers and clients on your network."""
#Copyright 2008-2018, William Stearns <william.l.stearns@gmail.com>
#Passer is a PASsive SERvice sniffer.
#Home site http://www.stearns.org/passer/
#Github repository https://github.com/organizations/activecm/passer/
#Dedicated to Mae Anne Laroche.
#Released under the GPL version 3:
#This program 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.
#This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#======== Imports ========
import os
import ipaddress
import sys
import re
import json
import binascii #converting hex text to raw bytes
import signal #For catching Ctrl-C
import string #Needed for python 2.5.2?
import warnings #Needed for p0f?
import unicodedata #Needed for removing control characters
import pytz
import __main__ #Needed to access variables in __main__ from functions without implicit/explicit globals
try:
#from scapy.all import p0f
#from scapy.all import ARP, CookedLinux, DHCP, DNS, DNSQR, DNSRR, Dot11, Dot11AssoReq, Dot11AssoResp, Dot11Auth, Dot11Beacon, Dot11Deauth, Dot11Elt, Dot11ProbeReq, Dot11ProbeResp, Dot11WEP, Dot3, ESP, Ether, GRE, ICMP, ICMPerror, ICMPv6DestUnreach, ICMPv6EchoRequest, ICMPv6EchoReply, ICMPv6MLDone, ICMPv6MLQuery, ICMPv6MLReport, ICMPv6ND_NA, ICMPv6ND_NS, ICMPv6ND_RA, ICMPv6ND_RS, ICMPv6ND_Redirect, ICMPv6NDOptDstLLAddr, ICMPv6NDOptPrefixInfo, ICMPv6NDOptRDNSS, ICMPv6NDOptSrcLLAddr, ICMPv6PacketTooBig, ICMPv6TimeExceeded, IP, IPerror, IPerror6, IPv6, IPv6ExtHdrHopByHop, ISAKMP, LLC, LLMNRQuery, NBNSQueryRequest, NBNSQueryResponse, NBTDatagram, NTPControl, NTPPrivate, PcapWriter, RadioTap, Radius, Raw, SNMP, SNMPget, SNMPbulk, SNMPvarbind, SNMPresponse, TCP, TCPerror, TFTP, UDP, UDPerror, conf, ls, sniff
#When running pylint, comment out the following line and uncomment the above, revert when done with pylint
from scapy.all import * #Required for Scapy 2.0 and above
use_scapy_all = True
except:
from scapy import * #Scapy 1.0
use_scapy_all = False
if use_scapy_all:
try:
from scapy.all import NTPHeader
has_advanced_ntp_headers = True #V2.2.0 and below don't have NTPHeader
except ImportError:
has_advanced_ntp_headers = False
else:
has_advanced_ntp_headers = False
sys.path.insert(0, '.') #Allows us to load from the current directory (There was one claim that we need to create an empty file __init__.py , but this does not appear to be required.)
from passer_lib import * #Support functions for this script
try:
if not passer_lib_version:
sys.stderr.write('Unable to load passer_lib , exiting.\n')
quit()
except NameError:
sys.stderr.write('Unable to load passer_lib , exiting.\n')
quit()
#Note, to get p0f working, one must:
#sudo hack /usr/lib/python2.6/site-packages/scapy/modules/p0f.py
#and add:
#from scapy.all import *
#And:
#def p0f_correl(x,y):
# d = 0
# # wwww can be "*" or "%nn"
# #d += (x[0] == y[0] or y[0] == "*" or (y[0][0] == "%" and x[0].isdigit() and (int(x[0]) % int(y[0][1:])) == 0))
#Change above line to:
# d += (x[0] == y[0] or y[0] == "*" or (y[0][0] == "%" and str(x[0]).isdigit() and (int(x[0]) % int(y[0][1:])) == 0))
if os.path.isfile("/etc/p0f/p0f.fp") or os.path.exists("/opt/local/share/p0f/p0f.fp") or os.path.exists("/usr/share/p0f/p0f.fp"):
load_module("p0f")
else:
sys.stderr.write("/etc/p0f/p0f.fp not found; please install p0f version 2 to enable OS fingerprinting.\n")
sys.stderr.flush
#======== Global arrays ========
#These two are used to discover servers. If we've seen a SYN go to a port, and a SYN/ACK back from it,
#that's a pretty good sign it's a server. Not truly stateful, but a generally good guess.
botnet_warning_list = {} #Dictionary of "IP,proto_port": ['warning1', 'warning2'] entries that say if you see that trio, that IP should get this/these warnings.
#If we see syn/ack coming back from tcp C&C's, tag the host as 'bot_candc' and the dest IP of the syn/ack as 'bot'
#For UDP, just use any data heading _to_ the CandC to tag both ends (source is 'bot', dest os 'bot_candc')
#FIXME - implement
must_stop = False #Set to true if exit requested by signal
#======== Port lists ========
#From 122.224.158.195, payload is "8'\x82\xd7\x8fZ\xdbc\xfe\x00\x00\x00\x00\x00"
fenull_scan_names = {"21": "udp-21", "22": "udp-22", "23": "udp-23", "25": "udp-25", "49": "udp-49", "80": "udp-80", "102": "udp-102", "110": "udp-110", "143": "udp-143", "636": "udp-636", "992": "udp-992", "993": "udp-993", "995": "udp-995"}
empty_payload_ports = ('1', '17', '19', '18895', '50174', '50597', '50902', '52498', '52576', '52620', '52775', '52956', '55180', '56089', '57347', '57563', '57694', '58034', '58153', '58861', '59024', '59413', '60463', '60799', '61016', '61651', '62473', '62915', '63137', '63556', '63571', '63878', '64727', '65154', '65251')
halflife_altport = ("1265", "2303", "20100", "21025", "21550", "27000", "27017", "27018", "27019", "27022", "27030", "27035", "27050", "27078", "27080", "28015", "28100", "45081")
#For all of the following, see if the payload contains snmp.
### IPv4/UDPv4/21 22 23 25 tacacs=49 http=80 iso-tsap=102 110 143 igmpv3lite=465 ldaps=636 omirr=808 992 993 995 client
snmp_altport = ("21", "22", "23", "25", "49", "80", "102", "110", "143", "465", "636", "808", "992", "993", "995")
meet_ports = ('19302', '19303', '19304', '19305', '19306', '19307', '19308', '19309') #https://support.google.com/a/answer/7582935?hl=en
qualys_udp_scan_port_names = {"7": "echo", "13": "daytime", "17": "qotd", "19": "chargen", "37": "time", "111": "sunrpc", "123": "ntp", "177": "xdmcp", "407": "timbuktu", "443": "udp443", "464": "kpasswd", "517": "talk", "518": "ntalk", "520": "rip", "623": "asf-rmcp", "1194": "openvpn", "1434": "mssql", "1645": "sightline", "1701": "l2f", "1812": "radius", "1978": "unisql", "2002": "globe", "2049": "nfs", "4000": "terabase"}
skype_ports = ('21105', '21546', '22795', '23353', '24484', '26079', '27252', '27944')
zmap_host_www_ports = ("80", "563", "655", "830", "898", "989", "990", "991", "992", "995", "1293", "1707", "1900", "2484", "3269", "3544", "4843", "5000", "5031", "6379", "6619", "9899", "11214", "11215", "18091", "18092", "37215")
www163com_ports = ("21", "22", "23", "25", "49", "80", "102", "110", "143", "636", "992", "993", "995")
#======== IP address lists ========
SteamFriendsServers = ("69.28.148.250", "69.28.156.250", "72.165.61.161", "72.165.61.185", "72.165.61.186", "72.165.61.188", "68.142.64.164", "68.142.64.165", "68.142.64.166")
meet_hosts = (
'2607:f8b0:4002:c08::7f', '2607:f8b0:400c:c00::7f', '2a00:1450:4013:c03::7f', '2a00:1450:400c:c08::7f', '2800:3f0:4003:c00::7f', '2a00:1450:400c:c08::7f', '2607:f8b0:4002:c07::7f', '2a00:1450:4010:c01::7f', '2607:f8b0:400d:c0d::7f', "2a00:1450:400c:c06::7f", '2404:6800:4003:c00::7f', '2607:f8b0:400d:c09::7f', '2a00:1450:400c:c06::7f', '2a00:1450:4010:c08::7f',
'2607:f8b0:4002:0c08:0000:0000:0000:007f', '2607:f8b0:400c:0c00:0000:0000:0000:007f', '2a00:1450:4013:0c03:0000:0000:0000:007f', '2a00:1450:400c:0c08:0000:0000:0000:007f', '2800:3f0:4003:0c00:0000:0000:0000:007f', '2a00:1450:400c:0c08:0000:0000:0000:007f', '2607:f8b0:4002:0c07:0000:0000:0000:007f', '2a00:1450:4010:0c01:0000:0000:0000:007f', '2607:f8b0:400d:0c0d:0000:0000:0000:007f', "2a00:1450:400c:0c06:0000:0000:0000:007f", '2404:6800:4003:c00:0000:0000:0000:7f', '2607:f8b0:400d:0c09:0000:0000:0000:007f', '2a00:1450:400c:0c06:0000:0000:0000:007f', '2a00:1450:4010:0c08:0000:0000:0000:007f',
'64.233.165.127', '64.233.177.127', '64.233.186.127', '66.102.1.127', '74.125.134.127', '74.125.140.127', '74.125.143.127', '74.125.196.127', '74.125.200.127', '173.194.207.127', '209.85.232.127'
) #Second line is the same as the first with ipv6 expanded.
skype_hosts = ('52.179.141.141', '100.112.42.45')
shodan_hosts = ('66.240.192.138', '66.240.236.119', '71.6.146.185', '80.82.77.33', '94.102.49.190') #census8.shodan.io, census6.shodan.io, pirate.census.shodan.io, sky.census.shodan.io, flower.census.shodan.io
qualys_scan_ips = ('64.39.99.152', '64.39.111.38')
qualys_subnet_starts = ('64.39.96.', '64.39.99.', '64.39.102.', '64.39.103.', '64.39.105.', '64.39.106.', '64.39.111.')
vonage_ntp = ("216.115.23.75", "216.115.23.76", "69.59.240.75")
vonage_sip_servers = ("216.115.30.28", "69.59.227.77", "69.59.232.33", "69.59.240.84")
aol_dns_servers = ("205.188.146.72", "205.188.157.241", "205.188.157.242", "205.188.157.243", "205.188.157.244", "64.12.51.145", "64.12.51.148", "149.174.54.131")
nessus_scan_ips = ('167.88.145.12')
known_scan_ips = ('137.226.113.7')
broadcast_udp_ports = ("2223", "8082", "8600", "8097", "9034", "9035", "9036", "9500", "9999", "21327", "21328")
#======== Decodes ========
nullbyte = binascii.unhexlify('00')
twobyte = binascii.unhexlify('02')
twozero = binascii.unhexlify('0200')
fournulls = binascii.unhexlify('00000000')
fenulls = binascii.unhexlify('fe0000000000')
stream_ihs_discovery_header = binascii.unhexlify('FFFFFFFF214C5FA0')
www163com_payload = binascii.unhexlify('03') + b"www" + binascii.unhexlify('03') + b"163" + binascii.unhexlify('03') + b"com" #\x03www\x03163\x03com
a0_string = b'A' + nullbyte
zeroone = binascii.unhexlify('0001')
zerotwo = binascii.unhexlify('0002')
eight_fs = binascii.unhexlify('FFFFFFFF')
crestron_prelude = binascii.unhexlify('14000000010400030000')
ip_start_bytes = binascii.unhexlify('4500')
two_prelude_ip_start = (binascii.unhexlify('020000004500'), binascii.unhexlify('020000004502'), binascii.unhexlify('020000004510'))
quake3_disconnect = binascii.unhexlify('FFFFFFFF') + b'disconnect'
torrent_connection_id = binascii.unhexlify('0000041727101980')
ethernetip_list_identity = binascii.unhexlify('6300')
ntp_get_monlist = binascii.unhexlify('1700032a')
cacti_payload = binascii.unhexlify('000100') + b'cacti-monitoring-system' + binascii.unhexlify('00')
ubiquiti_discover = binascii.unhexlify('01000000')
#======== Regexes ========
StoraHostnameMatch = re.compile('Hostname:<([a-zA-Z0-9_\.-]+)>')
SSDPLocationMatch = re.compile('LOCATION:([a-zA-Z0-9:,/_\. -]+)\r')
SSDPServerMatch = re.compile('[Ss][Ee][Rr][Vv][Ee][Rr]:([a-zA-Z0-9:,/_\. -]+)\r')
BrotherAnnounceMatch = re.compile('IP=([0-9][0-9\.]*):5492[56];IPv6=\[([0-9a-fA-F:][0-9a-fA-F:]*)\]:5492[56],\[([0-9a-fA-F:][0-9a-fA-F:]*)\]:5492[56];NODENAME="([0-9a-zA-Z][0-9a-zA-Z]*)"')
SyslogMatch = re.compile('^<[0-9][0-9]*>[A-Z][a-z][a-z] [ 0-9][0-9] [0-2][0-9]:[0-9][0-9]:[0-9][0-9] ([^ ][^ ]*) ([^: [][^: []*)[: []') #Match 1 is short hostname, match 2 is process name that generated the message
#======== Misc ========
#See "Reference ID (refid)" in https://www.ietf.org/rfc/rfc5905.txt
known_ntp_refs = ('1PPS', 'ACTS', 'ATOM', 'BCS', 'CDMA', 'CHU', 'CTD', 'DCF', 'DCFP', 'DCFa', 'DCFp', 'DCFs', 'GAL', 'GCC', 'GNSS', 'GOES', 'GPS', 'GPS1', 'GPSD', 'GPSm', 'GPSs', 'GOOG', 'HBG', 'INIT', 'IRIG', 'JJY', 'kPPS', 'LOCL', 'LORC', 'MRS', 'MSF', 'MSL', 'NICT', 'NIST', 'NMC1', 'NMEA', 'NTS', 'OCXO', 'ONBR', 'PPS', 'PPS0', 'PPS1', 'PTB', 'PTP', 'PZF', 'RATE', 'ROA', 'SHM', 'SLK', 'SOCK', 'STEP', 'TAC', 'TDF', 'TRUE', 'UPPS', 'USIQ', 'USNO', 'UTC', 'WWV', 'WWVB', 'WWVH', 'XMIS', 'i', 'shm0', '', None)
botnet_domains = ('ddos.cat.')
botnet_hosts = ('magnesium.ddos.cat.')
#For my internal use to look for new service strings
#This payload logging is disabled when prefs['devel'] == False
#Quite likely a security risk, I don't recommend enabling it.
ServerPayloadDir = '/var/tmp/passer-server/'
ClientPayloadDir = '/var/tmp/passer-client/'
debug_known_layer_lists = False
known_layer_lists = [
['802.3', 'LLC', 'Raw'],
['802.3', 'LLC', 'SNAP', 'Raw'],
['802.3', 'LLC', 'SNAP', 'Spanning Tree Protocol', 'Raw'],
['802.3', 'LLC', 'Spanning Tree Protocol', 'Padding'],
['802.3', 'Padding'],
['cooked linux', 'IP', 'ESP'],
['cooked linux', 'IP', 'ICMP'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP', 'Raw'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP', 'Raw', 'Padding'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP', 'Raw'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'DNS'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'DNS', 'Padding'],
['cooked linux', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Raw'],
['cooked linux', 'IP', 'ICMP', 'Raw'],
['cooked linux', 'IP', 'Raw'],
# p[CookedLinux].pkttype == 'unicast' will be useful
['cooked linux', 'IP', 'TCP'],
['cooked linux', 'IP', 'TCP', 'Raw'],
['cooked linux', 'IP', 'UDP', 'DNS'],
['cooked linux', 'IP', 'UDP', 'DNS', 'Raw'],
# Pull current timestamp out of this (.ref, .orig, .recv, or .sent fields of p[NTPHeader] ; see https://tools.ietf.org/html/rfc958)
['cooked linux', 'IP', 'UDP', 'NTPHeader'],
['cooked linux', 'IP', 'UDP', 'Private (mode 7)', 'Raw'],
['cooked linux', 'IP', 'UDP', 'Raw'],
['Ethernet', '802.1Q', 'ARP', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'ESP'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'TCP'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'TCP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'BOOTP', 'DHCP options'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'DNS'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'DNS', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'ISAKMP', 'ISAKMP SA'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'NBNS query request'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'NTPHeader'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'Private (mode 7)'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'Private (mode 7)', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'RIP header', 'RIP entry'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'SNMP'],
['Ethernet', '802.1Q', 'IP', 'GRE', 'IP', 'UDP', 'TFTP opcode', 'TFTP Read Request'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP', 'Raw', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'DNS'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'ICMP', 'Raw', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'Raw', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'TCP'],
['Ethernet', '802.1Q', 'IP', 'TCP', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'TCP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'TCP', 'Raw', 'Padding'],
# Warning; Skinny layer appears to be a mis-identification
['Ethernet', '802.1Q', 'IP', 'TCP', 'Skinny', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'UDP', 'DNS'],
['Ethernet', '802.1Q', 'IP', 'UDP', 'DNS', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'UDP', 'DNS', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'UDP', 'DNS', 'Raw', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'UDP', 'Raw'],
['Ethernet', '802.1Q', 'IP', 'UDP', 'Raw', 'Padding'],
['Ethernet', '802.1Q', 'IP', 'UDP', 'SNMP'],
['Ethernet', '802.1Q', 'IP', 'VRRP', 'Padding'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Destination Unreachable', 'IPv6 in ICMPv6', 'TCP in ICMP'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Destination Unreachable', 'IPv6 in ICMPv6', 'UDP in ICMP', 'DNS'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Destination Unreachable', 'IPv6 in ICMPv6', 'UDP in ICMP', 'Raw'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Echo Reply'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Echo Request'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Advertisement'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Advertisement', 'ICMPv6 Neighbor Discovery Option - Destination Link-Layer Address'],
# Grab source mac from last option
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Solicitation', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address'],
['Ethernet', '802.1Q', 'IPv6', 'ICMPv6 Time Exceeded', 'IPv6 in ICMPv6', 'UDP in ICMP', 'DNS'],
#(raw contains E\x00\x00 8 bytes in)
['Ethernet', '802.1Q', 'IPv6', 'IP', 'GRE', 'Raw'],
['Ethernet', '802.1Q', 'IPv6', 'Padding'],
['Ethernet', '802.1Q', 'IPv6', 'Raw'],
['Ethernet', '802.1Q', 'IPv6', 'TCP'],
['Ethernet', '802.1Q', 'IPv6', 'TCP', 'Raw'],
['Ethernet', '802.1Q', 'IPv6', 'UDP', 'DNS'],
['Ethernet', '802.1Q', 'IPv6', 'UDP', 'Raw'],
['Ethernet', '802.1Q', 'LLC', 'SNAP', 'Spanning Tree Protocol', 'Raw'],
['Ethernet', '802.1Q', 'Raw'],
['Ethernet', 'ARP'],
['Ethernet', 'ARP', 'Padding'],
['Ethernet', 'EAPOL', 'Raw'],
['Ethernet', 'IP', 'AH'],
['Ethernet', 'IP', 'ICMP'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'ICMP in ICMP', 'Raw', 'Padding'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP', 'Padding'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'TCP in ICMP', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Control message'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'DNS'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'DNS', 'Padding'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'DNS', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'ESP'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'ISAKMP', 'ISAKMP SA'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'ISAKMP', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NBNS query request'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NBNS query request', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NBNS query response', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NBT Datagram Packet', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NTPHeader'],
#(happened to be malicious, and headers were misparsed))
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NTPHeader', 'NTPv4 extensions'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NTPHeader', 'Padding'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'NTPHeader', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Padding'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Private (mode 7)'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Private (mode 7)', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'RIP header'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'RIP header', 'RIP entry'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'RIP header', 'RIP entry', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Radius'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'Raw', 'Padding'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'SNMP'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'SNMP', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'TFTP opcode', 'TFTP Read Request'],
['Ethernet', 'IP', 'ICMP', 'IP in ICMP', 'UDP in ICMP', 'TFTP opcode', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'Padding'],
['Ethernet', 'IP', 'ICMP', 'Raw'],
['Ethernet', 'IP', 'ICMP', 'Raw', 'Padding'],
['Ethernet', 'IP', 'Raw'],
['Ethernet', 'IP', 'Raw', 'Padding'],
['Ethernet', 'IP', 'TCP'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'NBT Session Packet', 'SMBNegociate Protocol Request Header', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail', 'SMB Negociate Protocol Request Tail'],
['Ethernet', 'IP', 'TCP', 'Padding'],
['Ethernet', 'IP', 'TCP', 'Raw'],
['Ethernet', 'IP', 'TCP', 'Raw', 'Padding'],
['Ethernet', 'IP', 'TCP', 'Skinny', 'Raw'],
['Ethernet', 'IP', 'UDP', 'BOOTP', 'DHCP options'],
['Ethernet', 'IP', 'UDP', 'BOOTP', 'DHCP options', 'Padding'],
['Ethernet', 'IP', 'UDP', 'Control message', 'Padding'],
#DNSRR for question record, but not a formal layer, it appears
['Ethernet', 'IP', 'UDP', 'DNS'],
['Ethernet', 'IP', 'UDP', 'DNS', 'Padding'],
['Ethernet', 'IP', 'UDP', 'DNS', 'Raw'],
['Ethernet', 'IP', 'UDP', 'DNS', 'Raw', 'Padding'],
['Ethernet', 'IP', 'UDP', 'ESP'],
['Ethernet', 'IP', 'UDP', 'HSRP', 'HSRP MD5 Authentication', 'Raw'],
['Ethernet', 'IP', 'UDP', 'HSRP', 'Padding'],
['Ethernet', 'IP', 'UDP', 'ISAKMP', 'ISAKMP SA'],
['Ethernet', 'IP', 'UDP', 'ISAKMP', 'ISAKMP SA', 'Padding'],
['Ethernet', 'IP', 'UDP', 'ISAKMP', 'Raw'],
['Ethernet', 'IP', 'UDP', 'Link Local Multicast Node Resolution - Query'],
['Ethernet', 'IP', 'UDP', 'NBNS query request'],
['Ethernet', 'IP', 'UDP', 'NBNS query request', 'Padding'],
['Ethernet', 'IP', 'UDP', 'NBNS query request', 'Raw'],
['Ethernet', 'IP', 'UDP', 'NBNS query response'],
['Ethernet', 'IP', 'UDP', 'NBNS query response', 'Raw'],
['Ethernet', 'IP', 'UDP', 'NBT Datagram Packet', 'Raw'],
['Ethernet', 'IP', 'UDP', 'NTPHeader'],
['Ethernet', 'IP', 'UDP', 'NTPHeader', 'Padding'],
['Ethernet', 'IP', 'UDP', 'NTPHeader', 'NTPv4 extensions'],
['Ethernet', 'IP', 'UDP', 'NTPHeader', 'Authenticator'],
['Ethernet', 'IP', 'UDP', 'NTPHeader', 'Raw'],
['Ethernet', 'IP', 'UDP', 'Padding'],
['Ethernet', 'IP', 'UDP', 'Private (mode 7)', 'Padding'],
['Ethernet', 'IP', 'UDP', 'Private (mode 7)', 'Raw'],
['Ethernet', 'IP', 'UDP', 'Private (mode 7)', 'Raw', 'Padding'],
['Ethernet', 'IP', 'UDP', 'Radius', 'Padding'],
['Ethernet', 'IP', 'UDP', 'RIP header', 'Padding'],
['Ethernet', 'IP', 'UDP', 'RIP header', 'RIP entry'],
['Ethernet', 'IP', 'UDP', 'RIP header', 'RIP entry', 'Padding'],
['Ethernet', 'IP', 'UDP', 'RIP header', 'RIP entry', 'Raw'],
['Ethernet', 'IP', 'UDP', 'Radius'],
['Ethernet', 'IP', 'UDP', 'Raw'],
['Ethernet', 'IP', 'UDP', 'Raw', 'Padding'],
['Ethernet', 'IP', 'UDP', 'SNMP'],
['Ethernet', 'IP', 'UDP', 'SNMP', 'Padding'],
['Ethernet', 'IP', 'UDP', 'SNMP', 'Raw'],
['Ethernet', 'IP', 'UDP', 'TFTP opcode', 'Raw', 'Padding'],
['Ethernet', 'IP', 'UDP', 'TFTP opcode', 'TFTP Read Request', 'Padding'],
['Ethernet', 'IP', 'VRRP'],
['Ethernet', 'IP', 'VRRP', 'Padding'],
['Ethernet', 'IPv6', 'ICMPv6 Destination Unreachable', 'IPv6 in ICMPv6', 'TCP in ICMP'],
['Ethernet', 'IPv6', 'ICMPv6 Destination Unreachable', 'IPv6 in ICMPv6', 'UDP in ICMP', 'DNS'],
['Ethernet', 'IPv6', 'ICMPv6 Destination Unreachable', 'IPv6 in ICMPv6', 'UDP in ICMP', 'Raw'],
['Ethernet', 'IPv6', 'ICMPv6 Echo Reply'],
['Ethernet', 'IPv6', 'ICMPv6 Echo Request'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Advertisement'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Advertisement', 'ICMPv6 Neighbor Discovery Option - Destination Link-Layer Address'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Solicitation'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Solicitation', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Neighbor Solicitation', 'Raw'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Advertisement', 'ICMPv6 Neighbor Discovery Option - MTU', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Advertisement', 'ICMPv6 Neighbor Discovery Option - Prefix Information'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Advertisement', 'ICMPv6 Neighbor Discovery Option - Recursive DNS Server Option', 'ICMPv6 Neighbor Discovery Option - Prefix Information', 'ICMPv6 Neighbor Discovery Option - Route Information Option', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Advertisement', 'ICMPv6 Neighbor Discovery Option - Recursive DNS Server Option', 'ICMPv6 Neighbor Discovery Option - Prefix Information', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Advertisement', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Advertisement', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address', 'ICMPv6 Neighbor Discovery Option - MTU', 'ICMPv6 Neighbor Discovery Option - Prefix Information'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Advertisement', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address', 'ICMPv6 Neighbor Discovery Option - Prefix Information'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Solicitation'],
['Ethernet', 'IPv6', 'ICMPv6 Neighbor Discovery - Router Solicitation', 'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address'],
['Ethernet', 'IPv6', 'ICMPv6 Packet Too Big', 'IPv6 in ICMPv6', 'TCP in ICMP', 'Raw'],
['Ethernet', 'IPv6', 'ICMPv6 Time Exceeded', 'IPv6 in ICMPv6', 'UDP in ICMP', 'DNS'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Fragmentation header', 'TCP', 'Raw'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Fragmentation header', 'UDP', 'Raw'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Fragmentation header', 'UDP', 'Raw', 'Padding'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Hop-by-Hop Options Header', 'ICMPv6 Neighbor Discovery - Neighbor Advertisement', 'ICMPv6 Neighbor Discovery Option - Destination Link-Layer Address'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Hop-by-Hop Options Header', 'ICMPv6 Neighbor Discovery - Neighbor Solicitation'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Hop-by-Hop Options Header', 'MLD - Multicast Listener Done'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Hop-by-Hop Options Header', 'MLD - Multicast Listener Query'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Hop-by-Hop Options Header', 'MLD - Multicast Listener Report'],
['Ethernet', 'IPv6', 'IPv6 Extension Header - Hop-by-Hop Options Header', 'Raw'],
['Ethernet', 'IPv6', 'Padding'],
['Ethernet', 'IPv6', 'Raw'],
['Ethernet', 'IPv6', 'TCP'],
['Ethernet', 'IPv6', 'TCP', 'Raw'],
['Ethernet', 'IPv6', 'UDP', 'DHCPv6 Confirm Message', 'DHCP6 Client Identifier Option', 'DHCP6 Option Request Option', 'DHCP6 Elapsed Time Option', 'DHCP6 Identity Association for Non-temporary Addresses Option'],
['Ethernet', 'IPv6', 'UDP', 'DHCPv6 Request Message', 'DHCP6 Client Identifier Option', 'DHCP6 Option Request Option', 'DHCP6 Elapsed Time Option', 'DHCP6 Server Identifier Option', 'DHCP6 Identity Association for Non-temporary Addresses Option'],
# p[DHCP6OptClientFQDN].fqdn is an fqdn
['Ethernet', 'IPv6', 'UDP', 'DHCPv6 Solicit Message', 'DHCP6 Client Identifier Option', 'DHCP6 Option Request Option', 'DHCP6 Elapsed Time Option', 'DHCP6 Rapid Commit Option', 'DHCP6 Option - Client FQDN', 'DHCP6 Identity Association for Non-temporary Addresses Option'],
['Ethernet', 'IPv6', 'UDP', 'DHCPv6 Solicit Message', 'DHCP6 Client Identifier Option', 'DHCP6 Option Request Option', 'DHCP6 Elapsed Time Option', 'DHCP6 Identity Association for Non-temporary Addresses Option'],
['Ethernet', 'IPv6', 'UDP', 'DHCPv6 Solicit Message', 'DHCP6 Elapsed Time Option', 'DHCP6 Client Identifier Option', 'DHCP6 Identity Association for Non-temporary Addresses Option', 'DHCP6 Option - Client FQDN', 'DHCP6 Vendor Class Option', 'DHCP6 Option Request Option'],
['Ethernet', 'IPv6', 'UDP', 'DHCPv6 Solicit Message', 'DHCP6 Elapsed Time Option', 'DHCP6 Client Identifier Option', 'DHCP6 Identity Association for Non-temporary Addresses Option', 'DHCP6 Option Request Option', 'DHCP6 Option - Client FQDN'],
['Ethernet', 'IPv6', 'UDP', 'DNS'],
['Ethernet', 'IPv6', 'UDP', 'DNS', 'Raw'],
['Ethernet', 'IPv6', 'UDP', 'Link Local Multicast Node Resolution - Query'],
['Ethernet', 'IPv6', 'UDP', 'NTPHeader'],
['Ethernet', 'IPv6', 'UDP', 'Raw'],
['Ethernet', 'Raw'],
['IP', 'ICMP', 'Raw'],
['IP', 'Raw'],
['IP', 'TCP'],
['IP', 'TCP', 'Raw'],
['IP', 'UDP'],
['IP', 'UDP', 'BOOTP', 'DHCP options'],
['IP', 'UDP', 'DNS'],
['IP', 'UDP', 'DNS', 'Raw'],
['IP', 'UDP', 'ISAKMP', 'ISAKMP SA'],
['IP', 'UDP', 'NBNS query request'],
['IP', 'UDP', 'NTPHeader'],
['IP', 'UDP', 'Private (mode 7)'],
['IP', 'UDP', 'Private (mode 7)', 'Raw'],
['IP', 'UDP', 'RIP header', 'RIP entry'],
['IP', 'UDP', 'Raw'],
['IP', 'UDP', 'SNMP'],
['IP', 'UDP', 'TFTP opcode', 'TFTP Read Request'],
['Raw']
]
#Following converts the label (readable string returned by ReturnLayers) to key (the string needed to find the actual layer in a packet.
#For example layer_label_to_key['Private (mode 7)' is 'NTPPrivate'
layer_label_to_key = {'802.1Q': 'Dot1Q', '802.3': 'Dot3',
'AH': 'AH', 'ARP': 'ARP', 'Authenticator': 'NTPAuthenticator',
'BOOTP': 'BOOTP',
'Control message': 'NTPControl',
'DHCP options': 'DHCP', 'DHCP6 Client Identifier Option': 'DHCP6OptClientId', 'DHCP6 Elapsed Time Option': 'DHCP6OptElapsedTime',
'DHCP6 Identity Association for Non-temporary Addresses Option': 'DHCP6OptIA_NA', 'DHCP6 Option - Client FQDN': 'DHCP6OptClientFQDN',
'DHCP6 Option Request Option': 'DHCP6OptOptReq', 'DHCP6 Rapid Commit Option': 'DHCP6OptRapidCommit',
'DHCP6 Server Identifier Option': 'DHCP6OptServerId', 'DHCPv6 Solicit Message': 'DHCP6_Solicit', 'DHCP6 Vendor Class Option': 'DHCP6OptVendorClass',
'DHCPv6 Confirm Message': 'DHCP6_Confirm', 'DHCPv6 Request Message': 'DHCP6_Request', 'DNS': 'DNS',
'EAPOL': 'EAPOL', 'ESP': 'ESP', 'Ethernet': 'Ethernet',
'GRE': 'GRE',
'HSRP': 'HSRP', 'HSRP MD5 Authentication': 'HSRPmd5',
'ICMP': 'ICMP', 'ICMP in ICMP': 'ICMPerror', 'ICMPv6 Destination Unreachable': 'ICMPv6DestUnreach', 'ICMPv6 Echo Reply': 'ICMPv6EchoReply', 'ICMPv6 Echo Request': 'ICMPv6EchoRequest',
'ICMPv6 Neighbor Discovery - Neighbor Advertisement': 'ICMPv6ND_NA',
'ICMPv6 Neighbor Discovery - Neighbor Solicitation': 'ICMPv6ND_NS',
'ICMPv6 Neighbor Discovery - Router Advertisement': 'ICMPv6ND_RA',
'ICMPv6 Neighbor Discovery - Router Solicitation': 'ICMPv6ND_RS',
'ICMPv6 Neighbor Discovery Option - Destination Link-Layer Address': 'ICMPv6NDOptDstLLAddr',
'ICMPv6 Neighbor Discovery Option - MTU': 'ICMPv6NDOptMTU',
'ICMPv6 Neighbor Discovery Option - Prefix Information': 'ICMPv6NDOptPrefixInfo',
'ICMPv6 Neighbor Discovery Option - Recursive DNS Server Option': 'ICMPv6NDOptRDNSS',
'ICMPv6 Neighbor Discovery Option - Route Information Option': 'ICMPv6NDOptRouteInfo',
'ICMPv6 Neighbor Discovery Option - Source Link-Layer Address': 'ICMPv6NDOptSrcLLAddr',
'ICMPv6 Packet Too Big': 'ICMPv6PacketTooBig', 'ICMPv6 Time Exceeded': 'ICMPv6TimeExceeded',
'IP': 'IP', 'IP in ICMP': 'IPerror', 'IPv6': 'IPv6', 'IPv6 Extension Header - Fragmentation header': 'IPv6ExtHdrFragment',
'IPv6 Extension Header - Hop-by-Hop Options Header': 'IPv6ExtHdrHopByHop', 'IPv6 in ICMPv6': 'IPerror6',
'ISAKMP': 'ISAKMP', 'ISAKMP SA': 'ISAKMP_payload_SA',
'LLC': 'LLC', 'Link Local Multicast Node Resolution - Query': 'LLMNRQuery',
'MLD - Multicast Listener Done': 'ICMPv6MLDone', 'MLD - Multicast Listener Query': 'ICMPv6MLQuery', 'MLD - Multicast Listener Report': 'ICMPv6MLReport',
'NBNS query request': 'NBNSQueryRequest', 'NBNS query response': 'NBNSQueryResponse', 'NBT Datagram Packet': 'NBTDatagram',
'NBT Session Packet': 'NBTSession', 'NTPHeader': 'NTPHeader', 'NTPv4 extensions': 'NTPExtensions', 'Padding': 'Padding',
'Private (mode 7)': 'NTPPrivate', 'Radius': 'Radius', 'RIP entry': 'RIPEntry', 'RIP header': 'RIP', 'Raw': 'Raw',
'SMBNegociate Protocol Request Header': 'SMBNegociate_Protocol_Request_Header', 'SMB Negociate Protocol Request Tail': 'SMBNegociate_Protocol_Request_Tail', 'SNAP': 'SNAP', 'SNMP': 'SNMP',
'Skinny': 'Skinny', 'Spanning Tree Protocol': 'STP',
'TCP': 'TCP', 'TCP in ICMP': 'TCPError', 'TFTP opcode': 'TFTP', 'TFTP Read Request': 'TFTP_RRQ',
'UDP': 'UDP', 'UDP in ICMP': 'UDPerror',
'VRRP': 'VRRP',
'cooked linux': 'CookedLinux'}
#===============================================================================================
phys_layers = set(['802.1Q', 'Ethernet', 'cooked linux'])
addr_layers = set(['IP', 'IPv6', 'IPv6 Extension Header - Fragmentation header', 'IPv6 Extension Header - Hop-by-Hop Options Header'])
task_layers = set(['BOOTP', 'Control message', 'DHCP options', 'DNS', 'GRE', 'HSRP', 'HSRP MD5 Authentication', 'ICMP', 'ICMPv6 Destination Unreachable', 'ICMPv6 Neighbor Discovery - Neighbor Solicitation', 'IP', 'IP in ICMP', 'ICMP in ICMP', 'ICMPv6 Packet Too Big', 'IPv6 in ICMPv6', 'ISAKMP', 'ISAKMP SA', 'NBNS query request', 'NBNS query response', 'NBT Datagram Packet', 'NTPHeader', 'Private (mode 7)', 'Radius', 'RIP header', 'RIP entry', 'Skinny', 'TCP', 'TCP in ICMP', 'TFTP opcode', 'TFTP Read Request', 'UDP', 'UDP in ICMP', 'SNMP', 'VRRP'])
trailer_layers = set(['Raw', 'Padding'])
special_layers = set(['802.1Q', '802.3', 'ARP', 'EAPOL', 'Ethernet', 'LLC', 'Padding', 'Raw', 'SNAP', 'Spanning Tree Protocol'])
meta = {} #Empty dictionary - not used in this version of passer, but will be used in the next. Fills the open space in the ShowPacket function call.
passerVersion = "2.90"
#======== Functions ========
def layer_slice(layer_l):
"""Break a list of layers into physical, address, task, trailer, special and unknown components. Either the first 4 will be lists
which, when concatenated will return the original list (and unknown will be []), special will contain a the original list (and the
rest will be []), or the first 5 will be [] and the original list will be in unknown."""
phys_l = []
addr_l = []
task_l = []
trailer_l = []
special_l = []
unknown_l = []
split_ok = True
if set(layer_l).issubset(special_layers):
return [], [], [], [], layer_l, []
addr_i = 0
while addr_i < len(layer_l) and layer_l[addr_i] not in addr_layers:
addr_i += 1
if addr_i == len(layer_l):
#No IP layer was found
split_ok = False
unknown_l = layer_l
else:
#IP layer was found at layer_l[addr_i]
phys_l = layer_l[0:addr_i]
addr_l = [layer_l[addr_i]]
task_l = layer_l[addr_i+1:]
while task_l and task_l[0] in addr_layers:
#We have an additional address layer at the beginning of task - append it to addr_l
addr_l.append(task_l[0])
task_l = task_l[1:]
while task_l and task_l[-1] in trailer_layers:
#Move this junk layer to the beginning of trailer and strip from task_l.
trailer_l.insert(0, task_l[-1])
task_l = task_l[0:-1]
split_ok = set(phys_l).issubset(phys_layers) and set(addr_l).issubset(addr_layers) and set(task_l).issubset(task_layers) and set(trailer_l).issubset(trailer_layers)
if split_ok:
return (phys_l, addr_l, task_l, trailer_l, [], [])
else:
return ([], [], [], [], [], layer_l)
#for X in known_layer_lists:
# p, a, t, z, s, u = layer_slice(X)
# if u:
# print(str(u))
# elif s:
# print("Special: " + str(s))
#quit()
def signal_handler(sig, frame):
"""_Should_ catch ctrl-C and allow graceful exit with a reporting feature on the way out.
Unfortunately, the handler is executed in the main python thread, and most of the script
is running inside sniff. May have to set a flag here and exit sniff if flag set?"""
#https://docs.python.org/3/library/signal.html
#https://www.cybrary.it/0p3n/sniffing-inside-thread-scapy-python/ ?
#For the moment we are _not_ stopping passer on ctrl-c.
global must_stop
if sig == signal.SIGINT:
#sys.stderr.write("Ctrl-C pressed, exiting in a moment.\n")
sys.stderr.write("Ctrl-C pressed, generating summary lines.\n")
generate_summary_lines()
must_stop = True
#sys.exit(1)
else:
sys.stderr.write("Unhandled signal type: " + str(sig) + "\n")
def exit_now():
"""Returns true if exit was requested. Checks global must_stop, which is set in signal_handler."""
sys.stderr.write("exit_now called")
return must_stop
def exit_now_packet_param(one_packet_param):
"""Returns true if exit was requested. Checks global must_stop, which is set in signal_handler. Packet handed to us is ignored."""
sys.stderr.write("exit_now_packet_param called")
return must_stop
def generate_summary_lines():
"""Print any remaining lines, generally ones that are stored but not a direct result of a packet."""
#Because this is called with no apparent way to hand down params other than the raw packet, we have to pull these two from main by hand.
prefs = cl_args
dests = destinations
#These come first because they may add 'scan' to the suspicious characteristics list for one or more IPs, which will be printed by the next loop.
#FIXME
if "ClosedUDPPortsReceived" in processpacket.__dict__: #Cross-function variable
for an_ip in sorted(processpacket.ClosedUDPPortsReceived):
if len(processpacket.ClosedUDPPortsReceived[an_ip]) >= min_closed_ports_for_scanner:
ReportId("IP", an_ip, "IP", "suspicious", 'Scanned ' + str(len(processpacket.ClosedUDPPortsReceived[an_ip])) + ' UDP closed ports.', (['scan', ]), prefs, dests)
#FIXME
#if "ClosedTCPPortsReceived" in processpacket.__dict__: #Cross-function variable
# for an_ip in sorted(processpacket.ClosedTCPPortsReceived):
# if len(processpacket.ClosedTCPPortsReceived[an_ip]) >= min_closed_ports_for_scanner:
# ReportId("IP", an_ip, "IP", "suspicious", 'Scanned ' + str(len(processpacket.ClosedTCPPortsReceived[an_ip])) + ' TCP closed ports.', (['scan', ]), prefs, dests)
for an_ip in sorted(ReportId.NewSuspiciousIPs): #Cross-function variable
ReportId("IP", an_ip, "IP", "suspicious", 'Warnings:' + ':'.join(ReportId.NewSuspiciousIPs[an_ip]), ([]), prefs, dests) #Cross-function variable
return
def remove_control_characters(s):
"""Strip out any control characters in the string."""
return "".join(ch for ch in unicode(s) if unicodedata.category(ch)[0] != "C")
def packet_timestamps(pt_p):
"""This returns the timestamp in (floating point) seconds-since-the-epoch and (string) UTC human readable formats."""
#Add , prefs, dests to params if any debug_out statements needed
p_timestamp = pt_p.time #packet.time can be read from an existing packet or written to a created packet.
p_seconds_since_epoch = float(time.mktime(datetime.fromtimestamp(p_timestamp).timetuple()))
#debug_out(str(p_seconds_since_epoch), prefs, dests)
p_human_readable_utc = datetime.fromtimestamp(p_seconds_since_epoch, tz=pytz.utc).strftime('%Y-%m-%d %H:%M:%S') #This shows UTC
#debug_out(p_human_readable, prefs, dests)
#Not used at the moment.
#p_human_readable_localtz = datetime.fromtimestamp(p_timestamp).strftime('%Y-%m-%d %H:%M:%S')
#debug_out(p_human_readable_localtz, prefs, dests) #This is the human readable timestamp in local time
return (p_seconds_since_epoch, p_human_readable_utc)
##FIXME - remove this function
#def LogNewPayload(PayloadDir, PayloadFile, Payload):
# """Saves the payload from an ack packet to a file named after the server or client port involved."""
#
# #Better yet, wrpcap("/path/to/pcap", list_of_packets)
#
# if prefs['devel']:
# if os.path.isdir(PayloadDir):
# if not Payload == b'None':
# pfile = open(PayloadFile, 'a')
# pfile.write(Payload)
# pfile.close()
def write_object(filename, generic_object):
"""Write out an object to a file."""
try:
with open(filename, "wb") as write_h:
write_h.write(generic_object.encode('utf-8'))
except:
sys.stderr.write("Problem writing " + filename + ", skipping.")
raise
return
#def mac_of_ipaddr(ipv6addr):
# """For a supplied IPv6 address in EUI-64 format, return the mac address of the system that's behind it. For an address not in that format, return ''."""
#May be able to do this with just a dict.
#def bot_warnings(bw_ip, bw_proto, bw_port):
# """For the given IP, TCP/UDP, port trio, return any additional warnings if that machine may be part of a bot."""
#
#
# bw_warnings = []
#
#
# orig_text = ''
#
# return
def ReportId(Type, CompressedIPAddr, Proto, State, Description, Warnings, prefs, dests):
"""Print and log a new piece of network information."""
#Can't use : for separator, IPv6, similarly '.' for ipv4
#Can't use "/" because of filesystem
#Don't want to use space because of filesystem
# Type, IPAddr, Proto State Optional description (may be empty)
# 'IP', IPaddr, 'IP', dead or live, p0f OS description
# 'MA', IPaddr, 'Ethernet', MacAddr, ManufDescription
# 'TC', IPaddr, 'TCP_'Port, closed or open, client description
# 'TS', IPaddr, 'TCP_'Port, closed or listening, server description
# 'UC', IPaddr, 'UDP_'Port, open or closed, udp client port description
# 'US', IPaddr, 'UDP_'Port, open or closed, udp server port description
# 'DN', IPaddr, 'A' or 'PTR', hostname, possible extra info
# 'RO', IPaddr, 'TTLEx', router, possible extra info
# 'PC', IPaddr, 'PROTO_'PNum open, protocol name
# 'PS', IPaddr, 'PROTO_'PNum open, protocol name
#Persistent data structures - these are loaded at first entry into the function and persist for the life of the process.
if "GenDesc" not in ReportId.__dict__:
#Dictionary of Dictionaries of sets, replaces the specific dictionaries. First key is 2 letter record type, second key is IP address, final value (a set) is what we have seen for that record type and IP.
ReportId.GenDesc = {'DN': {}, 'IP': {}, 'MA': {}, 'NA': {}, 'PC': {}, 'PS': {}, 'RO': {}, 'TC': {}, 'TS': {}, 'UC': {}, 'US': {}}
#Dictionary of lists. Key is IP address, value is list which contains all this IP address' suspicious characteristics.
if "SuspiciousIPs" not in ReportId.__dict__:
ReportId.SuspiciousIPs = load_json_from_file(suspicious_ips_file)
if ReportId.SuspiciousIPs:
for one_trusted in __main__.TrustedIPs:
if one_trusted in ReportId.SuspiciousIPs:
del ReportId.SuspiciousIPs[one_trusted]
else:
debug_out("Problem reading/parsing " + suspicious_ips_file + ", skipping.", prefs, dests)
ReportId.SuspiciousIPs = {}
#Just like above, but _only_ the entries added during this session; used for printing with ctrl-c or at the end.
if "NewSuspiciousIPs" not in ReportId.__dict__:
ReportId.NewSuspiciousIPs = {}
if "MacAddr" not in ReportId.__dict__:
ReportId.MacAddr = {} #String dictionary: For a given IP (key), what is its mac (value)?
if "EtherManuf" not in ReportId.__dict__:
ReportId.EtherManuf = {} #String dictionary: for a given key of the first three uppercase octets of a mac address ("00:01:0F"), who made this card?
ReportId.EtherManuf = MacDataDict(['/usr/share/ettercap/etter.finger.mac', '/opt/local/share/ettercap/etter.finger.mac', '/usr/share/nmap/nmap-mac-prefixes', '/opt/local/share/nmap/nmap-mac-prefixes', '/usr/share/wireshark/manuf', '/opt/local/share/wireshark/manuf', '/usr/share/ethereal/manuf', '/usr/share/arp-scan/ieee-oui.txt', '/opt/local/share/arp-scan/ieee-oui.txt'], prefs, dests)
if len(ReportId.EtherManuf) == 0:
debug_out("None of the default mac address listings found. Please install ettercap, nmap, wireshark, and/or arp-scan.", cl_args, destinations)
else:
debug_out(str(len(ReportId.EtherManuf)) + " mac prefixes loaded.", cl_args, destinations)
if "log_h" not in ReportId.__dict__:
ReportId.log_h = None
if prefs['log']:
try:
ReportId.log_h = open(prefs['log'], 'a')
except:
debug_out("Unable to append to " + prefs['log'] + ", no logging will be done.", cl_args, destinations)
IPAddr = explode_ip(CompressedIPAddr, prefs, dests)
Location = IPAddr + "," + Proto
Description = Description.replace('\n', '').replace('\r', '').replace(',', ' ')
if Warnings: #Non-empty set of strings
if Description:
Description += ' '
Description += 'Warnings:' + ':'.join(Warnings)
if IPAddr in __main__.TrustedIPs:
if Warnings == ['plaintext'] and Proto == 'UDP_514':
pass
elif Warnings == ['portpolicyviolation', ]:
debug_out("Attempt to add trusted IP " + IPAddr + " to SuspiciousIPs because of portpolicyviolation.", prefs, dests)
else:
debug_out("Attempt to add trusted IP " + IPAddr + " to SuspiciousIPs.", prefs, dests)
debug_out("Attempt to add trusted IP " + IPAddr + " to SuspiciousIPs." + '|' + str(Type) + '|' + str(Proto) + '|' + str(State) + '|' + str(Description) + '|' + str(Warnings), prefs, dests)
#quit()
elif 'spoofed' not in Warnings:
#We have to add this warning to ReportId.SuspiciousIPs, the master list of _all_ warnings for all IPs....
if IPAddr not in ReportId.SuspiciousIPs:
ReportId.SuspiciousIPs[IPAddr] = []
for one_warning in Warnings:
if one_warning not in ReportId.SuspiciousIPs[IPAddr]:
ReportId.SuspiciousIPs[IPAddr].append(one_warning)
#....and we have to add it to ReportId.NewSuspiciousIPs, which only holds the new things we've discovered this session.
if IPAddr not in ReportId.NewSuspiciousIPs:
ReportId.NewSuspiciousIPs[IPAddr] = []
for one_warning in Warnings:
if one_warning not in ReportId.NewSuspiciousIPs[IPAddr]:
ReportId.NewSuspiciousIPs[IPAddr].append(one_warning)
ShouldPrint = True
if Type not in ReportId.GenDesc:
ReportId.GenDesc[Type] = {}
if Type in ("TS", "US"):
if Location not in ReportId.GenDesc[Type]:
ReportId.GenDesc[Type][Location] = set()
if State + ',' + Description in ReportId.GenDesc[Type][Location]:
ShouldPrint = False #Don't print if we've already printed it with this state + description
else:
ReportId.GenDesc[Type][Location].add(State + ',' + Description)
elif Type in ("TC", "UC"):
if Location not in ReportId.GenDesc[Type]:
ReportId.GenDesc[Type][Location] = set()
if State + ',' + Description in ReportId.GenDesc[Type][Location]:
ShouldPrint = False #Don't print if we've already printed it with this state + description
else:
ReportId.GenDesc[Type][Location].add(State + ',' + Description)
elif Type in ("IP", "NA", "PC", "PS"):
if Location not in ReportId.GenDesc[Type]:
ReportId.GenDesc[Type][Location] = set()
if State + ',' + Description in ReportId.GenDesc[Type][Location]:
ShouldPrint = False #Don't print if we've already printed it with this state + description
else:
ReportId.GenDesc[Type][Location].add(State + ',' + Description)
elif Type == "DN":
#Note that State will be the Hostname, and Proto is the Record type
if Location not in ReportId.GenDesc[Type]:
ReportId.GenDesc[Type][Location] = set()
#FIXME - perhaps description could indicate low TTL? <300? <150?
if Proto in ('A', 'AAAA', 'CNAME', 'PTR') and State == '':
ShouldPrint = False
elif State == '' and IPAddr in ('::', '0000:0000:0000:0000:0000:0000:0000:0000'): #Not sure if this should be limited to hostnames with and Proto in ('A', 'AAAA', 'CNAME', 'PTR')
ShouldPrint = False
elif State + ',' + Description in ReportId.GenDesc[Type][Location]:
ShouldPrint = False
else:
ReportId.GenDesc[Type][Location].add(State + ',' + Description) #Add this Hostname to the list
elif Type == "RO":
if Description == '':
description_string = Proto #This holds the type of packet that causes us to believe it's a router, like "RouterAdv"
else:
description_string = Description
if IPAddr not in ReportId.GenDesc[Type]: #If we ever need to test if an IP is a router, use IPAddr in ReportId.GenDesc['RO']
ReportId.GenDesc[Type][IPAddr] = set()
if description_string in ReportId.GenDesc[Type][IPAddr]:
ShouldPrint = False #Don't print if we've already printed it with this description
else:
ReportId.GenDesc[Type][IPAddr].add(description_string)
elif Type == "MA":
State = State.upper()
if IPAddr in ('', '::', '0000:0000:0000:0000:0000:0000:0000:0000'):
ShouldPrint = False #Not registering :: as a null IP address
elif (IPAddr in ReportId.MacAddr) and (ReportId.MacAddr[IPAddr] == State):
ShouldPrint = False #Already known, no need to reprint
else:
ReportId.MacAddr[IPAddr] = State
if State[:8] in ReportId.EtherManuf:
Description = ReportId.EtherManuf[State[:8]].replace(',', ' ')
if ShouldPrint:
try:
OutString = Type + "," + IPAddr + "," + Proto + "," + State + "," + Description
if prefs['timestamp']:
OutString += ',' + str(processpacket.current_stamp) + ',' + processpacket.current_string
#else:
# OutString += ',,' #Future: When we're not showing the timestamps, still create the columns so logs line up
print(OutString)
if ReportId.log_h is not None:
ReportId.log_h.write(OutString + '\n')
ReportId.log_h.flush()
except UnicodeDecodeError:
pass
def ReportAll(output_tuple_set, prefs, dests):
"""Wrapper function for original passer script used to accept a set of tuples generated by {LAYER}_extract functions and send them to ReportId.
Example call: ReportAll(ARP_extract(p, meta)) ."""
for a_tuple in output_tuple_set:
ReportId(a_tuple[Type_e], a_tuple[IPAddr_e], a_tuple[Proto_e], a_tuple[State_e], a_tuple[Description_e], a_tuple[Warnings_e], prefs, dests)
def process_udp_ports(meta, p, prefs, dests):
"""Process a UDP packet (ipv4 or ipv6)."""
#Persistent variables
#String dictionary: What server is on this "IP,Proto_Port"? Locally found strings.
if "UDPManualServerDescription" not in process_udp_ports.__dict__:
process_udp_ports.UDPManualServerDescription = {}
#Transition variables
sIP = meta['sIP']
dIP = meta['dIP']
sport = meta['sport']
dport = meta['dport']
SrcService = meta['SrcService']
DstService = meta['DstService']
SrcClient = meta['SrcClient']
FromPort = sIP + ",UDP_" + sport
if p.getlayer(Raw):
Payload = p.getlayer(Raw).load
else:
Payload = b""
#Persistent variables
if "SipPhoneMatch" not in process_udp_ports.__dict__:
process_udp_ports.SipPhoneMatch = re.compile('Contact: ([0-9-]+) <sip')
ReportAll(UDP_extract(p, meta, prefs, dests), prefs, dests)
if dport in PolicyViolationUDPPorts:
ReportId("UC", sIP, "UDP_" + dport, "open", '', (['portpolicyviolation', ]), prefs, dests)
if sport in PolicyViolationUDPPorts:
ReportId("US", sIP, "UDP_" + sport, "open", '', (['portpolicyviolation', ]), prefs, dests)
if dport == "0":
ReportId("UC", sIP, "UDP_" + dport, "open", 'Invalid destination port 0', (['noncompliant', ]), prefs, dests)
if sport == "0":
ReportId("US", sIP, "UDP_" + sport, "open", 'Invalid source port 0', (['noncompliant', ]), prefs, dests)
process_udp_ports.UDPManualServerDescription[FromPort] = "Invalid source port 0"
if dport == "0" and Payload == cacti_payload:
ReportId("UC", sIP, "UDP_" + dport, "open", 'Cacti monitor', (['noncompliant', ]), prefs, dests)
### IP/UDP/qualys
elif sIP in qualys_scan_ips and dport in qualys_udp_scan_port_names and Payload == nullbyte:
ReportId("UC", sIP, "UDP_" + dport, "open", qualys_udp_scan_port_names[dport] + "/clientscanner qualys", (['scan', ]), prefs, dests)
elif sIP in qualys_scan_ips:
ReportId("UC", sIP, "UDP_" + dport, "open", "udp" + dport + "/clientscanner qualys unregistered port", (['scan', ]), prefs, dests)
elif sIP.startswith(qualys_subnet_starts) and dport in qualys_udp_scan_port_names and Payload == nullbyte:
ReportId("UC", sIP, "UDP_" + dport, "open", qualys_udp_scan_port_names[dport] + "/clientscanner qualys unregistered scanner IP address", (['scan', ]), prefs, dests)
elif sIP.startswith(qualys_subnet_starts):
ReportId("UC", sIP, "UDP_" + dport, "open", "udp" + dport + "/clientscanner qualys unregistered scanner IP address and unregistered port", (['scan', ]), prefs, dests)
#__ haslayer(DNS)
### IP/UDP/Multicast DNS, placed next to normal dns, out of numerical order
### IP/UDP/DNS=53
elif p.haslayer(DNS) and (isinstance(p[DNS], DNS)):
ReportAll(DNS_extract(p, meta, prefs, dests), prefs, dests)
#FIXME - copy over to mdns and ipv6
elif (sport == "5353") and (dport == "5353") and not p.haslayer(DNS): #No dns layer for some reason
UnhandledPacket(p, prefs, dests)
elif (dport == "5353") and ((meta['ttl'] == 1) or (meta['ttl'] == 2) or (meta['ttl'] == 255)): #2 may not be rfc-legal, but I'm seeing it on the wire.
if dIP in ("224.0.0.251", "ff02::fb", "ff02:0000:0000:0000:0000:0000:0000:00fb"):
ReportId("UC", sIP, "UDP_" + dport, "open", "mdns/broadcastclient", ([]), prefs, dests)
else:
ReportId("UC", sIP, "UDP_" + dport, "open", "mdns/client", ([]), prefs, dests)
#FIXME - add check for "if isinstance(p[DNS], whatevertype): here and at all p[] accesses.
elif (sport != "53") and (dport == "53") and not p.haslayer(DNS): #non-dns coming in from what looks like a DNS client.
UnhandledPacket(p, prefs, dests)
### IP/UDPv4/bootp_dhcp=67
elif meta['ip_class'] == '4' and (sport == "67") and (dport == "68"): #Bootp/dhcp server talking to client
ReportId("US", sIP, "UDP_" + sport, "open", "bootpordhcp/server", ([]), prefs, dests)
process_udp_ports.UDPManualServerDescription[FromPort] = "bootpordhcp/server"
elif meta['ip_class'] == '4' and (sport == "68") and (dport == "67"): #Bootp/dhcp client talking to server
#FIXME - pull ID field out as a name to report
if sIP != "0.0.0.0": #If the client is simply renewing an IP, remember it.
ReportId("UC", sIP, "UDP_" + dport, "open", "bootpordhcp/client", ([]), prefs, dests)
for one_opt in p[DHCP].options: #Can't directly access p.haslayer(DHCPOptions) because it's a list of tuples. https://stackoverflow.com/questions/22152130/how-can-i-get-option-number-from-an-dhcp-header-in-scapy
if one_opt[0] == 'hostname':
ReportId("NA", sIP, "DHCP", one_opt[1].decode('UTF-8'), "dhcp", ([]), prefs, dests)