Android port scanner tutorial with shell command

Android port scanner

Android port scanner shows all open ports in your android device. Along with the applications who opened those ports. It does this using shell command.

Class List:


Feature List:

1. Show all open ports
2. Applications package name and icon that open ports
3. Local IP
4. Foreign IP
5. Connection type
6. Connection status
7. Auto generation of Action button to go to the application info to force stop or anything
8. Firebase ad implementation
9. Refresh activity
10. Save log
11. Grab data from json file and show own advertise if permitted.


We are going to create:
1. A list activity named extending ListActivity
2. An adapter class named netInfoAdapter extending ArrayAdapter
3. A class named appNetInfo to get and add port type, uid, and conversion to string
4. An activity named to show solash screen with runtime permission check for nougat

We will use shell command using Runtime.getRuntime().exec() and pass command to it to get various port entry with pid. Commands are below:
“cat /proc/net/tcp”, “cat /proc/net/tcp6”, “cat /proc/net/udp”, “cat /proc/net/udp6”.
These commands will return us the details of all open port usage and we will organise that to show with a good structured list view. Usually it will return hexadecimal of the information that we will convert to string to view it in human readable form. Any application that open port will be grabbed by this app, also the type of network and their status will be shown as well. Usually the command returns pid attached with the port which is not human readable. We will get application package name from the pid to clearly understand which application opened the port.
Checkout the full source code of Port Scanner below.

Also you can check android port scanner apk from google play store before downloading the source to see how it works.

Android port scanner tutorial-1
Android port scanner tutorial-2

Post A Reply