Archive for category Networking

Netgear ReadyNAS Duo command line shut down utility

So I finished the backup app and compiled it for anyone who wants it- it’s used from the command prompt like so;
ShutdownNASBox -h <hostname> -u <username> -p <password>


ShutdownNASBox -h backup -u admin -p abc123

If you run the tool with administrator privileges, it will log to the Windows Event Log on the System tab.

You can download it here (note you will need dot net framework 4 installed)


Automatic NAS Box shutdown – How to POST the shutdown command over SSL with HTTP authentication from a dot net Console app (Part 1/2)

I recently purchased a Netgear ReadyNAS Duo RAIDed network storage box for general backup of my ‘stuff and things’, which sit’s on my desk and runs off the same power as my PC.  A couple of times now I’ve booted the box up to run a backup, then forgot to shut it down, then shut down my PC, flick the switch at the wall and then realise.  When I boot everything back up in a day or so, the NAS box has to do a full system check and maybe rebuild the RAID array if theres a problem etc etc – it’s a pain.

So I thought I would set about automating the NAS box shut down with my PC shut down which turned out to be pretty easy.  The NAS box is controller via a web UI- my box has the host name “BACKUP” so I can get to it over the browser on http://BACKUP/.  This uses basic HTTP authentication asking me to login, and also use’s https (which my browser always warns me about because it’s not from a trusts CA or whatever- so I just ignore the warnings and continue).  From the web UI you can go to the system tab and select shut down and the box goes down.  I figured as this is going to be a simple web call, it should be easy enough to write a simple console app which makes the same call which can be fired on Windows shutdown- so I fired up Firebug, opened the “Net” tab, which allows you to inspect all http calls made, and triggered a shut down. It’s probably worth noting at this point that the techniques used here could probably be applied to pretty much any other networked device with a web based UI (most routers, firewalls, switches, printers, media boxes etc) so this should hopefully be quite useful.

Sure enough the HTTPS POST made to a file called get_handler on the root could be seen, with the POST data string;

As we can see from firebug, the data sent is;


So six key value pairs separated by ampersands.  The code itself is pretty simple using WebClient class (System.Net namespace)- however there are a couple of complications, which as it happens are fairly common things to run into, so a good opportunity to give some example code for future reference;

  • We need to perform our Form Post over SSL

  • The SSL certificate of the server we are posting to will never be valid!

  • We must carry out our form post while supplying basic HTTP authentication credentials

I created a new Console application and added the following code;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections.Specialized;

namespace ShutdownNASBox
    class Program
        static void Main(string[] args)
            using (WebClient client = new WebClient())
                // add the basic http authentication username &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; password
                client.Credentials = new NetworkCredential("admin", "abc123");

                // register the face that the connection uses SSL
                // (otherwise it defaults to TLS and you get an exception)
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

                // set it to effectivly ignore the SSL certificate
                ServicePointManager.ServerCertificateValidationCallback =
                                                        delegate { return true; };

                // build a NameValueCollection which holds those 6 values we saw
                // being posted when we used firebug
                NameValueCollection c = new NameValueCollection();
                c.Add("PAGE", "System");
                c.Add("OUTER_TAB", "tab_shutdown");
                c.Add("INNER_TAB", "NONE");
                c.Add("shutdown_option1", "1");
                c.Add("command", "poweroff");
                c.Add("OPERATION", "set");

                    // Post the data!  This will return as a byte array
                    byte[] bytes =
                    client.UploadValues("https://backup/get_handler", c);

                    // convert the byte array into text we can read!
                    string result = Encoding.ASCII.GetString(bytes);

                    Console.Write("Shutdown Message Sent");

                catch (Exception e)
                    Console.Write("Shutdown Message Send Failure!");

And that’s all there is to it! An obvious and easy upgrade would be to make this parametrized and maybe get it to write to the windows log on failure.

In part two I shall do a quick post on how to schedule tasks to run on shut down in Windows 7.

You can see the finished app, with the above recommended improvements already implemented, here

, , , ,

No Comments

VPN Problems with Vista

Error 741: The local computer does not support the required data encryption type

Vista VPN Error

Vista VPN Error

I recently had this problem trying to connect to my work’s VPN connection, which I had previously connected to with no problems under XP.  Apparently this is due to the security standard in Vista being too high for our old school CHAP VPN connection- the fix;

  1. Right click the VPN connection and go to properties
  2. Click the security tab
  3. click the “Advanced (custom settings)” radio button, then click the settings button
  4. Select “Optional encryption” from the Data Encryption drop down
  5. Select the “Allow these protocols” radio button, and make sure “Challenge Handshake Authentication Protocol (CHAP)” is ticked, as well as “Microsoft CHAP Version 2 (MS-CHAP v2)
  6. hit ok, then ok in the parent window and connect!

Vista VPN Error - Fix

Vista VPN Error - Fix

No Comments