nicklasfrahm / netadm

A CLI and a set of client libraries to manage network devices written in Go.
MIT License
5 stars 0 forks source link

POE on/off? #1

Open baylanger opened 2 years ago

baylanger commented 2 years ago

Hello,

What does this cli support so far? It's not obvious because I haven't receive my Netgear POE managed switch yet.

Can this cli turn on/off POE ports? If not, is it a lot of work to add? I can look into it but I'm no Go programmer.

Thanx.

nicklasfrahm commented 2 years ago

Currently the CLI supports read operations only for most parameters. You can get a list for those via nsdp keys. PoE is not yet supported, but I could give it a try, so you can both read and write this option. šŸ˜Š

nicklasfrahm commented 2 years ago

@baylanger Which switch did you order? I could buy a PoE switch, but I don't really have a use-case for it. If you have your switch, I could implement this functionality if you commit to testing it.

baylanger commented 2 years ago

I still haven't receive the switch... I went with a GS308EPP but if you don't need so many ports there's the GS305EPP.

I have tp-link eap660hd access points and they need PoE+ but cameras usually don't need so much power, perhaps a few high end/expensive options?! maybe a small 5W heater for winter time?!

Netgear has a few other models like 8 ports w/ 4 ports PoE (+ ?) .. can't recall if that one was managed or not.

tp-link has a few options as well BUT per reviews on amazon.com etc .. they're not rated as good as the netgear. What bugs me is that if this switch fails, I'm out of wifi but the AP came with power adapters. In worst case, I have a backup plan. Maybe not for my cameras and that's fine for me.

In Canada and in the US the GS308EPP is back order, the GS305EPP is available on a few sites. If you happen to find GS308EPP in Europe, let me know I might ask you to ship me one ;)

baylanger commented 2 years ago

Oops ... forgot the last point. I see this is written in Go, I'm not a go guy but always wanted to learn it.

Let me first get the switch before starting any work :D , Newegg shows end of March to receive stock but last month the date was end of February. Delivery has already been pushed out at least once.

I'll be back ... hoping Putin doesn't nuke the world.

nicklasfrahm commented 2 years ago

You are a gem! Sorry I didn't come back earlier. I am currently getting ready to move.

Just FYI, I will rename the repo and make it more general purpose while retaining the same functionality.

You could try to order from amazon.de. They seem to have it in stock.

Sylensky commented 2 years ago

Iam really looking forward for these features. Keep up the great work!

baylanger commented 2 years ago

My order hasnā€™t ship yet ā€¦. Still back order everywhereā€¦. when it ships it will be obsolete and PoW will be available. That is Power over Wireless šŸ˜

nicklasfrahm commented 2 years ago

@baylanger I have a confession to make. I bought the GS308EPP and I might implement this now. šŸ˜…

Honestly just bought the switch because it seemed fun.

baylanger commented 2 years ago

@nicklasfrahm fantastic. Looks like there are other people inline waiting for this, I mean .. they already have such a switch. I might get mine after you've added this new feature šŸ¤” or just next year?! šŸ˜¢ With Silicon backlog, Netgear is likely prioritizing business products where they probably make more money.

FYI I did check on amazon.de and they won't deliver to Canada.

nicklasfrahm commented 2 years ago

I could send mine to you once I implement this feature. I don't have a timeline, but I have 0 usage for PoE haha. Literally just bought it to implement this feature.

nicklasfrahm commented 2 years ago

FYI, I am doing a major rewrite so that I can support multiple protocols in the future so this will take some time. Hope that is okay. If you urgently need this feature, I can postpone the rewrite.

baylanger commented 2 years ago

@nicklasfrahm thank you for the offer, I was quite busy last week. FYI I received an email from online store saying my item is still backorder ā€¦ currently the date shows in stock May 26. Is it really going to ship this week?!?!

Sylensky commented 2 years ago

Do you have an ETA for the rewrite and this particular feature?

baylanger commented 2 years ago

@nicklasfrahm fyi turns out my switch finally shipped outā€¦ I should receive it by end of day. Let us know at the end if you intend to sell it, perhaps someone here is interested. If you lose money, let us know - perhaps a few of us will chip in money to cover any lost.

nicklasfrahm commented 2 years ago

I put the rewrite on hold to prioritize this feature. Maximum a week, I would say.

nicklasfrahm commented 2 years ago

Okay, I need help. Are any of you running Windows?

