Android ioctl - root权限和使用

发布于 2024-11-28 17:46:44 字数 244 浏览 1 评论 0原文

我正在 Android 应用程序中开发一些路由功能,并且需要访问 ioctl。由于使用 ioctl 的应用程序需要 root 权限才能运行,因此我能够调用它们的唯一方法是链接一个单独的可执行文件并使用 Runtime.getRuntime().exec() 从 Java 调用它。

有没有一种方法可以从 Android 中的 JNI 访问 root 权限,而无需构建单独的可执行文件?构建可执行文件是访问 ioctl 的最佳方法吗?

I'm working on some routing functionality in an Android app, and need to access ioctls. Since apps that use ioctls need root permission to run, the only way I've been able to call them is linking a separate executable and calling that from Java with Runtime.getRuntime().exec().

Is there a way to access root permissions from JNI in Android without building a separate executable? Is building an executable the best approach to access an ioctl?

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

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

发布评论

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

评论(2

—━☆沉默づ 2024-12-05 17:46:44

非根进程无法成为根进程(除了漏洞利用之外),所以是的,您需要一个单独的进程。

这是从 Linux 继承下来的,没有改变 - 区别在于,没有直接的方法可以从启动器以 root 身份启动 Android 应用程序进程,因为这会向 zygote 发送意图,从而分叉并减少专门从事应用程序进程的子进程。 (可能有一种迂回方法来手动创建应用程序进程,但是您必须有一个应用程序进程来执行此操作,因此根据定义,它是一个辅助进程。并且,作为一个不是应用程序的应用程序,它的效率会很低。 zygote 的子进程不会继承系统库的共享映射,因此必须将其自己的唯一副本加载到内存中)

ioctl() 只是另一个系统调用,并且仅当对该 fd 的访问权限(来自其设备文件)时才需要 root ) 做。显然,对于您想要使用的那些来说就是这种情况,但其他人则没有特权。例如,大多数Android框架IPC最终都是通过Binder ioctl来实现的,它们通常用于控制网络套接字。

There is no means for a non-root process to become root (beyond exploits), so yes, you need a separate process.

This is inherited unchanged from linux - the difference being that there's no direct way to launch an android application process as root from the launcher, since that sends an intent to zygote which forks off and privilege-reduces a child that specializes into an application process. (There may be a roundabout method to manually create an application process, but you'd have to have an applications process to do it, so it would by definition be a secondary process. And it would be inefficient as an application that was not a child of zygote would not inherit the shared mapping of system libraries, and so would have to load its own unique copies into memory)

ioctl() is just another syscall, and only requires root if the access permissions to that fd (from its device file) does. Obviously that's the case for the ones you want to use, but others are unpriveleged. For example the majority of Android framework IPC is ultimately implemented with Binder ioctl's, and they are commonly used to control a network socket.

甜是你 2024-12-05 17:46:44

ioctl() 调用不明确要求 root 权限(或任何特定权限)才能使用。正如克里斯·斯特拉顿(Chris Stratton)所说,您需要获得访问相关特定设备的权限。如果您没有获得上述许可,则除了利用之外,您将无法获得其他许可。

您最终想要实现什么目标?

ioctl() calls do not explicitly require root permission (or any specific permission) to use. As Chris Stratton said, you'll need permission to access the particular device in question. If you don't have said permission, you're not going to get it other than exploits.

What are you ultimately trying to achieve?

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