jokob-sk / NetAlertX

πŸ’»πŸ” WIFI / LAN intruder detector. Scans for devices connected to your network and alerts you if new and unknown devices are found.
GNU General Public License v3.0
1.95k stars 100 forks source link

Plugin for Mikrotik DHCP Leases #532

Open elraro opened 6 months ago

elraro commented 6 months ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe

I was looking for the possibility to import directly from Mikrotik DHCP Leases, but I couldn't find a plugin to do it.

Describe the solution you'd like

The idea is to be able to import the DHCP Leases from the Mikrotik, just like the leiweibau fork: https://github.com/leiweibau/Pi.Alert/blob/24730e9269254a3ffcc06865feff7799e9fe7744/back/pialert.py#L729

Describe alternatives you've considered

I've been looking at how to create a plugin, and I think I might be able to do it, but I'm wondering how to install a library I need for Python, in order to make the plugin.

@jokob-sk could you confirm me if the python library needed for the plugin can be added here, or should I do it another way?

https://github.com/jokob-sk/Pi.Alert/blob/9f5884c4e769b026135be484dce38a36d6deadf8/install/install_python.sh#L16

Anything else?

More information about the Mikrotik DHCP Leases: https://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Server#Leases

jokob-sk commented 6 months ago

Hi @elraro,

Thanks for helping out!

Please extend the existing dhcp_leases plugin and add an option to import microtik-formatted dhcp.leases files. It should be pretty straightforward (e.g. let's say the mapped path needs to have microtik in it, same as with pihole):

https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/dhcp_leases/script.py#L59

Yes, additional python packages can be installed via the file you referenced: https://github.com/jokob-sk/Pi.Alert/blob/9f5884c4e769b026135be484dce38a36d6deadf8/install/install_python.sh#L16

Looking forward to the PR!

Please also update relevant documentation and settings descriptions.

Thanks, j

elraro commented 6 months ago

Hi @jokob-sk

The problem I see with extending the existing dhcp_leases plugin is this plugin reads the dhcp leases from files on disk. And in this case, I would connect to the mikrotik to read the console output. I had thought about making a new plugin, as the operation was completely different, but I can study it.

Thank you!

jokob-sk commented 6 months ago

Oh, in that case, sure thing. Go ahead and create a new plugin. I thought there was a file to read from.

elraro commented 5 months ago

Hi @jokob-sk

I'm not dead hehe but very busy due to my girlfriend's surgery. Hope I can start with this in a few weeks.

Thank you!

jokob-sk commented 5 months ago

@elraro glad to hear that you are still alive πŸ˜…

I hope the surgery goes well! πŸ€ And of course no rush.

Thank you in advance for helping out!

jokob-sk commented 1 week ago

Hi @elraro ,

If you have some time, I've created a walkthrough of creating a custom plugin: Watch the video

πŸŽ₯Watch the video πŸ™‚