更新记录

1.0.1(2026-08-08) 下载此版本

修复打包失败问题

1.0.0(2026-08-06) 下载此版本

检测APP是否开启代理的功能插件


平台兼容性

uni-app(4.56)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - - - - - - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - - -

uni-app x(4.57)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - 12.0 - - -

losfer-capture 抓包/代理检测插件

检测客户端是否存在抓包行为或代理设置,帮助应用识别潜在的安全风险。

平台兼容性

平台 Android iOS Web 鸿蒙 微信小程序
支持

检测能力

检测项 说明 Android iOS
HTTP代理 检测系统HTTP/HTTPS/SOCKS代理设置 System.getProperty + ProxySelector CFNetworkCopySystemProxySettings
VPN连接 检测VPN网络接口 NetworkInterface (tun/ppp/tap) -
抓包工具 检测已安装的抓包/Root工具 包名检测 (Charles/Fiddler/Magisk等) URL Scheme检测 (Charles/Surge等)
调试模式 检测应用是否可被调试 FLAG_DEBUGGABLE isatty

引入方式

import { detectCapture, detectCaptureSync, CaptureDetectResult } from '@/uni_modules/losfer-capture'

API

detectCaptureSync()

同步执行检测,直接返回结果。

返回值

字段 类型 说明
hasProxy boolean 是否检测到HTTP代理
proxyHost string 代理主机地址(无代理时为空字符串)
proxyPort number 代理端口(无代理时为0)
hasVpn boolean 是否检测到VPN连接
hasCaptureTool boolean 是否检测到抓包/Root工具
isDebuggable boolean 是否处于调试模式
riskLevel number 综合风险等级:0=安全,1=低风险,2=中风险,3=高风险
riskDesc string 风险描述摘要

示例

import { detectCaptureSync } from '@/uni_modules/losfer-capture'

const result = detectCaptureSync()
console.log('风险等级: ' + result.riskLevel)
console.log('风险描述: ' + result.riskDesc)
console.log('是否有代理: ' + result.hasProxy)
console.log('是否有VPN: ' + result.hasVpn)
console.log('是否有抓包工具: ' + result.hasCaptureTool)

detectCapture(options)

异步执行检测,通过回调返回结果。

参数

字段 类型 必填 说明
checkVpn boolean 是否检测VPN,默认true
checkDebuggable boolean 是否检测调试模式,默认true
checkCaptureTool boolean 是否检测抓包工具,默认true
success (res) => void 检测成功回调
fail (err) => void 检测失败回调
complete () => void 检测完成回调(无论成功失败)

示例

import { detectCapture } from '@/uni_modules/losfer-capture'

detectCapture({
  checkVpn: true,
  checkDebuggable: true,
  checkCaptureTool: true,
  success: (res) => {
    console.log('风险等级: ' + res.riskLevel)
    console.log('风险描述: ' + res.riskDesc)
    if (res.riskLevel >= 2) {
      // 中高风险处理
      uni.showModal({
        title: '安全警告',
        content: res.riskDesc,
        showCancel: false
      })
    }
  },
  fail: (err) => {
    console.log('检测失败: ' + err.errMsg)
  },
  complete: () => {
    console.log('检测完成')
  }
})

风险等级说明

等级 含义 触发条件
0 安全 未检测到任何风险
1 低风险 检测到代理或VPN
2 中风险 多项低风险叠加
3 高风险 检测到抓包/Root工具

实际使用示例

应用启动时检测

import { detectCaptureSync } from '@/uni_modules/losfer-capture'

onLaunch(() => {
  // #ifdef APP
  const result = detectCaptureSync()
  if (result.riskLevel >= 3) {
    // 高风险:检测到抓包工具,退出应用
    uni.showModal({
      title: '安全警告',
      content: '检测到抓包工具,应用无法继续运行',
      showCancel: false,
      success: () => {
        plus.runtime.quit()
      }
    })
  }
  // #endif
})

页面中按需检测

import { detectCaptureSync } from '@/uni_modules/losfer-capture'

function checkSecurity() {
  // #ifdef APP
  const result = detectCaptureSync()
  if (result.hasProxy) {
    console.log('代理地址: ' + result.proxyHost + ':' + result.proxyPort)
  }
  if (result.hasVpn) {
    console.log('检测到VPN连接')
  }
  // #endif
  // #ifndef APP
  console.log('仅APP端支持抓包检测')
  // #endif
}

错误码

错误码 说明
9010001 平台不支持
9010002 未知错误

注意事项

  1. 本插件仅支持 APP 端(Android/iOS),Web 和小程序端不支持。
  2. VPN检测在iOS上能力有限,因系统沙盒限制无法直接访问网络接口信息。
  3. 抓包工具检测基于已知包名/URL Scheme列表,无法覆盖所有工具。
  4. 检测结果仅供参考,无法100%防止抓包,建议配合SSL Pinning等方案使用。
  5. detectCaptureSync 为同步方法,检测过程很快,可在主线程直接调用。

隐私、权限声明

1. 本插件需要申请的系统权限列表:

无额外权限需求

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据,仅在本地检测网络代理状态

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议