pcap4j
pcap4j copied to clipboard
Add support for Android
GOGOGO
Oh. I've forgotten this....
How is the issue going?
I'm working on v2 and just waiting for someone's contribution for Android support for now....
Hey, how is the development going? Is there an ETA?
I'm planning to complete v2 development in March 2017. Then I will have time for Android support. It would take a month, I think.
I successfully added your library in Android project. I just need to write a Pcap file with ipv4 packets got from VPN . How can I do it?
Sorry but I'm not yet familiar with Android. It seems DNS66 project is using Pcap4J on Android, so could you consult its author?
Can i use this on Android to send ARP packet?
I have no idea for now.
Ok Thanks
Trying this library on android, I got:
FATAL EXCEPTION: main
Process: com.play.around, PID: 29329
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-arm/libjnidispatch.so) not found in resource path (.)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:866)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:826)
at com.sun.jna.Native.
How is the issue going?
No progress actually... I need to find someone who can help me.
I am not sure why this is happening. I got to the point where all the ".so" library would load properly but after that I get this error:
FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Error looking up function 'pcap_dump': undefined symbol: pcap_dump
at com.sun.jna.Function.<init>(Function.java:212)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:541)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:518)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:468)
at com.sun.jna.Function.getFunction(Function.java:82)
at org.pcap4j.core.NativeMappings.<clinit>(NativeMappings.java:47)
at org.pcap4j.core.NativeMappings.pcap_findalldevs(Native Method)
at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:51)
...........
However for this I had to custom compile libpcap(1.8.1) from here and include it in the project.
Is it that using libpcap 1.1.1 will fix this issue? or is this a entirely different problem?
I also tried to look at the DNS66 project. Didn't find anything special to make pcap4j work. :(
UPDATE: I got around the error that I was getting a while ago, and it was because of wrong config for building libpcap. I used the 1.3.0 version from here.
After compiling successfully, I found another problem. pcap4j can't find any interface in the device. Pcaps.findAllDevs() returns 0 length list. NifSelector().selectNetworkInterface() returns null. Most probably this is because of root access blocking the scan and root in android is only available via shell.
I think so, too. libpcap needs root privileges.
However, I noticed that tcpdump successfully and correctly runs and dumps all the packet information. The reason is most likely it can get root permission as its a native executable. That makes the only way to sniff on Android is using a native executable with a shell wrapper around it.
the main problem from what I can see is that you can't really have the app itself run in a root context (you can only open a root shell and run native programs from there). I was able to get it to work by re implementing the NativeMappings so instead of loading libpcap into the java process, I created a proxy native program that loads the library (and we can run it with root permissions from a shell) and using some dumb ipc (basically just using stdio) it will talk with the java program that will do all the calls.
I have not tested it with sending packets but I can get all the interfaces (even tho I am getting alot of not supported address families) and I can receive packets so it looks promising.
for the code of the native program and for the code of the java side
Sir,How is it going?I want to get some Information in LAN. I find it is available for Windows and Linux,But it is not useful when I play on the Android. Do you have any suggestions?