Chleba / netscanner

Terminal Network scanner & diagnostic tool with modern TUI
MIT License
848 stars 20 forks source link

Windows 11 support #39

Closed EphemeralSapient closed 5 days ago

EphemeralSapient commented 3 weeks ago

I'm kind of new to rust and open source development, so pardon me if I took wrong approach;

~1. I found that tokio-wifiscanner has been fixed by DJStompZone for Windows already [updated the toml]~

  1. get_user_home_dir was missing for windows, so I've included it on export.rs

NOTE : I've encountered link error on Packet.lib, so I've downloaded npcap SDK and set the env "LIB" to current path ./windows/npcap-sdk-1.13 [x64 specifically, for other arch you can find it on official sdk ]

And then I was able to successfully compile and run the executable file.

image

EphemeralSapient commented 3 weeks ago

Patch by DJStompZone seemed not to work [no output at all] and thus I've changed tokio-wifiscanner myself for windows support;

update : tokio-wifiscanner git url is set to my repo

Chleba commented 3 weeks ago

Hi, This is great. Thank You very much for Your PR. Export is great. I will make a small adjustments to Your PR. I don't know what to think about included libs files for windows. I have a PC with windows somewhere so I will test this on my windows PC and let you know another steps. Unfortunately I will get some spare time for this after this weekend so if I may ask for a little bit patience with me, I'll try to check that ASAP. Thanks again - great work :+1:

EphemeralSapient commented 3 weeks ago

Thank you for quick response, just now I learnt the way on how to link lib file dynamically, so that npcap can be utilized within main.rs itself instead of user installation

If you don't mind I would like to fix few glitchy bug that occurs only for windows platform [invalid active interface, crashes whenever ip scan is performed]

EphemeralSapient commented 3 weeks ago

Hi there, I've patched the windows related bugs

  1. Interface name is just windows device id and thus switches to description [actual name] only for windows
  2. function to check whether interface is on or off is not available for windows it seems, so disabled the check for it
  3. Npcap adds when build is triggered, so no need of manual lib path
  4. For some reasons it crashes on when scanning the network [ unwrap is called on null value ] so, added null check

image

However, I couldn't resolve a bug where I initiate scan for discovery, it freezes [loading animation is not played properly] entire thing

Chleba commented 3 weeks ago

Hi @EphemeralSapient,

Great amount of work You've done here. Amazing. Thank You very much.

  1. Awesome - thanks for fixing that. I didn't know that Windows has names of their interfaces in description.
  2. I take a quick look into a code and I will add some comments or I made a PR for your PR to address few things that I would do differently
  3. Yeah, nice work there, but I kind of don't like that app would download something, even if it's a another library. I'll take a look at this issue and get some information about windows development. I did a few crossplatform desktop applications but I don't use windows at all and kind don't like it that much (sorry). I'll made myself some virtual machine with windows to be able to fully support and test your implementation so that we have best solution for win support.
  4. Well ... there is no null value in Rust (that's the beautiful thing about Rust) :) but some bad logic behind some unwrapping - many thanks about that

About tokio-wifiscanner I'm having a branch where I'm implementing my own solution for scanning WiFi networks because MacOS just dropped support for airport and original crate wifiscanner looks like it's no longer suppported and there's many PRs that is not merged. I would like to ask you for your permission to use your code that fixed windows support from your repository.

Last thing - the bug that you mention as last, I am aware of it and I have to refactor a huge part of discovery code that would fixed that. That is also already in the making, but unfortunately I have have very little time lately to push and finish it and I am really sorry about it.

I am really grateful for your work on this tool and you did really nice job. Many thanks to You and I will try to add comments and test it for myself as soon as possible. Thanks again.

EphemeralSapient commented 3 weeks ago

man, you've said "thanks" too many times, and welcome; I use both linux and windows since my college and their exam platform always require windows only, so it became kind of habit and I just wanted netscanner to be portable, that's it

my 2nd statement and way of approach is wrong now I think, I'll try another way [ I just couldn't able to withstand the time of compilation (took 19 min every time I run cargo run) and wanted to debug faster out of frustration ]

and yeah, npcap seems to be reputable and standard library overall [ wireshark, and other well known softwares uses npcap SDK ]

I don't think windows exposes any SDK for packet capturing, however there's Pktmon in windows as built-in tool for network diagnostics and troubleshooting as a packet capture solution.

and sure you can use the code that fixed windows support from tokio-wifiscanner PR or repo that I created; I don't mind at all

I heard that flamegraphs can be useful for profiling! not sure if it'll be helpful for finding what's bottlenecking the discovery function through

Chleba commented 2 weeks ago

man, you've said "thanks" too many times, and welcome;

I know, sorry about that, but it's overwhelming feeling that somebody other then myself spending their time on this and I cannot describe how grateful I am.

Btw. I just finished another update of the netscanner that I would like to create a new version and I did tried fix a MacOS WiFi scanning that was successful. So I do have to rewrite above mentioned crate tokio-wifiscanner, so next step will be:

So if I may ask You for Your patience - I will do that ASAP. Thanks again :)

Chleba commented 1 week ago

Hi @EphemeralSapient, I tried Your changes on Win10, but unfortunately it building the app did not copied lib files into a right directory. I was unable to find them anywhere (but idk - I didn't used windows many years) but all and all it was working perfectly :). I was thinking about adding requirement for Windows users to download used library for their version of Windows using GUI installer and really not trying to download and unpack any zip file. What do You think ?

EphemeralSapient commented 5 days ago

ah sorry, I've been busy with college for a while now;

I don't know if it works for windows 10 but then for people who haven't installed npcap, it seems to show packet.dll error sometimes

I'll check and update the status soon for windows 10

and uh, I am not sure about unpacking the zip file since npcap already supports the GUI installer thing?

Chleba commented 4 days ago

Hi @EphemeralSapient, No need to apologize for anything. I just needed to move forward when I got time to progress with netscanner so I merge your wonderful work and I'm gonna continue working on wifiscanner to add macOS support to have it all together in another released version.

and uh, I am not sure about unpacking the zip file since npcap already supports the GUI installer thing?

Yes, I will add installation steps and requirements in README, so hopefully that's gonna be enough.