简体   繁体   中英

Why can't my Android APP use tcpdump eventhough I change the permission of tcpdump to 777?

I change the permission of /system/xbin/tcpdump to 777 and write the code in my Android APP like below.
But I still get the error message "stderr=tcpdump: any: You don't have permission to capture on that device" and "stderr=(socket: Operation not permitted)" .

Is there anyone know what's the problem here? Thanks.

Process process

String[] cmd = {"/system/xbin/tcpdump", "-i any", "-w /sdcard/tcpdump.pkt"};  
TextUtils.join(" ", cmd);  
process = Runtime.getRuntime().exec(cmd);  
BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line;
while ((line = errorReader.readLine()) != null) {
  Log.d(TAG, "stderr="+line);
}

Android does not support raw sockets, which would include the ability to collect raw frames using a sniffer, by any user space process on non-rooted devices.

If you check the main support site for TCPDump on Android , you'll find that one of the very first requirements is a rooted Android device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM