相关疑难解决方法(0)

从VPN Service + Packets阻止[Android]检测应用程序请求

我试图找出我的设备上的哪个应用程序已经发出任何互联网使用请求(称为任何api等).为此我创建了一个从"VpnService"类扩展的类,以确保我的设备流量通过我,虽然我实际上并没有连接到VPN,而是假装它让流量通过我到0.0.0.0.代码如下,它工作正常,但我想弄清楚哪个应用程序已启动使用互联网的请求或其数据包是在下面的主循环中进/出.另外,有没有办法可以阻止来自任何应用程序的请求 - 无论是[传入还是传出]?

    *private Thread mThread;
private ParcelFileDescriptor mInterface;
//a. Configure a builder for the interface.
Builder builder = new Builder();
// Services interface
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    this.getApplicationInfo();
    // Start a new session by creating a new thread.
    mThread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                //a. Configure the TUN and get the interface.
                mInterface = builder.setSession("MyVPNService")
                        .setMtu(1500)
                        .addAddress("192.168.1.66", 32)
                        .addRoute("0.0.0.0", 0).establish();
                //b. Packets to be sent are …
Run Code Online (Sandbox Code Playgroud)

java vpn android

10
推荐指数
1
解决办法
2492
查看次数

Android Q 中访问 /proc/net/tcp

在 Android-9 之前的我的 VPN 应用程序中,可以/proc/net/tcp从针对 API 级别 < 28 的应用程序读取文件。在 Android Q 中,从应用程序进行访问似乎不再有效。我 /proc/net/tcp: open failed: EACCES (Permission denied)在尝试读取文件时遇到错误。

在 Android-Q 隐私变更中,谷歌解决了访问 /proc/net 文件系统的限制

我认为ConnectivityManager.getConnectionOwnerUid()如果应用程序的compileSDK版本是29就可以使用。但不幸的是,目前我无法更改我的compileSDK版本,但我将targetSDK版本更新到最新的IE,29。

还有其他可能的方式来读取 Android-10 中的文件吗?贴出我的代码供参考

public static final int INDEX_UID_COL = 7;
public static final int INDEX_LOCAL_ADDRESS_COL = 1;
public static final String PROC_FILE = "/proc/net/tcp";

 public static String getPackageName(Context context, int srcPort) {
        String packageName = "";
        try {

            BufferedReader br = new BufferedReader(new FileReader(PROC_FILE));

            //Ignore first line
            String line …
Run Code Online (Sandbox Code Playgroud)

ip networking android linux-kernel android-10.0

7
推荐指数
1
解决办法
7070
查看次数

标签 统计

android ×2

android-10.0 ×1

ip ×1

java ×1

linux-kernel ×1

networking ×1

vpn ×1