-
-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NMAP Scan for Device Detection #645
Comments
This should be available in the next release. If you can, please have a look at the It would be great if you could test this (backup everything first or use a new container) on your end by switching to the above image and letting me know if the issue was resolved. Thanks in advance, |
Will check that tomorrow :-) Thanks a lot! |
Hi @jokob-sk , thanks a lot, definitely goes into the right direction. A few thoughts:
So far. If you need more information just tell me ;) |
Thanks for testing, can you send me the debug log output? I'd need the raw data to see what's being processed. Search your
And paste the redacted version of that output or send it to jokob@duck.com. Thanks in advance, |
Sent it, please have a look if it reached your mailbox. |
OK, I updated the code. If you can, please have a look at the netalertx-dev docker image, in about 15 minutes (or after the last action finishes) from now. |
Unfortunately I am now on a business trip with limited resources. But maybe I'll manage it somehow before Friday |
Hey @jokob-sk I've tested nmap with latest dev image. Looking in app.log it does work fine, but new devices are not added to the list. I am scanning neighboured networks, and in app.log I can see nmap is finding devices in those networks. And one suggestion regarding nmap scanner. In Settings I had to modify arguments and append networks: Also, maybe update UI so nmap has Scan Subnets field where we enter subnets instead of updating arguments. |
Hi @vladaurosh , Thanks for testing! I will look into it. The idea is to make this easy to configure so SCAN_SUBNETS is used for all network scanners. Any reason why scanning the main network is an issue? The results are collated and if the devices are already available, nothing gets overwritten AFAIK. |
Can you try to add the subnets you have added to the namp command sudo nmap -sn 192.168.2.0/24 192.168.3.0/24 from here to the main SCAN_SUBNETS setting? I think that will solve your issue |
Hey @jokob-sk I've tried with 2 neighboured subnets into SCAN_SUBNETS, same result. To add some details:
I can understand that for simplicity all subnets should be in SCAN_SUBNETS, but probably not optimal. For example, in my case of 1 main subnet and 2 neighboured subnets, there will be 6 scans, 3 arp scans (if arp scan is even started for neighboured subnets, for sure it's not needed as it doesn't work) plus 3 nmap scans (nmap scan of main subnet not needed here as it's already scanned in arp scan). |
Hi @vladaurosh , Thanks for testing 🙏
I'll think about having another Subnets setting for nmap but as you said - it's getting now complicated. Should every scanner using subnets have an override? It's starting to get complex and it's already difficult to get first time users set up the correct settings 🤔 I'd rather trade a bit of slowness (running namp 3x for 3 subnets) and consistency than overcomplicating the setup and to have edge cases for each plugin. Anyway, let me hear your thoughts 💭 |
Hi @jokob-sk Logs have been sent. If I have an idea about subnets, will let you know for sure. For me this way is not a problem, but not sure if someone has multiple subnets with a lot of hosts, duplicate scans will not help. |
Hi @vladaurosh , Thanks for the logs! I added some additional logging. Can you try to re-download the dev image in ~10 min? I also think I fixed some issues with parsing the output so you might already get better results and if not, we'll get at least better debug information to investigate further. |
Hi @jokob-sk Just tried latest dev, there are some changes in app.log but still doesn't work.
Hope this helps. |
Hi @vladaurosh , Thanks for the logs, this helps. I think the next dev build is better. Can you give it a go? You need to you update the Previously I was not forcing MAC address output and only passing the mask. Now I included the interface and forced MAC address output. Thanks in advance, |
Hey @jokob-sk Still doesn't work. I've ran
So we're not getting mac addresses here for neighboured subnets, and getting them correctly for main subnet. That's not the issue with nmap just a limit of network layout. Oh yeah, I see this in app.log for neighboured subnet:
|
Hi @vladaurosh , The issue of writing something into the MAC field is that if the device is discovered via other means and a proper MAC is discovered then this will detect 2 devices instead of correctly merging it into one based on the MAC address. You could argue to use the IP address only, but that would require an internal code rewrite on how the matching is done right now (e..g the MAC is used for Events, Presence, Plugin data matching). Another approach woudl be to use the IPs only for presence detection - but again - not a trivial internal change. Not sure if we can force NMAP to report MAC addresses on neighbored subnets? That would be the best solution if possible. Another alternative is to run 2 scanners - Arp scan and Nmap which gives better coverage I think as NMAP is more accurate detecting the online/offline state of a device? |
Hi @jokob-sk Makes perfect sense. Let me see if I am able to get MAC addresses from the hosts in other subnets. |
It generally is not possible to retrieve the MAC address of a neighbouring subnet because the traffic between them is routed which happens on the IP layer. You can use MAC addresses just within your routed domain or "area": to reach a PC within your own subnet, you are able to talk directly to it, no router needed. Because you're sending packets to the very device you want to reach, of course you need their MAC address (OSI Layer 2). However if you want to reach another subnet, your packet is routed from one IP to another, on OSI Layer 3. So the information of what's the other device's MAC address is kind of "lost" (at least from your perspective). Instead, the router replaces that MAC address with it's own as he is the "mediator": he needs to receive the packet on behalf of that device in order to forward it to the correct PC on the other subnet. It may work if your NetAlertX instance is running on the router that is connecting those subnets, depending on your specific setup. Other than that, there are some ways to overcome this basic (and useful) restriction of how networking works, but (at least according to my knowledge) none of them are trivial and often may have side-effects which could potentially negatively impact your network. With that in mind (and as long as everything keeps revolving around the MAC address as source of truth) I would see two options:
|
On a side note: I would strongly suggest not to simply parse the plain text output of Instead, please use the The result for Example scan (click to show)NB: The output has been shortened and neatly indented by me for nicer reading. <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nmaprun>
<?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?>
<!-- Nmap 7.70 scan initiated Tue Apr 30 10:15:05 2024 as: nmap -oX - -sn 192.168.0.0/24 -->
<nmaprun scanner="nmap" args="nmap -oX - -sn 192.168.0.0/24" start="1714464905" startstr="Tue Apr 30 10:15:05 2024" version="7.70" xmloutputversion="1.04">
<verbose level="0"/>
<debugging level="0"/>
<host>
<status state="up" reason="arp-response" reason_ttl="0"/>
<address addr="192.168.0.45" addrtype="ipv4"/>
<address addr="C4:5B:BE:B3:2A:0C" addrtype="mac"/>
<hostnames></hostnames>
<times srtt="86532" rttvar="86532" to="432660"/>
</host>
<host>
<status state="up" reason="arp-response" reason_ttl="0"/>
<address addr="192.168.0.114" addrtype="ipv4"/>
<address addr="B8:27:EB:F3:50:04" addrtype="mac" vendor="Raspberry Pi Foundation"/>
<hostnames></hostnames>
</host>
<!-- ...... manually trimmed for brevity ...... -->
<host>
<status state="up" reason="localhost-response" reason_ttl="0"/>
<address addr="192.168.0.1" addrtype="ipv4"/>
<hostnames>
<hostname name="cortex.home.lan" type="PTR"/>
</hostnames>
</host>
<runstats>
<finished time="1714464908" timestr="Tue Apr 30 10:15:08 2024" elapsed="3.40" summary="Nmap done at Tue Apr 30 10:15:08 2024; 256 IP addresses (40 hosts up) scanned in 3.40 seconds" exit="success"/>
<hosts up="40" down="216" total="256"/>
</runstats>
</nmaprun> |
Hey, rewritten into parsing the XML output if someone wants to test the dev image, Thanks, |
Looks good, thank you! I'm really impressed by your fast turn around time in this project. Keep up the awesome work! 🥳👍 |
Thanks, it's only possible with the plugin and auto-generating setting & UI system in place. Happy for anyone to contribute :) https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins Regarding 2: Providing a proxy agent - that sounds too big of an investment I'm currently not willing to make. There are other scan methods that can substitute it and you could theoretically run multiple instances of the container. I will keep it in the back of my mind for now. |
released -> closing for now |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe
Active detection of devices seems to be only possible via ARP scanning.
Describe the solution you'd like
Is there a chance that NMAP scans could be one source for detecting devices as well? With a unobtrusive scan as default option.
That would allow me to scan neighboured networks of the NetAlertX instance that it has no ARP access to.
Describe alternatives you've considered
Since NMAP is already on board I did not consider another option yet.
Anything else?
Maybe later.
The text was updated successfully, but these errors were encountered: