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