首页 > 编程知识 正文

手机抓socket包【转】

时间:2023-05-04 19:38:24 阅读:248978 作者:2637

转自https://magicly.me/ios-socket/

需要抓一个 app 的包, 不是 http, 一开始以为是 websocket 走了一些弯路, 最后发现是 socket。

抓 Http/Https

这个很容易, 有很多 proxy 可以, 比如 charles, fiddler, mitmproxy 等, 以及很多开源项目, 用 go 写的, 用 nodejs 写的都很多, 比如:

https://github.com/nodejitsu/node-http-proxyhttps://github.com/alibaba/anyproxyhttps://github.com/avwo/whistlehttps://github.com/snail007/goproxyhttps://github.com/elazarl/goproxy

这里遇到一个坑, android7.0 之后已经抓不到 https 包了, 哪怕你装了证书, 还需要在 app 内部配置, 也就是说你只能抓自己的 app 的包, 或者破解别人的 app 更改配置后重新打包, 或者 root 之后用 Xposed 的插件 JustTrueMe。

https://pediy.com/thread-219283.htmhttps://www.jianshu.com/p/e1ffb66e459chttps://blog.csdn.net/u011045726/article/details/76064048ios 抓 socket 包

转战 ios 抓, https 抓到了。发现 charles 里面看不到, 因为是 realtime 应用, 考虑估计用的是 websocket, 然后考虑把 ios 的流量全部导入代理(普通的只能代理 http/https)。

有人推荐了用 rvi 或者 mac 共享热点的方式, 然后用 wireshark 抓:

https://www.jianshu.com/p/eeb7fd12ef11https://blog.netspi.com/intercepting-native-ios-application-traffic/http://www.find-bug.com/archives/4901https://www.v2ex.com/t/383671https://www.zhihu.com/question/20467503https://github.com/sundy-li/wechat_brain/issues/18

但是 wireshark 不能通过简单地导入 ssl 证书抓 https, 配置稍微复杂:

http://感动的云朵.me/zh-cn/blog/walkthrough-decrypt-ssl-tls-traffic-https-and-http2-in-wiresharkhttps://imququ.com/post/how-to-decrypt-https.htmlhttps://imququ.com/post/http2-traffic-in-wireshark.html

后来发现 android 可以用 Drony 代理 socks 代理, ios 应该也有吧。 找了好久终于发现可以用 AnyLink, 免费好用!

然后就简单了, 开启 socks5 代理, 将全部流量导入 charles,charles 是支持 websocket 的, 结果发现其实是普通 socket, 也 ok。

然而 charles 貌似不能编程, 那很简单, 找一个支持 tcp 的开源代理项目就 ok 了。

https://github.com/armon/go-socks5https://github.com/mscdex/socksv5

懒得看,何不自己用 node.js 自己写一个, 几行代码的事情:

https://github.com/whtiehack/socket-proxyhttps://my.oschina.net/waterbear/blog/289739https://github.com/gonzalo123/nodejs.tcp.proxy

但是发现获取不到目标 ip 地址, 直接获取到的都是代理地址, 找了个项目

https://github.com/mscdex/socksv5

这个可以得到目标地址,具体实现是自己去解析 tcp 包, 这个是 socks5 的规范。

DSTPORT andDSTIP 两个域分别是目标主机的端口和 IP 地址。

https://blog.csdn.net/kalman2008/article/details/45919741

剩下的就是分析包了。

一些可能有用的资料:

https://github.com/txthinking/brookhttps://5socks.net/Manual/rdpiphoneeng.htmhttps://github.com/chrisballinger/ProxyKithttps://github.com/twotreeszf/PrettyTunnelhttps://github.com/halogenica/iphone-socks-proxy

Android 破解的一些资料:

http://www.520monkey.com/https://www.anquanke.com/post/id/91588https://blog.csdn.net/guolin_blog/article/details/49738023https://www.jianshu.com/p/9e0d1c3e342ehttps://juejin.im/entry/585f3646da2f600065903ff7https://segmentfault.com/a/1190000005133219https://medium.com/@fwouts/blocking-websites-on-android-90958a1aca5https://blog.csdn.net/dreamer2020/article/details/52761606https://www.jianshu.com/p/eb766d2bb837http://unclechen.github.io/2016/09/07/Android%E5%8F%8D%E7%BC%96%E8%AF%91%E6%8A%80%E6%9C%AF%E6%80%BB%E7%BB%93/https://github.com/ufologist/onekey-decompile-apkhttps://github.com/alibaba/dexposedhttps://blog.csdn.net/jiangwei0910410003/article/details/51671019

nb 的项目: https://github.com/CellularPrivacy/Android-IMSI-Catcher-Detector

Vue脚手架安装时遇到的无法安装问题详解linux登录欢迎页怎么做

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。