Merge pull request #1434 from gregmolnar/edge_detection

detect microsoft edge
This commit is contained in:
Brendan Coles
2017-08-29 16:56:42 +10:00
committed by GitHub
6 changed files with 40 additions and 16 deletions

View File

@@ -109,6 +109,15 @@ beef.browser = {
return !!window.XMLHttpRequest && !window.chrome && !window.opera && !!document.documentMode && !!window.performance && typeof navigator.msMaxTouchPoints !== "undefined" && typeof document.selection === "undefined" && typeof document.createStyleSheet === "undefined" && typeof window.createPopup === "undefined" && typeof window.XDomainRequest === "undefined";
},
/**
*
* Returns true if Edge.
* @example: beef.browser.isEdge()
*/
isEdge: function () {
return !beef.browser.isIE() && !!window.StyleMedia;
},
/**
* Returns true if IE.
* @example: beef.browser.isIE()
@@ -1261,7 +1270,7 @@ beef.browser = {
isC51iOS: function () {
return (!window.webkitPerformance && window.navigator.appVersion.match(/CriOS\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/CriOS\/(\d+)\./)[1], 10) == 51) ? true : false);
},
/**
* Returns true if Chrome 52.
* @example: beef.browser.isC52()
@@ -1269,15 +1278,15 @@ beef.browser = {
isC52: function () {
return (!!window.chrome && !!window.fetch && !window.webkitPerformance && window.navigator.appVersion.match(/Chrome\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10) == 52) ? true : false);
},
/**
* Returns true if Chrome for iOS 52.
* Returns true if Chrome for iOS 52.
* @example: beef.browser.isC52iOS()
*/
isC52iOS: function () {
return (!window.webkitPerformance && window.navigator.appVersion.match(/CriOS\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/CriOS\/(\d+)\./)[1], 10) == 52) ? true : false);
},
/**
* Returns true if Chrome 53.
* @example: beef.browser.isC53()
@@ -1285,7 +1294,7 @@ beef.browser = {
isC53: function () {
return (!!window.chrome && !!window.fetch && !window.webkitPerformance && window.navigator.appVersion.match(/Chrome\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10) == 53) ? true : false);
},
/**
* Returns true if Chrome for iOS 53.
* @example: beef.browser.isC53iOS()
@@ -1293,7 +1302,7 @@ beef.browser = {
isC53iOS: function () {
return (!window.webkitPerformance && window.navigator.appVersion.match(/CriOS\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/CriOS\/(\d+)\./)[1], 10) == 53) ? true : false);
},
/**
* Returns true if Chrome 54.
* @example: beef.browser.isC54()
@@ -1301,15 +1310,15 @@ beef.browser = {
isC54: function () {
return (!!window.chrome && !!window.fetch && !window.webkitPerformance && window.navigator.appVersion.match(/Chrome\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10) == 54) ? true : false);
},
/**
* Returns true if Chrome for iOS 54.
* @example: beef.browser.isC54iOS()
*/
isC54iOS: function () {
return (!window.webkitPerformance && window.navigator.appVersion.match(/CriOS\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/CriOS\/(\d+)\./)[1], 10) == 54) ? true : false);
},
},
/**
* Returns true if Chrome 55.
* @example: beef.browser.isC55()
@@ -1317,15 +1326,15 @@ beef.browser = {
isC55: function () {
return (!!window.chrome && !!window.fetch && !window.webkitPerformance && window.navigator.appVersion.match(/Chrome\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10) == 55) ? true : false);
},
/**
* Returns true if Chrome for iOS 55.
* @example: beef.browser.isC55iOS()
*/
isC55iOS: function () {
return (!window.webkitPerformance && window.navigator.appVersion.match(/CriOS\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/CriOS\/(\d+)\./)[1], 10) == 55) ? true : false);
},
},
/**
* Returns true if Chrome 56.
* @example: beef.browser.isC56()
@@ -1333,7 +1342,7 @@ beef.browser = {
isC56: function () {
return (!!window.chrome && !!window.fetch && !window.webkitPerformance && window.navigator.appVersion.match(/Chrome\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10) == 56) ? true : false);
},
/**
* Returns true if Chrome for iOS 56.
* @example: beef.browser.isC56iOS()
@@ -1341,7 +1350,7 @@ beef.browser = {
isC56iOS: function () {
return (!window.webkitPerformance && window.navigator.appVersion.match(/CriOS\/(\d+)\./)) && ((parseInt(window.navigator.appVersion.match(/CriOS\/(\d+)\./)[1], 10) == 56) ? true : false);
},
/**
* Returns true if Chrome 57.
* @example: beef.browser.isC57()
@@ -1546,7 +1555,6 @@ beef.browser = {
C57iOS: this.isC57iOS(), // Chrome 57 on iOS
C58: this.isC58(), // Chrome 58
C58iOS: this.isC58iOS(), // Chrome 58 on iOS
C: this.isC(), // Chrome any version
FF2: this.isFF2(), // Firefox 2
@@ -2016,7 +2024,7 @@ beef.browser = {
}
; // Chrome 58 for iOS
if (this.isFF2()) {
return '2'
}
@@ -2267,6 +2275,11 @@ beef.browser = {
}
; // Internet Explorer 11
if (this.isEdge()) {
return '1'
}
; // Microsoft Edge
if (this.isS4()) {
return '4'
}
@@ -2333,6 +2346,10 @@ beef.browser = {
return 'IE'
}
; // Internet Explorer any version
if (this.isEdge()) {
return 'E'
}
; // Microsoft Edge any version
if (this.isO()) {
return 'O'
}

View File

@@ -13,6 +13,7 @@ module Constants
FF = 'FF' # Firefox
M = 'M' # Mozilla
IE = 'IE' # Internet Explorer
E = 'E' # Microsoft Edge
S = 'S' # Safari
K = 'K' # Konqueror
C = 'C' # Chrome
@@ -27,6 +28,7 @@ module Constants
FRIENDLY_FF_NAME = 'Firefox'
FRIENDLY_M_NAME = 'Mozilla'
FRIENDLY_IE_NAME = 'Internet Explorer'
FRIENDLY_E_NAME = 'Microsoft Edge'
FRIENDLY_S_NAME = 'Safari'
FRIENDLY_K_NAME = 'Konqueror'
FRIENDLY_C_NAME = 'Chrome'
@@ -46,6 +48,7 @@ module Constants
when FF; return FRIENDLY_FF_NAME
when M ; return FRIENDLY_M_NAME
when IE; return FRIENDLY_IE_NAME
when E ; return FRIENDLY_E_NAME
when S ; return FRIENDLY_S_NAME
when K ; return FRIENDLY_K_NAME
when C ; return FRIENDLY_C_NAME

View File

@@ -67,6 +67,7 @@ module Models
browser = get(session_id, 'BrowserName')
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_IE_IMG if browser.eql? 'IE' # Internet Explorer
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_EDGE_IMG if browser.eql? 'E' # Microsoft Edge
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_FIREFOX_IMG if browser.eql? 'FF' # Firefox
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_SAFARI_IMG if browser.eql? 'S' # Safari
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_CHROME_IMG if browser.eql? 'C' # Chrome

View File

@@ -46,6 +46,7 @@ module Models
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_UNKNOWN_IMG if agent.nil?
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_IE_IMG if agent.include? BeEF::Extension::AdminUI::Constants::Agents::AGENT_IE_UA_STR
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_EDGE_IMG if agent.include? BeEF::Extension::AdminUI::Constants::Agents::AGENT_EDGE_UA_STR
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_FIREFOX_IMG if agent.include? BeEF::Extension::AdminUI::Constants::Agents::AGENT_FIREFOX_UA_STR
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_MOZILLA_IMG if agent.include? BeEF::Extension::AdminUI::Constants::Agents::AGENT_MOZILLA_UA_STR
return BeEF::Extension::AdminUI::Constants::Agents::AGENT_SAFARI_IMG if agent.include? BeEF::Extension::AdminUI::Constants::Agents::AGENT_SAFARI_UA_STR

View File

@@ -18,6 +18,8 @@ module Constants
AGENT_MOZILLA_IMG = 'mozilla.png'
AGENT_IE_UA_STR = 'MSIE'
AGENT_IE_IMG = 'msie.png'
AGENT_EDGE_UA_STR = 'Edge'
AGENT_EDGE_IMG = 'edge.png'
AGENT_SAFARI_UA_STR = 'Safari'
AGENT_SAFARI_IMG = 'safari.png'
AGENT_KONQ_UA_STR = 'Konqueror'

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB