Refactored the cpu detection JS code. Now starts to detect if the target is 64 bit, then moves to the other checks.

This commit is contained in:
antisnatchor
2015-07-29 10:25:32 +02:00
parent 157fd4104b
commit 568f63f13d

View File

@@ -12,21 +12,27 @@ beef.hardware = {
* @return: {String} CPU type * @return: {String} CPU type
**/ **/
cpuType: function() { cpuType: function() {
// IE var arch = 'UNKNOWN';
if (typeof navigator.cpuClass != 'undefined') { // note that actually WOW64 means IE 32bit and Windows 64 bit. we are more interested
cpu = navigator.cpuClass; // in detecting the OS arch rather than the browser build
if (cpu == "x86") return "32-bit"; if (navigator.userAgent.match('(WOW64|x64|x86_64)') || navigator.platform.toLowerCase() == "win64"){
if (cpu == "68K") return "Motorola 68K"; arch = 'x86_64';
if (cpu == "PPC") return "Motorola PPC"; }else if(typeof navigator.cpuClass != 'undefined'){
if (cpu == "Alpha") return "Digital"; switch (navigator.cpuClass) {
if (this.ua.match('Win64; IA64')) return "64-bit (Intel)"; case '68K':
if (this.ua.match('Win64; x64')) return "64-bit (AMD)"; arch = 'Motorola 68K';
// Firefox break;
} else if (typeof navigator.oscpu != 'undefined') { case 'PPC':
if (navigator.oscpu.match('(WOW64|x64|x86_64)')) return "64-bit"; arch = 'Motorola PPC';
break;
case 'Digital':
arch = 'Alpha';
break;
default:
arch = 'x86';
}
} }
if (navigator.platform.toLowerCase() == "win64") return "64-bit"; return arch;
return "32-bit";
}, },
/* /*