In this post, I’m going to talk about my new library for using NMAP in any Android project. I’ve released the library in my GitHub and Bintray. Using the library, you can use NMAP on non rooted Android device.
Alternatives
It is similar to other projects available in Google play such as Network Mapper. Actually the binary library is based on the binary versions published by kost same author of Network Mapper.
The binary files of NMAP are available in kosts’s GitHub repository.
How To Use
There is three simple step for using the library in your project:
- Add INTERNET permission to the Manifest
- Add NMAPAndroid dependency in your app level Gradle file.
- Write the simple code!
Here is the permission:
<uses-permission android:name="android.permission.INTERNET" />
Here is the dependency:
implementation 'ir.mstajbakhsh:nmap-android:1.0.0'
Here is the simple code:
NMAPUtilities n = new NMAPUtilities(context); n.startInstallation(); final StringBuilder line_buffer = new StringBuilder(); OutputStream ops = new OutputStream() { @Override public void write(int b) { if (b == '\n') { System.out.println(line_buffer.toString()); line_buffer.setLength(0); } else { line_buffer.append(Character.toChars(b)); } } }; try { n.execCommand(ops, "-A", "192.168.1.0/24", "--system-dns"); } catch (Exception e) { e.printStackTrace(); }
Here is the sample output of the project:

Limitation
Due to the size limit, only two binary versions are included inside the library including: arm and x86. Additionally, the flow chart of automatic installation of the library is depicted below:

Source Code
The source code is available in my personal repository in GitHub. https://github.com/mirsamantajbakhsh/NMAPAndroid
Donation
Do not forget to buy me a cup of coffee. My bitcoin wallet address is:
1F5uiEmdCLJX5KktWHE1wkc63feKJYMmxS