嗅探 Android 应用以查找 API URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20778072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sniffing an Android app to find API URL
提问by derpyderp
I'm curious as to how I could figure out the API URL an Android application (any app I have installed) uses if it makes API calls to some online server (a RESTful service for example). I presume I have to capture packets on the device and maybe analyse them in Wireshark or something to find the URL? I'm fairly competent in Java/Android development, but a bit lost when it comes to any sort of network analysis business.
我很好奇,如果 Android 应用程序(我安装的任何应用程序)对某个在线服务器(例如 RESTful 服务)进行 API 调用,我如何找出它使用的 API URL。我想我必须在设备上捕获数据包,然后在 Wireshark 或其他东西中分析它们以找到 URL?我在 Java/Android 开发方面相当能干,但在任何类型的网络分析业务方面都有点迷茫。
回答by Alok Singh Mahor
you can do this with help of WireShark. I am listing steps here
你可以在WireShark 的帮助下做到这一点。我在这里列出步骤
- Install WireSharkon your computer
- now we have to create Android virtual device(AVD) so we will download Android SDK from official site. Android SDK come with emulator for testing
- after setting up Android SDK, create a Android virtual Device(AVD) on which we will install app
- start that virtual device. you can use command line to start (
emulator @<AVD name>
) - after creating virtual device install app using adb command
adb install app_file_name.apk
- now we can start capturing the packets so I will suggest to close other application on your computer which are using network so our captured packets would be more relevant.
- now start wireshark with root access
select interface which you want to capture and click start to start capturing.
now start using that app so packets will transfer to and fro and wireshark will capture it.
if you have used app covering all sort of activity then you can stop wireshark to capture packets.
now start main business to analyse packets carefully but not all packets are usefull for our job. so lets filter packets which are relevant for you. lets your IP address is 192.168.0.32 then filter all the packets whose IP is this. so filter expression will be
ip.addr==192.168.0.32
apply this filter. still we an apply another filter to list up only relevant packets only so possibly that app is accessing API with HTTP protocol so apply HTTP filter. expression would behttp
. you can apply both are filter at onceip.addr==192.168.0.32 and http
press enter to apply.see the info carefully for listed packets you will see lot of important details, API keys, cookies etc
- 在您的计算机上安装WireShark
- 现在我们必须创建Android虚拟设备(AVD),所以我们将从官方网站下载Android SDK。Android SDK自带模拟器进行测试
- 设置Android SDK后,创建一个Android虚拟设备(AVD),我们将在其上安装应用程序
- 启动那个虚拟设备。您可以使用命令行启动 (
emulator @<AVD name>
) - 使用 adb 命令创建虚拟设备安装应用程序后
adb install app_file_name.apk
- 现在我们可以开始捕获数据包,所以我建议关闭您计算机上正在使用网络的其他应用程序,以便我们捕获的数据包更相关。
- 现在以root访问权限启动wireshark
选择要截取的界面,点击开始截取。
现在开始使用该应用程序,以便数据包来回传输,wireshark 将捕获它。
如果您使用了涵盖所有类型活动的应用程序,那么您可以停止wireshark 来捕获数据包。
现在开始主要业务,仔细分析数据包,但并非所有数据包都对我们的工作有用。所以让我们过滤与您相关的数据包。让你的 IP 地址是 192.168.0.32 然后过滤所有 IP 是这个的数据包。所以过滤器表达式将
ip.addr==192.168.0.32
应用这个过滤器。我们仍然应用另一个过滤器来仅列出相关数据包,因此可能该应用程序正在使用 HTTP 协议访问 API,因此应用 HTTP 过滤器。表达是http
. 您可以同时应用这两个过滤器,ip.addr==192.168.0.32 and http
然后按 Enter 键应用。仔细查看列出的数据包的信息,你会看到很多重要的细节、API 密钥、cookie 等
回答by reverie_ss
A very fast method.
Go to PlayStore, search for Packet Capture
一个非常快速的方法。
前往 PlayStore,搜索Packet Capture
Download, install and run.
It's easy simple and fast. It will give you details about the APIs, URLs and response with their headers.
下载、安装和运行。
这很容易简单快捷。它将为您提供有关 API、URL 和响应及其标头的详细信息。
This application follows the concept of Packet Sniffing. Thus, this might not work with much secured applications like WhatsApp, Facebook, Twitter.
此应用程序遵循数据包嗅探的概念。因此,这可能不适用于诸如 WhatsApp、Facebook、Twitter 之类的安全应用程序。
UPDATE 1:
The Packet Captureis no more available in playstore, try OS Monitor
更新1:
在 数据包捕获没有Play商店中的更多,请尝试OS监测器
UPDATE 2:
The Packet Captureis available again.
更新2:
将 数据包捕获再次可用。
回答by Davor Josipovic
Download Android +6.0 image for PC from this site: https://www.android-x86.org/.
从此站点下载适用于 PC 的 Android +6.0 映像:https: //www.android-x86.org/。
For example: https://www.android-x86.org/releases/releasenote-6-0-r3.html
例如:https: //www.android-x86.org/releases/releasenote-6-0-r3.html
Make sure that your app works with this Android version -- you can check the minimum Android version on Google Playstore --, and don't take a too high number for the Andriod version: the higher the number, the more security constraints is has.
确保您的应用适用于此 Android 版本——您可以在Google Play商店中查看最低 Android 版本——并且不要为 Andriod 版本取太高的数字:数字越高,安全限制越多已。
Install VirtualBox, mount the ISO image, boot Android, and install the app through Google Play.
安装VirtualBox,挂载 ISO 映像,启动 Android,然后通过 Google Play 安装应用程序。
Now you have two options:
现在你有两个选择:
If traffic is unencrypted, you can log all NIC traffic to a text file. e.g.
VBoxManage modifyvm "vm-name" --nictrace1 on --nictracefile1 c:\file.pcap
(cf. here)If traffic is encrypted, you can use a man-in-the-middle approach. An app that allows this is HttpCanary. It will make an VPN connection and redirect your traffic through that VPN. It decrypts and works well, but take care with your private data.
如果流量未加密,您可以将所有 NIC 流量记录到文本文件中。例如
VBoxManage modifyvm "vm-name" --nictrace1 on --nictracefile1 c:\file.pcap
(参见此处)如果流量被加密,您可以使用中间人方法。允许这样做的应用程序是HttpCanary。它将建立 VPN 连接并通过该 VPN 重定向您的流量。它解密并运行良好,但请注意您的私人数据。
回答by prithavi raj nagar
- install virtual box and genymotion http://www.2daygeek.com/install-upgrade-oracle-virtualbox-on-ubuntu-centos-debian-fedora-mint-rhel-opensuse/and http://www.2daygeek.com/install-genymotion-android-emulator-on-ubuntu-centos-debian-fedora-rhel-opensuse-arch-linux-mint/#
- Run genymotion . 3 . after that your desire android ADV install .
- now start wireshark with root access
- 安装 virtual box 和 genymotion http://www.2daygeek.com/install-upgrade-oracle-virtualbox-on-ubuntu-centos-debian-fedora-mint-rhel-opensuse/和http://www.2daygeek.com/ install-genymotion-android-emulator-on-ubuntu-centos-debian-fedora-rhel-opensuse-arch-linux-mint/#
- 运行 genymotion 。3 . 之后你想要的 android ADV 安装。
- 现在以root访问权限启动wireshark
回答by user8258945
Use debug proxy. Click on the play Button and you will be able to capture URLs and view more details
使用调试代理。单击播放按钮,您将能够捕获 URL 并查看更多详细信息
https://play.google.com/store/apps/details?id=com.dans.apps.webd
https://play.google.com/store/apps/details?id=com.dans.apps.webd