Skip to content

RF Sentinel (RFSentinel): free, open-source police detector app for Android. Spots police body cams, Flock ALPR cameras, AirTag trackers, Remote ID drones, smart glasses and fake cell towers from Bluetooth LE and WiFi. No root.

Categories from every identification clue; WiFi-client type in no category; beacon-named TVs on hidden networks

CIS-C0951457862554
diff --git a/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt b/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
index 10a5ef0..9266d1c 100644
--- a/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
+++ b/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
@@ -137,6 +137,51 @@ object DeviceIntel {
type?.let { PHONE_TYPE.containsMatchIn(it) } == true ||
name?.let { PHONE_NAME.containsMatchIn(it) && !NOT_PHONE_NAME.containsMatchIn(it) } == true
+ /** A device heard on a network (not an access point): it could be anything. */
+ const val WIFI_CLIENT_TYPE = "WiFi device (laptop, phone or camera on a network)"
+
+ /** What a name or model text says a device is (a network name's pattern, else a device name's), or null. */
+ fun textType(text: String): String? = ssidType(text) ?: NAME_TYPES.firstOrNull { it.first.containsMatchIn(text) }?.second
+
+ /** WPS device categories that name a kind the list has a category for (not routers: a provider's hotspot runs on one). */
+ private val WPS_KIND_TYPES = mapOf(
+ "Computer" to "Computer", "Camera" to "Camera", "Display" to "Smart TV / streaming device",
+ "Multimedia device" to "Smart TV / streaming device", "Gaming device" to "Game console", "Phone" to "Phone",
+ "Audio device" to "Audio device"
+ )
+
+ private fun vendorKind(v: String) = VENDOR_CLASSES.firstOrNull { it.first.containsMatchIn(v.trim()) }?.second
+
+ /** Maker classes that place a device from any evidence (not chip-module makers nor brand-wide guesses). */
+ private val HINT_VENDOR_KINDS by lazy {
+ WIFI_VENDOR_KINDS - setOf("IoT / smart-home module", "Smart-home / camera device") + setOf("Audio device", "Zepcam body camera")
+ }
+ private val PRODUCT_IN_PARENS = Regex("\\((.+)\\)$")
+ private val hintCache = java.util.concurrent.ConcurrentHashMap<List<Any?>, List<String>>()
+
+ /**
+ * Every kind of device the evidence points to besides the type that won: the device name (not a network
+ * name, which already decided the type), the beacon's WPS name, model and kind, its equipment makers'
+ * tags, the advertised appearance and model IDs, and the address registrant. The category chips use them
+ * all, so a device lands in its category whichever clue names it.
+ */
+ fun hintTypes(name: String?, facts: List<Pair<String, String>>, vendor: String?, nameIsSsid: Boolean): List<String> {
+ val key = listOf(name.takeUnless { nameIsSsid }, vendor, facts)
+ hintCache[key]?.let { return it }
+ val out = LinkedHashSet<String>()
+ if (!nameIsSsid) name?.takeIf { it.isNotBlank() }?.let { textType(it)?.let(out::add) }
+ for ((k, v) in facts) when (k) {
+ "AP model (WPS)", "AP device name (WPS)" -> textType(v)?.let(out::add)
+ "Apple model ID", "Google Fast Pair" -> PRODUCT_IN_PARENS.find(v)?.groupValues?.get(1)?.let { p -> out += p; textType(p)?.let(out::add) }
+ "Network name suggests", "Appearance" -> out += v
+ "Device kind (WPS)" -> WPS_KIND_TYPES[v]?.let(out::add)
+ "Equipment maker (vendor IEs)" -> v.split(", ").forEach { m -> vendorKind(m)?.takeIf { it in HINT_VENDOR_KINDS }?.let(out::add) }
+ }
+ vendor?.let { v -> vendorKind(v)?.takeIf { it in HINT_VENDOR_KINDS }?.let(out::add) }
+ if (hintCache.size > 5000) hintCache.clear()
+ return out.toList().also { hintCache[key] = it }
+ }
+
/** What a network's name says it is ([SSID_TYPES]), or null. */
fun ssidType(ssid: String): String? = SSID_TYPES.firstOrNull { it.first.containsMatchIn(ssid.trim()) }?.second
@@ -443,7 +488,7 @@ object DeviceIntel {
}
val ssid = a.name
val type = when {
- w?.client == true -> "WiFi device (laptop, phone or camera on a network)"
+ w?.client == true -> WIFI_CLIENT_TYPE
w?.standard == WIFI_AWARE -> "Drone Remote ID over Wi-Fi Aware"
ssid.isNullOrEmpty() -> "Hidden WiFi network"
TRAIN_SSID.containsMatchIn(ssid) -> "Train WiFi (passenger rail)"
@@ -482,6 +527,19 @@ object DeviceIntel {
}
if (!generic) return Identity(type, facts)
+ // What the beacon itself says the device is: its WPS name or model ("65\" TCL Roku TV"), else an
+ // equipment maker's tag (Roku, Nintendo...). Not a router or hotspot name: those are sorted below.
+ val byBeacon = listOfNotNull(ap.deviceName, ap.model).firstNotNullOfOrNull { t ->
+ textType(t)?.takeIf { !isRouter(it) && !it.contains("hotspot", true) && !it.contains("wifi", true) }
+ }?.let { (if (it == "TV / streaming device") "Smart TV / streaming device" else it) to "WPS name or model in the beacon" }
+ ?: ap.equipmentVendors.firstNotNullOfOrNull { v -> vendorKind(v)?.takeIf { it in WIFI_VENDOR_KINDS } }
+ ?.let { it to "equipment maker's tag in the beacon (vendor IE)" }
+ if (byBeacon != null) {
+ facts += "Identified by" to byBeacon.second
+ if (ssid.isNullOrEmpty()) facts += "Network name" to "Hidden (not broadcast)"
+ return Identity("${byBeacon.first} (WiFi)" + (ap.model?.let { " - $it" } ?: ""), facts)
+ }
+
// What kind of network a plain or hidden name hides, from the beacon itself.
networkKind(w, ap, macVendor, ssid.isNullOrEmpty())?.let { (kind, why) ->
facts += "Identified by" to why
diff --git a/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt b/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
index d47c66b..146ce69 100644
--- a/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
+++ b/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
@@ -497,7 +497,7 @@ object DeviceRegistry {
*/
private fun hiddenRouterType(t: Track): String? {
if (Advert.Source.WIFI !in t.sources || !t.name.isNullOrEmpty() || t.advert?.wifi?.client == true) return null
- if (DeviceIntel.isRouter(t.identity.type)) return null
+ if (DeviceIntel.isRouter(t.identity.type) || t.identity.type.contains(" (WiFi)")) return null
return tracks.values.firstNotNullOfOrNull { o ->
if (o === t || !WifiFingerprint.sameAccessPoint(t.mac, o.mac)) null
// Read without locking [o]: this runs under [t]'s lock, and the sibling facts lock the other way round.
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt
index 833880d..8b0bf0a 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt
@@ -63,7 +63,14 @@ enum class DeviceFilter(val label: String, val liveOnly: Boolean = false) {
val remoteId: Boolean = false,
/** The address registrant, when the address is a fixed one. */
val vendor: String? = null
- )
+ ) {
+ /** The type and every other kind the evidence points to ([DeviceIntel.hintTypes]): the category chips use them all. */
+ val types: List<String> by lazy {
+ // A device heard on someone's network only says it's some WiFi device: it counts for no category by itself.
+ listOfNotNull(type.takeUnless { it.startsWith(DeviceIntel.WIFI_CLIENT_TYPE) }) + DeviceIntel.hintTypes(name, facts, vendor, nameIsSsid = Advert.Source.BLE !in sources && Advert.Source.WIFI in sources)
+ }
+ fun anyType(re: Regex) = types.any { re.containsMatchIn(it) }
+ }
fun matches(s: DeviceRegistry.Snapshot): Boolean = matches(seen(s))
@@ -83,18 +90,19 @@ enum class DeviceFilter(val label: String, val liveOnly: Boolean = false) {
FAVORITES -> Favorites.contains(s.mac)
BLE -> Advert.Source.BLE in s.sources
WIFI -> Advert.Source.WIFI in s.sources
- VEHICLES -> VEHICLE_TYPE.containsMatchIn(s.type) || s.hits.any { it.category == Category.V2X }
+ // The kinds below look at every clue (the type and the hints, see [Seen.types]), not only the type that won.
+ VEHICLES -> s.anyType(VEHICLE_TYPE) || s.hits.any { it.category == Category.V2X }
// A watch counts as its owner's phone for tracker checks, not on this chip.
- PHONES -> DeviceIntel.isPhone(s.type, s.name) && !s.type.startsWith("Apple Watch")
- AUDIO -> (AUDIO_TYPE.containsMatchIn(s.type) || s.facts.contains("Identified by" to "Fast Pair model ID")) &&
+ PHONES -> (s.types.any { DeviceIntel.isPhone(it, null) } || DeviceIntel.isPhone(null, s.name)) && !s.type.startsWith("Apple Watch")
+ AUDIO -> (s.anyType(AUDIO_TYPE) || s.facts.contains("Identified by" to "Fast Pair model ID")) &&
s.hits.none { it.category == Category.AUDIO_SENSOR }
- CAMERAS -> CAMERA_TYPE.containsMatchIn(s.type) || s.hits.any { it.category in CAMERA_CATEGORIES }
- ROUTERS -> DeviceIntel.isRouter(s.type)
- HOTSPOTS -> HOTSPOT_TYPE.containsMatchIn(s.type)
- TVS -> TV_TYPE.containsMatchIn(s.type)
- SMART_HOME -> SMART_HOME_TYPE.containsMatchIn(s.type) && !VEHICLE_TYPE.containsMatchIn(s.type)
- COMPUTERS -> COMPUTER_TYPE.containsMatchIn(s.type) || s.name?.let { COMPUTER_NAME.containsMatchIn(it) } == true
- APPLE -> APPLE_TYPE.containsMatchIn(s.type) || s.vendor?.startsWith("Apple", ignoreCase = true) == true ||
+ CAMERAS -> s.anyType(CAMERA_TYPE) || s.hits.any { it.category in CAMERA_CATEGORIES }
+ ROUTERS -> s.types.any { DeviceIntel.isRouter(it) }
+ HOTSPOTS -> s.anyType(HOTSPOT_TYPE)
+ TVS -> s.anyType(TV_TYPE)
+ SMART_HOME -> s.anyType(SMART_HOME_TYPE) && !s.anyType(VEHICLE_TYPE)
+ COMPUTERS -> s.anyType(COMPUTER_TYPE) || s.name?.let { COMPUTER_NAME.containsMatchIn(it) } == true
+ APPLE -> s.anyType(APPLE_TYPE) || s.vendor?.startsWith("Apple", ignoreCase = true) == true ||
s.hits.any { com.rfsentinel.app.detect.SignatureEngine.isAppleFindMy(it) }
}
diff --git a/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt b/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
index d893a95..dc1fac1 100644
--- a/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
+++ b/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
@@ -346,7 +346,42 @@ class IdentifyMoreTest {
assertEquals(listOf(DeviceFilter.APPLE), kinds("Bluetooth device", vendor = "Apple, Inc."))
// Not computers: a guess that may be a phone, a plain WiFi client, a machine-like word.
assertTrue(DeviceFilter.COMPUTERS !in kinds("Apple device (iPhone, iPad, Mac or Watch)"))
- assertTrue(DeviceFilter.COMPUTERS !in kinds("WiFi device (laptop, phone or camera on a network)"))
+ assertEquals(emptyList<DeviceFilter>(), kinds("WiFi device (laptop, phone or camera on a network)"))
assertTrue(DeviceFilter.COMPUTERS !in kinds("Machine sensor"))
}
+
+ @Test
+ fun categoriesFromEveryClue() {
+ fun tlv(type: Int, value: String) = byteArrayOf((type shr 8).toByte(), type.toByte(), 0, value.length.toByte()) + value.toByteArray()
+ fun wps(vararg attrs: ByteArray) = 221 to (byteArrayOf(0x00, 0x50, 0xF2.toByte(), 0x04) + attrs.fold(ByteArray(0)) { a, b -> a + b })
+ val rokuTag = 221 to byteArrayOf(0xD8.toByte(), 0x31, 0x34, 0x01, 0x02)
+ fun hidden(mac: String, ies: List<Pair<Int, ByteArray>>) = DeviceIntel.identify(
+ Advert(mac, Advert.Source.WIFI, -60, null, wifi = Advert.WifiInfo(2437, "[WPA2-PSK-CCMP]", null, ies)), VendorDb.macVendor(mac))
+
+ // A TV's hidden network (random address) named by its WPS device name, or by the maker's tag alone.
+ val tv = hidden("06:00:00:00:00:81", listOf(wps(tlv(0x1011, "65\" TCL Roku TV")), rokuTag))
+ assertEquals("Smart TV / streaming device (WiFi)", tv.type)
+ assertTrue(tv.facts.contains("Network name" to "Hidden (not broadcast)"))
+ assertEquals("Smart TV / streaming device (WiFi)", hidden("06:00:00:00:00:82", listOf(rokuTag)).type)
+ // A router's WPS name stays a router.
+ val router = DeviceIntel.identify(Advert("02:11:22:33:44:83", Advert.Source.WIFI, -60, null,
+ wifi = Advert.WifiInfo(2437, "[WPA2-PSK-CCMP]", null, listOf(wps(tlv(0x1021, "NETGEAR, Inc."), tlv(0x1023, "R7000"), tlv(0x1011, "Nighthawk"))))))
+ assertEquals("Home router - NETGEAR R7000", router.type)
+
+ // The chips read every clue, not only the type that won.
+ fun kinds(type: String, facts: List<Pair<String, String>> = emptyList(), name: String? = null, vendor: String? = null,
+ sources: Set<Advert.Source> = setOf(Advert.Source.WIFI)) =
+ DeviceFilter.KINDS.filter { it.matches(DeviceFilter.Seen("06:00:00:00:00:84", type, name, emptyList(), sources, false, facts, vendor = vendor)) }
+ assertEquals(listOf(DeviceFilter.TVS), kinds("Hidden WiFi network", listOf("AP device name (WPS)" to "65\" TCL Roku TV")))
+ assertEquals(listOf(DeviceFilter.TVS), kinds("Hidden WiFi network", listOf("Equipment maker (vendor IEs)" to "Roku")))
+ assertEquals(listOf(DeviceFilter.TVS), kinds("WiFi access point", listOf("Device kind (WPS)" to "Gaming device")))
+ assertTrue(DeviceFilter.AUDIO in kinds("Bluetooth device", listOf("Google Fast Pair" to "Ready to pair, model ID 0x123456 (Pixel Buds Pro)"),
+ sources = setOf(Advert.Source.BLE)))
+ assertTrue(DeviceFilter.COMPUTERS in kinds("Bluetooth device", name = "Jane's MacBook Air", sources = setOf(Advert.Source.BLE)))
+ assertTrue(DeviceFilter.TVS in kinds("Bluetooth device", vendor = "Roku, Inc.", sources = setOf(Advert.Source.BLE)))
+ // A network's name already decided its type: it isn't read again (a router called "Galaxy" isn't a phone).
+ assertTrue(DeviceFilter.PHONES !in kinds("Home router - NETGEAR", name = "Galaxy"))
+ // A provider's hotspot on a home gateway stays off Routers.
+ assertEquals(listOf(DeviceFilter.HOTSPOTS), kinds("Public WiFi hotspot (Passpoint)", listOf("Device kind (WPS)" to "Router")))
+ }
}