Fidder抓包

下载安装

https://telerik-fiddler.s3.amazonaws.com/fiddler/FiddlerSetup.exe

Fiddler设置

Tools→options→https→勾上Capture Https Connections→勾上Decrypt HTTPS
traffic→选择from all process

在这里插入图片描述

Tools->Options->connections→Fiddler listens on port→填上8888→勾上Allow
remote computers to connect

在这里插入图片描述
查电脑ip
开始菜单输入cmd打开命令行,在里面输入ipconfig | findstr "IPv4"就可以看到电脑局域网ip
我的ip是10.13.0.6
在这里插入图片描述
手机设置
长按wifi,选择高级、代理为手动、填写电脑ip、端口8888。
在这里插入图片描述
安装证书
安装证书才可以抓到https的数据包。打开手机浏览器,输入证书网址ip+port
比如我的是 10.13.0.6:8888打开证书界面,点击FiddlerRoot certificate安装证书。
在这里插入图片描述
证书网页打不开
如果在手机浏览器上打不开证书网址 ,输入ip+port比如我的是 10.13.0.6:8888打不开怎么办不要急,先在电脑浏览器上打开证书网址。如果打不开的话,请检查你Fiddler版本和Fiddler设置。如果电脑可以正常打开证书网址,而手机打不开,那就设置下防火墙。还有一次情况是这样的、手机上就是打不开、当时是手机升级版本了、也不知道怎么处理、但是手机浏览器一直开着在尝试打开10.13.0.6:8888、过了大概五分钟自动打开了。

开始→控制面板→Windows 防火墙→允许程序→勾上Fiddler就可以了
在这里插入图片描述

捕获不到app的网络请求
targetSdkVersion 28 后android 9.0手机抓不到包。手机已经做出上述设置了、然后可以成功捕获手机chrome浏览器发出的网络请求、但是自己写的app的网络请求捕捉不到,最后排查发现是 targetSdkVersion 28 抓不到包。targetSdkVersion 28 会导致Cleartext HTTP traffic to not permitted 错误。解决方案有很多,比如在AndroidManifest.xml配置文件的标签中直接插入

android:usesCleartextTraffic="true"

Android 禁止代理抓包
https://blog.youkuaiyun.com/chenhuakang/article/details/82178988

    /**
     * Same as {@link #openConnection()}, except that the connection will be
     * made through the specified proxy; Protocol handlers that do not
     * support proxing will ignore the proxy parameter and make a
     * normal connection.
     *
     * Invoking this method preempts the system's default ProxySelector
     * settings.
     *
     * @param      proxy the Proxy through which this connection
     *             will be made. If direct connection is desired,
     *             Proxy.NO_PROXY should be specified.
     * @return     a <code>URLConnection</code> to the URL.
     * @exception  IOException  if an I/O exception occurs.
     * @exception  SecurityException if a security manager is present
     *             and the caller doesn't have permission to connect
     *             to the proxy.
     * @exception  IllegalArgumentException will be thrown if proxy is null,
     *             or proxy has the wrong type
     * @exception  UnsupportedOperationException if the subclass that
     *             implements the protocol handler doesn't support
     *             this method.
     * @see        java.net.URL#URL(java.lang.String, java.lang.String,
     *             int, java.lang.String)
     * @see        java.net.URLConnection
     * @see        java.net.URLStreamHandler#openConnection(java.net.URL,
     *             java.net.Proxy)
     * @since      1.5
     */
       public URLConnection openConnection(Proxy proxy)
        throws java.io.IOException {
        if (proxy == null) {
            throw new IllegalArgumentException("proxy can not be null");
        }
 
        // Create a copy of Proxy as a security measure
        Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : sun.net.ApplicationProxy.create(proxy);
        SecurityManager sm = System.getSecurityManager();
        if (p.type() != Proxy.Type.DIRECT && sm != null) {
            InetSocketAddress epoint = (InetSocketAddress) p.address();
            if (epoint.isUnresolved())
                sm.checkConnect(epoint.getHostName(), epoint.getPort());
            else
                sm.checkConnect(epoint.getAddress().getHostAddress(),
                                epoint.getPort());
        }
        return handler.openConnection(this, p);
    }

抓包https
如果抓不到https包,请增加如下配置
src/main/res/xml/network_security_config.xml
内容如下

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
<!--    https://www.charlesproxy.com/documentation/using-charles/ssl-certificates/-->
    <debug-overrides>
        <trust-anchors>
            <!-- Trust user added CAs while debuggable only -->
            <certificates src="user" />
        </trust-anchors>
    </debug-overrides>
</network-security-config>

然后在application中引用

<application
 android:networkSecurityConfig="@xml/network_security_config"
 >
### Fiddler 抓包过程中断网问题的解决方案 当遇到Fiddler抓包时出现断网的情况,这通常是因为网络代理配置不当引起的[^2]。为了确保Fiddler能够顺利工作而不影响正常的网络连接,可以采取以下几个措施: #### 1. 配置正确的代理设置 确认计算机上的浏览器和其他应用程序都指向了正确的HTTP/HTTPS代理服务器地址和端口。对于大多数情况,默认情况下Fiddler会自动配置这些设置。 如果手动设置了其他代理服务,则可能会与Fiddler发生冲突。此时应取消自定义代理设置或将它们更改为通过Fiddler转发请求的方式。 #### 2. 使用透明模式捕获流量 (Transparent Mode) 启用此功能可以让Fiddler作为系统的默认网关来拦截并记录所有进出的数据流而无需更改任何客户端软件中的代理设定。这样做的好处是可以减少因错误配置而导致的问题,并且适用于那些不支持直接修改其内部代理选项的应用程序。 要开启透明模式,在菜单栏中选择`Tools -> Options...`,切换到 `Connections`标签页勾选上`Allow remote computers to connect` 和 `Decrypt HTTPS traffic`两个选项即可完成基本配置[^1]。 请注意,在某些操作系统环境下(尤其是Windows Server),还需要额外调整防火墙规则允许特定端口号通信以及授予管理员权限给Fiddler进程本身才能正常使用该特性。 #### 3. 处理 SSL/TLS 握手失败 针对HTTPS加密网站访问时可能出现的安全层握手异常状况,可以通过安装由Fiddler签发的信任根证书来解决问题。不过需要注意的是,在较新的Android设备(>= Android 10) 上由于系统安全策略加强的原因,单纯依靠JustTrustMe插件已经不足以实现无缝兼容[^3];这时建议尝试官方文档推荐的方法或是寻找第三方替代品来进行适配处理。 ```bash # 安装FiddlerRoot证书至受信任位置 certutil -addstore "ROOT" fiddlerroot.cer ```
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值