adb forward支持无root通过vsock通信 #2
AngelaCooljx
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
这是不是就是官方终端的玩法 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
参考: https://github.com/msft-mirror-aosp/platform.packages.modules.Virtualization/blob/c984fc337c11ca5edc03ccf02037b2455dd8fcaf/android/vm/vm_shell.sh#L44
cid在
/apex/com.android.virt/bin/vm list就能看到一个示例使用场景:vm内预装好 openssh-server 和 socat 等软件包,开启sshd服务,使用 socat 捕获 TCP 22 流量,将其塞进 VSOCK 端口
socat VSOCK-LISTEN:22,fork TCP:127.0.0.1:22 > /tmp/ssh_vsock.log 2>&1 &宿主机 adb 无线配对和连接本机后使用
adb forward tcp:22222 vsock:2048:22(CID按实际情况填写)将流量吐给宿主机本地 TCP 22222,本机就可以ssh root@localhost -p22222直接连接vm了配合ssh -R或者gost搭建反向隧道再通过搭建http/socks5 proxy, wireguard等代理或组网工具理论上是可以让vm正常访问互联网的,同时还得在vm内用date命令手动更正当前时间,不过实际体验一言难尽,只要流量稍大一点速度就降为0卡住,降低MTU、限流等手段无解,暂时没找到好的解决办法
补充一个可能有用的东西 https://github.com/containers/gvisor-tap-vsock ,可以直接在vm内实现一个虚拟网卡,暂未尝试,无root的话大概率没戏补充:vm内不用socat直接创建一个ssh-vsock服务监听vsock::22也行
Beta Was this translation helpful? Give feedback.
All reactions