How can I find out which ports are open on my Android device and how to close them?

Is there an easy way to see which ports are open on my Android device and how to close open ports?

+7
android ports
source share
3 answers
  • Create a Wi-Fi hotspot on your phone.
  • Connect the computer to the access point
  • use ipconfig or ifconfig to find out the IP address of the gateway (i.e. your IP address of the phone).
  • Download nmap: http://nmap.org/
  • Use the nmap command: nmap -sS -Pn -p- your_phone_ip_adress

open TCP ports will be shown as follows:


65531 closed ports PORT
PUBLIC SERVICE 53 / tcp open domain
8187 / tcp open unknown
38647 / tcp open unknown
42761 / tcp open unknown MAC address: A4: 9A: 58::: ** (Samsung Electronics Co.)


  • PS: For UDP ports use: nmap -sU -Pn -p- your_phone_ip_adress
+6
source share

You can determine the current open ports by reading text / proc pseudo-files, such as

/proc/net/tcp /proc/net/udp 

This is basically what the netstat command does (where implemented) - you might want to find and study the source of a simple netstat implementation (maybe it can be ported to java)

However, when running as an unprivileged appid application, you can only close sockets belonging to your own process (or workarounds related to ptrace or process processing, other processes belonging to your user ID). Also note that closing a socket does not necessarily make this port available for immediate reuse.

+3
source share

You can try various network commands through runtime and check the results

 // netstat -lptu // netstat -vat Process su = Runtime.getRuntime().exec("netstat -vat "); 
0
source share

All Articles