9***@qq.com
9***@qq.com
  • 发布:2024-06-20 11:03
  • 更新:2024-06-20 11:03
  • 阅读:129

Android抓包配置

分类:uni-app

1、创建network_security_config.xml文件,并将其拷贝到应用资源nativeResources\android\res\xml目录下

<?xml version="1.0" encoding="utf-8"?>  
<network-security-config>  
  <base-config cleartextTrafficPermitted="true">  
    <trust-anchors>  
      <certificates src="system" />  
      <certificates src="user" />  
    </trust-anchors>  
  </base-config>  
</network-security-config>

2、创建AndroidManifest.template.xml文件

<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"   
  package="你自己的包名">  

    <!-- 信任用户证书,用于非生产环境抓包 -->  
    <application android:networkSecurityConfig="@xml/network_security_config">  

    </application>  
</manifest>

3、修改vue.config.js或vite.config.js

const fs = require('fs');  
const path = require('path');  
const templateFilePath = path.join(__dirname, 'AndroidManifest.template.xml');  
const outputFilePath = path.join(__dirname, 'AndroidManifest.xml');  
const config = require('./config.js')  

// #ifdef APP  
// 非生产环境,添加网络安全配置,用于抓包  
if(config.env !== 'prod'){  
    fs.copyFileSync(templateFilePath, outputFilePath);  
}else if(fs.existsSync(outputFilePath)){  
    fs.unlinkSync(outputFilePath)  
}  
// #endif

4、下载抓包工具Reqable
下载地址:https://reqable.com/zh-CN/download

0 关注 分享

要回复文章请先登录注册