Kismet wifi monitor device_tracker component

I have created a new custom device_tracker component that connects to a kismet server instance and tracks people (MACs actually). Kismet (for those who do not know it) is a wifi monitor program that puts a wifi card in monitor mode and hops around the channels listening for wifi beacons and probe requests. It can capture packets, create reports and recently has a REST API that you can query to see if MAC address AA:BB:CC:DD:EE:FF was seen around in the last 50 seconds. This is what this tracker component does.

To use it, you need a recent kismet version. Versions bundled with Ubuntu 16.04 or 18.04 are too old and donā€™t have the REST API. You can install it by following this guide: https://github.com/kismetwireless/kismet/blob/master/README. Youā€™ll also need a wifi card that supports monitor mode. You can use multiple servers located at different places if needed.

Currently, the kismet device_tracker can be used as a custom component - which you can install following these steps:

 $ sudo su - homeassistant
 $ cd .homeassistant
 $ mkdir -p custom_components/device_tracker
 $ cd custom_components/device_tracker
 $ wget -O kismet.py https://raw.githubusercontent.com/mad-ady/home-assistant-customizations/master/custom_components/device_tracker/kismet.py

You will need to edit configuration.yaml and add the component:

 device_tracker:
   - platform: kismet
     interval_seconds: 30
     host: 192.168.1.15
      port: 2501
      consider_home: 420
     clients:
       - 84:98:66:47:cf:aa
       - d0:31:69:38:f2:99
     ssids:
       - DIGI

For extra debugging, you can set the component to debug inside the logger as well:

 logger:
   default: error
   logs:
     custom_components.device_tracker.kismet: debug

Once you restart the component will connect periodically to the kismet instance and query for the devices you listed. It will get results for the last ā€œinterval_secondsā€ period (e.g. for the last 30 seconds), so even if the mobile device was active for a little while in that interval it will get picked up and reported. The length of interval_seconds only affects how quickly a device is seen, not whether it is seen or not.
The parameters have the following meaning:

  • interval_seconds - how often to ask for updates from the kismet server
  • host - the kismet server IP/FQDN (127.0.0.1 by default)
  • port - the port where kismet is running (2501 by default)
  • consider_home - how long should a client be still considered at home if he hasnā€™t been seen (7 minutes is ok for clients with wifi open, but not associated to a network. May depend from device to device)
  • clients - a list of MAC addresses to look for. Can be a regular expression
  • ssids - a list of SSIDs to look for. Can be a regular expression

Devices which are discovered are added to known_devices.yaml, like regular trackers.

Now, I need the communityā€™s help to add this as a standard component inside HA. I can add the code and ask for a PR, but what repo do I need to fork for the documentation? Also, is the code written ok to be used by others? Do I need to change formatting/add more comments?

Thanks

5 Likes

Ohhhhā€¦very cool. Thank you very kindly. Look forward to finding the time to playing with this. :slight_smile:

@mad_ady this worked pretty well for me up until some months agoā€¦
Have you used it or found something similar?

Hey! Iā€™m actually in the process of reworking it a bit. I want to test it with current kismet versions and there is a configuration issue that causes HA to complain on startup. Iā€™m doing some internal testing and cleanup and hope to push it to HACS in a few weeks. I too am interested in getting it up to date :slight_smile:
Will keep you posted.

If you want any help I have had kismet running recently and have a few sensors I can test it on.

When I used this I wanted to keep track of all local devices, i.e. not just mine, as a sort of Intrusion Detection System/log, etc. It sort of polluted the device tracker entity list though!

My current system is in nodejs and uses node red for a UI, and tracks APā€™s as well as clients locally, and when I travel (err, wardrive/walk) around. Mapping/graphing/statisticsā€¦ want to use it to keep track of my own devices also. Hope to have it posted shortly.

Interesting setup :slight_smile:

