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.

Probe fingerprint: WPS UUID, probe details, sharing count, UUID grouping

CIS-C00e8dbd565d09
diff --git a/app/src/main/java/com/rfsentinel/app/data/ProbeLog.kt b/app/src/main/java/com/rfsentinel/app/data/ProbeLog.kt
index 2d4c7d5..384eaa9 100644
--- a/app/src/main/java/com/rfsentinel/app/data/ProbeLog.kt
+++ b/app/src/main/java/com/rfsentinel/app/data/ProbeLog.kt
@@ -32,13 +32,13 @@ object ProbeLog {
@Synchronized
fun record(context: Context, mac: String, ssids: Collection<String>, rssi: Int, now: Long = System.currentTimeMillis(),
force: Boolean = false, wps: com.rfsentinel.app.usb.ProbeIntel.Wps? = null, fingerprint: String? = null,
- at: Pair<Double, Double>? = null) {
+ at: Pair<Double, Double>? = null, traits: String? = null) {
if (ssids.isEmpty() && wps == null && fingerprint == null) return
if (!(force || com.rfsentinel.app.util.Prefs.recordProbes(context))) return
ensureLoaded(context)
ssids.forEach { book.record(it, mac, rssi, now, at) }
if (at != null && onMap?.let { m -> ssids.any { it.equals(m, ignoreCase = true) } } == true) version++
- if (!book.recordDevice(mac, ssids, rssi, now, wps?.deviceName, wps?.product, fingerprint)) return
+ if (!book.recordDevice(mac, ssids, rssi, now, wps?.deviceName, wps?.product, fingerprint, wps?.uuid, traits)) return
dirty = true
if (now - lastSave > SAVE_EVERY_MS) save(context, now)
}
@@ -156,12 +156,16 @@ class ProbeBook(private val maxNetworks: Int = 1000, private val maxDevices: Int
/** Maker, model and number from its WPS block. */
var wpsProduct: String? = null,
/** How it builds its probe requests ([com.rfsentinel.app.usb.ProbeIntel.fingerprint]). */
- var fingerprint: String? = null
+ var fingerprint: String? = null,
+ /** Its WPS UUID: the same on every address of one device ([com.rfsentinel.app.usb.ProbeIntel.Wps.uuid]). */
+ var wpsUuid: String? = null,
+ /** What its probe requests say about it in words ([com.rfsentinel.app.usb.ProbeIntel.traits]). */
+ var traits: String? = null
)
/**
- * Devices shown together: one address, or random addresses with the same rare probe fingerprint that
- * asked for a network name in common ([likelySame]).
+ * Devices shown together: one address, or addresses with the same WPS UUID, or random addresses with
+ * the same rare probe fingerprint that asked for a network name in common ([likelySame]).
*/
data class Group(val devices: List<Device>, val likelySame: Boolean) {
val lastSeen get() = devices.maxOf { it.lastSeen }
@@ -213,7 +217,8 @@ class ProbeBook(private val maxNetworks: Int = 1000, private val maxDevices: Int
* kept; returns false when nothing was noted.
*/
fun recordDevice(mac: String, ssids: Collection<String>, rssi: Int, now: Long,
- wpsName: String? = null, wpsProduct: String? = null, fingerprint: String? = null): Boolean {
+ wpsName: String? = null, wpsProduct: String? = null, fingerprint: String? = null,
+ wpsUuid: String? = null, traits: String? = null): Boolean {
val m = mac.uppercase()
val d = probers[m] ?: run {
if (ssids.isEmpty()) return false
@@ -227,6 +232,8 @@ class ProbeBook(private val maxNetworks: Int = 1000, private val maxDevices: Int
wpsName?.let { d.wpsName = it }
wpsProduct?.let { d.wpsProduct = it }
fingerprint?.let { d.fingerprint = it }
+ wpsUuid?.let { d.wpsUuid = it }
+ traits?.let { d.traits = it }
if (probers.size > maxProbers) {
probers.values.sortedBy { it.lastSeen }.take(probers.size - maxProbers).forEach { probers.remove(it.mac) }
}
@@ -242,7 +249,7 @@ class ProbeBook(private val maxNetworks: Int = 1000, private val maxDevices: Int
/**
* The devices as groups, newest first: random addresses ([isRandom]) with the same fingerprint, shared
* by at most [rareMax] addresses, that asked for at least one name in common are likely one device
- * changing its address. Fixed addresses always stand alone.
+ * changing its address. Addresses sending the same WPS UUID are one device for certain, whatever they asked for.
*/
fun groups(isRandom: (String) -> Boolean, rareMax: Int = 20): List<Group> {
val list = devices()
@@ -258,6 +265,8 @@ class ProbeBook(private val maxNetworks: Int = 1000, private val maxDevices: Int
if (list[same[y]].ssids.any { it.lowercase() in asked }) parent[root(same[y])] = root(same[x])
}
}
+ list.indices.filter { list[it].wpsUuid != null }.groupBy { list[it].wpsUuid }.values
+ .forEach { same -> same.drop(1).forEach { parent[root(it)] = root(same[0]) } }
return list.indices.groupBy { root(it) }.values
.map { idx -> Group(idx.map { list[it] }, likelySame = idx.size > 1) }
.sortedByDescending { it.lastSeen }
diff --git a/app/src/main/java/com/rfsentinel/app/probes/ProbeListActivity.kt b/app/src/main/java/com/rfsentinel/app/probes/ProbeListActivity.kt
index 05d0f1d..6b0f4aa 100644
--- a/app/src/main/java/com/rfsentinel/app/probes/ProbeListActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/probes/ProbeListActivity.kt
@@ -306,12 +306,16 @@ class ProbeListActivity : AppCompatActivity() {
val df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
val dp = resources.displayMetrics.density
val text = buildString {
- if (g.likelySame) append("These random addresses have the same rare probe fingerprint and asked for a network " +
- "name in common, so they are likely one device changing its address.\n\n")
+ if (g.likelySame) append(if (g.devices.mapNotNull { it.wpsUuid }.let { u -> u.size == g.devices.size && u.distinct().size == 1 })
+ "These addresses send the same WPS UUID, so they are one device changing its address.\n\n"
+ else "These addresses send the same WPS UUID, or have the same rare probe fingerprint and asked for a " +
+ "network name in common, so they are likely one device changing its address.\n\n")
g.devices.forEach { d ->
append(d.mac).append(" ").append(maker(d.mac)).append('\n')
d.wpsName?.let { append(" Name: $it\n") }
d.wpsProduct?.let { append(" Model: $it\n") }
+ d.wpsUuid?.let { append(" WPS UUID: $it\n") }
+ d.traits?.let { append(" Probe details: $it\n") }
d.fingerprint?.let { fp ->
val n = ProbeLog.sharing(this@ProbeListActivity, fp)
append(" Probe fingerprint: $fp" + if (n > 1) " (shared by $n addresses)\n" else "\n")
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 e5e8ec3..4b9b3a7 100644
--- a/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
+++ b/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
@@ -265,12 +265,14 @@ object DeviceRegistry {
* Address-rotation linking: if exactly one device with the same advert
* fingerprint went silent shortly before this new address appeared, treat
* them as the same device and carry its matches over. Two or more
- * candidates (e.g. several identical earbuds) means no link.
+ * candidates (e.g. several identical earbuds) means no link. A random WiFi
+ * address uses the WPS UUID its probe requests send (USB adapter) instead.
*/
private fun linkRotatedAddress(t: Track, a: Advert, now: Long) {
- val fp = AdvertFingerprint.of(a) ?: return
+ val uuid = if (a.isWifi && com.rfsentinel.app.util.MacUtil.isRandomized(a.mac)) com.rfsentinel.app.usb.ProbeIntel.of(a.mac)?.wps?.uuid else null
+ val fp = AdvertFingerprint.of(a) ?: uuid?.let { "uuid:$it" } ?: return
synchronized(t) { t.fingerprint = fp }
- if (!AdvertFingerprint.mayRotate(a)) return
+ if (!AdvertFingerprint.mayRotate(a) && uuid == null) return
val candidates = tracks.values.filter { o ->
o !== t && synchronized(o) {
o.fingerprint == fp && o.lastSeen <= now - ROTATION_SILENCE_MS && now - o.lastSeen <= ROTATION_WINDOW_MS
@@ -281,8 +283,9 @@ object DeviceRegistry {
(prev.hits.ifEmpty { prev.inherited }).map { h ->
h.copy(
confidence = (h.confidence - 5).coerceAtLeast(0),
- evidence = "Same device as ${prev.mac} before its address rotated (identical advert " +
- "fingerprint, ${(now - prev.lastSeen) / 1000} s gap). Original evidence: ${h.evidence}"
+ evidence = "Same device as ${prev.mac} before its address rotated (identical " +
+ (if (uuid != null) "WPS UUID" else "advert fingerprint") +
+ ", ${(now - prev.lastSeen) / 1000} s gap). Original evidence: ${h.evidence}"
)
} to (prev.name to prev.role)
}
diff --git a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt
index 4b97d23..d08e5c3 100644
--- a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt
+++ b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt
@@ -822,16 +822,17 @@ class ScanForegroundService : Service() {
*/
private fun noteProbes(mac: String, ssids: List<String>, rssi: Int, now: Long,
wps: com.rfsentinel.app.usb.ProbeIntel.Wps? = null, fingerprint: String? = null, hidden: Boolean = false,
- skeleton: Long? = null) {
- com.rfsentinel.app.usb.ProbeIntel.note(mac, wps, fingerprint, ssids, hidden, skeleton)
+ skeleton: Long? = null, traits: String? = null) {
+ com.rfsentinel.app.usb.ProbeIntel.note(mac, wps, fingerprint, ssids, hidden, skeleton, traits)
// Kept in the requested-networks list when that's on, and always while a trace records.
// Where it was asked for: this phone's position, when the fix is fresh and good enough to place devices.
val at = lastFix?.takeIf { usableForPlacing(it) }
?.let { it.latitude to it.longitude }
com.rfsentinel.app.data.ProbeLog.record(this, mac, ssids, rssi, now, force = TripRecorder.isRecording,
- wps = wps, fingerprint = fingerprint, at = at)
+ wps = wps, fingerprint = fingerprint, at = at, traits = traits)
val hits = OuiWatchlist.probeHits(ssids) + OuiWatchlist.fingerprintHits(fingerprint) + OuiWatchlist.wpsHits(wps) +
- OuiWatchlist.fingerprintHits(skeleton?.let { com.rfsentinel.app.usb.ProbeIntel.shapeKey(it) })
+ OuiWatchlist.fingerprintHits(skeleton?.let { com.rfsentinel.app.usb.ProbeIntel.shapeKey(it) }) +
+ OuiWatchlist.fingerprintHits(wps?.uuid?.let { com.rfsentinel.app.usb.ProbeIntel.uuidKey(it) })
if (hits.isEmpty()) return
val before = probeHits[mac]
probeHits[mac] = now to hits
@@ -843,7 +844,7 @@ class ScanForegroundService : Service() {
val now = System.currentTimeMillis()
val mac = com.rfsentinel.app.util.MacUtil.normalize(m.mac)
com.rfsentinel.app.esp.HeardBy.usb.mark(mac, now)
- noteProbes(mac, m.probedSsids, m.rssi, now, m.wps, m.fingerprint, m.hiddenNetwork, m.probeSkeleton)
+ noteProbes(mac, m.probedSsids, m.rssi, now, m.wps, m.fingerprint, m.hiddenNetwork, m.probeSkeleton, m.probeTraits)
val a = Advert(
// A client has no network name; its WPS device name or model says what it is.
mac = mac, source = Advert.Source.WIFI, rssi = m.rssi, name = m.ssid ?: m.wps?.label,
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceActions.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceActions.kt
index f51bf74..919f350 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceActions.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceActions.kt
@@ -178,6 +178,12 @@ object DeviceActions {
val fp = com.rfsentinel.app.usb.ProbeIntel.of(mac)?.fingerprint
// FlipDeFlock's coarser probe shape: also survives random addresses, but many phones share one.
val shape = com.rfsentinel.app.usb.ProbeIntel.of(mac)?.skeleton?.let { com.rfsentinel.app.usb.ProbeIntel.shapeKey(it) }
+ // Its WPS UUID: one exact device, the same under every random address it uses.
+ val uuid = com.rfsentinel.app.usb.ProbeIntel.of(mac)?.wps?.uuid?.let { com.rfsentinel.app.usb.ProbeIntel.uuidKey(it) }
+ if (uuid != null) {
+ b.scopeUuid.visibility = View.VISIBLE
+ b.scopeUuid.text = "This exact device, under any address (WPS UUID ${uuid.removePrefix("uuid-")})"
+ }
if (shape != null) {
b.scopeShape.visibility = View.VISIBLE
b.scopeShape.text = "Every device whose probe requests are built the same way (${shape.removePrefix("shape-")}; " +
@@ -211,11 +217,13 @@ object DeviceActions {
val wholePrefix = b.scopePrefix.isChecked
val byFingerprint = fp != null && b.scopeFingerprint.isChecked
val byShape = shape != null && b.scopeShape.isChecked
+ val byUuid = uuid != null && b.scopeUuid.isChecked
val start = b.startsInput.text.toString().trim()
val byStart = named.isNotEmpty() && b.scopeStarts.isChecked
if (byStart && start.isEmpty()) { toast(activity, "Not added: enter the start of the name"); return@setPositiveButton }
val key = when {
byStart -> OuiEntry.STARTS + start
+ byUuid -> OuiEntry.FINGERPRINT + uuid
byShape -> OuiEntry.FINGERPRINT + shape; byFingerprint -> OuiEntry.FINGERPRINT + fp
wholePrefix -> MacUtil.prefix(mac, digits); else -> mac
}
@@ -224,6 +232,7 @@ object DeviceActions {
val label = typed.ifEmpty {
when {
byStart -> (if (wifi) "SSID starts with " else "Name starts with ") + start
+ byUuid -> "Device WPS UUID ${uuid!!.removePrefix("uuid-")}"
byShape -> "Probe shape ${shape!!.removePrefix("shape-")}"; byFingerprint -> "Device type $fp"
wholePrefix -> "Custom prefix $key"; else -> "Custom device $mac"
}
@@ -272,6 +281,9 @@ object DeviceActions {
options += Option(OuiEntry.ADVERT + key, "Its Bluetooth advert pattern ($key)", LEARNED_SCORE,
if (shared >= MAX_SHARED) "$shared devices nearby send the same pattern" else null)
}
+ com.rfsentinel.app.usb.ProbeIntel.of(mac)?.wps?.uuid?.let { u ->
+ options += Option(OuiEntry.FINGERPRINT + com.rfsentinel.app.usb.ProbeIntel.uuidKey(u), "Its WPS UUID ($u)", LEARNED_SCORE, null)
+ }
com.rfsentinel.app.usb.ProbeIntel.of(mac)?.fingerprint?.let { fp ->
val shared = com.rfsentinel.app.usb.ProbeIntel.sharing(fp)
options += Option(OuiEntry.FINGERPRINT + fp, "Its WiFi probe fingerprint ($fp)", LEARNED_SCORE,
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceSections.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceSections.kt
index 493029a..78814b1 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceSections.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceSections.kt
@@ -108,8 +108,15 @@ object DeviceSections {
?: "It hides its name - shown once a device joins or asks for it (USB WiFi adapter)")
r.wps?.deviceName?.let { id += "Device name (WPS)" to it }
r.wps?.product?.let { id += "Maker / model (WPS)" to it }
+ r.wps?.uuid?.let { u ->
+ id += "WPS UUID" to u + if (OuiWatchlist.isFingerprintWatched(com.rfsentinel.app.usb.ProbeIntel.uuidKey(u))) " · on your watchlist" else
+ " (same on every address this device uses - Watchlist can watch it)"
+ }
+ r.traits?.let { id += "Probe details" to it }
r.fingerprint?.let { fp ->
- id += "Probe fingerprint" to fp + if (OuiWatchlist.isFingerprintWatched(fp)) " · on your watchlist" else
+ val n = com.rfsentinel.app.usb.ProbeIntel.sharing(fp)
+ id += "Probe fingerprint" to fp + (if (n > 1) " · shared by $n addresses this session" else "") +
+ if (OuiWatchlist.isFingerprintWatched(fp)) " · on your watchlist" else
" (same for every device of this model / OS - Watchlist can watch it)"
}
r.skeleton?.let { sk ->
diff --git a/app/src/main/java/com/rfsentinel/app/usb/MonitorFrames.kt b/app/src/main/java/com/rfsentinel/app/usb/MonitorFrames.kt
index d5e6484..9e1f7e2 100644
--- a/app/src/main/java/com/rfsentinel/app/usb/MonitorFrames.kt
+++ b/app/src/main/java/com/rfsentinel/app/usb/MonitorFrames.kt
@@ -27,8 +27,10 @@ class MonitorFrames {
var wildcard = false; var flockIe = false
/** How steadily it sends wildcard probes ([com.rfsentinel.app.detect.ProbeBehaviour]). */
var probeRate: com.rfsentinel.app.detect.ProbeBehaviour.Counter? = null
- /** An access point's latest beacon elements (refreshed every [IES_REFRESH_MS]) and its "protected" capability bit. */
+ /** An access point's latest beacon elements and its "protected" capability bit; [iesAt]: when they, or a client's [traits], were read. */
var ies: List<Pair<Int, ByteArray>>? = null; var iesAt = 0L; var privacy = false
+ /** What a client's probe requests say about it in words ([ProbeIntel.traits]), refreshed every [IES_REFRESH_MS]. */
+ var traits: String? = null
/** When its WiFi started, from the beacon clock (TSF, microseconds since the radio came up). */
var upSince: Long? = null
/** Data-frame bytes it sent while heard. */
@@ -130,6 +132,9 @@ class MonitorFrames {
if (ies.flockIe) s.flockIe = true
ProbeIntel.fingerprint(b, d + 24, body)?.let { s.fingerprint = it }
ProbeIntel.skeletonHash(b, d + 24, body)?.let { s.skeleton = it }
+ if (s.traits == null || now - s.iesAt > IES_REFRESH_MS) {
+ ProbeIntel.traits(elements(b, d + 24, body))?.let { s.traits = it }; s.iesAt = now
+ }
ies.ssid?.takeIf { validSsid(it) }?.let { name ->
s.probed.remove(name); s.probed.add(name)
if (s.probed.size > MAX_PROBED) s.probed.remove(s.probed.first())
@@ -202,6 +207,7 @@ class MonitorFrames {
probedSsids = s.probed.toList(),
wps = s.wps,
fingerprint = s.fingerprint,
+ probeTraits = s.traits,
probeSkeleton = s.skeleton,
hiddenNetwork = s.hidden,
wildcardProbe = s.wildcard,
diff --git a/app/src/main/java/com/rfsentinel/app/usb/ProbeIntel.kt b/app/src/main/java/com/rfsentinel/app/usb/ProbeIntel.kt
index a8121d0..2a36907 100644
--- a/app/src/main/java/com/rfsentinel/app/usb/ProbeIntel.kt
+++ b/app/src/main/java/com/rfsentinel/app/usb/ProbeIntel.kt
@@ -14,7 +14,12 @@ import java.util.zip.CRC32
*/
object ProbeIntel {
- data class Wps(val manufacturer: String?, val model: String?, val modelNumber: String?, val deviceName: String?) {
+ /**
+ * [uuid]: its UUID-E (32 hex digits). Many WPS stacks derive it once for the device, so it stays the same on
+ * every random address the device uses: one exact device, not just a model.
+ */
+ data class Wps(val manufacturer: String?, val model: String?, val modelNumber: String?, val deviceName: String?,
+ val uuid: String? = null) {
/** "Maker Model Number", or null when the block named nothing. */
val product: String? get() = listOfNotNull(manufacturer, model, modelNumber).distinct().joinToString(" ").ifBlank { null }
/** The best single name for the device list. */
@@ -26,6 +31,7 @@ object ProbeIntel {
/** Parses a WPS vendor element's body (after the 00:50:F2:04 header): big-endian type / length attributes. */
fun parseWps(b: ByteArray, from: Int, end: Int): Wps? {
var manufacturer: String? = null; var model: String? = null; var number: String? = null; var name: String? = null
+ var uuid: String? = null
var i = from
while (i + 4 <= end) {
val type = ((b[i].toInt() and 0xff) shl 8) or (b[i + 1].toInt() and 0xff)
@@ -37,11 +43,12 @@ object ProbeIntel {
0x1023 -> model = v()
0x1024 -> number = v()
0x1011 -> name = v()
+ 0x1047 -> if (len == 16) uuid = hex(b, i + 4, 16).takeUnless { u -> u.all { it == '0' } || u.all { it == 'f' } }
}
i += 4 + len
}
- if (manufacturer == null && model == null && number == null && name == null) return null
- return Wps(manufacturer, model, number, name)
+ if (manufacturer == null && model == null && number == null && name == null && uuid == null) return null
+ return Wps(manufacturer, model, number, name, uuid)
}
private fun text(b: ByteArray, at: Int, len: Int): String? {
@@ -105,6 +112,34 @@ object ProbeIntel {
/** How a watched probe shape is written in the watchlist (after "fp:"), next to 8-digit fingerprints. */
fun shapeKey(shape: Long) = "shape-%08x".format(shape)
+ /** How a watched WPS UUID (one exact device, whatever its address) is written in the watchlist, after "fp:". */
+ fun uuidKey(uuid: String) = "uuid-$uuid"
+
+ /**
+ * What a probe request's elements say about the device in words, e.g. "WiFi 6 · 2x2 · Apple tags ·
+ * Broadcom chipset · 802.11v · MBO": what the 8-digit fingerprint stands for. Null with too little to say.
+ */
+ fun traits(ies: List<Pair<Int, ByteArray>>): String? {
+ if (ies.none { it.first != 0 && it.first != 1 && it.first != 3 && it.first != 50 }) return null
+ val info = com.rfsentinel.app.detect.WifiFingerprint.parse(ies)
+ val ext = ies.firstOrNull { it.first == 127 }?.second
+ // Extended capabilities: bit 19 BSS transition (802.11v), bit 31 interworking (Passpoint).
+ fun bit(n: Int) = ext != null && n / 8 < ext.size && (ext[n / 8].toInt() shr (n % 8)) and 1 == 1
+ // Wi-Fi Alliance 50:6F:9A type 0x16: MBO / OCE (Agile Multiband).
+ val mbo = ies.any { (id, d) -> id == 221 && d.size >= 4 && (d[0].toInt() and 0xff) == 0x50 && (d[1].toInt() and 0xff) == 0x6F &&
+ (d[2].toInt() and 0xff) == 0x9A && d[3].toInt() == 0x16 }
+ fun names(v: List<String>) = v.map { com.rfsentinel.app.detect.DeviceIntel.shortVendor(it) }.distinct().joinToString("/").ifEmpty { null }
+ return listOfNotNull(
+ MonitorFrames.standard(ies).substringBefore(" ("),
+ info.streams?.let { "${it}x$it" },
+ names(info.equipmentVendors)?.let { "$it tags" },
+ names(info.chipsetVendors)?.let { "$it chipset" },
+ "802.11v".takeIf { bit(19) },
+ "Passpoint".takeIf { bit(31) },
+ "MBO".takeIf { mbo }
+ ).joinToString(" · ")
+ }
+
/** [end] without the 4-byte checksum some drivers keep on a frame starting at [d]. */
fun withoutFcs(b: ByteArray, d: Int, end: Int): Int {
if (end - d < 28) return end
@@ -117,16 +152,19 @@ object ProbeIntel {
/** What external hardware learned about a device this scan, for its detail screen. */
data class Record(val wps: Wps?, val fingerprint: String?, val probed: List<String>, val hidden: Boolean = false,
- val skeleton: Long? = null)
+ val skeleton: Long? = null, val traits: String? = null)
private val byMac = ConcurrentHashMap<String, Record>()
- fun note(mac: String, wps: Wps?, fingerprint: String?, probed: List<String>, hidden: Boolean = false, skeleton: Long? = null) {
- if (wps == null && fingerprint == null && probed.isEmpty() && !hidden && skeleton == null) return
+ fun note(mac: String, wps: Wps?, fingerprint: String?, probed: List<String>, hidden: Boolean = false, skeleton: Long? = null,
+ traits: String? = null) {
+ if (wps == null && fingerprint == null && probed.isEmpty() && !hidden && skeleton == null && traits == null) return
val key = mac.uppercase()
val old = byMac[key]
- byMac[key] = Record(wps ?: old?.wps, fingerprint ?: old?.fingerprint, probed.ifEmpty { old?.probed.orEmpty() },
- hidden || old?.hidden == true, skeleton ?: old?.skeleton)
+ // A later WPS block without its UUID keeps the one already heard.
+ val w = wps?.let { if (it.uuid == null && old?.wps?.uuid != null) it.copy(uuid = old.wps.uuid) else it }
+ byMac[key] = Record(w ?: old?.wps, fingerprint ?: old?.fingerprint, probed.ifEmpty { old?.probed.orEmpty() },
+ hidden || old?.hidden == true, skeleton ?: old?.skeleton, traits ?: old?.traits)
if (byMac.size > 5000) byMac.keys.take(500).forEach { byMac.remove(it) }
}
diff --git a/app/src/main/java/com/rfsentinel/app/usb/UsbWifi.kt b/app/src/main/java/com/rfsentinel/app/usb/UsbWifi.kt
index 52f9a85..2567549 100644
--- a/app/src/main/java/com/rfsentinel/app/usb/UsbWifi.kt
+++ b/app/src/main/java/com/rfsentinel/app/usb/UsbWifi.kt
@@ -27,6 +27,8 @@ data class MonitorSighting(
val wps: ProbeIntel.Wps? = null,
/** How it builds its probe requests: marks a device model / OS ([ProbeIntel.fingerprint]). */
val fingerprint: String? = null,
+ /** What its probe requests say about it in words ([ProbeIntel.traits]). */
+ val probeTraits: String? = null,
/** FlipDeFlock's probe skeleton hash ([ProbeIntel.skeletonHash]). */
val probeSkeleton: Long? = null,
/** An access point hiding its name; [ssid] is then the name revealed by a device joining or asking for it. */
diff --git a/app/src/main/res/layout/dialog_add_watchlist.xml b/app/src/main/res/layout/dialog_add_watchlist.xml
index bf32fc0..1a0cb96 100644
--- a/app/src/main/res/layout/dialog_add_watchlist.xml
+++ b/app/src/main/res/layout/dialog_add_watchlist.xml
@@ -47,6 +47,12 @@
android:layout_height="wrap_content"
android:visibility="gone" />
+ <RadioButton
+ android:id="@+id/scopeUuid"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+
<RadioButton
android:id="@+id/scopeStarts"
android:layout_width="match_parent"
diff --git a/app/src/test/java/com/rfsentinel/app/usb/ProbeFingerprintMoreTest.kt b/app/src/test/java/com/rfsentinel/app/usb/ProbeFingerprintMoreTest.kt
new file mode 100644
index 0000000..3f40a6a
--- /dev/null
+++ b/app/src/test/java/com/rfsentinel/app/usb/ProbeFingerprintMoreTest.kt
@@ -0,0 +1,61 @@
+package com.rfsentinel.app.usb
+
+import com.rfsentinel.app.data.ProbeBook
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class ProbeFingerprintMoreTest {
+
+ private fun ie(id: Int, vararg v: Int) = id to v.map { it.toByte() }.toByteArray()
+
+ /** A WPS attribute list holding only a UUID-E. */
+ private fun uuidAttr(vararg u: Int) = byteArrayOf(0x10, 0x47, 0, 16) + u.map { it.toByte() }.toByteArray()
+
+ @Test
+ fun traitsSayWhatTheFingerprintStandsFor() {
+ val ies = listOf(
+ ie(0), ie(1, 0x82, 0x84),
+ ie(45, *IntArray(26).also { it[3] = 0xFF; it[4] = 0xFF }), // HT, 2 streams
+ ie(127, 0, 0, 0x08, 0x80), // bits 19 + 31
+ ie(221, 0x50, 0x6F, 0x9A, 0x16, 0x01)) // MBO
+ val t = ProbeIntel.traits(ies)!!
+ assertTrue(t, t.startsWith("WiFi 4 · 2x2"))
+ assertTrue(t, t.contains("802.11v") && t.contains("Passpoint") && t.endsWith("MBO"))
+ // Only a name, rates and channel: nothing worth saying.
+ assertNull(ProbeIntel.traits(listOf(ie(0), ie(1, 0x82), ie(3, 6))))
+ }
+
+ @Test
+ fun wpsUuidIsReadAndBlankOnesAreDropped() {
+ val a = uuidAttr(*IntArray(16) { it + 1 })
+ assertEquals("0102030405060708090a0b0c0d0e0f10", ProbeIntel.parseWps(a, 0, a.size)!!.uuid)
+ val zero = uuidAttr(*IntArray(16))
+ assertNull(ProbeIntel.parseWps(zero, 0, zero.size))
+ }
+
+ @Test
+ fun aLaterWpsBlockWithoutUuidKeepsIt() {
+ ProbeIntel.clear()
+ ProbeIntel.note("02:00:00:00:00:01", ProbeIntel.Wps(null, null, null, null, "abc"), null, emptyList(), traits = "WiFi 6")
+ ProbeIntel.note("02:00:00:00:00:01", ProbeIntel.Wps("Acme", null, null, null), null, emptyList())
+ val r = ProbeIntel.of("02:00:00:00:00:01")!!
+ assertEquals("abc", r.wps?.uuid); assertEquals("Acme", r.wps?.manufacturer); assertEquals("WiFi 6", r.traits)
+ ProbeIntel.clear()
+ }
+
+ @Test
+ fun addressesWithTheSameUuidAreOneDevice() {
+ val book = ProbeBook()
+ book.recordDevice("02:00:00:00:00:01", listOf("Home"), -60, 1, wpsUuid = "u1")
+ book.recordDevice("06:00:00:00:00:02", listOf("Work"), -60, 2, wpsUuid = "u1")
+ book.recordDevice("0A:00:00:00:00:03", listOf("Cafe"), -60, 3, wpsUuid = "u2")
+ val groups = book.groups({ true })
+ assertEquals(2, groups.size)
+ val same = groups.single { it.likelySame }
+ assertEquals(setOf("02:00:00:00:00:01", "06:00:00:00:00:02"), same.devices.map { it.mac }.toSet())
+ assertFalse(groups.single { !it.likelySame }.devices.single().wpsUuid == "u1")
+ }
+}