运行时获取字节码

发布于 2024-12-21 02:45:18 字数 332 浏览 3 评论 0原文

在 Android 上,我需要在运行时从执行类中检索字节码。 如果您想知道为什么,原因是我想计算它的哈希值,以便实现一些反盗版机制来检查文件是否未被篡改。

无论如何,我正在这样尝试:

InputStream is = this.getClass().getClassLoader()
                     .getResourceAsStream("org/foo/bar");

无论我在 getResourceAsStream() 中传递哪个参数,它总是返回 null。

实际上有没有办法在 Android 上运行时访问字节码?

On Android, I need to retrieve the bytecode from the executing class at runtime.
If you're wondering why, the reason is that I'd like to compute a hash of it in order ton implement some anti-piracy mechanism that would check that the file hasn't been tampered.

Anyway, I'm trying it like this:

InputStream is = this.getClass().getClassLoader()
                     .getResourceAsStream("org/foo/bar");

Whichever parameter I pass in the getResourceAsStream(), it always return null.

Is there actually a way to get access ti the bytecode at runtime on Android?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆之渊 2024-12-28 02:45:18

不确定这是否可能,您应该信任用于 APK 的签名系统。我见过的唯一的黑客行为是将这个应用程序包装在另一个包含恶意代码的应用程序中,谷歌修复了这个问题(我认为)。类已经有一个哈希码,但我确信这不会给出与您想要执行的操作相同的结果。

如果有人可以更改您的代码,他们也会禁用您的检查。

我见过并尝试过一个逆向工程应用程序,用我自己的应用程序来检查 Android 字节代码的安全性,它只适用于 root 系统,并且禁用的代码非常可怕,无法使用。这与反汇编 Java 应用程序不同。

盗版游戏不需要修改。

Not sure if that is possible, you should trust the signature system used for APK's. The only hack that I have seen with these is wrapping that app in another app that contains the malicious code and Google fixed that ( I think ). Classes already have a hash code but I'm sure that will not give the same results to what you want to do.

If someone can change your code they will also disable your checks.

I have seen and tried a reverse engineering app to check the security of Android's byte code with an app of my own and it only worked on rooted systems and the disabled code is so horrendous it's unusable. It's not the same as dissembling a Java app.

Pirating a game does not require it to be modified.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文