简体   繁体   English

如何在没有用户证书或修改应用程序的情况下将 Burp 与 Android 模拟器一起使用?

[英]How to utilize Burp with the Android Emulator without a user certificate or modifying the application?

In order to perform some Android Penetration Testing, I'd like to setup Burp to intercept traffic from the Android Emulator.为了执行一些 Android 渗透测试,我想设置 Burp 来拦截来自 Android 模拟器的流量。 Unfortunately, with later versions of Android, this requires modifying the manifest in order to include interception by a proxy with a user supplied certificate.不幸的是,在更高版本的 Android 中,这需要修改清单以包括由具有用户提供的证书的代理进行的拦截。 Surely, there is a better / easier way?当然,有更好/更简单的方法吗?

Yes, there is a better way.是的,有更好的方法。 You can create a certificate authority for Burp to utilize, and then add this certificate authority to the system partition so that its like any other CA and will automatically be trusted.您可以创建一个供 Burp 使用的证书颁发机构,然后将此证书颁发机构添加到系统分区中,以便它像任何其他 CA 一样自动被信任。

NOTE: I have found you can't just use the default CA from Burp and have this work.注意:我发现你不能只使用 Burp 的默认 CA 来完成这项工作。 You need to follow these full instructions to create a new CA.您需要按照这些完整说明创建新 CA。

Step #1: Setup a CA for Burp & Import It:第 1 步:为 Burp 设置 CA 并导入它:

  1. Download the latest version of OpenSSL and extract the zip file . 下载最新版本的 OpenSSL 并解压缩 zip 文件

  2. Either add the location of the extracted files to the path, and open up a command window or open up a command window in the same directory where you see "openssl.exe".将提取文件的位置添加到路径中,然后打开命令窗口或在您看到“openssl.exe”的同一目录中打开命令窗口。

  3. Execute the following commands to create a certificate authority, and sign a root certificate, following all the prompts:按照所有提示执行以下命令以创建证书颁发机构,并签署根证书:

    openssl genrsa -des3 -out burpCA.key 4096 openssl genrsa -des3 -out burpCA.key 4096

    openssl req -x509 -new -nodes -key burpCA.key -sha256 -days 2048 -out burpCA.crt openssl req -x509 -new -nodes -key burpCA.key -sha256 -days 2048 -out burpCA.crt

    openssl pkcs12 -export -in burpCA.crt -inkey burpCA.key -name burp -out burpCA.p12 openssl pkcs12 -export -in burpCA.crt -inkey burpCA.key -name burp -out burpCA.p12

  4. Open a project in Burp you're going to utilize and import burpCA.p12 and navigate to the "Proxy tab", and the "Options" section.在 Burp 中打开一个您将要使用的项目并导入 burpCA.p12 并导航到“代理选项卡”和“选项”部分。

  5. Click the button "Import / export CA certificate" and choose "Certificate and private key from PKCS#12 keystore" from under the "Import" section, and then click "Next".单击“导入/导出 CA 证书”按钮并从“导入”部分下选择“来自 PKCS#12 密钥库的证书和私钥”,然后单击“下一步”。

  6. Navigate to the burpCA.p12 file you created before and enter the password.导航到您之前创建的 burpCA.p12 文件并输入密码。

Step 2: Add the Certificate to the Android Emulator第 2 步:将证书添加到 Android 模拟器

This can either be done globally for ALL Android Virtual Devices (AVD) going forward, or can be done on a single AVD.这可以为所有 Android 虚拟设备 (AVD) 全局完成,也可以在单个 AVD 上完成。 I prefer to do it for everything going forward, but I will cover both.我更喜欢为未来的所有事情做这件事,但我会涵盖两者。

Option 1: Adding the Certificate Globally NOTE: This method does NOT require root access to the emulator, and therefore can be used with Google API versions.选项 1:全局添加证书注意:此方法不需要对模拟器进行 root 访问,因此可以与 Google API 版本一起使用。

  1. Download Arsenal Image Mounter and extract it.下载Arsenal Image Mounter并解压。 We're going to utilize this to edit the base system drive image.我们将利用它来编辑基本系统驱动器映像。

  2. Run Arsenal Image Mounter and open the system.img file for the SDK version(s) you want to edit.运行 Arsenal Image Mounter 并打开您要编辑的 SDK 版本的 system.img 文件。 When Aresenal prompts you, choose the option "Write original disk device".当 Aresenal 提示您时,选择“写入原始磁盘设备”选项。 The system.img files are found under the following directory: system.img 文件位于以下目录下:

    %userprofile%\AppData\Local\Android\Sdk\system-images %userprofile%\AppData\Local\Android\Sdk\system-images

eg For Nougat it would be found at the following location:例如,对于 Nougat,可以在以下位置找到:

%userprofile%\AppData\Local\Android\Sdk\system-images\android-25\default\x86_64\system.img
  1. Arsenal will mount the given system.img file and will assign it a drive letter.阿森纳将挂载给定的 system.img 文件并为其分配一个驱动器号。 Navigate to that drive and navigate to the following file path:导航到该驱动器并导航到以下文件路径:

    /etc/security/cacerts/ /etc/security/cacerts/

  2. Pick any Certificate Authority within that folder that you don't mind losing / becoming invalid and open it in notepad.在该文件夹中选择您不介意丢失/失效的任何证书颁发机构,然后在记事本中打开它。 This is done rather than adding a new file because in later versions of Android there are special SELinux tags on the existing files that are needed for the file to be able to be read that can't easily be created on Windows.这样做而不是添加新文件,因为在更高版本的 Android 中,现有文件上存在特殊的 SELinux 标签,这些标签是读取文件所需的,而这些标签在 Windows 上不容易创建。 If we edit a file, they are preserved / saved.如果我们编辑文件,它们会被保留/保存。 If we add a new file, we have to add these tags when Android is running, which is a pain with the system image being mounted read-only by default.如果我们添加一个新文件,我们必须在 Android 运行时添加这些标签,这对于默认挂载为只读的系统映像来说是一个痛苦。

If available, I'd choose 1676090a.0, which is associated with China Internet Network Information center.如果有的话,我会选择1676090a.0,它与中国互联网络信息中心相关联。

  1. Open burpCA.crt from wherever you created it in the CA steps, copy its contents, and paste it into the file you opened in the prior step and save it.从您在 CA 步骤中创建的任何位置打开 burpCA.crt,复制其内容,并将其粘贴到您在上一步中打开的文件中并保存。
  2. Unmount the system.img file from within Arsenal and create a new AVD utilizing the version of Android you just modified the system.img file for.从阿森纳中卸载 system.img 文件并使用您刚刚修改 system.img 文件的 Android 版本创建一个新的 AVD。

Option 2: Adding the Certificate to a Single Android Virtual Device NOTE: This can be done INSTEAD of the global option.选项 2:将证书添加到单个 Android 虚拟设备注意:这可以代替全局选项来完成。 You don't need to do this if you do the global option.如果您执行全局选项,则无需执行此操作。

  1. Create an Android Virtual Device within Android Studio and give it a simple name such as PT1.在 Android Studio 中创建一个 Android 虚拟设备,并给它一个简单的名称,例如 PT1。

  2. Open up a command window and navigate to the following directory:打开命令窗口并导航到以下目录:

    %userprofile%/AppData/Local/Android/Sdk/emulator/ %userprofile%/AppData/Local/Android/Sdk/emulator/

  3. Run the following command, substituting your AVD name for PT1:运行以下命令,将您的 AVD 名称替换为 PT1:

    emulator -avd PT1 -writable-system模拟器 -avd PT1 -writable-system

  4. When its booted up, in another command window run the following commands to run adb as root, and remount the drives:启动后,在另一个命令窗口中运行以下命令以 root 身份运行 adb,然后重新挂载驱动器:

    adb root adb remount adb root adb 重新挂载

  5. Copy your Burp certificate onto the system drive utilizing the following command.使用以下命令将 Burp 证书复制到系统驱动器上。 You will need to either do this from where you created your certificates, or have the file path properly reference that file:您需要从创建证书的位置执行此操作,或者让文件路径正确引用该文件:

    adb push burpCA.crt /etc/security/cacerts/000000.0 adb push burpCA.crt /etc/security/cacerts/000000.0

Step 3: Configure the AVD to Proxy第 3 步:将 AVD 配置为代理

  1. Configure Burp to listen on all interfaces by clicking on the Listener and choosing "Edit" under the "Options" page of the "Proxy" tab and choosing "Bind to Address: All interfaces"通过单击侦听器并在“代理”选项卡的“选项”页面下选择“编辑”并选择“绑定到地址:所有接口”,将 Burp 配置为侦听所有接口

  2. Get your IP address by opening a command window and running the command:通过打开命令窗口并运行以下命令来获取您的 IP 地址:

    ipconfig ipconfig

  3. Start your in Android Studio's Device Manager (Under "More Actions" from Android Studio).在 Android Studio 的设备管理器中启动您的设备(在 Android Studio 的“更多操作”下)。

  4. Hit the "..." from the bar that is to the right of the running emulator and choose "Settings" -> "Proxy" and enter your IP address and the port you have Burp listening on (Default is 8080).从正在运行的模拟器右侧的栏中点击“...”,然后选择“设置”->“代理”并输入您的 IP 地址和 Burp 侦听的端口(默认为 8080)。

NOTE: localhost does NOT work here.注意:本地主机在这里不起作用。 You need an actual interface IP address.您需要一个实际的接口 IP 地址。

You're now all set to proxy.您现在已全部设置为代理。 You should be able to go to SSL sites without an issue.您应该能够毫无问题地访问 SSL 站点。

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

相关问题 burp 套件适用于 android 原生应用程序吗? - Is burp suite worked for android native application? Burp Suite-Pixel 2 XL(Android P)找不到使用Burp Suite进行证书的方法 - Burp Suite - Pixel 2 XL (Android P) can't find a way to certificate using Burp Suite 在 android 8.1.0 上安装 burp 证书后出现“您的连接不是私有的”错误 - "YOUR CONNECTION IS NOT PRIVATE" error after installing burp certificate on android 8.1.0 我如何发布没有证书的android应用程序? - How can i publish my android application without certificate? 如何在没有用户交互的情况下以编程方式在 Android 上安装 CA 证书 - how to install CA certificate programmatically on Android without user interaction 如何使用给定的pfx证书文件将证书安装到android模拟器 - how to install a certificate to android emulator with a given pfx certificate file Android,无需模拟器或任何设备即可运行应用程序 - Android, Run application without emulator or any device 编译 android 应用程序而不将其发送到仿真器 - Compile android application without sending it to emulator 在模拟器中重新加载Android应用程序而无需在Eclipse中重新启动模拟器? - Reload Android application in emulator without restarting emulator in Eclipse? 如何激活组件以在另一个Android应用程序中利用? - How to activate a component to utilize within another application Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM