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.