如何打开“ adb shell”窗口在正在调试的应用程序的上下文中(在非root用户的设备上)? [英] How to open "adb shell" in context of application being debugged (on non-rooted device)?

查看:218
本文介绍了如何打开“ adb shell”窗口在正在调试的应用程序的上下文中(在非root用户的设备上)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我刚运行 adb shell 时,我从 uid = 2000(shell)gid = 2000(shell),没有对我的应用程序的ptrace访问权限。

When I just run adb shell, I get shell running from uid=2000(shell) gid=2000(shell), without ptrace access to my application.

如何用与已启动的应用程序相同的UID打开外壳程序?

How to open a shell with the same UID as launched application?

推荐答案

使用socat的解决方法:

Workaround way using socat:


  1. 添加 android。允许您访问您的应用程序;

  2. 放入 socat二进制文件镜像 )到 / data / local / tmp / 。确保每个人都可以启动它;

  3. 添加 Runtime.getRuntime()。exec( / data / local / tmp / socat tcp-l:4446,fork,reuseaddr exec:/ system / bin / sh,pty,stderr,setsid); 在基于Java的应用程序启动时;

  4. 亚行转发tcp:4446 tcp:4446

  5. 使用 socat`tty`,raw,echo = 0,opost = 1 tcp:127.0 .0.1:4446 在主机上连接到应用程序上下文中的Shell。

  1. Add android.permission.INTERNET to your application;
  2. Put socat binary (mirror) to /data/local/tmp/. Ensure everybody can start it;
  3. Add Runtime.getRuntime().exec("/data/local/tmp/socat tcp-l:4446,fork,reuseaddr exec:/system/bin/sh,pty,stderr,setsid"); at startup of your Java-based application;
  4. adb forward tcp:4446 tcp:4446
  5. Use socat `tty`,raw,echo=0,opost=1 tcp:127.0.0.1:4446 on host to connect to the shell in your application context.

请注意,此设置是不安全的,不应留在生产应用中。

Note that this setup is not secure and should not be left in production app.

这篇关于如何打开“ adb shell”窗口在正在调试的应用程序的上下文中(在非root用户的设备上)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