My current plan is to rewrite the device_tracker for kismet so that it doesnā€™t register anymore as a legacy device tracker and so that it uses current kismet API. The API I was using (from summer 2018) no longer works with newer kismet releases (kismet introduced mandatory login from spring 2019 onwards). So, it will be a bit of a rewrite, but I want to do it anyway. Not sure how much time I have, but Iā€™m working on it in my spare time.

One thing I want to add is GPS support to the device tracker, so that it reports kismetā€™s location to Home Assistant - so that if you have a tracked entity that moves around you will get the zone the device is in HA. If you have GPS-enabled kismet I may need your help to test some queries.

Hey, I will go and take a closer look at your code and get kismet up and running in the next few days. I have phones running BlueNMEA that I use for GPS. I donā€™t have zones setup yet though.

I want to integrate my code into HA in some way, it is similar in ways to your plugin - but doesnā€™t use kismet.

Mainly because Iā€™ve had it running for days on end and it crashed and broke interfaces more often than not, but also because code Iā€™ve been running for a few years just works at recording wireless macs into mongodb.

How do I get notifications of responses to threads?
Ahh I have to mark the post as Watching instead of Tracking.

Hey @ceebee,
I pushed my changes to github: https://github.com/mad-ady/home-assistant-customizations/commit/07d3f02387a3ea31c0819f408e927f63d50514d7
It should work with the current HA version and kismet 2019-09-R1.
I still need to rewrite it to add support for GPS coordinates. But this should do in the meantime.

@ceebee Is your code available somewhere, Iā€™d be interested in your Node-Red version you have running?

Hey, Iā€™m still working on it, I will try and post something soon!

I am also interested in this. Have you gotten it running?

Any plans to add the Kismet Bluetooth tracking?

Sorry guys, I havenā€™t been active on this - mostly because I stopped using Kismet wifi tracking, and also because the device_tracker API changed since Iā€™ve implemented it and it needs to be completely rewritten to use the newer API.
Once there is a stable device_tracker (with regard to API), I guess BT tracking can be added, as long as itā€™s exposed by Kismet.

So, apart from my original post, I donā€™t expect to be working on it any time soon. Fell free to fork it and improve it for your needs, but it requires rewriting mostlyā€¦

Itā€™s sad that the project was abandoned ā€¦ it worked well, it detected my device further and earlier than it was connected to the wifi.
I made a kismet addon for hassio . If someone continues the project and corrects it for a modern device_tracker api, I will be happy to share addon.

Does this work for Bluetooth devices? I want to integrate 2 itags (cheap bluetooth keyfinders) in home assistant.

Any chance of this getting fixed up or updated? I recently got kismet up and running in my home but would like it to connect to my home assistant. Looks like some code may need to be re-written. Maybe can use some code from here? GitHub - josevnz/kismet_home: Kismet home contains a group of scripts to help you secure your wireless home network

Have you looked at Nmap? Theyre not exactly the same but, they have a lot of overlapping festures and functions.

Sorry guys, as I said earlier somebody needs to rewrite the module according to the new HA API. D

Hi all,

Iā€™ve managed to get the Kismet added as a sensor to HA to get what I want without the python code. Just modified the device alert settings on the Kismet from kismet_alerts.conf, here can specify MAC or OUI of devices with ā€œdevicefoundā€ alert. Then added the following to configuration.yaml in HA.

sensor:

  • platform: rest
    json_attributes:
    • kismet.alert.header
    • kismet.alert.source_mac
      method: GET
      name: ā€œKismet_Sensorā€
      resource_template: ā€œhttp://[kismet_address]:[port]/alerts/all_alerts.jsonā€
      username: [censored]
      password: [censored]
      authentication: basic
      scan_interval: 60
      value_template: ā€˜{{ value_json[0][ā€œkismet.alert.headerā€],value_json[0][ā€œkismet.alert.source_macā€] }}ā€™

Now I can create HA automations to my liking using the sensor and json attribute changes. Thanks all for your guidance along this journey!