1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Remotely shutting down a NAS

Discussion in 'Earlier Versions of Windows' started by GarroteYou, Sep 24, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. GarroteYou

    GarroteYou Thread Starter

    Joined:
    Jan 2, 2003
    Messages:
    21
    Hello -

    This may not be the right forum for this particular issue, but I'll give it a shot -

    I have an EFG80 from linksys. It's an NAS box for a home network. Every night I shut this thing down along with three other 2000 systems. I would like to be able to remotely kill all 4 devices with one click.

    The windows boxes are easy

    Code:
    psshutdown -u admin -p passwd -k -f -t 15 -m "System is going down" \\sys2
    psshutdown -u admin -p passwd -k -f -t 15 -m "System is going down" \\sys1
    psshutdown -k -f -t 15 "System is going down"
    
    (psshutdown)

    The EFG80 can only be shut down from within the web based administration pages installed within the unit. Anyone with a linksys or probably any number of other manufacturers router WAP etc. know what I'm talking about.

    I can get to the page with the button directly:

    http://192.168.1.xx/Management/setup.cgi?next_file=status.htm

    The button is javascript based, <a href="javascript:action(1);">"button image"</a>

    Here is the action() function:

    Code:
    <script language="JavaScript" type="text/javascript">
    <!-- Start Script
    
    // other functions
    
    function action(no)
    {
    	var cf = document.status;
    	if (no == 1)
    		cf.todo.value = "shutdown_now";
    	if (no == 2)
    		cf.todo.value = "restart_now";
    	cf.submit();
    }
    
    // other functions
    
    </script>
    </head>
    The problem is that I must authenticate via a '.htpasswd' before running the cgi script which serves the page with my configuration.

    http://192.168.1.xx/Management/setup.cgi?next_file=status.htm

    I can see the '.htpasswd' file by:

    http://192.168.1.xx/Management/

    Which gives a listing of all the files which make up the admin web pages, I don't think they want their users poking around that folder, but there is nothing there any way.

    The box runs an embedded linux dist and thttpd/2.20c. Linksys claims a shell is not available.

    Can I script the submiting of my admin credentials along with the execution of the shutdown function?

    What is a document.status object, and what does the submit(); function do?

    Would it be possible to create a perl, or other lang. script which would supply the admin user and pass, and execute the java function ultimately shutting down the system?

    Thanks in advance

    ~Dave
     
  2. putasolution

    putasolution

    Joined:
    Mar 20, 2003
    Messages:
    4,823
  3. GarroteYou

    GarroteYou Thread Starter

    Joined:
    Jan 2, 2003
    Messages:
    21
    The EMCO software will work for the windows machines much like the psshutdown utility from sysinternals. For shutting down the NAS box however, I'm trying to execute a java function within the administration of the hardware so the EMCO software will not work.
     
  4. GarroteYou

    GarroteYou Thread Starter

    Joined:
    Jan 2, 2003
    Messages:
    21
    I got it! Using Sniffer Pro, I watched each packet as sent from this box to the NAS.

    The sequence of strings which need to be sent to the NAS is the following:

    Code:
    [TELNET] CONNECT (NAS-DEVICE/192.168.1.88)
    
    GET /Management/setup.cgi?next_file=status.htm HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
    Host: 192.168.1.88
    Connection: Keep-Alive
    
    
    The NAS replies with:

    Code:
    HTTP/1.1 401 Unauthorized
    Server: thttpd/2.20c 21nov01
    Content-type: text/html
    Date: Wed, 01 Oct 2003 00:34:05 GMT
    Last-modified: Wed, 01 Oct 2003 00:34:05 GMT
    Accept-Ranges: bytes
    Connection: close
    WWW-Authenticate: Basic realm="Administration"
    
    <HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
    <BODY BGCOLOR="#cc9999"><H2>401 Unauthorized</H2>
    Authorization required for the URL '/Management/setup.cgi?next_file=status.htm'.
    <!--
    Padding so that MSIE deigns to show this error instead of its own canned one.
    Padding so that MSIE
    deigns to show this error instead of its own canned one.
    Padding so that MSIE deigns to show this error instead of its own canned one.
    Padding so that MSIE deigns to show this error instead of its own canned one.
    Padding so that MSIE deigns to show this error instead of its own canned one.
    Padding so that MSIE deigns to show this error instead of its own canned one.
    -->
    <HR>
    <ADDRESS><A HREF="http://www.acme.com/software/thttpd/">thttpd/2.20c 21nov01</A></ADDRESS>
    </BODY></HTML>
    
    [TELNET] INFO: DISCONNECTED
    From that response, a browser would ask for authentication, and try again:

    Code:
    [TELNET] CONNECT (NAS-DEVICE/192.168.1.88)
    
    GET /Management/setup.cgi?next_file=status.htm HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
    Host: 192.168.1.88
    Connection: Keep-Alive
    Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
    This being the second request in a row, the server accepts the authentication, and serves the page.

    Next comes the request which simulates the shutdown button:

    Code:
    [TELNET] CONNECT (NAS-DEVICE/192.168.1.88)
    
    POST /Management/setup.cgi HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
    Referer: [url]http://192.168.1.88/Management/setup.cgi[/url]
    Accept-Language: en-us
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
    Host: 192.168.1.88
    Content-Length: 222
    Connection: Keep-Alive
    Cache-Control: no-cache
    Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
    Here is the correct string:

    Code:
    email_enable=&[email protected]&email_2=&email_subject=GigaDrive+report&h_email_enable=checked&message=&this_file=status.htm&todo=shutdown_now&[email protected]&h_email_2=&h_email_subject=GigaDrive+report
    Now I just need to create a program which will connect to the box, and feed these strings in on by one...

    ~Dave
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/167235

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice