Skip to content

Commit 757cf18

Browse files
committed
Land rapid7#2135 - Update FF detection
2 parents 6c59e30 + 92ae90b commit 757cf18

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

lib/rex/exploitation/javascriptosdetect.js

Lines changed: 43 additions & 5 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,24 +186,56 @@ 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
191201
// Firefox and Mozilla, so it's probably good enough for now.
192202
ua_name = clients_ff;
193203
// Thanks to developer.mozilla.org "Firefox for developers" series for most
194204
// of these.
195-
if ('mozConnection' in navigator) {
205+
// Release changelogs: http://www.mozilla.org/en-US/firefox/releases/
206+
if ('HTMLTimeElement' in window) {
207+
ua_version = '22.0'
208+
} else if ('createElement' in document &&
209+
document.createElement('main') &&
210+
document.createElement('main').constructor === window['HTMLElement']) {
211+
ua_version = '21.0'
212+
} else if ('imul' in Math) {
213+
ua_version = '20.0'
214+
} else if (css_is_valid('font-size', 'fontSize', '23vmax')) {
215+
ua_version = '19.0'
216+
} else if ('devicePixelRatio' in window) {
217+
ua_version = '18.0'
218+
} else if ('createElement' in document &&
219+
document.createElement('iframe') &&
220+
'sandbox' in document.createElement('iframe')) {
221+
ua_version = '17.0'
222+
} else if ('mozApps' in navigator && 'install' in navigator.mozApps) {
223+
ua_version = '16.0'
224+
} else if ('HTMLSourceElement' in window &&
225+
HTMLSourceElement.prototype &&
226+
'media' in HTMLSourceElement.prototype) {
227+
ua_version = '15.0'
228+
} else if ('mozRequestPointerLock' in document.body) {
229+
ua_version = '14.0'
230+
} else if ('Map' in window) {
231+
ua_version = "13.0"
232+
} else if ('mozConnection' in navigator) {
196233
ua_version = "12.0";
197234
} else if ('mozVibrate' in navigator) {
198235
ua_version = "11.0";
199-
} else if ('mozCancelFullScreen' in document) {
236+
} else if (css_is_valid('-moz-backface-visibility', 'MozBackfaceVisibility', 'hidden')) {
237+
ua_version = "10.0";
238+
} else if ('doNotTrack' in navigator) {
200239
ua_version = "9.0";
201240
} else if ('insertAdjacentHTML' in document.body) {
202241
ua_version = "8.0";
@@ -221,7 +260,6 @@ window.os_detect.getVersion = function(){
221260
} else {
222261
ua_version = "1";
223262
}
224-
225263
if (navigator.oscpu != navigator.platform) {
226264
ua_is_lying = true;
227265
}

0 commit comments

Comments
 (0)