baylanger commented 2 years ago

Depends what you need. I have access to a Windows computer but no admin accessā€¦ canā€™t install anything.

Sylensky commented 2 years ago

I can test on whether OS you would like to except Mac OS.

nicklasfrahm commented 2 years ago

Could you modify the PoE configuration via the ProSafe tool from Netgear, record that via Wireshark and send me the capture file? For some reason I can only see my GS308E, but not my GS308EPP switch when I run the ProSafe tool via wine on Ubuntu.

Sylensky commented 2 years ago

Iam not sure if i missed something but the switch is detected from the prosafe plus utility but it doesn't let me login and tells me "The ProSafe Plus Utility management for this switch is currently disabled". I checked the webconfiguration and iam unable to find an entry that should enable this feature. Is it even included in that switch with firmware version 1.0.0.8?

nicklasfrahm commented 2 years ago

If you navigate to Settings > Switch Discovery you will find a toggle that is disabled by default. Setting this to On and clicking Apply will enable the Netgear Switch Discovery Protocol for out-of-band management. Please also see the attached screenshot. image

baylanger commented 2 years ago

When I was looking for Netgear Prosafeā€¦ on the web site it says product is end of life.

When I search for gs308epp , the download link shows a new discovery product. Would this new tool do the job?

https://www.netgear.com/support/product/gs308epp.aspx#download

Thereā€™s a Mac and Linux version.

baylanger commented 2 years ago

I refer to the "netgear switch discovery toolā€œ but I just noticed on that same download page, Prosafe tool is also there.

Using search engine I tried to find information on the difference between the 2 tools and couldnā€™t find anything. Iā€™m away from home otherwise Iā€™d download the ā€œnew?ā€ tool and give it a try.

baylanger commented 2 years ago

Iā€™m on my phone in a waiting roomā€¦. I really have nothing to do šŸ¤“

Netgear donā€™t seem to have any documentation available for NSDT , not even on the ā€œofficialā€ download page.

https://www.netgear.com/support/product/netgear-switch-discovery-tool.aspx

nicklasfrahm commented 2 years ago

FYI, Netgear provides two tools. The fancy, new NSDT and the old ProSAFE Plus Configuration Utility v2.7.8, which may also be found on the website you provided. The tool from which I need the logs is the ProSAFE Plus Configuration Utility v2.7.8, because NSDT can only discover switches and link to their web interface, but not configure them. It is a really dumb tool, IMO.

baylanger commented 2 years ago

I kept telling myself, Netgearā€™s new tool must do everything the ā€deprecatedā€ tool was doingā€¦. but per the name (discovery) it did sound like it was only to discover. Thanx for confirming Netgear is doing something ā€¦ the wrong way :)

Sylensky commented 2 years ago

If you navigate to Settings > Switch Discovery you will find a toggle that is disabled by default. Setting this to On and clicking Apply will enable the Netgear Switch Discovery Protocol for out-of-band management. Please also see the attached screenshot. image

This setting is enabled else i wouldnt see the switch in the ProSAFE Utility... However this is error is appearing when i try to access the switch from the Utility: image

baylanger commented 2 years ago

On the download for the GS308EPP , the Prosafe is there along with NSDT ... but Prosafe doesn't support that switch. That doesn't look very good :/

@nicklasfrahm aside from the POE on/off , with netadm are you able to control anything on that switch? If so... is it worth looking into the firmware's binary? I found these but I don't think it helps at all.

/poe.cgi
/PoEPortConfig.cgi
/getPoePortEdit.cgi
/getPoePortStatus.cgi
/UninterruptedPoE.cgi

edit_poe_port_info();
back_poe_port_info();

While looking into the firmware, I found these :

Back door key check: Invalid checksum.
%s_%s.bin.key
Back door key check: Invalid magic number.
Back door key check: Invalid file name.
Back door key check: success.

I'm not sure what the above is all about .. but quickly that doesn't look too good.

baylanger commented 2 years ago

@Sylensky Just to make sure, you have Prosafe 2.7.8 ? That looks like the latest version but Netgear web site sucks. Maybe a newer release is hidden somewhere.....

Sylensky commented 2 years ago

yes i used v2.7.8

nicklasfrahm commented 2 years ago

Currently, the netadm tool does not support write operations, but in the depths of GitHub I found a PR that shows how to check for the key exchange mechanism and thus implement write operations.

