Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will it work for android os? #71

Closed
dkumar1987 opened this issue Apr 22, 2015 · 17 comments
Closed

Will it work for android os? #71

dkumar1987 opened this issue Apr 22, 2015 · 17 comments

Comments

@dkumar1987
Copy link

If i compile this as .so then it'll work in ip packet parsing?

@dkumar1987 dkumar1987 changed the title Will this work for android os? Will it work for android os? Apr 22, 2015
@mfontanini
Copy link
Owner

Good question. I guess it should, since android OS is Linux based. Of course you'd need to either compile inside an android OS, or cross-compile, but I guess it should work.

@einarjon
Copy link
Contributor

The answer is yes, but there are a couple of things that need to be done.
I've been meaning to push my changes upstream, but I'm still using libtins 2.0

  1. Add ifaddrs, because it is missing in the android NDK (or was when I last checked in jan 2014).
    https://github.com/kmackay/android-ifaddrs
    I use cmake to only include/compile that folder when building for android.
  2. Add libpcap (or at least the header files). Should be trivial.
  3. fix a compiler error in src/network_interface.cpp
--- a/src/network_interface.cpp
+++ b/src/network_interface.cpp
@@ -97,7 +97,7 @@ struct InterfaceInfoCollector {
-                        info->bcast_addr = IPv4Address(((struct sockaddr_in *)addr->ifa_ifu.ifu_broadaddr)->sin_addr.s_addr);
+                        info->bcast_addr = IPv4Address(((struct sockaddr_in *)addr->ifa_broadaddr)->sin_addr.s_addr);
  1. add a couple of includes in utils.cpp
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -43,6 +43,10 @@
+    #ifdef __ANDROID_API__
+        #include <linux/in.h>
+        #include <linux/in6.h>
+    #endif

@dkumar1987
Copy link
Author

Will libpcap work for non rooted devices in android?

@einarjon
Copy link
Contributor

It should be enough to add only pcap.h and pcap/bpf.h include files. That are the only includes that libtins is using*, and you don't actually need the libpcap.so binaries.

Otherwise you need to build and install the library. I'm not sure if you can do that on a non-rooted android.
*) At least for LibTins 2,0 without 802.11/WPA2 support.

@dkumar1987
Copy link
Author

Thanks, I try.

@mfontanini
Copy link
Owner

I just added those fixes to the code, so you shouldn't need to touch anything besides including the ifaddrs files.

Thanks @einarjon for the instructions! I'm going to add some tutorial on the website on how to compile it on android soon based on them.

Closing since it should compile on android now.

@nbroeking
Copy link

I know this issue is closed but I figured I would add another comment because I know many people will be frustrated with the information given. It will compile for android but it wont run. Android does not have the proper drivers installed to do monitor mode on their devices and thus you need to get drivers that can do that work for you. You should look into the work being done on bcmon.

@lattice0
Copy link
Contributor

But instead of monitoring can I craft and send packets in Android and iOS?

@einarjon
Copy link
Contributor

einarjon commented Dec 20, 2019 via email

@lattice0
Copy link
Contributor

Are the modifications still needed?

https://github.com/kmackay/android-ifaddrs

does not exists anymore

@ilyasKerbal
Copy link

@lattice0 any updates?

@lattice0
Copy link
Contributor

lattice0 commented Nov 21, 2022 via email

@ilyasKerbal
Copy link

Thanks @lattice0 #471
Can you share the steps to setup?

@lattice0
Copy link
Contributor

lattice0 commented Nov 21, 2022 via email

@ilyasKerbal
Copy link

For some reason I get the following error:

  1. Could NOT find PCAP (missing: PCAP_LIBRARY PCAP_INCLUDE_DIR)

@lattice0

@lattice0
Copy link
Contributor

You can disable https://github.com/mfontanini/libtins/blob/master/CMakeLists.txt#L60

maybe unset(LIBTINS_ENABLE_PCAP) or set(LIBTINS_ENABLE_PCAP OFF) before add_subdirectory, I don't remember exactly

@ilyasKerbal
Copy link

Thank you so much @lattice0 I just solved the problem. Your guidance helped a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants