csicar / Ning

Network-Scanner for Android
216 stars 35 forks source link

Vendor detection not working on android 11 #118

Open 5hahryar opened 2 years ago

5hahryar commented 2 years ago

Hello, because of the new restrictions on android for accessing the ARP table and ip commands, the mac address and vendor detection do not work any more. Is there any way to fix this issue? I've noticed some apps have found a way to work around this.

csicar commented 2 years ago

Yeah. Good point. I'll try to fix this

5hahryar commented 2 years ago

These are the ways that I've tried and failed:

  1. Set the target SDK on 29 and below, which solves the problem but any app that uses this method can no longer be published on google play.
  2. Using raw sockets in order to read the ethernet frame of packets and find the destination mac address; looks like it cannot be done because sending these kinds of packets needs root access.
  3. Using protocols like UPNP, NetBios, NSD, mDNS, ... which are very useful sometimes to gather additional data from the network, but none provide the desired information.
  4. Using SNMP; I came across this protocol when I was capturing packets that "Fing" sends throughout the network on port 161. I'm not sure if it is being used to gather mac address info or some other type of data. just consider this as a possible solution.
csicar commented 2 years ago

In my PR i chose the 1. approach. I'm not publishing to google play atm, so luckily I don't need to care about googles rules.

Ning already has a custom mDNS system (because the android buildin system is slow and unreliable). There seem to be some bugs in parsing the DNS-Records resulting in some response data not being understood by Ning.

looks like it cannot be done because sending these kinds of packets needs root access.

If I would require root access, reading from /proc/arp would also be possible

Option 4 founds interesting. I have never heard of SNMP, so I might look into that

Android-X13 commented 1 year ago

Vendor detection has lately (during the past couple weeks?) stopped working for me on Android 10.

apollo1220 commented 1 year ago

Even with the targetSdk set to 29 this doesn't work on Android 13 Looks like SNMP isn't enabled by default on most devices, so that must not be what Fing is relying on (which Fing does still work on Android 13)

apollo1220 commented 1 year ago

I found this library which replacing the attempt to read /proc/net/arp with this and then changing index 3 to 4 when mapping gets it working for Android 13 as long as you continue to target sdk 29

https://github.com/fulvius31/ip-neigh-sdk30