I was actually seeing the same issue with the ProSAFE tool, but I was suspecting an issue with wine. Thanks for verifying that this is indeed a limitation of the tool.

The reason why it sucks that the ProSAFE tool doesn't work is that it is otherwise very hard to figure out the type identifiers that are used to set these properties.

I could attempt to write a script that does a dump of all parameters. šŸ¤” I will try that Sunday or beginning of next week as tomorrow is my sister's birthday.

baylanger commented 2 years ago

Can you share the PR that you found? I might not be able to help but at least I can understand a little more the issue.

Iā€™m not sure how you can dump Ā«Ā all typeĀ Ā» but seems you might have a way to Ā«Ā travelĀ Ā» (loop?) into them. Iā€™ll take also a look at netadm source code, might give me some insights.

nicklasfrahm commented 2 years ago

The PR in question can be found at tabacha/ProSafeLinux#35. What's interesting is this piece of code.

baylanger commented 2 years ago

Interesting I was looking at the hashkey ā€¦. I was telling myself something seems very wrong here in terms of securityā€¦

The README from that ProSafeLinux confirms thereā€™s a security issue. Not sure if thereā€™s a way to disable or if Netgear patched their latest firmwareā€¦. if so, perhaps it explains why Prosafe would not work with latest switches/firmware?

baylanger commented 2 years ago

Netgear routers included in Zuorat.

https://thehackernews.com/2022/06/zuorat-malware-hijacking-home-office.html

Sylensky commented 2 years ago

I found the time to test out some various things with no success so far. Combined various firmware files and tried to connect to the switch via various ProSAFE versions aswell.

So far i tried:

Furthermore i traced some packets with wireshark with the webUI. I dont know if its beneficial to you but heres what i did:

  1. logged into switch, changed password
  2. go to poe page
  3. disabled poe on port 3
  4. disabled poe on port 4
  5. enabled poe on port 3
  6. enabled poe on port 4

Here are the captured packets captured.zip .

nicklasfrahm commented 2 years ago

@Sylensky Thanks for the captured packages. I did some work on the CLI to support looking up the encryption mode and I am currently implementing the write functionality. Could you just check which encryption mode your device supports using the following commands:

# List interfaces.
netadm if
# List devices on the local network.
netadm -i <interface> scan
Sylensky commented 2 years ago

It supports Hash64.

pi@raspberrypi ~ $ ./go/bin/netadm -i eth0 scan
Name        Model       MAC Address          IP Address         DHCP    Firmware     Encryption
GS308EPP    GS308EPP    34:98:b5:b1:3a:9d    192.168.100.135    true    V1.0.0.10    Hash64
nicklasfrahm commented 2 years ago

@Sylensky I have now implemented the set command for strings. It works for setting the device name. :rocket: Please try it out and report back if it works for you as well.

Now we need to figure out what the key ID for the PoE state is and then this issue should finally be resolved. I will have a look at the provided capture logs. :mag:

Sylensky commented 2 years ago

Alright i had the time to test the set command and it did not work for me. This is the output of it:

./go/bin/netadm set 192.168.100.135 name=TEST -i eth0 -p <password>
Error: operation failed with status code 0x0F00

@nicklasfrahm Can you share details about your setup and how you were able to execute the commands successfully?

nicklasfrahm commented 2 years ago

I have just checked it again and I am running into the same issue with my GS308EPP with firmware version V1.0.0.10, but not with my GS308E running firmware version 1.0.0.10 (yes this is not a typo, the firmware versioning is inconsistent).

The wireshark script that is included in ProSafeLinux claims that the management protocol is not enabled (code 0x0F00):

git clone https://github.com/tabacha/ProSafeLinux
cd ProSafeLinux/wireshark && sudo ./startWireshark.sh

This is very strange as the management protocol seems to be enabled when checking the web interface. This may be related to the issue you were describing with the official tool. I really hope this is not a bug in their firmware.

Screenshot from 2022-08-21 20-57-14

I also tried messing around with the settings for Access Control with no luck.

It may be due to me being sloppy with the sequence numbers as I generate them before dispatching the message to the device based on the current timestamp and they are most often not contiguous. I will try to handle that more nicely.

Sylensky commented 2 years ago

I really hope this is not a bug in their firmware.

If so it must be consistent throughout a lot of version i just tested before and i highly doubt that. I could do some more testing with previous firmware versions and the set command to see if that is the case.

Sylensky commented 1 year ago

Were you able to make any progress with this?