<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>iOS &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/ios/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 28 Nov 2022 18:25:24 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] 用Charles Proxy抓包iOS App的数据</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e7%94%a8charles-proxy%e6%8a%93%e5%8c%85ios-app%e7%9a%84%e6%95%b0%e6%8d%ae/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e7%94%a8charles-proxy%e6%8a%93%e5%8c%85ios-app%e7%9a%84%e6%95%b0%e6%8d%ae/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sat, 19 Nov 2022 10:34:15 +0000</pubDate>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[Charles Proxy]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[抓包]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=13689</guid>

					<description><![CDATA[<div style="text-align: center;">
	<img decoding="async" alt="charles proxy" src="https://www.codelast.com/wp-content/uploads/2022/02/charles_proxy.png" style="text-align: center; width: 571px; height: 221px;" /></div>
<p>查看Charles Proxy文章合集，请点击<a href="https://www.codelast.com/?p=13742" rel="noopener" target="_blank">这里</a>。</p>
<p><span style="color: rgb(255, 0, 0);">➤</span>&#160;使用场景<br />
当我们需要分析 iOS App 发送接收的数据时，需要对App进行抓包。可以在&#160;iOS&#160;上安装抓包工具来完成这个工作，更常见的做法是在PC上安装Charles Proxy之类的软件，再对&#160;iOS&#160;进行一定的配置让这二者关联起来，从而可以在PC上完成抓包工作。毕竟在PC大屏上进行数据分析比触屏的&#160;iOS&#160;设备更为方便。<br />
其基本原理是：Charles Proxy运行起来后，会在PC上启动一个代理服务器，在 iOS&#160;设备上配置通过这个代理服务器来访问网络，那么iOS上的HTTP流量都将走过Charles Proxy，自然也就被Charles Proxy截获了数据。另外，对于HTTPS的加密流量，Charles Proxy还提供了一个SSL证书，把这个证书安装到&#160;iOS&#160;设备上，就可以让&#160;iOS App 发送的HTTPS流量被Charles Proxy&#160;解密，我们就能分析App发送的数据明文。<br />
<span id="more-13689"></span><br />
<span style="color: rgb(255, 0, 0);">➤</span>&#160;软件环境<br />
PC：macOS 13.0.1<br />
Charles Proxy：4.6.2<br />
iOS：15.7.1（其他版本的iOS也行，只不过在某些步骤上有些许差别而已）</p>
<p><span style="color: rgb(255, 0, 0);">➤</span>&#160;Charles Proxy配置<br />
下面的配置，诸如端口号之类的参数可以视实际情况修改。<br />
依次点击菜单设置：<br />
（1）Proxy&#8594;Proxy Settings<br />
<a href="https://www.codelast.com" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy proxy settings" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_proxy_settings_1.png" style="width: 600px; height: 530px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<a href="https://www.codelast.com" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy proxy settings" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_proxy_settings_2.png" style="width: 600px; height: 532px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
（2）Proxy&#8594;SSL Proxy Settings<br />
<a href="https://www.codelast.com" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy ssl proxy settings" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_ssl_proxy_settings.png" style="width: 600px; height: 484px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e7%94%a8charles-proxy%e6%8a%93%e5%8c%85ios-app%e7%9a%84%e6%95%b0%e6%8d%ae/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<div style="text-align: center;">
	<img decoding="async" alt="charles proxy" src="https://www.codelast.com/wp-content/uploads/2022/02/charles_proxy.png" style="text-align: center; width: 571px; height: 221px;" /></div>
<p>查看Charles Proxy文章合集，请点击<a href="https://www.codelast.com/?p=13742" rel="noopener" target="_blank">这里</a>。</p>
<p><span style="color: rgb(255, 0, 0);">➤</span>&nbsp;使用场景<br />
当我们需要分析 iOS App 发送接收的数据时，需要对App进行抓包。可以在&nbsp;iOS&nbsp;上安装抓包工具来完成这个工作，更常见的做法是在PC上安装Charles Proxy之类的软件，再对&nbsp;iOS&nbsp;进行一定的配置让这二者关联起来，从而可以在PC上完成抓包工作。毕竟在PC大屏上进行数据分析比触屏的&nbsp;iOS&nbsp;设备更为方便。<br />
其基本原理是：Charles Proxy运行起来后，会在PC上启动一个代理服务器，在 iOS&nbsp;设备上配置通过这个代理服务器来访问网络，那么iOS上的HTTP流量都将走过Charles Proxy，自然也就被Charles Proxy截获了数据。另外，对于HTTPS的加密流量，Charles Proxy还提供了一个SSL证书，把这个证书安装到&nbsp;iOS&nbsp;设备上，就可以让&nbsp;iOS App 发送的HTTPS流量被Charles Proxy&nbsp;解密，我们就能分析App发送的数据明文。<br />
<span id="more-13689"></span><br />
<span style="color: rgb(255, 0, 0);">➤</span>&nbsp;软件环境<br />
PC：macOS 13.0.1<br />
Charles Proxy：4.6.2<br />
iOS：15.7.1（其他版本的iOS也行，只不过在某些步骤上有些许差别而已）</p>
<p><span style="color: rgb(255, 0, 0);">➤</span>&nbsp;Charles Proxy配置<br />
下面的配置，诸如端口号之类的参数可以视实际情况修改。<br />
依次点击菜单设置：<br />
（1）Proxy&rarr;Proxy Settings<br />
<a href="https://www.codelast.com" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy proxy settings" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_proxy_settings_1.png" style="width: 600px; height: 530px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<a href="https://www.codelast.com" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy proxy settings" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_proxy_settings_2.png" style="width: 600px; height: 532px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
（2）Proxy&rarr;SSL Proxy Settings<br />
<a href="https://www.codelast.com" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy ssl proxy settings" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_ssl_proxy_settings.png" style="width: 600px; height: 484px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
点击上图的&ldquo;Add&rdquo;按钮添加你想要抓包数据的域名：<br />
<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy ssl proxy settings" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_ssl_proxy_settings_edit_location.png" style="width: 500px; height: 222px;" /></a><br />
Port不用填。<br />
这里只是举一个例子，如果你要抓包的App访问的是其他域名，要把它们都添加进去。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
（3）Proxy&rarr;macOS Proxy（勾选）<br />
<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="charles proxy enable macos proxy" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_enable_masos_proxy.png" style="width: 500px; height: 488px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a></p>
<p><span style="color: rgb(255, 0, 0);">➤</span>&nbsp;iOS配置<br />
（1）在iOS上使用Charles Proxy启动的代理服务器来访问网络</p>
<blockquote>
<p>
		编辑WiFi网络连接&rarr;配置代理&rarr;选择&ldquo;手动&rdquo;&rarr;填上Charles Proxy的代理服务器IP地址及端口</p>
</blockquote>
<p>正如前面的图示，我们已经把端口设置成了8888，所以iOS代理配置的端口就填8888。<br />
那么代理服务器的IP地址是什么？点击Charles Proxy软件的菜单 <span style="color:#ff0000;">Help</span>&rarr;<span style="color:#ff0000;">Local IP&nbsp;Address</span>，在弹出的对话框中就可以看到IP地址。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
（2）安装Charles Proxy提供的证书<br />
Charles Proxy&nbsp;给了一个指南，告诉我们在iOS上应该怎么配置，点击菜单 <span style="color:#ff0000;">Help</span>&rarr;<span style="color:#ff0000;">SSL Proxying</span>&rarr;<span style="color:#ff0000;">Install Charles Root on a Mobile Device or Remote Browser</span>&nbsp;会弹出对话框：<br />
<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_ssl_proxying.png" style="width: 600px; height: 141px;" /></a><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
它让我们在移动设备上用浏览器访问 <span style="color:#ff0000;">chls.pro/ssl</span>&nbsp;这个URL，照做：<br />
<img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_downloading_configuration_profile.jpg" style="width: 500px; height: 813px;" /><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
点击&ldquo;允许&rdquo;，再回到系统&ldquo;设置&rdquo;界面，会看到&ldquo;已下载描述文件&rdquo;：<br />
<img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_configuration_profile_downloaded.jpg" style="width: 400px; height: 552px;" /><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
点进去，会看到描述文件的信息：<br />
<img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_install_configuration_profile.jpg" style="width: 500px; height: 632px;" /><br />
点击右上角的&ldquo;安装&rdquo;，就可以把证书安装到iOS设备上了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
（3）证书过期的处理<br />
如果按照以上步骤操作之后，Charles Proxy可以抓包，但对HTTPS的数据仍然看不到明文，那么有可能是Charles Proxy的证书过期了，此时你需要点击菜单 <span style="color:#ff0000;">Help</span>&rarr;<span style="color:#ff0000;">SSL Proxying</span>&rarr;<span style="color:#ff0000;">Reset Charles Root Certificate</span>：<br />
<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2022/11/charles_proxy_ios_app_reset_charles_root_certificate.png" style="width: 700px; height: 331px;" /></a><br />
然后回到iOS上，重新从安装证书开始执行一遍后面的步骤即可。<br />
上面的步骤完成后，回到Charles Proxy软件，会发现它已经可以成功抓包iOS App的数据了，包括HTTPS的流量。</p>
<p>
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：<br />
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="color: rgb(77, 77, 77); font-size: 13px; width: 200px; height: 200px;" /><br />
	以及我的微信视频号：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="" src="https://www.codelast.com/wechat_shipinhao_qr_code.jpg" style="text-align: center; width: 200px; height: 199px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e7%94%a8charles-proxy%e6%8a%93%e5%8c%85ios-app%e7%9a%84%e6%95%b0%e6%8d%ae/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
