-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathport_scanner.html
More file actions
1337 lines (1180 loc) · 67.3 KB
/
port_scanner.html
File metadata and controls
1337 lines (1180 loc) · 67.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Network Connectivity Tester</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: #18191a;
color: #e4e6eb;
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
margin: 0;
padding: 2rem;
}
.container {
background-color: #242526;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
width: 100%;
max-width: 1000px;
text-align: center;
}
h1 {
margin-top: 0;
color: #e4e6eb;
}
.input-group {
margin-bottom: 1rem;
text-align: left;
}
.input-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
}
input[type="text"] {
width: 100%;
padding: 0.75rem;
border: 1px solid #404040;
border-radius: 6px;
font-size: 1rem;
box-sizing: border-box;
background-color: #3a3b3c;
color: #e4e6eb;
}
button {
width: 100%;
padding: 0.75rem;
border: none;
border-radius: 6px;
background-color: #1877f2;
color: #fff;
font-size: 1.1rem;
font-weight: bold;
cursor: pointer;
transition: background-color 0.2s;
}
button:hover {
background-color: #166fe5;
}
.home-button {
position: absolute;
top: 1rem;
left: 1rem;
padding: 0.5rem 1rem;
background-color: #3a3b3c;
color: #e4e6eb;
text-decoration: none;
border-radius: 6px;
font-size: 0.9rem;
font-weight: 500;
border: 1px solid #404040;
transition: background-color 0.2s;
}
.home-button:hover {
background-color: #4e4f50;
text-decoration: none;
}
#results {
margin-top: 1.5rem;
text-align: left;
}
.scan-section {
margin-bottom: 2rem;
padding: 1rem;
background-color: #3a3b3c;
border: 1px solid #404040;
border-radius: 6px;
}
.scan-section h3 {
margin-top: 0;
margin-bottom: 1rem;
color: #e4e6eb;
display: flex;
align-items: center;
gap: 0.5rem;
}
.port-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.port-item {
background-color: #2a2b2c;
padding: 0.75rem;
border-radius: 4px;
border-left: 3px solid #404040;
transition: border-color 0.3s;
}
.port-item.open {
border-left-color: #4caf50;
}
.port-item.closed {
border-left-color: #f44336;
}
.port-item.filtered {
border-left-color: #ff9800;
}
.port-item.unknown {
border-left-color: #9e9e9e;
}
.port-item.accessible {
border-left-color: #4caf50;
}
.port-item.unreachable {
border-left-color: #f44336;
}
.port-item.browser-limitation {
border-left-color: #9e9e9e;
}
.port-item.scanning {
border-left-color: #2196f3;
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.port-number {
font-weight: bold;
font-size: 1.1rem;
color: #e4e6eb;
}
.port-service {
font-size: 0.9rem;
color: #8a8b8c;
margin: 0.25rem 0;
}
.port-status {
font-size: 0.8rem;
font-weight: bold;
padding: 0.2rem 0.5rem;
border-radius: 12px;
display: inline-block;
margin-top: 0.25rem;
}
.status-open {
background-color: #2e4a2f;
color: #6aba6e;
}
.status-closed {
background-color: #5a2a2a;
color: #ff8a80;
}
.status-filtered {
background-color: #5a4a2a;
color: #ffb74d;
}
.status-unknown {
background-color: #4a4a4a;
color: #9e9e9e;
}
.status-accessible {
background-color: #2e4a2f;
color: #6aba6e;
}
.status-unreachable {
background-color: #5a2a2a;
color: #ff8a80;
}
.status-browser-limitation {
background-color: #4a4a4a;
color: #9e9e9e;
}
.status-scanning {
background-color: #2a4a5a;
color: #64b5f6;
}
.loading {
text-align: center;
color: #8a8b8c;
font-style: italic;
padding: 2rem;
}
.progress-bar {
width: 100%;
height: 6px;
background-color: #404040;
border-radius: 3px;
overflow: hidden;
margin: 1rem 0;
}
.progress-fill {
height: 100%;
background-color: #1877f2;
transition: width 0.3s ease;
width: 0%;
}
.summary {
background-color: #3a3b3c;
border: 1px solid #404040;
border-radius: 6px;
padding: 1rem;
margin-bottom: 1.5rem;
}
.summary h3 {
margin-top: 0;
color: #e4e6eb;
}
.summary-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.summary-item {
text-align: center;
padding: 1rem;
background-color: #2a2b2c;
border-radius: 4px;
}
.summary-count {
font-size: 2rem;
font-weight: bold;
margin-bottom: 0.5rem;
}
.count-open {
color: #4caf50;
}
.count-closed {
color: #f44336;
}
.count-filtered {
color: #ff9800;
}
.count-unknown {
color: #9e9e9e;
}
.count-total {
color: #2196f3;
}
.warning {
background-color: #5a4a2a;
color: #ffb74d;
padding: 1rem;
border-radius: 6px;
margin-bottom: 1rem;
border-left: 4px solid #ff9800;
}
.scan-time {
font-size: 0.9rem;
color: #8a8b8c;
margin-top: 0.5rem;
}
</style>
</head>
<body>
<a href="index.html" class="home-button">← Home</a>
<div class="container">
<h1>Network Connectivity Tester</h1>
<div class="warning">
<strong>Network Connectivity Tester:</strong> This tool tests network connectivity across multiple protocols
(TCP, UDP, ICMP) using various methods. Results show exactly which protocols succeeded, matching how
firewalls control access. Note: Direct ICMP ping and raw UDP sockets are limited in browsers, but we use
alternative detection methods.
</div>
<div class="input-group">
<label for="target">Target Host</label>
<input type="text" id="target" placeholder="e.g., example.com or 192.168.1.1">
</div>
<button id="scanButton">Test Network Connectivity</button>
<div id="results"></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const targetInput = document.getElementById('target');
const scanButton = document.getElementById('scanButton');
const resultsDiv = document.getElementById('results');
// Common ports to scan with their services
const COMMON_PORTS = [
// Web Services
{ port: 80, service: 'HTTP', protocol: 'tcp', category: 'Web' },
{ port: 443, service: 'HTTPS', protocol: 'tcp', category: 'Web' },
{ port: 8080, service: 'HTTP Alt', protocol: 'tcp', category: 'Web' },
{ port: 8443, service: 'HTTPS Alt', protocol: 'tcp', category: 'Web' },
{ port: 8000, service: 'HTTP Alt', protocol: 'tcp', category: 'Web' },
{ port: 8008, service: 'HTTP Alt', protocol: 'tcp', category: 'Web' },
{ port: 8888, service: 'HTTP Alt', protocol: 'tcp', category: 'Web' },
{ port: 9000, service: 'HTTP Alt', protocol: 'tcp', category: 'Web' },
{ port: 9090, service: 'HTTP Alt', protocol: 'tcp', category: 'Web' },
{ port: 3000, service: 'Node.js/React Dev', protocol: 'tcp', category: 'Web' },
{ port: 4200, service: 'Angular Dev', protocol: 'tcp', category: 'Web' },
{ port: 5000, service: 'Flask/Python Dev', protocol: 'tcp', category: 'Web' },
{ port: 8081, service: 'HTTP Proxy', protocol: 'tcp', category: 'Web' },
{ port: 8082, service: 'HTTP Proxy', protocol: 'tcp', category: 'Web' },
// Mail Services
{ port: 25, service: 'SMTP', protocol: 'tcp', category: 'Mail' },
{ port: 587, service: 'SMTP (Submission)', protocol: 'tcp', category: 'Mail' },
{ port: 465, service: 'SMTPS', protocol: 'tcp', category: 'Mail' },
{ port: 110, service: 'POP3', protocol: 'tcp', category: 'Mail' },
{ port: 995, service: 'POP3S', protocol: 'tcp', category: 'Mail' },
{ port: 143, service: 'IMAP', protocol: 'tcp', category: 'Mail' },
{ port: 993, service: 'IMAPS', protocol: 'tcp', category: 'Mail' },
{ port: 2525, service: 'SMTP Alt', protocol: 'tcp', category: 'Mail' },
// Remote Access
{ port: 22, service: 'SSH', protocol: 'tcp', category: 'Remote' },
{ port: 23, service: 'Telnet', protocol: 'tcp', category: 'Remote' },
{ port: 3389, service: 'RDP', protocol: 'tcp', category: 'Remote' },
{ port: 5900, service: 'VNC', protocol: 'tcp', category: 'Remote' },
{ port: 5901, service: 'VNC Alt', protocol: 'tcp', category: 'Remote' },
{ port: 5902, service: 'VNC Alt', protocol: 'tcp', category: 'Remote' },
{ port: 5985, service: 'WinRM HTTP', protocol: 'tcp', category: 'Remote' },
{ port: 5986, service: 'WinRM HTTPS', protocol: 'tcp', category: 'Remote' },
{ port: 2222, service: 'SSH Alt', protocol: 'tcp', category: 'Remote' },
{ port: 2022, service: 'SSH Alt', protocol: 'tcp', category: 'Remote' },
// File Transfer
{ port: 21, service: 'FTP', protocol: 'tcp', category: 'File Transfer' },
{ port: 22, service: 'SFTP', protocol: 'tcp', category: 'File Transfer' },
{ port: 69, service: 'TFTP', protocol: 'udp', category: 'File Transfer' },
{ port: 989, service: 'FTPS Data', protocol: 'tcp', category: 'File Transfer' },
{ port: 990, service: 'FTPS Control', protocol: 'tcp', category: 'File Transfer' },
{ port: 2049, service: 'NFS', protocol: 'tcp', category: 'File Transfer' },
{ port: 2049, service: 'NFS', protocol: 'udp', category: 'File Transfer' },
// DNS & Network
{ port: 53, service: 'DNS', protocol: 'tcp', category: 'DNS' },
{ port: 53, service: 'DNS', protocol: 'udp', category: 'DNS' },
{ port: 853, service: 'DNS over TLS', protocol: 'tcp', category: 'DNS' },
{ port: 5353, service: 'mDNS', protocol: 'udp', category: 'DNS' },
// Database
{ port: 3306, service: 'MySQL', protocol: 'tcp', category: 'Database' },
{ port: 5432, service: 'PostgreSQL', protocol: 'tcp', category: 'Database' },
{ port: 1433, service: 'MSSQL', protocol: 'tcp', category: 'Database' },
{ port: 1521, service: 'Oracle', protocol: 'tcp', category: 'Database' },
{ port: 27017, service: 'MongoDB', protocol: 'tcp', category: 'Database' },
{ port: 6379, service: 'Redis', protocol: 'tcp', category: 'Database' },
{ port: 5984, service: 'CouchDB', protocol: 'tcp', category: 'Database' },
{ port: 9200, service: 'Elasticsearch', protocol: 'tcp', category: 'Database' },
{ port: 9300, service: 'Elasticsearch', protocol: 'tcp', category: 'Database' },
{ port: 11211, service: 'Memcached', protocol: 'tcp', category: 'Database' },
{ port: 50000, service: 'DB2', protocol: 'tcp', category: 'Database' },
// System Services
{ port: 135, service: 'RPC Endpoint', protocol: 'tcp', category: 'System' },
{ port: 139, service: 'NetBIOS Session', protocol: 'tcp', category: 'System' },
{ port: 445, service: 'SMB/CIFS', protocol: 'tcp', category: 'System' },
{ port: 161, service: 'SNMP', protocol: 'udp', category: 'System' },
{ port: 162, service: 'SNMP Trap', protocol: 'udp', category: 'System' },
{ port: 137, service: 'NetBIOS Name', protocol: 'udp', category: 'System' },
{ port: 138, service: 'NetBIOS Datagram', protocol: 'udp', category: 'System' },
{ port: 389, service: 'LDAP', protocol: 'tcp', category: 'System' },
{ port: 636, service: 'LDAPS', protocol: 'tcp', category: 'System' },
{ port: 88, service: 'Kerberos', protocol: 'tcp', category: 'System' },
{ port: 88, service: 'Kerberos', protocol: 'udp', category: 'System' },
// Application Services
{ port: 6000, service: 'X11', protocol: 'tcp', category: 'Application' },
{ port: 6001, service: 'X11 Alt', protocol: 'tcp', category: 'Application' },
{ port: 7000, service: 'Cassandra', protocol: 'tcp', category: 'Application' },
{ port: 7001, service: 'Cassandra SSL', protocol: 'tcp', category: 'Application' },
{ port: 9042, service: 'Cassandra CQL', protocol: 'tcp', category: 'Application' },
{ port: 2181, service: 'Zookeeper', protocol: 'tcp', category: 'Application' },
{ port: 9092, service: 'Kafka', protocol: 'tcp', category: 'Application' },
{ port: 5672, service: 'RabbitMQ', protocol: 'tcp', category: 'Application' },
{ port: 15672, service: 'RabbitMQ Management', protocol: 'tcp', category: 'Application' },
{ port: 4369, service: 'Erlang Port Mapper', protocol: 'tcp', category: 'Application' },
// Proxy & Load Balancer
{ port: 3128, service: 'Squid Proxy', protocol: 'tcp', category: 'Proxy' },
{ port: 8118, service: 'Privoxy', protocol: 'tcp', category: 'Proxy' },
{ port: 1080, service: 'SOCKS Proxy', protocol: 'tcp', category: 'Proxy' },
{ port: 9050, service: 'Tor SOCKS', protocol: 'tcp', category: 'Proxy' },
{ port: 80, service: 'HAProxy Stats', protocol: 'tcp', category: 'Proxy' },
{ port: 8404, service: 'HAProxy Stats', protocol: 'tcp', category: 'Proxy' },
// Monitoring & Management
{ port: 9090, service: 'Prometheus', protocol: 'tcp', category: 'Monitoring' },
{ port: 3000, service: 'Grafana', protocol: 'tcp', category: 'Monitoring' },
{ port: 9093, service: 'Alertmanager', protocol: 'tcp', category: 'Monitoring' },
{ port: 9100, service: 'Node Exporter', protocol: 'tcp', category: 'Monitoring' },
{ port: 8086, service: 'InfluxDB', protocol: 'tcp', category: 'Monitoring' },
{ port: 5601, service: 'Kibana', protocol: 'tcp', category: 'Monitoring' },
{ port: 4040, service: 'Spark UI', protocol: 'tcp', category: 'Monitoring' },
// Container & Orchestration
{ port: 2375, service: 'Docker API', protocol: 'tcp', category: 'Container' },
{ port: 2376, service: 'Docker API TLS', protocol: 'tcp', category: 'Container' },
{ port: 2377, service: 'Docker Swarm', protocol: 'tcp', category: 'Container' },
{ port: 6443, service: 'Kubernetes API', protocol: 'tcp', category: 'Container' },
{ port: 10250, service: 'Kubelet API', protocol: 'tcp', category: 'Container' },
{ port: 10255, service: 'Kubelet Read-only', protocol: 'tcp', category: 'Container' },
{ port: 8001, service: 'Kubernetes Proxy', protocol: 'tcp', category: 'Container' },
// Gaming & Entertainment
{ port: 25565, service: 'Minecraft', protocol: 'tcp', category: 'Gaming' },
{ port: 27015, service: 'Steam/Source', protocol: 'tcp', category: 'Gaming' },
{ port: 7777, service: 'Game Server', protocol: 'tcp', category: 'Gaming' },
{ port: 7777, service: 'Game Server', protocol: 'udp', category: 'Gaming' },
{ port: 1935, service: 'RTMP (Streaming)', protocol: 'tcp', category: 'Gaming' },
// Security & VPN
{ port: 1194, service: 'OpenVPN', protocol: 'udp', category: 'Security' },
{ port: 1723, service: 'PPTP VPN', protocol: 'tcp', category: 'Security' },
{ port: 500, service: 'IPSec IKE', protocol: 'udp', category: 'Security' },
{ port: 4500, service: 'IPSec NAT-T', protocol: 'udp', category: 'Security' },
{ port: 1812, service: 'RADIUS Auth', protocol: 'udp', category: 'Security' },
{ port: 1813, service: 'RADIUS Accounting', protocol: 'udp', category: 'Security' },
// IoT & Embedded
{ port: 1883, service: 'MQTT', protocol: 'tcp', category: 'IoT' },
{ port: 8883, service: 'MQTT over SSL', protocol: 'tcp', category: 'IoT' },
{ port: 5683, service: 'CoAP', protocol: 'udp', category: 'IoT' },
{ port: 5684, service: 'CoAP over DTLS', protocol: 'udp', category: 'IoT' },
{ port: 502, service: 'Modbus', protocol: 'tcp', category: 'IoT' },
// Legacy & Misc
{ port: 79, service: 'Finger', protocol: 'tcp', category: 'Legacy' },
{ port: 70, service: 'Gopher', protocol: 'tcp', category: 'Legacy' },
{ port: 119, service: 'NNTP', protocol: 'tcp', category: 'Legacy' },
{ port: 563, service: 'NNTPS', protocol: 'tcp', category: 'Legacy' },
{ port: 194, service: 'IRC', protocol: 'tcp', category: 'Legacy' },
{ port: 6667, service: 'IRC', protocol: 'tcp', category: 'Legacy' },
{ port: 6697, service: 'IRC SSL', protocol: 'tcp', category: 'Legacy' },
{ port: 513, service: 'rlogin', protocol: 'tcp', category: 'Legacy' },
{ port: 514, service: 'rsh', protocol: 'tcp', category: 'Legacy' },
{ port: 515, service: 'LPD/LPR', protocol: 'tcp', category: 'Legacy' },
{ port: 631, service: 'IPP/CUPS', protocol: 'tcp', category: 'Legacy' },
// High Ports & Services
{ port: 49152, service: 'Dynamic/Private', protocol: 'tcp', category: 'High Ports' },
{ port: 32768, service: 'Dynamic/Private', protocol: 'tcp', category: 'High Ports' },
{ port: 32769, service: 'Dynamic/Private', protocol: 'tcp', category: 'High Ports' },
{ port: 65535, service: 'Highest Port', protocol: 'tcp', category: 'High Ports' }
];
// Remove duplicates and create unique port list
const uniquePorts = COMMON_PORTS.reduce((acc, current) => {
const key = `${current.port}-${current.protocol}`;
if (!acc.find(item => `${item.port}-${item.protocol}` === key)) {
acc.push(current);
}
return acc;
}, []);
const testConnectivity = async (host, port, expectedProtocol, timeout = 4000) => {
return new Promise((resolve) => {
const startTime = Date.now();
const tests = [];
// UDP Test (limited browser support)
if (expectedProtocol === 'udp') {
tests.push({
name: 'UDP-Probe',
protocol: 'UDP',
test: () => {
return new Promise((udpResolve) => {
// Try to create a fake UDP "connection" via fetch to a likely UDP service
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 1000);
// For DNS port 53, try a DNS-over-HTTPS query as proxy
if (port === 53) {
fetch(`https://${host}/dns-query?name=test.com&type=A`, {
method: 'GET',
mode: 'no-cors',
signal: controller.signal
}).then(() => {
clearTimeout(timeoutId);
udpResolve({
success: true,
protocol: 'UDP',
method: 'UDP-Probe',
details: 'UDP DNS service likely accessible (via DoH proxy test)'
});
}).catch(() => {
clearTimeout(timeoutId);
udpResolve({
success: false,
protocol: 'UDP',
method: 'UDP-Probe',
details: 'UDP DNS service test failed (browser limitation)'
});
});
} else {
// For other UDP ports, we can't really test them
setTimeout(() => {
udpResolve({
success: false,
protocol: 'UDP',
method: 'UDP-Probe',
details: 'UDP connectivity cannot be directly tested from browsers (security restriction)'
});
}, 100);
}
});
}
});
}
// ICMP Ping Test (using multiple HTTP requests to infer host reachability)
tests.push({
name: 'ICMP-Ping',
protocol: 'ICMPv4',
test: () => {
return new Promise((pingResolve) => {
const testStartTime = Date.now();
let completedTests = 0;
let successfulConnections = 0;
const totalTests = 3;
const checkComplete = () => {
completedTests++;
if (completedTests === totalTests) {
const responseTime = Date.now() - testStartTime;
if (successfulConnections > 0) {
pingResolve({
success: true,
protocol: 'ICMPv4',
method: 'ICMP-Ping',
details: `Host reachable (${successfulConnections}/${totalTests} HTTP probes successful, ${responseTime}ms)`
});
} else if (responseTime > 2000) {
pingResolve({
success: false,
protocol: 'ICMPv4',
method: 'ICMP-Ping',
details: 'Host likely unreachable (all HTTP probes timed out)'
});
} else {
pingResolve({
success: false,
protocol: 'ICMPv4',
method: 'ICMP-Ping',
details: 'Host status unclear (HTTP services may be blocked, but host could be up)'
});
}
}
};
// Test multiple common HTTP endpoints to infer host reachability
const testEndpoints = [
`http://${host}/`,
`http://${host}/favicon.ico`,
`http://${host}/robots.txt`
];
testEndpoints.forEach((url, index) => {
const controller = new AbortController();
const timeoutId = setTimeout(() => {
controller.abort();
checkComplete();
}, 1500);
fetch(url, {
method: 'HEAD',
mode: 'no-cors',
signal: controller.signal,
cache: 'no-cache'
}).then(() => {
clearTimeout(timeoutId);
successfulConnections++;
checkComplete();
}).catch((error) => {
clearTimeout(timeoutId);
// Even network errors indicate the host responded
if (error.name !== 'AbortError') {
successfulConnections++;
}
checkComplete();
});
});
});
}
});
// HTTP GET Test
if (port === 80 || port === 8000 || port === 8008 || port === 8080 || port === 8081 || port === 8082 || port === 8888 || port === 9000 || port === 9090 || port === 3000 || port === 5000 || port === 4200) {
tests.push({
name: 'HTTP-Service-Detection',
protocol: 'TCP',
test: () => {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 3000);
return fetch(`http://${host}:${port}/`, {
method: 'GET',
mode: 'no-cors',
signal: controller.signal,
cache: 'no-cache',
headers: { 'User-Agent': 'NetworkConnectivityTester/1.0' }
}).then(async (response) => {
clearTimeout(timeoutId);
// Try to detect service type from headers and response
let serviceInfo = 'HTTP Service';
let serverHeader = '';
try {
// Try to get server header (may be blocked by CORS)
serverHeader = response.headers.get('Server') || '';
if (serverHeader) {
if (serverHeader.includes('nginx')) serviceInfo = 'Nginx Web Server';
else if (serverHeader.includes('Apache')) serviceInfo = 'Apache Web Server';
else if (serverHeader.includes('IIS')) serviceInfo = 'Microsoft IIS';
else if (serverHeader.includes('Express')) serviceInfo = 'Express.js Server';
else if (serverHeader.includes('Kestrel')) serviceInfo = 'ASP.NET Core Kestrel';
else if (serverHeader.includes('Tomcat')) serviceInfo = 'Apache Tomcat';
else if (serverHeader.includes('Jetty')) serviceInfo = 'Eclipse Jetty';
else serviceInfo = `HTTP Server (${serverHeader})`;
}
} catch (e) {
// Headers blocked by CORS, try to infer from port and response
if (port === 3000) serviceInfo = 'Development Server (likely Node.js/React)';
else if (port === 4200) serviceInfo = 'Development Server (likely Angular)';
else if (port === 5000) serviceInfo = 'Development Server (likely Flask/Python)';
else if (port === 8080) serviceInfo = 'HTTP Proxy or Tomcat';
else if (port === 9000) serviceInfo = 'HTTP Service or Play Framework';
else if (port === 8888) serviceInfo = 'HTTP Service (possibly Jupyter)';
}
return {
success: true,
protocol: 'TCP',
method: 'HTTP-Service-Detection',
service: serviceInfo,
details: `${serviceInfo} detected on TCP port ${port} (HTTP status: ${response.status || 'opaque'})`
};
}).catch((error) => {
clearTimeout(timeoutId);
if (error.name === 'AbortError') {
return { success: false, protocol: 'TCP', method: 'HTTP-Service-Detection', details: 'TCP connection timeout' };
}
if (error.message.includes('CORS') || error.message.includes('network')) {
// Service is running but CORS is blocking us
let serviceInfo = 'HTTP Service (CORS protected)';
if (port === 3000) serviceInfo = 'Development Server (likely Node.js/React, CORS protected)';
else if (port === 4200) serviceInfo = 'Development Server (likely Angular, CORS protected)';
else if (port === 5000) serviceInfo = 'Development Server (likely Flask/Python, CORS protected)';
else if (port === 8080) serviceInfo = 'HTTP Proxy/Tomcat (CORS protected)';
return {
success: true,
protocol: 'TCP',
method: 'HTTP-Service-Detection',
service: serviceInfo,
details: `${serviceInfo} detected on TCP port ${port}`
};
}
return { success: false, protocol: 'TCP', method: 'HTTP-Service-Detection', details: `TCP connection failed: ${error.message}` };
});
}
});
// HTTP POST Test
tests.push({
name: 'HTTP-POST',
protocol: 'TCP',
test: () => {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000);
return fetch(`http://${host}:${port}/`, {
method: 'POST',
mode: 'no-cors',
signal: controller.signal,
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
'User-Agent': 'NetworkConnectivityTester/1.0'
},
body: JSON.stringify({ test: 'connectivity' })
}).then((response) => {
clearTimeout(timeoutId);
return {
success: true,
protocol: 'TCP',
method: 'HTTP-POST',
details: `TCP connection successful via HTTP POST (status: ${response.status || 'opaque'})`
};
}).catch((error) => {
clearTimeout(timeoutId);
if (error.name === 'AbortError') {
return { success: false, protocol: 'TCP', method: 'HTTP-POST', details: 'TCP connection timeout' };
}
if (error.message.includes('CORS') || error.message.includes('network')) {
return {
success: true,
protocol: 'TCP',
method: 'HTTP-POST',
details: 'TCP connection successful (CORS blocked, but service accessible)'
};
}
return { success: false, protocol: 'TCP', method: 'HTTP-POST', details: `TCP connection failed: ${error.message}` };
});
}
});
}
// HTTPS GET Test
if (port === 443 || port === 8443 || port === 8000 || port === 3000 || port === 5000 || port === 4200 || port === 9000) {
tests.push({
name: 'HTTPS-Service-Detection',
protocol: 'TCP+TLS',
test: () => {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 3000);
return fetch(`https://${host}:${port}/`, {
method: 'GET',
mode: 'no-cors',
signal: controller.signal,
cache: 'no-cache',
headers: { 'User-Agent': 'NetworkConnectivityTester/1.0' }
}).then(async (response) => {
clearTimeout(timeoutId);
// Try to detect HTTPS service type
let serviceInfo = 'HTTPS Service';
let serverHeader = '';
try {
serverHeader = response.headers.get('Server') || '';
if (serverHeader) {
if (serverHeader.includes('nginx')) serviceInfo = 'Nginx HTTPS Server';
else if (serverHeader.includes('Apache')) serviceInfo = 'Apache HTTPS Server';
else if (serverHeader.includes('IIS')) serviceInfo = 'Microsoft IIS HTTPS';
else if (serverHeader.includes('Express')) serviceInfo = 'Express.js HTTPS Server';
else if (serverHeader.includes('Kestrel')) serviceInfo = 'ASP.NET Core Kestrel HTTPS';
else if (serverHeader.includes('Tomcat')) serviceInfo = 'Apache Tomcat HTTPS';
else if (serverHeader.includes('Jetty')) serviceInfo = 'Eclipse Jetty HTTPS';
else serviceInfo = `HTTPS Server (${serverHeader})`;
}
} catch (e) {
// Infer from port
if (port === 443) serviceInfo = 'HTTPS Web Server (standard port)';
else if (port === 8443) serviceInfo = 'HTTPS Web Server (alternate port)';
else if (port === 3000) serviceInfo = 'Development HTTPS Server (likely Node.js/React)';
else if (port === 4200) serviceInfo = 'Development HTTPS Server (likely Angular)';
else if (port === 5000) serviceInfo = 'Development HTTPS Server (likely Flask/Python)';
}
return {
success: true,
protocol: 'TCP+TLS',
method: 'HTTPS-Service-Detection',
service: serviceInfo,
details: `${serviceInfo} detected on TCP+TLS port ${port} (HTTPS status: ${response.status || 'opaque'})`
};
}).catch((error) => {
clearTimeout(timeoutId);
if (error.name === 'AbortError') {
return { success: false, protocol: 'TCP+TLS', method: 'HTTPS-Service-Detection', details: 'TCP+TLS connection timeout' };
}
if (error.message.includes('CORS') || error.message.includes('network')) {
let serviceInfo = 'HTTPS Service (CORS protected)';
if (port === 443) serviceInfo = 'HTTPS Web Server (standard port, CORS protected)';
else if (port === 8443) serviceInfo = 'HTTPS Web Server (alternate port, CORS protected)';
return {
success: true,
protocol: 'TCP+TLS',
method: 'HTTPS-Service-Detection',
service: serviceInfo,
details: `${serviceInfo} detected on TCP+TLS port ${port}`
};
}
return { success: false, protocol: 'TCP+TLS', method: 'HTTPS-Service-Detection', details: `TCP+TLS connection failed: ${error.message}` };
});
}
});
// HTTPS POST Test
tests.push({
name: 'HTTPS-POST',
protocol: 'TCP+TLS',
test: () => {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000);
return fetch(`https://${host}:${port}/`, {
method: 'POST',
mode: 'no-cors',
signal: controller.signal,
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
'User-Agent': 'NetworkConnectivityTester/1.0'
},
body: JSON.stringify({ test: 'connectivity' })
}).then((response) => {
clearTimeout(timeoutId);
return {
success: true,
protocol: 'TCP+TLS',
method: 'HTTPS-POST',
details: `TCP+TLS connection successful via HTTPS POST (status: ${response.status || 'opaque'})`
};
}).catch((error) => {
clearTimeout(timeoutId);
if (error.name === 'AbortError') {
return { success: false, protocol: 'TCP+TLS', method: 'HTTPS-POST', details: 'TCP+TLS connection timeout' };
}
if (error.message.includes('CORS') || error.message.includes('network')) {
return {
success: true,
protocol: 'TCP+TLS',
method: 'HTTPS-POST',
details: 'TCP+TLS connection successful (CORS blocked, but service accessible)'
};
}
return { success: false, protocol: 'TCP+TLS', method: 'HTTPS-POST', details: `TCP+TLS connection failed: ${error.message}` };
});
}
});
}
// WebSocket Test (TCP-based)
tests.push({
name: 'Service-Detection',
protocol: 'TCP',
test: () => {
return new Promise((wsResolve) => {
try {
const ws = new WebSocket(`ws://${host}:${port}`);
let resolved = false;
const timeoutId = setTimeout(() => {
if (!resolved) {
resolved = true;
ws.close();
wsResolve({
success: false,
protocol: 'TCP',
method: 'WebSocket',
details: 'TCP connection timeout via WebSocket'
});
}
}, 1500);
ws.onopen = () => {
if (!resolved) {
resolved = true;
clearTimeout(timeoutId);
ws.close();
// Detect service based on port
let serviceInfo = 'WebSocket Service';
if (port === 80 || port === 8080) serviceInfo = 'WebSocket over HTTP port';
else if (port === 443 || port === 8443) serviceInfo = 'WebSocket over HTTPS port';
else if (port === 3000) serviceInfo = 'WebSocket Development Server';
else if (port === 9000) serviceInfo = 'WebSocket Application Server';
wsResolve({
success: true,
protocol: 'TCP',
method: 'Service-Detection',
service: serviceInfo,
details: `${serviceInfo} detected on TCP port ${port}`
});
}
};
ws.onerror = () => {
if (!resolved) {
resolved = true;
clearTimeout(timeoutId);
const responseTime = Date.now() - startTime;
wsResolve({
success: false,
protocol: 'TCP',
method: 'WebSocket',
details: responseTime < 100 ? 'TCP connection refused (port closed)' : 'TCP connection failed (filtered/blocked)'
});
}
};
ws.onclose = (event) => {
if (!resolved) {
resolved = true;
clearTimeout(timeoutId);
const responseTime = Date.now() - startTime;
if (responseTime < 200 && event.code === 1006) {
// Service is running but doesn't speak WebSocket
let serviceInfo = 'Unknown TCP Service';
// Try to identify service by port
if (port === 22) serviceInfo = 'SSH Server';
else if (port === 23) serviceInfo = 'Telnet Server';
else if (port === 25) serviceInfo = 'SMTP Mail Server';
else if (port === 53) serviceInfo = 'DNS Server';
else if (port === 110) serviceInfo = 'POP3 Mail Server';
else if (port === 143) serviceInfo = 'IMAP Mail Server';
else if (port === 993) serviceInfo = 'IMAPS Mail Server';
else if (port === 995) serviceInfo = 'POP3S Mail Server';
else if (port === 587) serviceInfo = 'SMTP Submission Server';
else if (port === 465) serviceInfo = 'SMTPS Mail Server';
else if (port === 21) serviceInfo = 'FTP Server';
else if (port === 3389) serviceInfo = 'RDP Server';
else if (port === 5900) serviceInfo = 'VNC Server';
else if (port === 3306) serviceInfo = 'MySQL Database';
else if (port === 5432) serviceInfo = 'PostgreSQL Database';
else if (port === 1433) serviceInfo = 'MSSQL Database';
else if (port === 27017) serviceInfo = 'MongoDB Database';
else if (port === 6379) serviceInfo = 'Redis Database';
else if (port === 9200) serviceInfo = 'Elasticsearch';
else if (port === 5672) serviceInfo = 'RabbitMQ';
else if (port === 9092) serviceInfo = 'Kafka';
else if (port === 2181) serviceInfo = 'Zookeeper';
else if (port === 6443) serviceInfo = 'Kubernetes API';
else if (port === 2375 || port === 2376) serviceInfo = 'Docker API';
else if (port === 25565) serviceInfo = 'Minecraft Server';
else if (port === 1883) serviceInfo = 'MQTT Broker';
else if (port === 161) serviceInfo = 'SNMP Agent';
else if (port === 389) serviceInfo = 'LDAP Server';
else if (port === 636) serviceInfo = 'LDAPS Server';
wsResolve({
success: true,
protocol: 'TCP',