forked from beefproject/beef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardware.js.html
368 lines (321 loc) · 11.8 KB
/
hardware.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: hardware.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: hardware.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>//
// Copyright (c) 2006-2020 Wade Alcorn - wade@bindshell.net
// Browser Exploitation Framework (BeEF) - http://beefproject.com
// See the file 'doc/COPYING' for copying permission
//
/**
* @namespace beef.hardware
*/
beef.hardware = {
ua: navigator.userAgent,
/**
* @return {String} CPU type
*/
getCpuArch: function() {
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';
}
}
// TODO we can infer the OS is 64 bit, if we first detect the OS type (os.js).
// For example, if OSX is at least 10.7, most certainly is 64 bit.
return arch;
},
/**
* Returns number of CPU cores
* @return {String}
*/
getCpuCores: function() {
var cores = 'unknown';
try {
if(typeof navigator.hardwareConcurrency != 'undefined') {
cores = navigator.hardwareConcurrency;
}
} catch(e) {
cores = 'unknown';
}
return cores;
},
/**
* Returns CPU details
* @return {String}
*/
getCpuDetails: function() {
return {
arch: beef.hardware.getCpuArch(),
cores: beef.hardware.getCpuCores()
}
},
/**
* Returns GPU details
* @return {object}
*/
getGpuDetails: function() {
var gpu = 'unknown';
var vendor = 'unknown';
// use canvas technique:
// https://github.com/Valve/fingerprintjs2
// http://codeflow.org/entries/2016/feb/10/webgl_debug_renderer_info-extension-survey-results/
try {
var getWebglCanvas = function () {
var canvas = document.createElement('canvas')
var gl = null
try {
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl')
} catch (e) { }
if (!gl) { gl = null }
return gl;
}
var glContext = getWebglCanvas();
var extensionDebugRendererInfo = glContext.getExtension('WEBGL_debug_renderer_info');
var gpu = glContext.getParameter(extensionDebugRendererInfo.UNMASKED_RENDERER_WEBGL);
var vendor = glContext.getParameter(extensionDebugRendererInfo.UNMASKED_VENDOR_WEBGL);
beef.debug("GPU: " + gpu + " - Vendor: " + vendor);
} catch (e) {
beef.debug('Failed to detect WebGL renderer: ' + e.toString());
}
return {
gpu: gpu,
vendor: vendor
}
},
/**
* Returns RAM (GiB)
* @return {String}
*/
getMemory: function() {
var memory = 'unknown';
try {
if(typeof navigator.deviceMemory != 'undefined') {
memory = navigator.deviceMemory;
}
} catch(e) {
memory = 'unknown';
}
return memory;
},
/**
* Returns battery details
* @return {Object}
*/
getBatteryDetails: function() {
var battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery;
if (!!battery) {
return {
chargingStatus: battery.charging,
batteryLevel: battery.level * 100 + "%",
chargingTime: battery.chargingTime,
dischargingTime: battery.dischargingTime
}
} else {
return {
chargingStatus: 'unknown',
batteryLevel: 'unknown',
chargingTime: 'unknown',
dischargingTime: 'unknown'
}
}
},
/**
* Returns zombie screen size and color depth.
* @return {Object}
*/
getScreenSize: function () {
return {
width: window.screen.width,
height: window.screen.height,
colordepth: window.screen.colorDepth
}
},
/**
* Is touch enabled?
* @return {Boolean} true or false.
*/
isTouchEnabled: function() {
if ('ontouchstart' in document) return true;
return false;
},
/**
* Is virtual machine?
* @return {Boolean} true or false.
*/
isVirtualMachine: function() {
if (this.getGpuDetails().vendor.match('VMware, Inc'))
return true;
if (this.isMobileDevice())
return false;
// if the screen resolution is uneven, and it's not a known mobile device
// then it's probably a VM
if (screen.width % 2 || screen.height % 2)
return true;
return false;
},
/**
* Is a Laptop?
* @return {Boolean} true or false.
*/
isLaptop: function() {
if (this.isMobileDevice()) return false;
// Most common laptop screen resolution
if (screen.width == 1366 && screen.height == 768) return true;
// Netbooks
if (screen.width == 1024 && screen.height == 600) return true;
return false;
},
/**
* Is Nokia?
* @return {Boolean} true or false.
*/
isNokia: function() {
return (this.ua.match('(Maemo Browser)|(Symbian)|(Nokia)|(Lumia )')) ? true : false;
},
/**
* Is Zune?
* @return {Boolean} true or false.
*/
isZune: function() {
return (this.ua.match('ZuneWP7')) ? true : false;
},
/**
* Is HTC?
* @return {Boolean} true or false.
*/
isHtc: function() {
return (this.ua.match('HTC')) ? true : false;
},
/**
* Is Ericsson?
* @return {Boolean} true or false.
*/
isEricsson: function() {
return (this.ua.match('Ericsson')) ? true : false;
},
/**
* Is Motorola?
* @return {Boolean} true or false.
*/
isMotorola: function() {
return (this.ua.match('Motorola')) ? true : false;
},
/**
* Is Google?
* @return {Boolean} true or false.
*/
isGoogle: function() {
return (this.ua.match('Nexus One')) ? true : false;
},
/**
* Returns true if the browser is on a Mobile device
* @return {Boolean} true or false
*
* @example: if(beef.hardware.isMobileDevice()) { ... }
*/
isMobileDevice: function() {
return MobileEsp.DetectMobileQuick();
},
/**
* Returns true if the browser is on a game console
* @return {Boolean} true or false
*
* @example: if(beef.hardware.isGameConsole()) { ... }
*/
isGameConsole: function() {
return MobileEsp.DetectGameConsole();
},
getName: function() {
var ua = navigator.userAgent.toLowerCase();
if(MobileEsp.DetectIphone()) { return "iPhone"};
if(MobileEsp.DetectIpod()) { return "iPod Touch"};
if(MobileEsp.DetectIpad()) { return "iPad"};
if (this.isHtc()) { return 'HTC'};
if (this.isMotorola()) { return 'Motorola'};
if (this.isZune()) { return 'Zune'};
if (this.isGoogle()) { return 'Google Nexus One'};
if (this.isEricsson()) { return 'Ericsson'};
if(MobileEsp.DetectAndroidPhone()) { return "Android Phone"};
if(MobileEsp.DetectAndroidTablet()) { return "Android Tablet"};
if(MobileEsp.DetectS60OssBrowser()) { return "Nokia S60 Open Source"};
if(ua.search(MobileEsp.deviceS60) > -1) { return "Nokia S60"};
if(ua.search(MobileEsp.deviceS70) > -1) { return "Nokia S70"};
if(ua.search(MobileEsp.deviceS80) > -1) { return "Nokia S80"};
if(ua.search(MobileEsp.deviceS90) > -1) { return "Nokia S90"};
if(ua.search(MobileEsp.deviceSymbian) > -1) { return "Nokia Symbian"};
if (this.isNokia()) { return 'Nokia'};
if(MobileEsp.DetectWindowsPhone7()) { return "Windows Phone 7"};
if(MobileEsp.DetectWindowsPhone8()) { return "Windows Phone 8"};
if(MobileEsp.DetectWindowsPhone10()) { return "Windows Phone 10"};
if(MobileEsp.DetectWindowsMobile()) { return "Windows Mobile"};
if(MobileEsp.DetectBlackBerryTablet()) { return "BlackBerry Tablet"};
if(MobileEsp.DetectBlackBerryWebKit()) { return "BlackBerry OS 6"};
if(MobileEsp.DetectBlackBerryTouch()) { return "BlackBerry Touch"};
if(MobileEsp.DetectBlackBerryHigh()) { return "BlackBerry OS 5"};
if(MobileEsp.DetectBlackBerry()) { return "BlackBerry"};
if(MobileEsp.DetectPalmOS()) { return "Palm OS"};
if(MobileEsp.DetectPalmWebOS()) { return "Palm Web OS"};
if(MobileEsp.DetectGarminNuvifone()) { return "Gamin Nuvifone"};
if(MobileEsp.DetectArchos()) { return "Archos"}
if(MobileEsp.DetectBrewDevice()) { return "Brew"};
if(MobileEsp.DetectDangerHiptop()) { return "Danger Hiptop"};
if(MobileEsp.DetectMaemoTablet()) { return "Maemo Tablet"};
if(MobileEsp.DetectSonyMylo()) { return "Sony Mylo"};
if(MobileEsp.DetectAmazonSilk()) { return "Kindle Fire"};
if(MobileEsp.DetectKindle()) { return "Kindle"};
if(MobileEsp.DetectSonyPlaystation()) { return "Playstation"};
if(ua.search(MobileEsp.deviceNintendoDs) > -1) { return "Nintendo DS"};
if(ua.search(MobileEsp.deviceWii) > -1) { return "Nintendo Wii"};
if(ua.search(MobileEsp.deviceNintendo) > -1) { return "Nintendo"};
if(MobileEsp.DetectXbox()) { return "Xbox"};
if(this.isLaptop()) { return "Laptop"};
if(this.isVirtualMachine()) { return "Virtual Machine"};
return 'Unknown';
}
};
beef.regCmp('beef.hardware');
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="beef.are.html">are</a></li><li><a href="beef.browser.html">browser</a></li><li><a href="beef.browser.cookie.html">cookie</a></li><li><a href="beef.browser.popup.html">popup</a></li><li><a href="beef.dom.html">dom</a></li><li><a href="beef.encode.base64.html">base64</a></li><li><a href="beef.encode.json.html">json</a></li><li><a href="beef.geolocation.html">geolocation</a></li><li><a href="beef.hardware.html">hardware</a></li><li><a href="beef.init.html">init</a></li><li><a href="beef.logger.html">logger</a></li><li><a href="beef.mitb.html">mitb</a></li><li><a href="beef.net.html">net</a></li><li><a href="beef.net.connection.html">connection</a></li><li><a href="beef.net.cors.html">cors</a></li><li><a href="beef.net.dns.html">dns</a></li><li><a href="beef.net.local.html">local</a></li><li><a href="beef.net.portscanner.html">portscanner</a></li><li><a href="beef.net.requester.html">requester</a></li><li><a href="beef.net.xssrays.html">xssrays</a></li><li><a href="beef.os.html">os</a></li><li><a href="beef.session.html">session</a></li><li><a href="beef.timeout.html">timeout</a></li><li><a href="beef.updater.html">updater</a></li><li><a href="beef.webrtc.html">webrtc</a></li><li><a href="beef.websocket.html">websocket</a></li><li><a href="BeefJS.html">BeefJS</a></li><li><a href="browser_jools.html">browser_jools</a></li><li><a href="platform.html">platform</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 02 2020 16:29:11 GMT+1000 (Australian Eastern Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>