盒子
盒子
文章目录
  1. IP地址获取
  2. FTP端口扫描
  3. 获取浏览器插件列表:
  4. 获取flash版本
  5. 获取Java版本
  6. 参考链接

JS可以实现的一些好玩的功能

本文非原创,所写都是我验证过的,介绍JS可以实现的一些好玩的功能

本文主要还是收集了一些关于WebRTC的一些实用的例子,运用于信息收集,下文的资源都是别人写的,感谢大牛们的分享

IP地址获取

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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h4>
Demo for:
<a href="https://github.com/diafygi/webrtc-ips">
https://github.com/diafygi/webrtc-ips
</a>
</h4>
<p>
This demo secretly makes requests to STUN servers that can log your
request. These requests do not show up in developer consoles and
cannot be blocked by browser plugins (AdBlock, Ghostery, etc.).
</p>
<h4>Your local IP addresses:</h4>
<ul></ul>
<h4>Your public IP addresses:</h4>
<ul></ul>
<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
<script>
//get the IP addresses associated with an account
function getIPs(callback){
var ip_dups = {};
//compatibility for firefox and chrome
var RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
var useWebKit = !!window.webkitRTCPeerConnection;
//bypass naive webrtc blocking using an iframe
if(!RTCPeerConnection){
//NOTE: you need to have an iframe in the page right above the script tag
//
//<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
//<script>...getIPs called in here...
//
var win = iframe.contentWindow;
RTCPeerConnection = win.RTCPeerConnection
|| win.mozRTCPeerConnection
|| win.webkitRTCPeerConnection;
useWebKit = !!win.webkitRTCPeerConnection;
}
//minimal requirements for data connection
var mediaConstraints = {
optional: [{RtpDataChannels: true}]
};
//firefox already has a default stun server in about:config
// media.peerconnection.default_iceservers =
// [{"url": "stun:stun.services.mozilla.com"}]
var servers = undefined;
//add same stun server for chrome
if(useWebKit)
servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
//construct a new RTCPeerConnection
var pc = new RTCPeerConnection(servers, mediaConstraints);
function handleCandidate(candidate){
//match just the IP address
var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3})/
var ip_addr = ip_regex.exec(candidate)[1];
//remove duplicates
if(ip_dups[ip_addr] === undefined)
callback(ip_addr);
ip_dups[ip_addr] = true;
}
//listen for candidate events
pc.onicecandidate = function(ice){
//skip non-candidate events
if(ice.candidate)
handleCandidate(ice.candidate.candidate);
};
//create a bogus data channel
pc.createDataChannel("");
//create an offer sdp
pc.createOffer(function(result){
//trigger the stun server request
pc.setLocalDescription(result, function(){}, function(){});
}, function(){});
//wait for a while to let everything done
setTimeout(function(){
//read candidate info from local description
var lines = pc.localDescription.sdp.split('\n');
lines.forEach(function(line){
if(line.indexOf('a=candidate:') === 0)
handleCandidate(line);
});
}, 1000);
}
//insert IP addresses into the page
getIPs(function(ip){
var li = document.createElement("li");
li.textContent = ip;
//local IPs
if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/))
document.getElementsByTagName("ul")[0].appendChild(li);
//assume the rest are public IPs
else
document.getElementsByTagName("ul")[1].appendChild(li);
});
</script>

</body>
</html>

FTP端口扫描

1
<script src="ftp://50.116.13.6" onload="alert('21 open')"></script>

获取浏览器插件列表:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function plugin_list()
{

var agent = navigator.userAgent.toLowerCase();
var all = new Array();
if (navigator.plugins && navigator.plugins.length)
{
for (x = 0; x < navigator.plugins.length; x++)
{
all.push(navigator.plugins[x].name.replace(/,/g, " ") + "(Name:" + navigator.plugins[x].filename.replace(/,/g, " ") + ")");
}
}
all=all.join("\r\n");
return all;
}
alert(plugin_list());

