简体   繁体   English

在OSX上使用透明的mitmproxy测试iOS应用的SSL / TLS证书验证

[英]Testing an iOS app's SSL/TLS certificate validation using a transparent mitmproxy on OSX

As part of a security test of an iOS app I'm developing, I'd like to verify that it correctly validates SSL/TLS certificates when connecting to various APIs. 作为我正在开发的iOS应用程序的安全测试的一部分,我想验证其在连接到各种API时是否正确验证了SSL / TLS证书。 I installed mitmproxy on my Mac and configured it as a transparent proxy , then configured the WiFi based on this transparent proxy iOS WiFi screenshot . 我在Mac上安装了mitmproxy并将其配置为透明代理 ,然后根据此透明代理iOS WiFi屏幕截图配置了WiFi。 The iPhone takes a very long time to show that it's connected to WiFi, and after it does, it can't access the network. iPhone需要很长时间才能显示它已连接到WiFi,并且连接之后无法访问网络。 Nothing at all shows up in mitmproxy, including in its event log: mitmproxy完全不显示任何内容,包括其事件日志中: mitmproxy什么也没显示

Details of the mitmproxy configuration mitmproxy配置的详细信息

I installed mitmproxy 0.11.3 in my system python (and renamed the outdated pyOpenSSL that ships with OSX, so that it uses pyOpenSSL 0.14 as installed with mitmproxy by pip). 我在系统python中安装了mitmproxy 0.11.3(并将其重命名为OSX附带的过时的pyOpenSSL,以便它使用pyOpenSSL 0.14并通过pip与mitmproxy一起安装)。

I'm using the following script to configure and start pf and mitmproxy: 我正在使用以下脚本来配置和启动pf和mitmproxy:

#!/bin/bash -x
sudo sysctl -w net.inet.ip.forwarding=1

# sudo sysctl -w net.inet.ip.scopedroute=0
## OSX can't change the net.inet.ip.scopedroute kernel flag in user space so I used:
## sudo defaults write "/Library/Preferences/SystemConfiguration/com.apple.Boot" "Kernel     Flags" "net.inet.ip.scopedroute=0
## and then rebooted
sudo defaults read /Library/Preferences/SystemConfiguration/com.apple.Boot

cat > pf.conf << _EOF_
rdr on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
_EOF_
cat pf.conf

sudo pfctl -d
sudo pfctl -f pf.conf
sudo pfctl -e

mitmproxy -T --host

Interface en0 is my Mac's WiFi connection. en0接口是Mac的WiFi连接。

The output from that script (visible after stopping mitmproxy with control-C) looks like this: 该脚本的输出(在用control-C停止mitmproxy后可见):

$ ./transparent.sh 
+ sudo sysctl -w net.inet.ip.forwarding=1
net.inet.ip.forwarding: 1 -> 1
+ sudo defaults read /Library/Preferences/SystemConfiguration/com.apple.Boot
{
    "Kernel Flags" = "net.inet.ip.scopedroute=0";
}
+ cat
+ cat pf.conf
rdr on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
+ sudo pfctl -d
No ALTQ support in kernel
ALTQ related functions disabled
pf disabled
+ sudo pfctl -f pf.conf
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.

No ALTQ support in kernel
ALTQ related functions disabled
+ sudo pfctl -e
No ALTQ support in kernel
ALTQ related functions disabled
pf enabled
+ mitmproxy -T --host

Details of the iOS configuration iOS配置的详细信息

I'm using a physical iPhone5s on iOS 8.1 and connecting to the same WiFi network as the Mac. 我在iOS 8.1上使用物理iPhone5,并连接到与Mac相同的WiFi网络。 My WiFi configuration looks like this: 我的WiFi配置如下所示: iPhone上的透明代理wifi配置

I've used 192.168.20.118 because that is the IP address of my Mac on the same WiFi network, which I found using ifconfig: 我使用了192.168.20.118,因为这是我的Mac在同一WiFi网络上的IP地址,该地址是使用ifconfig找到的:

$ ifconfig
[...]
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether xx:xx:xx:xx:xx:xx 
    inet6 fe80::22c9:d0ff:fe84:983b%en0 prefixlen 64 scopeid 0x4 
    inet 192.168.20.118 netmask 0xffffff00 broadcast 192.168.20.255
    nd6 options=1<PERFORMNUD>
    media: autoselect
    status: active
[...]

I got the same problem. 我遇到了同样的问题。 In my case, i turn off Mac OS Firewall in Setting panel. 就我而言,我在“设置”面板中关闭了Mac OS防火墙。 It works and i can use mitmproxy as a transparent proxy. 它可以工作,我可以使用mitmproxy作为透明代理。

我今天也遇到同样的问题。我只解决了dns问题。我认为mitmproxy不提供dns

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM