# Reversing Native Libraries

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

### [WhiteIntel](https://whiteintel.io)

<figure><img src="/files/YEhfJ0lgKxxdqFKA17yB" alt=""><figcaption></figcaption></figure>

[**WhiteIntel**](https://whiteintel.io) 是一个由**暗网**支持的搜索引擎，提供免费功能，用于检查公司或其客户是否受到**窃取恶意软件**的**侵害**。

WhiteIntel的主要目标是打击由信息窃取恶意软件导致的账户劫持和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

***

**更多信息请查看：**[**https://maddiestone.github.io/AndroidAppRE/reversing\_native\_libs.html**](https://maddiestone.github.io/AndroidAppRE/reversing_native_libs.html)

Android应用程序可以使用本地库，通常用C或C++编写，用于性能关键任务。恶意软件创建者也使用这些库，因为它们比DEX字节码更难逆向工程。本节强调针对Android定制的逆向工程技能，而不是教授汇编语言。提供ARM和x86版本的库以确保兼容性。

### 关键要点：

* **Android应用程序中的本地库：**
* 用于性能密集型任务。
* 用C或C++编写，使逆向工程具有挑战性。
* 以`.so`（共享对象）格式找到，类似于Linux二进制文件。
* 恶意软件创建者更喜欢本地代码以增加分析难度。
* **Java本机接口（JNI）和Android NDK：**
* JNI允许在本地代码中实现Java方法。
* NDK是用于编写本地代码的Android特定工具集。
* JNI和NDK将Java（或Kotlin）代码与本地库连接起来。
* **库加载和执行：**
* 使用`System.loadLibrary`或`System.load`将库加载到内存中。
* 在加载库时执行JNI\_OnLoad。
* Java声明的本机方法链接到本机函数，实现执行。
* **将Java方法链接到本机函数：**
* **动态链接：** 本地库中的函数名称与特定模式匹配，从而实现自动链接。
* **静态链接：** 使用`RegisterNatives`进行链接，提供函数命名和结构的灵活性。
* **逆向工程工具和技术：**
* 工具如Ghidra和IDA Pro有助于分析本地库。
* `JNIEnv`对于理解JNI函数和交互至关重要。
* 提供练习以实践加载库、链接方法和识别本机函数。

### 资源：

* **学习ARM汇编：**
* 建议深入了解底层架构。
* 推荐来自Azeria Labs的[ARM汇编基础知识](https://azeria-labs.com/writing-arm-assembly-part-1/)。
* **JNI和NDK文档：**
* [Oracle的JNI规范](https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/jniTOC.html)
* [Android的JNI技巧](https://developer.android.com/training/articles/perf-jni)
* [开始使用NDK](https://developer.android.com/ndk/guides/)
* **调试本地库：**
* [使用JEB反编译器调试Android本地库](https://medium.com/@shubhamsonani/how-to-debug-android-native-libraries-using-jeb-decompiler-eec681a22cf3)

### [WhiteIntel](https://whiteintel.io)

<figure><img src="/files/YEhfJ0lgKxxdqFKA17yB" alt=""><figcaption></figcaption></figure>

[**WhiteIntel**](https://whiteintel.io) 是一个由**暗网**支持的搜索引擎，提供免费功能，用于检查公司或其客户是否受到**窃取恶意软件**的**侵害**。

WhiteIntel的主要目标是打击由信息窃取恶意软件导致的账户劫持和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacktricks.xsx.tw/mobile-pentesting/android-app-pentesting/reversing-native-libraries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
