-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecon_iot_scada.py
More file actions
executable file
·5944 lines (5466 loc) · 268 KB
/
Copy pathrecon_iot_scada.py
File metadata and controls
executable file
·5944 lines (5466 loc) · 268 KB
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/env python3
"""
╔══════════════════════════════════════════════════════════════════════════════╗
║ LAN Recon — Ultimate IoT / SCADA / Camera Device Discovery ║
║ Identifies industrial, IoT, and IP camera devices on LAN ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ Usage : sudo python3 recon_iot_scada.py <network/cidr> ║
║ Deps : pip install python-nmap scapy ║
╚══════════════════════════════════════════════════════════════════════════════╝
"""
import sys
import os
import re
import socket
import struct
import time
import shutil
import subprocess
import ipaddress
import argparse
import threading
import base64
import atexit
import signal
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor, as_completed
# ── Dependency checks ─────────────────────────────────────────────────────────
try:
import nmap
except ImportError:
print("[!] python-nmap not found. Run: pip install python-nmap")
sys.exit(1)
# Script's own directory — used for output file placement
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
try:
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from scapy.all import ARP, Ether, srp, conf as _scapy_conf
_scapy_conf.verb = 0
SCAPY_AVAILABLE = True
except Exception:
# Catches ImportError (not installed) and PermissionError / OSError
# (scapy tries to open raw netlink sockets at import time — fails rootless)
SCAPY_AVAILABLE = False
print("[~] scapy unavailable — will use nmap ping sweep instead.")
# ─────────────────────────────────────────────────────────────────────────────
# PORT DEFINITIONS
# ─────────────────────────────────────────────────────────────────────────────
# SCADA / ICS
SCADA_TCP_PORTS = [
89, # Tridium legacy
102, # Siemens S7 / TPKT / IEC 61850 MMS
502, # Modbus/TCP
1911, # Tridium Niagara Fox — building automation (HVAC, access, lighting)
1962, # PCWorx (Phoenix Contact)
2404, # IEC 60870-5-104
4840, # OPC UA
4000, # Emerson DeltaV
4001, # Emerson DeltaV
4911, # Tridium Niagara Fox SSL
5007, # Mitsubishi MELSEC-Q
9600, # OMRON FINS
18245, # GE SRTP
20000, # DNP3
20547, # ProConOS (Phoenix Contact)
44818, # EtherNet/IP (CIP)
2455, # WAGO
34980, # EtherNet/IP explicit messaging
]
SCADA_UDP_PORTS = [
47808, # BACnet/IP
2222, # EtherNet/IP I/O
34962, # PROFINET RT (cyclic)
34963, # PROFINET RT (acyclic)
34964, # PROFINET DCP
9600, # OMRON FINS UDP
]
# IoT
IOT_TCP_PORTS = [
21, # FTP
22, # SSH
23, # Telnet
80, # HTTP admin
139, # NetBIOS Session Service (SMB legacy)
443, # HTTPS admin
445, # SMB / Windows file sharing
2375, # Docker daemon API (unauthenticated = instant host root)
3389, # RDP (BlueKeep / Windows remote desktop)
1883, # MQTT
4786, # Cisco Smart Install (CSI) — unauthenticated config r/w, firmware replace
5222, # XMPP
2049, # NFS — unauthenticated share mount
5432, # PostgreSQL — default/no-auth database
5672, # AMQP
6379, # Redis — unauthenticated / default no-password
7001, # Oracle WebLogic — CVE-2019-2725 pre-auth RCE (T3/IIOP deserialization)
8009, # Apache Tomcat AJP — CVE-2020-1938 Ghostcat file read/inclusion
6668, # Tuya local control (TCP)
7547, # TR-069 (CWMP)
8080, # HTTP-Alt
8291, # MikroTik Winbox — CVE-2018-14847 unauthenticated credential extraction
8443, # HTTPS-Alt
8728, # MikroTik API (unencrypted)
8883, # MQTT/SSL
8888, # HTTP admin alt
9000, # HTTP misc
]
IOT_UDP_PORTS = [
# NOTE: SNMP (161) is NOT here — nmap UDP scanning is too slow for it.
# We probe port 161 directly in run_probes() instead (fast UDP send/recv).
623, # IPMI / RMCP — BMC out-of-band management (servers, switches, routers)
1900, # UPnP / SSDP
3702, # WS-Discovery (ONVIF camera self-announcement)
5353, # mDNS / Bonjour
5683, # CoAP
5684, # CoAP/DTLS
6666, # Tuya local discovery
6667, # Tuya local discovery (encrypted)
37020, # Hikvision SADP — device discovery / serial / firmware / SDK port
]
# IP Camera / CCTV
CAM_TCP_PORTS = [
554, # RTSP
8554, # RTSP alt
1935, # RTMP
37777, # Dahua TCP
34567, # Dahua UDP TCP alt
37778, # Dahua RTSP
8899, # Swann / Zmodo
9527, # Various DVR
34599, # Dahua mobile
5000, # Hikvision SDK
8000, # Hikvision SDK alt
]
ALL_TCP_PORTS = sorted(set(SCADA_TCP_PORTS + IOT_TCP_PORTS + CAM_TCP_PORTS))
ALL_UDP_PORTS = sorted(set(SCADA_UDP_PORTS + IOT_UDP_PORTS))
SCADA_PORTS_SET = set(SCADA_TCP_PORTS + SCADA_UDP_PORTS)
IOT_PORTS_SET = set(IOT_TCP_PORTS + IOT_UDP_PORTS)
CAM_PORTS_SET = set(CAM_TCP_PORTS)
# Human-readable protocol name per port
PORT_LABEL = {
# SCADA
89: 'ATISSR',
102: 'S7/TPKT (Siemens)',
502: 'Modbus/TCP',
1962: 'PCWorx (Phoenix Contact)',
2404: 'IEC 60870-5-104',
4840: 'OPC UA',
4000: 'Emerson DeltaV',
4001: 'Emerson DeltaV',
5007: 'Mitsubishi MELSEC-Q',
9600: 'OMRON FINS',
18245: 'GE SRTP',
20000: 'DNP3',
20547: 'ProConOS',
44818: 'EtherNet/IP (CIP)',
2455: 'WAGO',
34980: 'EtherNet/IP explicit',
47808: 'BACnet/IP',
2222: 'EtherNet/IP I/O',
34962: 'PROFINET RT cyclic',
34963: 'PROFINET RT acyclic',
34964: 'PROFINET DCP',
# IoT
21: 'FTP',
22: 'SSH',
23: 'Telnet',
80: 'HTTP',
139: 'NetBIOS (SMB)',
443: 'HTTPS',
445: 'SMB / CIFS',
2049: 'NFS',
1883: 'MQTT',
5222: 'XMPP',
5353: 'mDNS',
5672: 'AMQP',
5683: 'CoAP',
5684: 'CoAP/DTLS',
7547: 'TR-069 (CWMP)',
8080: 'HTTP-Alt',
8443: 'HTTPS-Alt',
8883: 'MQTT/SSL',
8888: 'HTTP Admin',
161: 'SNMP',
1900: 'UPnP/SSDP',
3702: 'WS-Discovery',
6666: 'Tuya local discovery',
6667: 'Tuya local discovery (enc)',
6668: 'Tuya local control',
9000: 'HTTP misc',
5432: 'PostgreSQL',
6379: 'Redis',
7001: 'Oracle WebLogic',
8009: 'Tomcat AJP (Ghostcat)',
# Camera
554: 'RTSP',
8554: 'RTSP-Alt',
1935: 'RTMP',
37777: 'Dahua TCP',
34567: 'DVR/NVR TCP',
37778: 'Dahua RTSP',
8899: 'DVR (Swann/Zmodo)',
9527: 'DVR misc',
34599: 'Dahua mobile',
5000: 'Hikvision SDK',
8000: 'Hikvision SDK',
34568: 'Dahua UDP search',
37020: 'Hikvision discovery',
4786: 'Cisco Smart Install',
8291: 'MikroTik Winbox',
8728: 'MikroTik API',
}
PROBE_TIMEOUT = 3
VERSION = "1.0.0"
# ─────────────────────────────────────────────────────────────────────────────
# OUI DATABASE
# ─────────────────────────────────────────────────────────────────────────────
# Subset focused on SCADA, IoT, and camera vendors.
# Keys = uppercase hex, no separators, first 3 bytes (6 chars).
BUILTIN_OUI = {
# Siemens
'001A4E': 'Siemens AG',
'0019A7': 'Siemens AG',
'001CEF': 'Siemens AG',
'000E8C': 'Siemens AG',
# Rockwell Automation / Allen-Bradley
'000BC5': 'Rockwell Automation',
'001D9C': 'Rockwell Automation',
'0050BF': 'Rockwell Automation',
'000E8F': 'Rockwell Automation',
# Schneider Electric
'0080F4': 'Schneider Electric',
'00A070': 'Schneider Electric',
'0000ED': 'Schneider Electric',
'001EBD': 'Schneider Electric',
# Honeywell
'000CF8': 'Honeywell',
'00808C': 'Honeywell',
# ABB
'000A14': 'ABB',
'00104A': 'ABB',
# GE / General Electric
'001CF4': 'GE Automation',
'0001F4': 'GE Fanuc',
'0060E9': 'GE Industrial',
# Mitsubishi Electric
'00E0E9': 'Mitsubishi Electric',
'00B0C7': 'Mitsubishi Electric',
# Omron
'00000A': 'OMRON',
'00EEBD': 'OMRON',
'000225': 'OMRON',
# Phoenix Contact
'000C29': 'Phoenix Contact',
'00A05E': 'Phoenix Contact',
# Beckhoff
'001B45': 'Beckhoff Automation',
# Moxa (serial/ethernet gateways, common in SCADA)
'0090E8': 'Moxa Technologies',
'00D09E': 'Moxa Technologies',
'00C0A7': 'Moxa Technologies',
# Emerson / Fisher-Rosemount
'000A3A': 'Emerson Electric',
'001275': 'Emerson Electric',
# Yokogawa
'002054': 'Yokogawa Electric',
'000B28': 'Yokogawa Electric',
# Advantech
'0008A1': 'Advantech',
'002590': 'Advantech',
# Lantronix (serial device servers)
'0080A3': 'Lantronix',
'00C012': 'Lantronix',
# WAGO
'000A97': 'WAGO Kontakttechnik',
# Pilz
'001A86': 'Pilz GmbH',
# TP-Link
'14CC20': 'TP-Link Technologies',
'50C7BF': 'TP-Link Technologies',
'A0F3C1': 'TP-Link Technologies',
'B0487A': 'TP-Link Technologies',
'C46E1F': 'TP-Link Technologies',
'54A74E': 'TP-Link Technologies',
'F81A67': 'TP-Link Technologies',
'300514': 'TP-Link Technologies',
# D-Link
'00265A': 'D-Link',
'1CBDB9': 'D-Link',
'9094E4': 'D-Link',
# Netgear
'00146C': 'Netgear',
'28C68E': 'Netgear',
'20E52A': 'Netgear',
# Ubiquiti
'0418D6': 'Ubiquiti Networks',
'24A43C': 'Ubiquiti Networks',
'DC9FDB': 'Ubiquiti Networks',
'FC:EC:DA': 'Ubiquiti Networks',
# Raspberry Pi
'B827EB': 'Raspberry Pi Foundation',
'DCA632': 'Raspberry Pi Foundation',
'E45F01': 'Raspberry Pi Foundation',
'2CCF67': 'Raspberry Pi Foundation',
# Espressif (ESP8266 / ESP32 IoT modules)
'ECFABC': 'Espressif Inc (ESP)',
'24B2DE': 'Espressif Inc (ESP)',
'84F3EB': 'Espressif Inc (ESP)',
'A4CF12': 'Espressif Inc (ESP)',
'30AEA4': 'Espressif Inc (ESP)',
'246F28': 'Espressif Inc (ESP)',
'7CDFA1': 'Espressif Inc (ESP)',
'40F520': 'Espressif Inc (ESP)',
'18FE34': 'Espressif Inc (ESP)',
# Philips Hue / Signify
'001788': 'Signify / Philips Hue',
'EC2D9D': 'Signify / Philips Hue',
# Belkin / Wemo
'94103E': 'Belkin International',
'B4750E': 'Belkin International',
'EC1A59': 'Belkin International',
# Samsung (smart TVs, home devices)
'002339': 'Samsung Electronics',
'0021D1': 'Samsung Electronics',
'8C7712': 'Samsung Electronics',
'5CF7E6': 'Samsung Electronics',
# LG Electronics
'000E62': 'LG Electronics',
'A8B860': 'LG Electronics',
# Hikvision (IP cameras / DVR / NVR)
'C05627': 'Hikvision Digital Technology',
'4C1FCC': 'Hikvision Digital Technology',
'BC1023': 'Hikvision Digital Technology',
'44190B': 'Hikvision Digital Technology',
'282504': 'Hikvision Digital Technology',
# Dahua Technology (IP cameras)
'E0501E': 'Dahua Technology',
'90D7EB': 'Dahua Technology',
'001881': 'Dahua Technology',
# Axis Communications (IP cameras)
'00408C': 'Axis Communications',
'ACCC8E': 'Axis Communications',
'B8A44F': 'Axis Communications',
# Hanwha / Samsung Techwin
'C80CC8': 'Hanwha Vision (Samsung Techwin)',
'000E2E': 'Hanwha Vision',
# Uniview (IP cameras)
'201895': 'Uniview Technologies',
# Reolink
'EC71DB': 'Reolink Digital Technology',
# Vivotek (IP cameras)
'00D0F1': 'Vivotek',
# Bosch Security Systems
'0004A3': 'Bosch Security Systems',
# Pelco
'000CE5': 'Pelco',
# Nest Labs (Google)
'18B430': 'Nest Labs (Google)',
'64DBA0': 'Nest Labs (Google)',
# Amazon (Echo, Ring, etc.)
'40B4CD': 'Amazon Technologies',
'74C246': 'Amazon Technologies',
'A002DC': 'Amazon Technologies',
'FC6516': 'Amazon Technologies',
'68370B': 'Amazon Technologies',
# Apple (HomeKit, HomePod, etc.)
'001451': 'Apple Inc',
'000A27': 'Apple Inc',
'3C5AB4': 'Apple Inc',
# Shelly (smart relays)
'3494B4': 'Allterco Robotics (Shelly)',
# Tuya Smart (platform used by hundreds of white-label IoT brands)
'D8F15B': 'Tuya Smart',
'500291': 'Tuya Smart',
'A08908': 'Tuya Smart',
'C44F33': 'Tuya Smart',
'7C87CE': 'Tuya Smart',
'68ABBC': 'Tuya Smart',
'7403BD': 'Tuya Smart',
'B4E842': 'Tuya Smart',
'105A17': 'Tuya Smart',
'C83A35': 'Tuya Smart',
# Wyze
'2CAA8E': 'Wyze Labs',
# Ring
'B02A4C': 'Ring (Amazon)',
# MikroTik
'4C5E0C': 'MikroTik',
'6C3B6B': 'MikroTik',
'E48D8C': 'MikroTik',
# Cisco
'00000C': 'Cisco Systems',
'0001C7': 'Cisco Systems',
'0023EB': 'Cisco Systems',
# ── Additional SCADA / ICS ───────────────────────────────────────────────
# HMS Industrial Networks (Anybus, eWON, Netbiter)
'003011': 'HMS Industrial Networks',
'000752': 'HMS Industrial Networks',
# Hirschmann Automation / Belden (industrial Ethernet switches)
'008063': 'Hirschmann Automation (Belden)',
'000E0E': 'Hirschmann Automation (Belden)',
# National Instruments / NI
'00802F': 'National Instruments',
'001FB9': 'National Instruments',
'0026B9': 'National Instruments',
# Digi International (serial/IoT gateways)
'00409D': 'Digi International',
'001517': 'Digi International',
'0040A5': 'Digi International',
# B&R Industrial Automation
'00C07D': 'B&R Industrial Automation',
# TURCK (industrial sensors / fieldbus)
'0007E8': 'TURCK',
# ifm electronic (sensors / I/O modules)
'0006F5': 'ifm electronic',
# SICK AG (sensors, safety)
'000C52': 'SICK AG',
'00E0FE': 'SICK AG',
# Festo (pneumatics / industrial automation)
'000EF0': 'Festo AG',
# Lenze (drives / automation)
'001941': 'Lenze SE',
# Weidmüller (terminal blocks / I/O)
'001EC0': 'Weidmüller Interface',
# Belden (industrial cabling / networking, also Hirschmann parent)
'0004DF': 'Belden',
# Westermo (industrial routers)
'0007A8': 'Westermo Network Technologies',
# ProSoft Technology (communication modules for PLCs)
'001A85': 'ProSoft Technology',
# Red Lion Controls (HMI / protocol conversion)
'0006EA': 'Red Lion Controls',
# Opto 22 (I/O systems, SNAP PAC)
'000084': 'Opto 22',
# Koyo / AutomationDirect (PLCs)
'000B99': 'Koyo Electronics / AutomationDirect',
# IDEC Corporation (PLCs / HMIs)
'00041B': 'IDEC Corporation',
# Yaskawa Electric (servo drives / robots)
'000773': 'Yaskawa Electric',
# Fanuc (CNC / robotics)
'00113D': 'Fanuc Corporation',
# KUKA Roboter
'000C78': 'KUKA Roboter GmbH',
# Pepperl+Fuchs (sensors / intrinsic safety)
'000AF8': 'Pepperl+Fuchs',
# Endress+Hauser (process instrumentation)
'000705': 'Endress+Hauser',
# Danfoss (drives / HVAC controls)
'00606F': 'Danfoss A/S',
# SEW-EURODRIVE (drives)
'001A66': 'SEW-EURODRIVE',
# Murrelektronik (field bus infrastructure)
'0013A6': 'Murrelektronik GmbH',
# Rittal (enclosures / cooling — network-connected)
'000DA3': 'Rittal GmbH',
# ── Additional IP Camera / CCTV ──────────────────────────────────────────
# Additional Hikvision OUIs
'BCAD28': 'Hikvision Digital Technology',
'4CEB BD': 'Hikvision Digital Technology',
'285B81': 'Hikvision Digital Technology',
'3CEF8C': 'Hikvision Digital Technology',
'50E549': 'Hikvision Digital Technology',
# Additional Dahua OUIs
'4C11BF': 'Dahua Technology',
'305A3A': 'Dahua Technology',
'A46CF1': 'Dahua Technology',
# EZVIZ (Hikvision consumer brand)
'9C685B': 'EZVIZ (Hikvision)',
'E8B8A0': 'EZVIZ (Hikvision)',
# Avigilon (Motorola Solutions)
'00186E': 'Avigilon Corporation',
'000AF3': 'Avigilon Corporation',
'5800E9': 'Avigilon Corporation',
# FLIR Systems (thermal / IP cameras)
'1866DA': 'FLIR Systems',
'000D9A': 'FLIR Systems',
# MOBOTIX AG
'000C2D': 'MOBOTIX AG',
# Sony Corporation (Sony cameras / NVR)
'00014A': 'Sony Corporation',
'001A80': 'Sony Corporation',
# Hanwha Vision — additional OUIs
'000918': 'Hanwha Vision',
'00166E': 'Hanwha Vision',
# GeoVision (IP cameras / access control)
'000B97': 'GeoVision Inc',
# ACTi Corporation (IP cameras)
'000399': 'ACTi Corporation',
# Vivotek — additional
'000D96': 'Vivotek',
# Milesight (IP cameras / IoT gateways)
'2CAA8E': 'Milesight Technology',
# Tiandy Technologies
'9C8ECD': 'Tiandy Technologies',
# Foscam Digital Technologies
'00266C': 'Foscam Digital Technologies',
# Arecont Vision
'00188E': 'Arecont Vision',
# IndigoVision
'0013F1': 'IndigoVision',
# March Networks
'000462': 'March Networks',
# Digital Watchdog
'001CF0': 'Digital Watchdog',
# Amcrest Technologies (Dahua OEM)
'9C8E99': 'Amcrest Technologies',
# Lorex Technology (FLIR subsidiary)
'00265F': 'Lorex Technology',
# Swann Communications
'002765': 'Swann Communications',
# Provision-ISR
'001659': 'Provision-ISR',
# CP Plus / Aditya Infotech
'000316': 'CP Plus',
# ── Additional IoT / Smart Home ──────────────────────────────────────────
# IKEA of Sweden (Tradfri smart home)
'000B57': 'IKEA of Sweden',
'786A89': 'IKEA of Sweden',
# LIFX (smart bulbs)
'D073D5': 'LIFX',
# Sonos (smart speakers)
'000E58': 'Sonos Inc',
'5CAAD4': 'Sonos Inc',
'B8E937': 'Sonos Inc',
# Ecobee (smart thermostats)
'44619F': 'Ecobee Inc',
# Arlo Technologies (cameras / home security)
'20F5EA': 'Arlo Technologies',
# Eufy Security / Anker Innovations
'6CF1FE': 'Anker Innovations (Eufy)',
# DoorBird / Bird Home Automation
'1CCAE3': 'Bird Home Automation (DoorBird)',
# 2N Telecommunications (IP intercoms)
'000EE8': '2N Telecommunications',
# Eero (Amazon mesh WiFi)
'40D855': 'Eero (Amazon)',
# ASUS (routers / smart home)
'00E04C': 'ASUSTek Computer',
'049226': 'ASUSTek Computer',
'AC220B': 'ASUSTek Computer',
# Linksys (Belkin)
'001310': 'Linksys',
'001CF0': 'Linksys',
# Synology (NAS)
'001132': 'Synology Inc',
'0011320': 'Synology Inc',
# QNAP Systems (NAS)
'247703': 'QNAP Systems',
'0008A8': 'QNAP Systems',
# Western Digital (NAS / IoT storage)
'000C50': 'Western Digital',
'0090A9': 'Western Digital',
# Silicon Labs (IoT chips — Zigbee/Z-Wave hub manufacturers)
'000B57': 'Silicon Laboratories',
# Sonoff / ITEAD Studio
'10521C': 'ITEAD Studio (Sonoff)',
'E8DB84': 'ITEAD Studio (Sonoff)',
# Nanoleaf (smart lighting panels)
'A0556E': 'Nanoleaf',
# Govee Home
'A4C138': 'Govee',
# Roku (streaming devices)
'B00414': 'Roku Inc',
'AC3A7A': 'Roku Inc',
'CC6EDA': 'Roku Inc',
# Logitech (Harmony hub, etc.)
'00F020': 'Logitech',
'B4AEE3': 'Logitech',
# Google (Chromecast, Nest WiFi, etc.)
'1CB72C': 'Google LLC',
'3C5AB4': 'Google LLC',
'48D705': 'Google LLC',
'F4F5E8': 'Google LLC',
# Fibaro (Z-Wave smart home)
'000479': 'Fibaro',
# Vera Control (SmartHome hub)
'006037': 'Vera Control',
# Daikin Industries (network-connected AC units)
'0030D3': 'Daikin Industries',
# Sharp Corporation (IEEE confirmed, WiFi-connected AC/appliances)
'00041E': 'Sharp Corporation',
# Hitachi Cable (IEEE confirmed, Hitachi WiFi-connected AC)
'000087': 'Hitachi Cable',
# Fujitsu Limited (IEEE confirmed, Airstage WiFi AC)
'000B5D': 'Fujitsu Limited',
}
# Keywords for SCADA/ICS vendor classification
SCADA_VENDOR_KW = {
# Big automation vendors
'siemens', 'rockwell', 'allen-bradley', 'schneider', 'honeywell',
'abb', 'ge fanuc', 'ge automation', 'ge industrial', 'ge digital',
'ge proficy', 'mitsubishi electric', 'omron', 'phoenix contact',
'beckhoff', 'moxa', 'emerson', 'emerson electric', 'yokogawa',
'advantech', 'lantronix', 'wago', 'pilz', 'keyence', 'weintek',
# Drives & motion
'yaskawa', 'fanuc', 'kuka', 'bosch rexroth', 'parker hannifin',
'parker automation', 'danfoss', 'sew-eurodrive', 'sew eurodrive',
'lenze', 'kollmorgen', 'nidec', 'fuji electric',
# Sensors & instrumentation
'pepperl+fuchs', 'pepperl fuchs', 'endress+hauser', 'endress hauser',
'turck', 'hans turck', 'ifm electronic', 'sick ag', 'sick sensor',
'balluff', 'leuze', 'contrinex', 'vega grieshaber', 'krohne',
'festo', 'smc corporation',
# Industrial networking
'hirschmann', 'belden industrial', 'westermo', 'ruggedcom',
'prosoft', 'red lion', 'opto 22', 'digi international',
'hms industrial', 'hms networks', 'anybus', 'ewon', 'netbiter',
'hilscher', 'softing industrial',
# Fieldbuses & I/O
'weidmuller', 'weidmüller', 'murrelektronik', 'murr elektronik',
'rittal', 'eaton', 'datexel', 'acromag', 'kontakttechnik',
'b&r industrial', 'b&r automation',
# SCADA software / historians
'inductive automation', 'ignition', 'aveva', 'wonderware',
'kepware', 'ge proficy', 'national instruments', 'ni corp',
'automationdirect', 'koyo', 'idec', 'delta tau',
# Note: 'bosch security' intentionally NOT here — it is a camera brand
}
# Keywords for IP camera vendor classification
CAM_VENDOR_KW = {
# Tier-1 manufacturers
'hikvision', 'dahua', 'axis communications', 'hanwha', 'samsung techwin',
'uniview', 'reolink', 'vivotek', 'pelco', 'bosch security',
# Professional / enterprise
'avigilon', 'motorola solutions', 'milestone systems', 'genetec',
'march networks', 'indigo vision', 'indigovision', 'arecont vision',
'digital watchdog', 'speco technologies', 'vicon industries',
'american dynamics', 'verint', 'dedicated micros',
# Thermal & specialty
'flir', 'flir systems', 'mobotix', 'geovision', 'acti corporation',
'sony imaging', 'lilin', 'surveon', 'tiandy', 'milesight',
# Consumer / prosumer
'ezviz', 'amcrest', 'foscam', 'swann', 'annke', 'cp plus', 'cp-plus',
'lorex', 'night owl', 'zmodo', 'provision-isr', 'tapo',
'eufy', 'arlo', 'blink', 'doorbird', '2n telecommunications',
}
# Keywords for IoT consumer device classification
IOT_VENDOR_KW = {
# Networking / gateways
'tp-link', 'kasa smart', 'd-link', 'netgear', 'ubiquiti', 'linksys',
'asus', 'mikrotik', 'eero',
# Dev boards / modules
'raspberry pi', 'espressif', 'arduino', 'particle industries',
'nordic semiconductor', 'silicon labs', 'silicon laboratories',
'microchip technology',
# Smart lighting
'signify', 'philips hue', 'lifx', 'nanoleaf', 'govee', 'sengled',
'ikea of sweden', 'ledvance', 'osram',
# Smart home hubs & plugs
'belkin', 'wemo', 'shelly', 'allterco', 'sonoff', 'itead studio',
'tuya', 'fibaro', 'vera control', 'smartthings',
# Voice / streaming / media
'nest labs', 'amazon technologies', 'apple inc', 'google llc',
'roku', 'sonos', 'logitech',
# Security / cameras (consumer-grade IoT)
'wyze', 'ring', 'arlo technologies', 'blink', 'eufy', 'anker',
# Consumer electronics
'samsung electronics', 'lg electronics',
# NAS / storage
'synology', 'qnap', 'western digital',
# Intercoms
'bird home automation', '2n telecommunications',
# Thermostat / climate / HVAC
'ecobee', 'daikin',
# WiFi-connected AC brands (broad coverage for banner/SNMP detection)
'panasonic', 'fujitsu general', 'fujitsu', 'hitachi', 'toshiba',
'sharp', 'haier', 'midea', 'gree electric', 'gree', 'aux air',
'carrier', 'lennox', 'trane', 'york hvac', 'mitsubishi heavy',
'mitsubishi electric hvac',
}
# ─────────────────────────────────────────────────────────────────────────────
# OUI LOOKUP
# ─────────────────────────────────────────────────────────────────────────────
class OUILookup:
"""MAC OUI vendor lookup — uses local file if available, else built-in DB."""
def __init__(self, oui_file=None):
self.db = {}
loaded = False
# User-supplied file takes priority
candidates = []
if oui_file:
candidates.append(oui_file)
# Auto-detect well-known system locations
candidates += [
'oui.txt', # current directory
'/usr/share/nmap/nmap-mac-prefixes', # nmap
'/usr/share/wireshark/manuf', # wireshark
'/usr/share/misc/oui.txt', # misc
]
for path in candidates:
if path and os.path.isfile(path):
loaded = self._load_file(path)
if loaded:
break
if not loaded:
self.db = BUILTIN_OUI.copy()
print("[~] Using built-in OUI database. For full coverage, place oui.txt "
"next to the script (IEEE OUI or Wireshark manuf format).")
def _load_file(self, path):
count = 0
try:
with open(path, 'r', errors='ignore') as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
# nmap-mac-prefixes: "000000 Vendor Name"
# Also matches IEEE "(base 16)" lines — strip that prefix if present
m = re.match(r'^([0-9A-Fa-f]{6})\s+(.+)$', line)
if m:
vendor_raw = m.group(2).strip()
# IEEE OUI files have lines like: "BCDDС2 (base 16) Espressif Inc."
vendor_raw = re.sub(r'^\(base 16\)\s*', '', vendor_raw, flags=re.IGNORECASE).strip()
if vendor_raw:
self.db[m.group(1).upper()] = vendor_raw
count += 1
continue
# Wireshark manuf: "00:00:00 Short Vendor Long Name"
m = re.match(r'^([0-9A-Fa-f]{2}):([0-9A-Fa-f]{2}):([0-9A-Fa-f]{2})\s+\S+\s+(.+)$', line)
if m:
key = (m.group(1) + m.group(2) + m.group(3)).upper()
self.db[key] = m.group(4).strip()
count += 1
continue
# IEEE OUI format: "00-00-00 (hex) Vendor Name"
m = re.match(r'^([0-9A-Fa-f]{2})-([0-9A-Fa-f]{2})-([0-9A-Fa-f]{2})\s+\(hex\)\s+(.+)$', line)
if m:
key = (m.group(1) + m.group(2) + m.group(3)).upper()
self.db[key] = m.group(4).strip()
count += 1
if count:
print(f"[+] Loaded {count:,} OUI entries from {path}")
return True
except Exception as e:
print(f"[!] OUI file error ({path}): {e}")
return False
def lookup(self, mac: str) -> str:
if not mac or mac in ('N/A', 'Unknown', ''):
return 'Unknown'
clean = re.sub(r'[:\-\.]', '', mac).upper()
if len(clean) < 6:
return 'Unknown'
return self.db.get(clean[:6], 'Unknown')
# ─────────────────────────────────────────────────────────────────────────────
# PROTOCOL PROBES
# ─────────────────────────────────────────────────────────────────────────────
class ProtocolProber:
"""Sends targeted protocol handshakes to confirm and fingerprint devices."""
def __init__(self, timeout=PROBE_TIMEOUT):
self.timeout = timeout
# ── helpers ──────────────────────────────────────────────────────────────
def _tcp(self, ip, port):
"""Return connected socket or None."""
s = None
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(self.timeout)
s.connect((ip, port))
return s
except Exception:
if s:
try: s.close()
except Exception: pass
return None
def _udp(self, ip, port, data, size=1024):
"""Send UDP, return response bytes or None."""
s = None
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(self.timeout)
s.sendto(data, (ip, port))
resp, _ = s.recvfrom(size)
s.close()
return resp
except Exception:
if s:
try: s.close()
except Exception: pass
return None
# ── Modbus/TCP — port 502 ────────────────────────────────────────────────
def probe_modbus(self, ip):
s = self._tcp(ip, 502)
if not s:
return None
try:
# FC 0x2B / MEI 0x0E — Read Device Identification (basic stream)
req = struct.pack('>HHHB', 0x0001, 0x0000, 0x0005, 0x01) # MBAP
req += b'\x2B\x0E\x01\x00' # FC, MEI type, read dev id code, object id
s.sendall(req)
resp = s.recv(256)
s.close()
if not resp or len(resp) < 8:
return None
result = {'protocol': 'Modbus/TCP', 'port': 502}
# Parse device identification objects starting at byte 8
try:
offset = 8
if len(resp) > offset + 4:
num_obj = resp[offset + 4]
o = offset + 5
names = {0: 'vendor', 1: 'product', 2: 'version'}
for _ in range(min(num_obj, 8)):
if o + 2 > len(resp):
break
oid = resp[o]
olen = resp[o + 1]
val = resp[o + 2: o + 2 + olen].decode('utf-8', errors='replace').strip()
if val:
result[names.get(oid, f'obj_{oid:02X}')] = val
o += 2 + olen
except Exception:
pass
# FC3: Read Holding Registers (unauthenticated)
try:
s2 = self._tcp(ip, 502)
if s2:
fc3 = struct.pack('>HHHBBHH', 0x0002, 0x0000, 0x0006,
0x01, 0x03, 0x0000, 0x000A)
s2.sendall(fc3)
r3 = s2.recv(128)
s2.close()
if r3 and len(r3) > 9 and r3[7] == 0x03:
n_bytes = r3[8]
n_regs = n_bytes // 2
if n_regs > 0 and len(r3) >= 9 + n_bytes:
regs = list(struct.unpack_from(f'>{n_regs}H', r3, 9))
result['holding_registers'] = regs[:10]
result['unauth_read'] = True
except Exception:
pass
# FC1: Read Coils (unauthenticated)
try:
s3 = self._tcp(ip, 502)
if s3:
fc1 = struct.pack('>HHHBBHH', 0x0003, 0x0000, 0x0006,
0x01, 0x01, 0x0000, 0x0010)
s3.sendall(fc1)
r1 = s3.recv(64)
s3.close()
if r1 and len(r1) > 9 and r1[7] == 0x01:
n_bytes = r1[8]
coil_bytes = r1[9:9 + n_bytes]
coils = []
for b in coil_bytes:
for bit in range(8):
coils.append((b >> bit) & 1)
result['coils'] = coils[:16]
except Exception:
pass
return result
except Exception:
s.close()
return None
# ── IEC 60870-5-104 — port 2404 ──────────────────────────────────────────
def probe_iec104(self, ip):
s = self._tcp(ip, 2404)
if not s:
return None
try:
s.sendall(b'\x68\x04\x07\x00\x00\x00') # STARTDT_ACT
resp = s.recv(64)
s.close()
if resp and len(resp) >= 6 and resp[0] == 0x68:
result = {'protocol': 'IEC 60870-5-104', 'port': 2404}
if resp[2] == 0x0B:
result['response'] = 'STARTDT_CON'
else:
result['response'] = f'APCI control=0x{resp[2]:02X}'
return result
except Exception:
s.close()
return None
# ── Siemens S7 — port 102 ────────────────────────────────────────────────
def probe_s7(self, ip):
s = self._tcp(ip, 102)
if not s:
return None
try:
# TPKT + COTP Connection Request
cotp_cr = (
b'\x03\x00\x00\x16' # TPKT header (length=22)
b'\x11\xe0' # COTP length + Connect Request
b'\x00\x00\x00\x01\x00' # dst-ref, src-ref, class
b'\xc0\x01\x0a' # TPDU size param
b'\xc1\x02\x01\x00' # src-TSAP
b'\xc2\x02\x01\x02' # dst-TSAP (S7 CPU rack 0, slot 2)
)
s.sendall(cotp_cr)
resp = s.recv(64)
if not resp or len(resp) < 5 or resp[5] != 0xD0: # 0xD0 = CC (Connect Confirm)
s.close()
return None
# S7 Communication Setup (negotiate PDU size)
s7_setup = (
b'\x03\x00\x00\x19' # TPKT
b'\x02\xf0\x80' # COTP DT (Data Transfer)
b'\x32\x01\x00\x00' # S7 protocol id + ROSCTR=JOB
b'\x00\x00\x00\x08' # PDU ref, param length
b'\x00\x00' # data length
b'\xf0\x00' # Function: Setup Communication
b'\x00\x01\x00\x01' # max ack / max jobs
b'\x03\xc0' # PDU size 960
)
s.sendall(s7_setup)
resp2 = s.recv(64)
s.close()
if resp2 and len(resp2) >= 7:
result = {'protocol': 'Siemens S7', 'port': 102}
# Extract any readable ASCII strings (module name, etc.)
parts = re.findall(b'[ -~]{4,}', resp2)
info_strs = [p.decode('ascii', errors='replace').strip()
for p in parts if p.strip()]
if info_strs:
result['info'] = info_strs[:4]
return result
except Exception:
s.close()
return None
# ── EtherNet/IP (CIP) — port 44818 ───────────────────────────────────────
def probe_enip(self, ip):
s = self._tcp(ip, 44818)
if not s:
return None
try:
# List Identity encapsulation command (0x0065), all zeros header
list_id = (
b'\x65\x00' # Command: List Identity
b'\x00\x00' # Length: 0
b'\x00\x00\x00\x00' # Session handle
b'\x00\x00\x00\x00' # Status
b'\x00\x00\x00\x00\x00\x00\x00\x00' # Sender context (8 bytes)
b'\x00\x00\x00\x00' # Options
)
s.sendall(list_id)
resp = s.recv(1024)
s.close()
if not resp or len(resp) < 4:
return None
cmd = struct.unpack_from('<H', resp, 0)[0]
if cmd != 0x0065:
return None
result = {'protocol': 'EtherNet/IP (CIP)', 'port': 44818}
# Identity item starts after 24-byte encap header + 4 bytes item list header
try:
offset = 28 # encap(24) + item_count(2) + item_type(2)
# skip item length (2)
offset += 2