Skip to content

Commit 2e838d7

Browse files
committed
Fix minor bugs discovered when testing.
1 parent 7e2fc14 commit 2e838d7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

lib/rex/exploitation/javascriptosdetect.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ window.os_detect.getVersion = function(){
4545
var version = "";
4646
var unknown_fingerprint = null;
4747

48+
var css_is_valid = function(prop, propCamelCase, css) {
49+
if (!document.createElement) return false;
50+
var d = document.createElement('div');
51+
d.setAttribute('style', prop+": "+css+";")
52+
return d.style[propCamelCase] === css;
53+
}
54+
4855
//--
4956
// Client
5057
//--
@@ -179,12 +186,15 @@ window.os_detect.getVersion = function(){
179186
if (!ua_version || 0 == ua_version.length) {
180187
ua_is_lying = true;
181188
}
182-
} else if (!document.all && navigator.taintEnabled) {
189+
} else if (!document.all && navigator.taintEnabled ||
190+
'MozBlobBuilder' in window) {
183191
// Use taintEnabled to identify FF since other recent browsers
184192
// implement window.getComputedStyle now. For some reason, checking for
185193
// taintEnabled seems to cause IE 6 to stop parsing, so make sure this
186194
// isn't IE first.
187-
//
195+
196+
// Also check MozBlobBuilder because FF 9.0.1 does not support taintEnabled
197+
188198
// Then this is a Gecko derivative, assume Firefox since that's the
189199
// only one we have sploits for. We may need to revisit this in the
190200
// future. This works for multi/browser/mozilla_compareto against
@@ -201,19 +211,20 @@ window.os_detect.getVersion = function(){
201211
ua_version = '21.0'
202212
} else if ('imul' in Math) {
203213
ua_version = '20.0'
204-
} else if ('HTMLCanvasElement' in window &&
205-
'toBlob' in HTMLCanvasElement.prototype) {
214+
} else if (css_is_valid('font-size', 'fontSize', '23vmax')) {
215+
// this is fuxored
206216
ua_version = '19.0'
207217
} else if ('devicePixelRatio' in window) {
208218
ua_version = '18.0'
209-
} else if ('HTMLIFrameElement' in window &&
210-
'sandbox' in HTMLIFrameElement.prototype) {
219+
} else if ('createElement' in document &&
220+
document.createElement('iframe') &&
221+
'sandbox' in document.createElement('iframe')) {
211222
ua_version = '17.0'
212-
} else if ('CSS2Properties' in window &&
213-
'animation' in CSS2Properties.prototype) {
223+
} else if ('mozApps' in navigator && 'install' in navigator.mozApps) {
214224
ua_version = '16.0'
215225
} else if ('HTMLSourceElement' in window &&
216-
'media' in HTMLSourceElement.prototype) {
226+
HTMLSourceElement.prototype &&
227+
'media' in HTMLSourceElement.prototype) {
217228
ua_version = '15.0'
218229
} else if ('mozRequestPointerLock' in document.body) {
219230
ua_version = '14.0'
@@ -223,7 +234,9 @@ window.os_detect.getVersion = function(){
223234
ua_version = "12.0";
224235
} else if ('mozVibrate' in navigator) {
225236
ua_version = "11.0";
226-
} else if ('mozCancelFullScreen' in document) {
237+
} else if (css_is_valid('-moz-backface-visibility', 'MozBackfaceVisibility', 'preserve-3d')) {
238+
ua_version = "10.0";
239+
} else if ('doNotTrack' in navigator) {
227240
ua_version = "9.0";
228241
} else if ('insertAdjacentHTML' in document.body) {
229242
ua_version = "8.0";
@@ -248,7 +261,6 @@ window.os_detect.getVersion = function(){
248261
} else {
249262
ua_version = "1";
250263
}
251-
252264
if (navigator.oscpu != navigator.platform) {
253265
ua_is_lying = true;
254266
}

0 commit comments

Comments
 (0)