获取flash版本

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
function flashver() {
var flash = function() {};
flash.prototype.controlVersion = function() {
var version;
var axo;
var e;
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
version = axo.GetVariable("$version")
} catch(e) {}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
version = "WIN 6,0,21,0";
axo.AllowScriptAccess = "always";
version = axo.GetVariable("$version")
} catch(e) {}
}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
version = axo.GetVariable("$version")
} catch(e) {}
}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
version = "WIN 3,0,18,0"
} catch(e) {}
}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
version = "WIN 2,0,0,11"
} catch(e) {
version = -1
}
}
var verArr = version.toString().split(",");
var str = "";
for (var i = 0,
l = verArr.length; i < l; i++) {
if (verArr[i].indexOf("WIN") != -1) {
str += verArr[i].substring(3);
str += "."
} else {
if (i == (l - 1)) {
str += verArr[i]
} else {
str += verArr[i];
str += "."
}
}
}
return (str)
};
flash.prototype.getSwfVer = function() {
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true: false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true: false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true: false;
var flashVer = -1;
if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0": "";
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
var descArray = flashDescription.split(" ");
var tempArrayMajor = descArray[2].split(".");
var versionMajor = tempArrayMajor[0];
var versionMinor = tempArrayMajor[1];
var versionRevision = descArray[3];
if (versionRevision == "") {
versionRevision = descArray[4]
}
if (versionRevision[0] == "d") {
versionRevision = versionRevision.substring(1)
} else {
if (versionRevision[0] == "r") {
versionRevision = versionRevision.substring(1);
if (versionRevision.indexOf("d") > 0) {
versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"))
}
}
}
var flashVer = versionMajor + "." + versionMinor + "." + versionRevision
}
} else {
if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) {
flashVer = 4
} else {
if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) {
flashVer = 3
} else {
if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) {
flashVer = 2
} else {
if (isIE && isWin && !isOpera) {
flashVer = new flash().controlVersion()
}
}
}
}
}
return flashVer
};
if (flash.prototype.getSwfVer() == -1) {
return "No Flash!"
} else {
return "Shockwave Flash " + flash.prototype.getSwfVer()
}
}
alert(flashver());

获取Java版本

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
function java() {
var deployJava = function() {
var l = {
core: ["id", "class", "title", "style"],
i18n: ["lang", "dir"],
events: ["onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup"],
applet: ["codebase", "code", "name", "archive", "object", "width", "height", "alt", "align", "hspace", "vspace"],
object: ["classid", "codebase", "codetype", "data", "type", "archive", "declare", "standby", "height", "width", "usemap", "name", "tabindex", "align", "border", "hspace", "vspace"]
};
var b = l.object.concat(l.core, l.i18n, l.events);
var m = l.applet.concat(l.core);
function g(n) {
if (!d.debug) {
return
}
if (console.log) {
console.log(n)
} else {
alert(n)
}
}
function k(o, n) {
if (o == null || o.length == 0) {
return true
}
var q = o.charAt(o.length - 1);
if (q != "+" && q != "*" && (o.indexOf("_") != -1 && q != "_")) {
o = o + "*";
q = "*"
}
o = o.substring(0, o.length - 1);
if (o.length > 0) {
var p = o.charAt(o.length - 1);
if (p == "." || p == "_") {
o = o.substring(0, o.length - 1)
}
}
if (q == "*") {
return (n.indexOf(o) == 0)
} else {
if (q == "+") {
return o <= n
}
}
return false
}
function e() {
var n = "//java.com/js/webstart.png";
try {
return document.location.protocol.indexOf("http") != -1 ? n: "http:" + n
} catch(o) {
return "http:" + n
}
}
function j(p, o) {
var n = p.length;
for (var q = 0; q < n; q++) {
if (p[q] === o) {
return true
}
}
return false
}
function c(n) {
return j(m, n.toLowerCase())
}
function i(n) {
return j(b, n.toLowerCase())
}
function a(n) {
if ("MSIE" != deployJava.browserName) {
return true
}
if (deployJava.compareVersionToPattern(deployJava.getPlugin().version, ["10", "0", "0"], false, true)) {
return true
}
if (n == null) {
return false
}
return ! k("1.6.0_33+", n)
}
var d = {
debug: null,
version: "20120801",
firefoxJavaVersion: null,
myInterval: null,
preInstallJREList: null,
returnPage: null,
brand: null,
locale: null,
installType: null,
EAInstallEnabled: false,
EarlyAccessURL: null,
getJavaURL: "http://jdl.sun.com/webapps/getjava/BrowserRedirect?host=java.com",
oldMimeType: "application/npruntime-scriptable-plugin;DeploymentToolkit",
mimeType: "application/java-deployment-toolkit",
launchButtonPNG: e(),
browserName: null,
browserName2: null,
getJREs: function() {
var r = new Array();
if (this.isPluginInstalled()) {
var q = this.getPlugin();
var n = q.jvms;
for (var p = 0; p < n.getLength(); p++) {
r[p] = n.get(p).version
}
} else {
var o = this.getBrowser();
if (o == "MSIE") {
if (this.testUsingActiveX("1.7.0")) {
r[0] = "1.7.0"
} else {
if (this.testUsingActiveX("1.6.0")) {
r[0] = "1.6.0"
} else {
if (this.testUsingActiveX("1.5.0")) {
r[0] = "1.5.0"
} else {
if (this.testUsingActiveX("1.4.2")) {
r[0] = "1.4.2"
} else {
if (this.testForMSVM()) {
r[0] = "1.1"
}
}
}
}
}
} else {
if (o == "Netscape Family") {
this.getJPIVersionUsingMimeType();
if (this.firefoxJavaVersion != null) {
r[0] = this.firefoxJavaVersion
} else {
if (this.testUsingMimeTypes("1.7")) {
r[0] = "1.7.0"
} else {
if (this.testUsingMimeTypes("1.6")) {
r[0] = "1.6.0"
} else {
if (this.testUsingMimeTypes("1.5")) {
r[0] = "1.5.0"
} else {
if (this.testUsingMimeTypes("1.4.2")) {
r[0] = "1.4.2"
} else {
if (this.browserName2 == "Safari") {
if (this.testUsingPluginsArray("1.7.0")) {
r[0] = "1.7.0"
} else {
if (this.testUsingPluginsArray("1.6")) {
r[0] = "1.6.0"
} else {
if (this.testUsingPluginsArray("1.5")) {
r[0] = "1.5.0"
} else {
if (this.testUsingPluginsArray("1.4.2")) {
r[0] = "1.4.2"
}
}
}
}
}
}
}
}
}
}
}
}
}
if (this.debug) {
for (var p = 0; p < r.length; ++p) {
g("[getJREs()] We claim to have detected Java SE " + r[p])
}
}
return r
},
installJRE: function(q, o) {
var n = false;
if (this.isPluginInstalled() && this.isAutoInstallEnabled(q)) {
var p = false;
if (this.isCallbackSupported()) {
p = this.getPlugin().installJRE(q, o)
} else {
p = this.getPlugin().installJRE(q)
}
if (p) {
this.refresh();
if (this.returnPage != null) {
document.location = this.returnPage
}
}
return p
} else {
return this.installLatestJRE()
}
},
isAutoInstallEnabled: function(n) {
if (!this.isPluginInstalled()) {
return false
}
if (typeof n == "undefined") {
n = null
}
return a(n)
},
isCallbackSupported: function() {
return this.isPluginInstalled() && this.compareVersionToPattern(this.getPlugin().version, ["10", "2", "0"], false, true)
},
installLatestJRE: function(p) {
if (this.isPluginInstalled() && this.isAutoInstallEnabled()) {
var q = false;
if (this.isCallbackSupported()) {
q = this.getPlugin().installLatestJRE(p)
} else {
q = this.getPlugin().installLatestJRE()
}
if (q) {
this.refresh();
if (this.returnPage != null) {
document.location = this.returnPage
}
}
return q
} else {
var o = this.getBrowser();
var n = navigator.platform.toLowerCase();
if ((this.EAInstallEnabled == "true") && (n.indexOf("win") != -1) && (this.EarlyAccessURL != null)) {
this.preInstallJREList = this.getJREs();
if (this.returnPage != null) {
this.myInterval = setInterval("deployJava.poll()", 3000)
}
location.href = this.EarlyAccessURL;
return false
} else {
if (o == "MSIE") {
return this.IEInstall()
} else {
if ((o == "Netscape Family") && (n.indexOf("win32") != -1)) {
return this.FFInstall()
} else {
location.href = this.getJavaURL + ((this.returnPage != null) ? ("&returnPage=" + this.returnPage) : "") + ((this.locale != null) ? ("&locale=" + this.locale) : "") + ((this.brand != null) ? ("&brand=" + this.brand) : "")
}
}
return false
}
}
},
runApplet: function(o, t, q) {
if (q == "undefined" || q == null) {
q = "1.1"
}
var r = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
var n = q.match(r);
if (this.returnPage == null) {
this.returnPage = document.location
}
if (n != null) {
var p = this.getBrowser();
if (p != "?") {
if (this.versionCheck(q + "+")) {
this.writeAppletTag(o, t)
} else {
if (this.installJRE(q + "+")) {
this.refresh();
location.href = document.location;
this.writeAppletTag(o, t)
}
}
} else {
this.writeAppletTag(o, t)
}
} else {
g("[runApplet()] Invalid minimumVersion argument to runApplet():" + q)
}
},
writeAppletTag: function(q, v) {
var n = "<applet ";
var p = "";
var r = "</applet>";
var w = true;
if (null == v || typeof v != "object") {
v = new Object()
}
for (var o in q) {
if (!c(o)) {
v[o] = q[o]
} else {
n += (" " + o + '="' + q[o] + '"');
if (o == "code") {
w = false
}
}
}
var u = false;
for (var t in v) {
if (t == "codebase_lookup") {
u = true
}
if (t == "object" || t == "java_object" || t == "java_code") {
w = false
}
p += '<param name="' + t + '" value="' + v[t] + '"/>'
}
if (!u) {
p += '<param name="codebase_lookup" value="false"/>'
}
if (w) {
n += (' code="dummy"')
}
n += ">";
document.write(n + "\n" + p + "\n" + r)
},
versionCheck: function(o) {
var u = 0;
var w = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$";
var x = o.match(w);
if (x != null) {
var q = false;
var t = false;
var p = new Array();
for (var r = 1; r < x.length; ++r) {
if ((typeof x[r] == "string") && (x[r] != "")) {
p[u] = x[r];
u++
}
}
if (p[p.length - 1] == "+") {
t = true;
q = false;
p.length--
} else {
if (p[p.length - 1] == "*") {
t = false;
q = true;
p.length--
} else {
if (p.length < 4) {
t = false;
q = true
}
}
}
var v = this.getJREs();
for (var r = 0; r < v.length; ++r) {
if (this.compareVersionToPattern(v[r], p, q, t)) {
return true
}
}
return false
} else {
var n = "Invalid versionPattern passed to versionCheck: " + o;
g("[versionCheck()] " + n);
alert(n);
return false
}
},
isWebStartInstalled: function(q) {
var p = this.getBrowser();
if (p == "?") {
return true
}
if (q == "undefined" || q == null) {
q = "1.4.2"
}
var o = false;
var r = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
var n = q.match(r);
if (n != null) {
o = this.versionCheck(q + "+")
} else {
g("[isWebStartInstaller()] Invalid minimumVersion argument to isWebStartInstalled(): " + q);
o = this.versionCheck("1.4.2+")
}
return o
},
getJPIVersionUsingMimeType: function() {
for (var o = 0; o < navigator.mimeTypes.length; ++o) {
var p = navigator.mimeTypes[o].type;
var n = p.match(/^application\/x-java-applet;jpi-version=(.*)$/);
if (n != null) {
this.firefoxJavaVersion = n[1];
if ("Opera" != this.browserName2) {
break
}
}
}
},
launchWebStartApplication: function(q) {
var n = navigator.userAgent.toLowerCase();
this.getJPIVersionUsingMimeType();
if (this.isWebStartInstalled("1.7.0") == false) {
if ((this.installJRE("1.7.0+") == false) || ((this.isWebStartInstalled("1.7.0") == false))) {
return false
}
}
var t = null;
if (document.documentURI) {
t = document.documentURI
}
if (t == null) {
t = document.URL
}
var o = this.getBrowser();
var p;
if (o == "MSIE") {
p = '<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="0" height="0"><PARAM name="launchjnlp" value="' + q + '"><PARAM name="docbase" value="' + t + '"></object>'
} else {
if (o == "Netscape Family") {
p = '<embed type="application/x-java-applet;jpi-version=' + this.firefoxJavaVersion + '" width="0" height="0" launchjnlp="' + q + '"docbase="' + t + '" />'
}
}
if (document.body == "undefined" || document.body == null) {
document.write(p);
document.location = t
} else {
var r = document.createElement("div");
r.id = "div1";
r.style.position = "relative";
r.style.left = "-10000px";
r.style.margin = "0px auto";
r.className = "dynamicDiv";
r.innerHTML = p;
document.body.appendChild(r)
}
},
createWebStartLaunchButtonEx: function(p, o) {
if (this.returnPage == null) {
this.returnPage = p
}
var n = "javascript:deployJava.launchWebStartApplication('" + p + "');";
document.write('<a href="' + n + '" onMouseOver="window.status=\'\'; return true;"><img src="' + this.launchButtonPNG + '" border="0" /></a>')
},
createWebStartLaunchButton: function(p, o) {
if (this.returnPage == null) {
this.returnPage = p
}
var n = "javascript:if (!deployJava.isWebStartInstalled(&quot;" + o + "&quot;)) {if (deployJava.installLatestJRE()) {if (deployJava.launch(&quot;" + p + "&quot;)) {}}} else {if (deployJava.launch(&quot;" + p + "&quot;)) {}}";
document.write('<a href="' + n + '" onMouseOver="window.status=\'\'; return true;"><img src="' + this.launchButtonPNG + '" border="0" /></a>')
},
launch: function(n) {
document.location = n;
return true
},
isPluginInstalled: function() {
var n = this.getPlugin();
if (n && n.jvms) {
return true
} else {
return false
}
},
isAutoUpdateEnabled: function() {
if (this.isPluginInstalled()) {
return this.getPlugin().isAutoUpdateEnabled()
}
return false
},
setAutoUpdateEnabled: function() {
if (this.isPluginInstalled()) {
return this.getPlugin().setAutoUpdateEnabled()
}
return false
},
setInstallerType: function(n) {
this.installType = n;
if (this.isPluginInstalled()) {
return this.getPlugin().setInstallerType(n)
}
return false
},
setAdditionalPackages: function(n) {
if (this.isPluginInstalled()) {
return this.getPlugin().setAdditionalPackages(n)
}
return false
},
setEarlyAccess: function(n) {
this.EAInstallEnabled = n
},
isPlugin2: function() {
if (this.isPluginInstalled()) {
if (this.versionCheck("1.6.0_10+")) {
try {
return this.getPlugin().isPlugin2()
} catch(n) {}
}
}
return false
},
allowPlugin: function() {
this.getBrowser();
var n = ("Safari" != this.browserName2 && "Opera" != this.browserName2);
return n
},
getPlugin: function() {
this.refresh();
var n = null;
if (this.allowPlugin()) {
n = document.getElementById("deployJavaPlugin")
}
return n
},
compareVersionToPattern: function(u, o, q, r) {
if (u == undefined || o == undefined) {
return false
}
var v = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
var w = u.match(v);
if (w != null) {
var t = 0;
var x = new Array();
for (var p = 1; p < w.length; ++p) {
if ((typeof w[p] == "string") && (w[p] != "")) {
x[t] = w[p];
t++
}
}
var n = Math.min(x.length, o.length);
if (r) {
for (var p = 0; p < n; ++p) {
if (x[p] < o[p]) {
return false
} else {
if (x[p] > o[p]) {
return true
}
}
}
return true
} else {
for (var p = 0; p < n; ++p) {
if (x[p] != o[p]) {
return false
}
}
if (q) {
return true
} else {
return (x.length == o.length)
}
}
} else {
return false
}
},
getBrowser: function() {
if (this.browserName == null) {
var n = navigator.userAgent.toLowerCase();
g("[getBrowser()] navigator.userAgent.toLowerCase() -> " + n);
if ((n.indexOf("msie") != -1) && (n.indexOf("opera") == -1)) {
this.browserName = "MSIE";
this.browserName2 = "MSIE"
} else {
if (n.indexOf("iphone") != -1) {
this.browserName = "Netscape Family";
this.browserName2 = "iPhone"
} else {
if ((n.indexOf("firefox") != -1) && (n.indexOf("opera") == -1)) {
this.browserName = "Netscape Family";
this.browserName2 = "Firefox"
} else {
if (n.indexOf("chrome") != -1) {
this.browserName = "Netscape Family";
this.browserName2 = "Chrome"
} else {
if (n.indexOf("safari") != -1) {
this.browserName = "Netscape Family";
this.browserName2 = "Safari"
} else {
if ((n.indexOf("mozilla") != -1) && (n.indexOf("opera") == -1)) {
this.browserName = "Netscape Family";
this.browserName2 = "Other"
} else {
if (n.indexOf("opera") != -1) {
this.browserName = "Netscape Family";
this.browserName2 = "Opera"
} else {
this.browserName = "?";
this.browserName2 = "unknown"
}
}
}
}
}
}
}
g("[getBrowser()] Detected browser name:" + this.browserName + ", " + this.browserName2)
}
return this.browserName
},
testUsingActiveX: function(n) {
var p = "JavaWebStart.isInstalled." + n + ".0";
if (typeof ActiveXObject == "undefined" || !ActiveXObject) {
g("[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?");
return false
}
try {
return (new ActiveXObject(p) != null)
} catch(o) {
return false
}
},
testForMSVM: function() {
var o = "{08B0E5C0-4FCB-11CF-AAA5-00401C608500}";
if (typeof oClientCaps != "undefined") {
var n = oClientCaps.getComponentVersion(o, "ComponentID");
if ((n == "") || (n == "5,0,5000,0")) {
return false
} else {
return true
}
} else {
return false
}
},
testUsingMimeTypes: function(o) {
if (!navigator.mimeTypes) {
g("[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?");
return false
}
for (var p = 0; p < navigator.mimeTypes.length; ++p) {
s = navigator.mimeTypes[p].type;
var n = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
if (n != null) {
if (this.compareVersions(n[1], o)) {
return true
}
}
}
return false
},
testUsingPluginsArray: function(o) {
if ((!navigator.plugins) || (!navigator.plugins.length)) {
return false
}
var n = navigator.platform.toLowerCase();
for (var p = 0; p < navigator.plugins.length; ++p) {
s = navigator.plugins[p].description;
if (s.search(/^Java Switchable Plug-in (Cocoa)/) != -1) {
if (this.compareVersions("1.5.0", o)) {
return true
}
} else {
if (s.search(/^Java/) != -1) {
if (n.indexOf("win") != -1) {
if (this.compareVersions("1.5.0", o) || this.compareVersions("1.6.0", o)) {
return true
}
}
}
}
}
if (this.compareVersions("1.5.0", o)) {
return true
}
return false
},
IEInstall: function() {
location.href = this.getJavaURL + ((this.returnPage != null) ? ("&returnPage=" + this.returnPage) : "") + ((this.locale != null) ? ("&locale=" + this.locale) : "") + ((this.brand != null) ? ("&brand=" + this.brand) : "");
return false
},
done: function(o, n) {},
FFInstall: function() {
location.href = this.getJavaURL + ((this.returnPage != null) ? ("&returnPage=" + this.returnPage) : "") + ((this.locale != null) ? ("&locale=" + this.locale) : "") + ((this.brand != null) ? ("&brand=" + this.brand) : "") + ((this.installType != null) ? ("&type=" + this.installType) : "");
return false
},
compareVersions: function(q, r) {
var o = q.split(".");
var n = r.split(".");
for (var p = 0; p < o.length; ++p) {
o[p] = Number(o[p])
}
for (var p = 0; p < n.length; ++p) {
n[p] = Number(n[p])
}
if (o.length == 2) {
o[2] = 0
}
if (o[0] > n[0]) {
return true
}
if (o[0] < n[0]) {
return false
}
if (o[1] > n[1]) {
return true
}
if (o[1] < n[1]) {
return false
}
if (o[2] > n[2]) {
return true
}
if (o[2] < n[2]) {
return false
}
return true
},
enableAlerts: function() {
this.browserName = null;
this.debug = true
},
poll: function() {
this.refresh();
var n = this.getJREs();
if ((this.preInstallJREList.length == 0) && (n.length != 0)) {
clearInterval(this.myInterval);
if (this.returnPage != null) {
location.href = this.returnPage
}
}
if ((this.preInstallJREList.length != 0) && (n.length != 0) && (this.preInstallJREList[0] != n[0])) {
clearInterval(this.myInterval);
if (this.returnPage != null) {
location.href = this.returnPage
}
}
},
writePluginTag: function() {
var n = this.getBrowser();
if (n == "MSIE") {} else {
if (n == "Netscape Family" && this.allowPlugin()) {
this.writeEmbedTag()
}
}
},
refresh: function() {
navigator.plugins.refresh(false);
var n = this.getBrowser();
if (n == "Netscape Family" && this.allowPlugin()) {
var o = document.getElementById("deployJavaPlugin");
if (o == null) {
this.writeEmbedTag()
}
}
},
writeEmbedTag: function() {
var n = false;
if (navigator.mimeTypes != null) {
for (var o = 0; o < navigator.mimeTypes.length; o++) {
if (navigator.mimeTypes[o].type == this.mimeType) {
if (navigator.mimeTypes[o].enabledPlugin) {
n = true
}
}
}
if (!n) {
for (var o = 0; o < navigator.mimeTypes.length; o++) {
if (navigator.mimeTypes[o].type == this.oldMimeType) {
if (navigator.mimeTypes[o].enabledPlugin) {}
}
}
}
}
}
};
d.writePluginTag();
if (d.locale == null) {
var h = null;
if (h == null) {
try {
h = navigator.userLanguage
} catch(f) {}
}
if (h == null) {
try {
h = navigator.systemLanguage
} catch(f) {}
}
if (h == null) {
try {
h = navigator.language
} catch(f) {}
}
if (h != null) {
h.replace("-", "_");
d.locale = h
}
}
return d
} ();
var temp = deployJava.getJREs();
var re = "";
if (temp == "") {
re = "No Java or Disable!";
} else {
re = "Java Version is:" + temp;
}
return re;
}
alert(java());

参考链接

获得flash版本 http://jsbin.com/rukirayuca
获得java版本 http://jsbin.com/cabirudale
获得插件列表 http://jsbin.com/vejujatuxa
获得内网IP http://jsbin.com/riyisavura
扫描HTTP端口 http://jsbin.com/ziwununivo
扫描WEB容器 http://jsbin.com/piwemaquwa
扫描FTP端口 http://jsbin.com/kulahicide
通过WebRTC获取内网和公网真实IP地址 http://borghan.com/archives/get-local-and-real-public-IP-via-WebRTC.html