如何反编译我的 appconfig.json

How do I decompile my appconfig.json

我正在使用 Xamarin,我的所有 API 密钥都存储在我的 PCL 中一个名为 appconfig.json

的文件中

生成 APK 后,我的 API 密钥存储在哪里?

有人可以拿这个 APK 反编译得到这个文件的内容吗?

我知道这是可能的,但我使用的是 mac,因此无法使用 windows 工具。

有人可以引导我完成这些步骤,以便在编译后阅读 appconfig.json 的内容吗?这只是为了证明它可以完成——我知道它可以,只是花了我太长时间。谢谢!

对于 Android 应用,您可以在 APK 中包含任意文件作为 Assets

string config;

AssetManager assets = this.Assets;
using (StreamReader sr = new StreamReader (assets.Open ("appconfig.json")))
{
    config = sr.ReadToEnd ();
}

所以假设我在我的应用程序程序集之一(调用 SomeLibrary)中将此 json 文件标记为 EmbeddedResource

{
    "Password": "SushiHangover",
    "Logging": {
        "Debug": {
            "LogLevel": {
                "Default": "Warning"
            }
        },
        "Console": {
            "LogLevel": {
                "Default": "Warning"
            }
        }
    }
}

我存档并发布 .apk

提取 apk 内容

unzip com.sushihangover.SomeApp.apk -d foobar

搜索所有嵌入式资源:

使用ikdasm搜索嵌入资源:

find . -name "*.dll" -print0 | xargs -n 1 -0 -J % ikdasm % | grep .mresource

.mresource public charinfo.nlp
.mresource public collation.core.bin
.mresource public collation.tailoring.bin
.mresource public mscorlib.xml
.mresource public SomeLibrary.appconfig.json

找到 appconfig.json 资源,所以我们可以再次使用 ikdasm 从详细信息中获取。

SomeLibrary.appconfig.json 详情:

ikdasm assemblies/SomeLibrary.dll

结果:

~~~~
69 62 72 61 72 79 00 00 ) // ...SomeLibrary..
  .hash algorithm 0x00008004
  .ver 1:0:0:0
}
.mresource public SomeLibrary.appconfig.json
{
  // Offset: 0x00000000 Length: 0x00000116
  // WARNING: managed resource file SomeLibrary.appconfig.json created
}
.module SomeLibrary.dll
// MVID: {3100E9F8-3BB0-4E49-ADC7-33B284FCCFAE}
.imagebase 0x00400000
~~~~

string获取详细信息的程序集:

cd foobar
find . -name "*.dll" -print0 | xargs -n 1 -0 -J % strings %

~~~
mscoree.dll
!This program cannot be run in DOS mode.
.text
`.rsrc
@.reloc
    "Password": "SushiHangover",
    "Logging": {
        "Debug": {
            "LogLevel": {
                "Default": "Warning"
            }
        },
        "Console": {
            "LogLevel": {
                "Default": "Warning"
            }
        }
    }
BSJB
v4.0.30319
~~~~