mzdrale / pyubee

Simple library for getting stats from Ubee routers.
GNU General Public License v3.0
2 stars 4 forks source link

DDW36C Not supported #19

Closed Hukuma1 closed 4 years ago

Hukuma1 commented 4 years ago

Here is the submitted information to try and get support added for one more Ubee device. Thank you!

pyubee -m DVW32CB 192.168.0.1 admin "XXXXXXXXXX"
No connected devices found

Auto-detect the model 1 0 http://192.168.0.1:80 urn:schemas-upnp-org:device:InternetGatewayDevice:1 Ubee DDW36C Ubee http://www.ubeeinteractive.com DDW36C DDW36C DDW36C http://www.ubeeinteractive.com (unimplemented) uuid:upnp-InternetGatewayDevice-1_0-XXXXXXXXXXXX (unimplemented) urn:schemas-upnp-org:service:Layer3Forwarding:1 urn:upnp-org:serviceId:L3Forwarding1 /Layer3Forwarding.xml /Layer3Forwarding /Layer3Forwarding urn:schemas-upnp-org:device:WANDevice:1 Ubee DDW36C Ubee http://www.ubeeinteractive.com DDW36C DDW36C DDW36C http://www.ubeeinteractive.com (unimplemented) uuid:upnp-WANDevice-1_0-XXXXXXXXXXXX (unimplemented) urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 urn:upnp-org:serviceId:WANCommonIFC1 /WANCommonInterfaceConfig.xml /WANCommonInterfaceConfig /WANCommonInterfaceConfig urn:schemas-upnp-org:device:WANConnectionDevice:1 Ubee DDW36C Ubee http://www.ubeeinteractive.com DDW36C DDW36C DDW36C http://www.ubeeinteractive.com (unimplemented) uuid:upnp-WANConnectionDevice-1_0-XXXXXXXXXXXX (unimplemented) urn:schemas-upnp-org:service:WANIPConnection:1 urn:upnp-org:serviceId:WANIPConn1 /WANIPConnection.xml /WANIPConnection /WANIPConnection /

Logging in http://192.168.0.1/RgSwInfo.asp

ubee

 

                        <tr>
                            <td colspan="3">DHCP Clients</td>
                        </tr>
                        <tr>
                            <td>
<table style="font-family: Helvetica;font-size:14"><tr bgcolor=#9900FF><td>MAC Address</td><td>IP Address</td><td>Subnet Mask</td><td>Duration</td><td>Expires</td><td>Select</td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.2</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:21:17 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(1);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.3</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:29:58 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(2);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.5</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:14:25 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(3);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.6</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:16:19 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(4);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.8</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:28:04 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(5);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.9</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 10:54:34 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(6);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.12</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:21:33 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(7);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.29</td><td>255.255.255.0</td><td>D:-- H:-- M:-- S:--</td><td>*** STATIC IP ADDRESS **</td><td></td></tr>
</table>
<br>
                                <b>Current System Time:</b> Wed Mar 04 10:33:43 2020

                </td>
                        </tr>

Going to that URL prompts me for the login. Cannot see source to the ASP link, unless I hit cancel and get unauthorized access message.

Logging out http://192.168.0.1/logout.asp

Check if we are logged in Invokes http://192.168.0.1/logout.asp and I cannot see page source of dialog box.

Get the connected devices via LAN

    <tr>
                            <td colspan="3">DHCP Clients</td>
                        </tr>
                        <tr>
                            <td>
<table style="font-family: Helvetica;font-size:14"><tr bgcolor=#9900FF><td>MAC Address</td><td>IP Address</td><td>Subnet Mask</td><td>Duration</td><td>Expires</td><td>Select</td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.2</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:51:18 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(1);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.5</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:44:27 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(2);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.6</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:46:21 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(3);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.8</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:28:04 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(4);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.9</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:35:07 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(5);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.12</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 04 11:51:34 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(6);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.29</td><td>255.255.255.0</td><td>D:-- H:-- M:-- S:--</td><td>*** STATIC IP ADDRESS **</td><td></td></tr>
</table>
<br>
                                <b>Current System Time:</b> Wed Mar 04 10:53:18 2020

                </td>
                        </tr>

Get the connected devices via WiFi

<table>
                        <tr valign="top">
                            <td align="right">Connected Clients</td>
                            <td>
                                <table>
<tr bgcolor=#fda506><td>&nbsp;MAC Address&nbsp;</td><td>&nbsp;Age(s)&nbsp;</td><td>&nbsp;RSSI(dBm)&nbsp;</td><td>&nbsp;IP Addr&nbsp;</td><td>&nbsp;Host Name&nbsp;</td><td>Mode</td><td>Speed (kbps)</td></tr><tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>11455</td><td>-57</td><td>192.168.0.8</td><td>IPhone</td><td>AC</td><td>27000</td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>27949</td><td>-57</td><td>192.168.0.6</td><td>Google-Home-Mini</td><td>AC</td><td>6500</td></tr>

                                </table>
                            </td>
                        </tr>
                    </table>
StevenLooman commented 4 years ago

Supporting a new model without access to it is very hard. Your best bet is to try to add support yourself. Do you have the knowledge and means to do this?

Other entries in this table might help you by using these as an example.

Hukuma1 commented 4 years ago

I am not a coder, sorry. I only suggested to see if support for DDW36C device because it is VERY similar to DVW32CB that was just added. Figured if it was similar in hardware, the software part would be as well. But that's just a guess at this point.

Hukuma1 commented 4 years ago
'DVW32CB': {
        'url_session_active': '/main.asp',
        'url_login': '/RgSwInfo.asp',
        'url_logout': '/logout.asp',
        # includes all devices, also WiFi
        'url_connected_devices_lan': '/RgDhcp.asp',
        'url_connected_devices_wifi': '/wlanAccess.asp',
        'regex_login': re.compile(r'name="loginUsername"'),
        'regex_wifi_devices': re.compile(
            r'<tr bgcolor=#[0-9a-fA-F]+>'
            r'<td>([0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:'  # mac address
            r'[0-9a-fA-F]{2}:[0-9a-fA-F]{2})</td>'  # mac address, cont'd
            r'<td>\d+</td>'  # age
            r'<td>.*</td>'  # rssi
            r'<td>.*</td>'  # ip address
            r'<td>(.*)</td>'  # hostname
            r'<td>.*</td>'  # mode
            r'<td>\d+</td>'  # speed
            r'</tr>'
        ),

Testing links by http://routerip/ e.g. http://192.168.0.1/main.asp

    'url_session_active': '/main.asp', = WORKS (not 404)
    'url_login': '/RgSwInfo.asp', = WORKS (not 404)
    'url_logout': '/logout.asp', = WORKS (not 404)
    'url_connected_devices_lan': '/RgDhcp.asp' = WORKS (not 404)
    'url_connected_devices_wifi': '/wlanAccess.asp' = WORKS (not 404) (only seems to be same page for 2.4G Hz and 5G Hz networks)

I can provide a photo of each page if that helps, but it seems to be working with same links as the recently-added model.

StevenLooman commented 4 years ago

If you provide DVW32CB as the model and query your own router, does it give the information you expect?

Hukuma1 commented 4 years ago

You mean to try to connect as if it were a DVW32CB? I get this:

pyubee -m DVW32CB 192.168.0.1 admin "XXXXXXXXXX"
No connected devices found
StevenLooman commented 4 years ago

What output do you get if you add the -d (debug) flag?

Hukuma1 commented 4 years ago
DEBUG:pyubee:Using model: DVW32CB
DEBUG:pyubee:HTTP GET: http://192.168.0.1/main.asp
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgDhcp.asp
DEBUG:pyubee:LAN devices: {}
DEBUG:pyubee:HTTP GET: http://192.168.0.1/wlanAccess.asp
DEBUG:pyubee:WIFI devices: {}
No connected devices found
StevenLooman commented 4 years ago

Can you add this to the table and try again?

    'DDW36C': {
        'url_session_active': '/main.asp',
        'url_login': '/RgSwInfo.asp',
        'url_logout': '/logout.asp',
        'url_connected_devices_lan': '/RgDhcp.asp',
        'url_connected_devices_wifi': '/wlanAccess.asp',
        'regex_login': re.compile(r'name="loginUsername"'),
        'regex_wifi_devices': re.compile(
            r'<tr bgcolor=#[0-9a-fA-F]+>'
            r'<td>([0-9a-fA-F:]{17})</td>'  # mac address
            r'<td>.*</td>'  # age
            r'<td>.*</td>'  # rssi
            r'<td>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})</td>'  # ip address
        ),
        'regex_lan_devices': re.compile(
            r'<tr bgcolor=#[0-9a-fA-F]+>'
            r'<td>([0-9a-fA-F:]{17})</td>'  # mac address
            r'<td>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})</td>'  # ip address
        ),
        'authenticator': DefaultAuthenticator
    },

The run the command:

$ pyubee -m DDW36C -d 192.168.0.1 admin "XXXXXXXXXX"

Replace XXXXXXXXXX with your password.

Hukuma1 commented 4 years ago

Is there a way you could push a test version that I can install?

So I can run something like pip3 install pyubee-test

StevenLooman commented 4 years ago

Try this:

$ pip3 install git+https://github.com/mzdrale/pyubee.git@DDW36C
Hukuma1 commented 4 years ago

DEBUG:pyubee:Using model: DDW36C
DEBUG:pyubee:HTTP GET: http://192.168.0.1/main.asp
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgDhcp.asp
DEBUG:pyubee:LAN devices: {}
DEBUG:pyubee:HTTP GET: http://192.168.0.1/wlanAccess.asp
DEBUG:pyubee:WIFI devices: {}
No connected devices found

Is there some networking requirement maybe not met on my host install?

StevenLooman commented 4 years ago

No, your host does retrieve the URLs it mentions, that seems to work. I think the regular expressions in the table might be incomplete/incorrect.

It is hard for me to help further, the data you have provided matched for me. Maybe there are some newlines/enters or other spacing characters which did not come across properly in this issue.

I think we're getting there, there just is some 'minor' work of perfecting the regular expressions. Unfortunately, you'll probably have to do this yourself. You can do this by:

  1. Going to Debuggex
  2. Choose Python as the regex engine (by default it chooses JavaScript)
  3. Enter the regular expression for LAN devices (currently <tr bgcolor=#[0-9a-fA-F]+><td>([0-9a-fA-F:]{17})</td><td>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})</td>)
  4. Copy and paste the whole page from the router which lists the LAN devices
  5. Try fiddling with the regular expression from 3, try to make it match.

If the regular expression matches, it marks the matched parts.

Hukuma1 commented 4 years ago

itworks

If I hover over the highlighted lines it says it's a successful match. Using your default regular expression line you pasted above as you can see.

Hukuma1 commented 4 years ago

Full HTML if helpful. Just redacted MAC addresses

http://192.168.0.1/RgDhcp.asp

<html>
<head>
    <link rel="stylesheet" type="text/css" href="ubee_main.css" />
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Residential Gateway Configuration: Basic - DHCP</title>
    <script language="javascript">
    document.oncontextmenu = new Function("return false");
    <!-- hide me

    //Darren add start, 2011/10/19
    function InitPage(){
        //CurOperationMode
        //BridgeMode:        0; 
        //NATMode:           1; 
        //RouterMode:       2; 
        //NATRouterMode: 3; 
        if ( window.document.Dhcp.CurOperationMode.value == 1) {
            window.document.Dhcp.StartingPublicAddressIP3.disabled = true;
            window.document.Dhcp.NumberOfCpes2.disabled = true;
            window.document.Dhcp.publicPoolEnable.disabled = true;
        } else if ( window.document.Dhcp.CurOperationMode.value == 2) {
            window.document.Dhcp.StartingLocalAddressIP3.disabled = true;
            window.document.Dhcp.NumberOfCpes.disabled = true;
            window.document.Dhcp.privatePoolEnable.disabled = true;
            window.document.Dhcp.ForceAvailable_T.disabled = true;
        }
        DisableButton();
    }
    //Darren add end, 2011/10/19

    function EnableButton()
    {
        var the_box = window.document.Dhcp.DhcpServerEnable;

        if (the_box.checked == true) {
            window.document.Dhcp.DhcpServerDisable.checked = false;
            //Darren add start, 2011/10/19
            window.document.Dhcp.StartingLocalAddressIP3.disabled = false;
            window.document.Dhcp.NumberOfCpes.disabled = false;
            window.document.Dhcp.StartingPublicAddressIP3.disabled = false;
            window.document.Dhcp.NumberOfCpes2.disabled = false;
            window.document.Dhcp.LeaseTime.disabled = false;
            window.document.Dhcp.privatePoolEnable.disabled = false;
            window.document.Dhcp.publicPoolEnable.disabled = false;
            InitPage();
            //Darren add end, 2011/10/19
        }
    }

    function privatePool()
    {
        var the_box = window.document.Dhcp.privatePoolEnable;

        if (the_box.checked == true) {
            window.document.Dhcp.publicPoolEnable.checked = false;
        }
    }

    function publicPool()
    {
        var the_box = window.document.Dhcp.publicPoolEnable;

        if (the_box.checked == true) {
            window.document.Dhcp.privatePoolEnable.checked = false;
        }
    }

    function DisableButton()
    {
        var the_box = window.document.Dhcp.DhcpServerDisable;

        if (the_box.checked == true) {
            window.document.Dhcp.DhcpServerEnable.checked = false;
            //Darren add start, 2011/10/19
            window.document.Dhcp.StartingLocalAddressIP3.disabled = true;
            window.document.Dhcp.NumberOfCpes.disabled = true;
            window.document.Dhcp.StartingPublicAddressIP3.disabled = true;
            window.document.Dhcp.NumberOfCpes2.disabled = true;
            window.document.Dhcp.LeaseTime.disabled = true;
            window.document.Dhcp.privatePoolEnable.disabled = true;
            window.document.Dhcp.publicPoolEnable.disabled = true;
            //Darren add end, 2011/10/19
        }
    }

    function ApplyButton()
    {
        window.document.Dhcp.ApplyAction.value = 1;
    }

    function ForceAvailable()
    {
        window.document.Dhcp.LeaseSelected.value = 1;
        window.document.Dhcp.ForceAction.value = 1;
    }

    function selectedLease(index)
    {
        window.document.Dhcp.LeaseToFree.value = index;
    }

    function AddWinsPrimary()
    {
        window.document.Dhcp.WinsAddressAction.value = 1;
    }

    function AddWinsSecondary()
    {
        window.document.Dhcp.WinsAddressAction.value = 2;
    }

    function AddWinsTertiary()
    {
        window.document.Dhcp.WinsAddressAction.value = 3;
    }

    function RemoveWinsAddress()
    {
        window.document.Dhcp.WinsAddressAction.value = 4;
    }

    function ClearAllWins()
    {
        window.document.Dhcp.WinsAddressAction.value = 5;
    }

    function checkStartIpRange(ipObject)
    {
        f = window.document.Dhcp;
        if (ipObject.value < 2 || ipObject.value > 254) {     // APRTWC10054 .Ip range is 192.168.0.2 to 192.168.0.254
            ipObject.value = 2;
            ipObject.focus();
            ShowStatusMsg(msg1206,1);        
        } else {
            ShowStatusMsg(msg1000,1);
        }         

        sum = parseInt(f.NumberOfCpes.value) + parseInt(ipObject.value);

        if ( (sum-1) > 254) {                  // APRTWC10054 .Ip range is 192.168.0.2 to 192.168.0.254
            f.NumberOfCpes.value = 255 - parseInt(ipObject.value);
        }
    }    

    function checkStartIpRange2(ipObject)
    {
        f = window.document.Dhcp;
        if (ipObject.value < 2 || ipObject.value > 254) {
            ipObject.value = 2;
            ipObject.focus();
            ShowStatusMsg(msg1206,1);        
        } else {
            ShowStatusMsg(msg1000,1);
        }         

        sum = parseInt(f.NumberOfCpes2.value) + parseInt(ipObject.value);

        if ( (sum-1) > 254) {
            f.NumberOfCpes2.value = 255 - parseInt(ipObject.value);
        }
    }    

    function checkCpeNumber()
    {

        f = window.document.Dhcp;

        if ( f.NumberOfCpes.value < 1 ||  f.NumberOfCpes.value > 253) {
            f.NumberOfCpes.value = 255 - parseInt(f.StartingLocalAddressIP3.value);
            f.NumberOfCpes.focus();
            ShowStatusMsg(msg1207,1);  
        } else {
            sum = parseInt(f.NumberOfCpes.value) + parseInt(f.StartingLocalAddressIP3.value);

            if ((sum-1) > 254) {           // APRTWC10054 .Ip range is 192.168.0.2 to 192.168.0.254
                f.StartingLocalAddressIP3.value = 255 - parseInt(f.NumberOfCpes.value);
                f.NumberOfCpes.focus();
                //ShowStatusMsg(msg1208,1);
            } else {
                ShowStatusMsg(msg1000,1);
            }        
        }
    }  

    function checkCpeNumber2()
    {

        f = window.document.Dhcp;

        if ( f.NumberOfCpes2.value < 1 ||  f.NumberOfCpes2.value > 253) {
            f.NumberOfCpes2.value = 255 - parseInt(f.StartingPublicAddressIP3.value);
            f.NumberOfCpes2.focus();
            ShowStatusMsg(msg1214,1);  
        } else {
            sum = parseInt(f.NumberOfCpes2.value) + parseInt(f.StartingPublicAddressIP3.value);

            if ((sum-1) > 254) {
                //f.NumberOfCpes2.value = 1; //Darren modify, 2011/10/19
                f.StartingPublicAddressIP3.value = 255 - parseInt(f.NumberOfCpes2.value);
                f.NumberOfCpes2.focus();
                //ShowStatusMsg(msg1208,1);
            } else {
                ShowStatusMsg(msg1000,1);
            }        
        }
    }

    // show me -->

    </script>
</head>
<!--Darren add InitPage(), 2011/10/19-->
<body  onload="InitPage();" >
<CENTER>
    <div class="ubeeContainer">
        <div id="ubeeHeader">
            <a href="http://www.ubeeinteractive.com/"><img border="0" src="ubee_header.jpg"></a>
        </div>
        <div id="navigation_header">
            <ul>
    <li><a href="RgSwInfo.asp">Status</a></li><li><a class="current" href="RgSetup.asp">Basic</a></li><li><a href="RgOptions.asp">Advanced</a></li><li><a href="RgContentFilter.asp">Firewall</a></li><li><a href="RgUserSetup.asp">Parental Control</a></li><li><a href="RgVpnBasic.asp">VPN</a></li><li><a href="wlanRadio.asp">Wireless</a></li><li><a href="MoCA.asp">MoCA</a></li><li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="logout.asp">Logout</a></div></div></div></div></li>

            </ul>
        </div>
        <div id="navigationSubHeader">
            <table border="0" width="1024" height="127">
                <tbody>
                <tr>
                    <td width="235"><font face="Arial" color="#ffffff" size="5">
                        <center>
                            Basic
                        </center>
                        </font></td>
                    <td></td>
                </tr>
                </tbody>
            </table>
        </div>
        <div id="navigation_bar">
            <ul>
    <li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="RgSetup.asp">Setup</a></div></div></div></div></li><li><div class="box_current"><div class="box-outer"><div class="box-inner"><div class="box-final"><a class="current" href="RgDhcp.asp">DHCP</a></div></div></div></div></li><li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="RgDhcpV6.asp">DHCPv6</a></div></div></div></div></li><li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="RgIPv6.asp">LAN IPv6</a></div></div></div></div></li><li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="RgDdns.asp">DDNS</a></div></div></div></div></li><li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="RgStaticLease.asp">Static Lease</a></div></div></div></div></li><li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="RgBackup.asp">Backup</a></div></div></div></div></li><li><div class="box"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="RgTime.asp">Time</a></div></div></div></div></li><div id="version" style="visibility:hidden">1.0</div>

            </ul>
        </div>
        <div id="main_page">
            <div class="description">
                <hr size="1" noshade="" width="346" color="#c8c8c8" align="right">
                <table border="0">
                    <tbody>
                    <tr>
                        <td width="10"><img src="ubee_symbols.bmp"></td>
                        <td width="400"><font size="5"><b>DHCP</b></font></td>
                        <td width="32" align="right"><img src="ubee_home.bmp"></td>
                        <td width="250" align="left"><font size="2">> Basic > <b>DHCP </b></font></td>
                    </tr>
                    </tbody>
                </table>
                <hr size="1" noshade width="692" color="#c8c8c8">
            </div>
            <div class="description2">
                <form style="margin-top:25px;" action=/goform/RgDhcp method="POST" name="Dhcp">

                    <table>
                        <tr valign="top">
                            <td>

                                <table>
                                    <tr valign>
                                        <td>DHCP Server</td>
                                        <td>
                                            <input type="radio" name="DhcpServerEnable" value="0x1000" CHECKED ENABLED  onClick="EnableButton();" >
                                            Yes</td>
                                        <td>
                                            <input type="radio" name="DhcpServerDisable" value="0x1000"    ENABLED onClick="DisableButton();" >
                                            No</td>
                                    </tr>
                                </table>
                                <!--Darren add start, 2011/10/19-->
                                <input type="hidden" name="CurOperationMode" value=1>
                                <!--Darren add end, 2011/10/19-->
                                <table>
                                    <tr valign>
                                        <td>Starting  Address Set </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="radio" name="privatePoolEnable" value="1" CHECKED onClick="privatePool();" >
                                            Private Starting  Address </td>
                                        <td><b>
                                            192.168.0.
                                            <input name=StartingLocalAddressIP3 size="3" maxlength="3" value=2  ENABLED "onChange"="checkStartIpRange(this);" >
                                            </b> (2~254)&nbsp;&nbsp;&nbsp;Number of CPEs
                                            <input type="text" name="NumberOfCpes" size="3" maxlength="3" value=253  ENABLED "onChange"="checkCpeNumber();">
                                        </td>
                                    </tr>
                                    <tr valign="bottom">
                                        <td valign="bottom">
                                            <input type="radio" name="publicPoolEnable" value="2"   onClick="publicPool();" >
                                            Public Starting  Address </td>
                                        <td valign="bottom"><b>
                                            0.0.0.
                                            <input name=StartingPublicAddressIP3 size="3" maxlength="3" value=0  ENABLED "onChange"="checkStartIpRange2(this);" >
                                            </b> (2~254)&nbsp;&nbsp;&nbsp;Number of CPEs
                                            <input type="text" name="NumberOfCpes2" size="3" maxlength="3" value=0  ENABLED "onChange"="checkCpeNumber2();">
                                        </td>
                                    </tr>
                                    <tr valign>
                                        <td>Lease Time</td>
                                        <td>
                                            <input type="text" name="LeaseTime" size="10" maxlength="10" value=3600  ENABLED>
                                        </td>
                                    </tr>
                                </table>

                            </td>

                        </tr>
                        <tr>
                            <td colspan="3" align="left">
                                <input type="Submit" value="Apply" align="MIDDLE" onClick="ApplyButton();">
                                <input type="hidden" name="ApplyAction" value=RgFactoryDefault.submit();>
                            </td>
                        </tr>
                        <br>
                        <tr>
                            <td colspan="3">DHCP Clients</td>
                        </tr>
                        <tr>
                            <td>
<table style="font-family: Helvetica;font-size:14"><tr bgcolor=#9900FF><td>MAC Address</td><td>IP Address</td><td>Subnet Mask</td><td>Duration</td><td>Expires</td><td>Select</td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.2</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 11 14:27:59 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(1);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.5</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 11 14:21:48 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(2);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.6</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 11 14:04:15 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(3);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.7</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 11 14:20:08 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(4);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.8</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 11 14:04:34 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(5);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.9</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 11 14:04:51 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(6);"></td></tr>
<tr bgcolor=#99CCFF><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.12</td><td>255.255.255.0</td><td>D:00 H:01 M:00 S:00</td><td>Wed Mar 11 14:28:25 2020
</td><td align=center><input type="radio" name="lease" onClick="selectedLease(7);"></td></tr>
<tr bgcolor=#9999CC><td>XX:XX:XX:XX:XX:XX</td><td>192.168.0.29</td><td>255.255.255.0</td><td>D:-- H:-- M:-- S:--</td><td>*** STATIC IP ADDRESS **</td><td></td></tr>
</table>
<br>
                                <b>Current System Time:</b> Wed Mar 11 13:29:39 2020

                </td>
                        </tr>

                        <tr>
                            <td colspan="3" align="center">
                                <input type="Submit" value="Force Available" align="MIDDLE" onClick="ForceAvailable();">
                                <input type="hidden" name="LeaseToFree"   value=>
                                <input type="hidden" name="LeaseSelected" value=>
                                <input type="hidden" name="ForceAction"   value=>
                            </td>
                        </tr>

                    </table>
                </form>
            </div>
        </div>
        <div id="ubee_tail">
            <ul>
                <a>
                <center>
                    &#x00a9; 2016 Ubee Interactive. All rights reserved.
                </center>
                </a>
            </ul>
        </div>
    </div>
</CENTER>
</body>
</html>
StevenLooman commented 4 years ago

Can you re-install pyubee and run with the added -t flag?

Reinstalling pyubee:

$ pip uninstall pyubee
...
$ pip install pip3 install git+https://github.com/mzdrale/pyubee.git@DDW36C
Hukuma1 commented 4 years ago
DEBUG:pyubee:Using model: DDW36C
DEBUG:pyubee:HTTP GET: http://192.168.0.1/main.asp
DEBUG:pyubee.traffic:Sending request:
DEBUG:pyubee.traffic:  HTTP GET http://192.168.0.1/main.asp
DEBUG:pyubee.traffic:  Header: Host: 192.168.0.1
DEBUG:pyubee.traffic:Received response:
DEBUG:pyubee.traffic:  Status: 200, Reason: OK
DEBUG:pyubee.traffic:  Header: Content-type: text/html
DEBUG:pyubee.traffic:  Header: Expires: Thu, 3 Oct 1968 12:00:00 GMT
DEBUG:pyubee.traffic:  Header: Connection: close
DEBUG:pyubee.traffic:  Header: Pragma: no-cache
DEBUG:pyubee.traffic:  Header: Content-Length: 2525
DEBUG:pyubee.traffic:  Data: '<html>\n<head>\n    <link rel="stylesheet" type="text/css" href="ubee_main.css" />\n    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">\n    <meta name="ProgId" content="FrontPage.Editor.Document">\n    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">\n    <title>Residential Gateway Configuration: Login</title>\n    <script language="JavaScript">\n\tdocument.oncontextmenu = new Function("return false");\n\t</script>\n</head>\n\n<body>\n<CENTER>\n    <div class="ubeeContainer">\n        <div id="ubeeHeader">\n            <a href="http://www.ubeeinteractive.com/"><img border="0" src="ubee_header.jpg"></a>\n        </div>\n        <div id="navigation_header">\n        </div>\n        <div id="navigationSubHeader">\n            <table width="1024" height="127">\n                <tbody>\n                <tr>\n                    <td width="235"><font face="Arial" color="#ffffff" size="5"></font></td>\n                    <td></td>\n                </tr>\n                </tbody>\n            </table>\n        </div>\n            <div id="navigation_bar">\n          <ul>\n            <li><div class="box_current"><div class="box-outer"><div class="box-inner"><div class="box-final"><a href="/RgSwInfo.asp">Login</a></div></div></div></div></li>\n          </ul>\n        </div>\n        <div id="main_page">\n            <div class="table_data">\n            \t  <font size="4"><b>Cable Modem Information</b></font><br>\n                <table>\n                   <tr><td>Cable Modem : DOCSIS 3.0 Compliant</td></tr>\n                   <tr><td>MAC Address : XX:XX:XX:XX:XX:XX</td></tr>\n                   <tr><td>Serial Number : XXXXXXXXXXXXX</td></tr>\n                   <tr><td>Boot Code Version : 15.1.4</td></tr>\n                   <tr><td>Software Version : 8.22.2121</td></tr>\n                   <tr><td>Hardware Version : 3.22.1</td></tr>\n                   <tr><td>CA Key : Installed</td></tr>\n                </table>\n                <!--\n                <br>\n                <font size="4"><b>MTA Information</b></font><br>\n                <table>   \n                   <tr><td>MAC Address : </td></tr>\n                   <tr><td>CA Key : </td></tr>\n                </table>\n                -->\n            </div>\n        </div>\n        <div id="ubee_tail">\n            <ul>\n                <a>\n                <center>\n                    &#x00a9; 2016 Ubee Interactive. All rights reserved.\n                </center>\n                </a>\n            </ul>\n        </div>\n    </div>\n</CENTER>\n</body>\n</html>'
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgDhcp.asp
DEBUG:pyubee.traffic:Sending request:
DEBUG:pyubee.traffic:  HTTP GET http://192.168.0.1/RgDhcp.asp
DEBUG:pyubee.traffic:  Header: Host: 192.168.0.1
DEBUG:pyubee.traffic:Received response:
DEBUG:pyubee.traffic:  Status: 401, Reason: Unauthorized
DEBUG:pyubee.traffic:  Header: Content-type: text/html
DEBUG:pyubee.traffic:  Header: WWW-Authenticate: Basic realm="Ubee"
DEBUG:pyubee.traffic:  Header: Connection: close
DEBUG:pyubee.traffic:  Header: Pragma: no-cache
DEBUG:pyubee.traffic:  Data: '<html><head><title>HTTP 401 - Unauthorized</title></head><body><h4>HTTP 401 - Unauthorized</h4><p>Authorization is required to access the configuration server.<p>You must enter the correct username and/or password.</body></html>\r\n'
DEBUG:pyubee:LAN devices: {}
DEBUG:pyubee:HTTP GET: http://192.168.0.1/wlanAccess.asp
DEBUG:pyubee.traffic:Sending request:
DEBUG:pyubee.traffic:  HTTP GET http://192.168.0.1/wlanAccess.asp
DEBUG:pyubee.traffic:  Header: Host: 192.168.0.1
DEBUG:pyubee.traffic:Received response:
DEBUG:pyubee.traffic:  Status: 401, Reason: Unauthorized
DEBUG:pyubee.traffic:  Header: Content-type: text/html
DEBUG:pyubee.traffic:  Header: WWW-Authenticate: Basic realm="Ubee"
DEBUG:pyubee.traffic:  Header: Connection: close
DEBUG:pyubee.traffic:  Header: Pragma: no-cache
DEBUG:pyubee.traffic:  Data: '<html><head><title>HTTP 401 - Unauthorized</title></head><body><h4>HTTP 401 - Unauthorized</h4><p>Authorization is required to access the configuration server.<p>You must enter the correct username and/or password.</body></html>\r\n'
DEBUG:pyubee:WIFI devices: {}
No connected devices found

Looks like it's not able to login. This is the login screen:

<a href="/RgSwInfo.asp">Login</a>

I double checked the name/password, it's correct. To confirm, the password has to be in quotes, right? admin "MYPASSWORD"

StevenLooman commented 4 years ago

Indeed, the problem is not able to login.

The password does not have to be in quotes if it is a single word with no certain special characters. Putting it in quotes cannot do any harm though. Does your password include a $-sign?

StevenLooman commented 4 years ago

I have added some more debug messages which would have helped us identify not being logged in earlier. Please update your pyubee installation and run again with the -d and -t flags.

What is a valid page which redirects you to a login form when you're not logged in, but keeps you on that page when you are logged in?

Hukuma1 commented 4 years ago
DEBUG:pyubee:Using model: DDW36C
DEBUG:pyubee:Checking if session is active
DEBUG:pyubee:HTTP GET: http://192.168.0.1/main.asp
DEBUG:pyubee:Response status code: 200
DEBUG:pyubee:Did not find login page, session active
DEBUG:pyubee:Getting list of connected lan devices
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgDhcp.asp
DEBUG:pyubee:Response status code: 401
DEBUG:pyubee:LAN devices: {}
DEBUG:pyubee:Getting list of connected wifi devices
DEBUG:pyubee:HTTP GET: http://192.168.0.1/wlanAccess.asp
DEBUG:pyubee:Response status code: 401
DEBUG:pyubee:WIFI devices: {}
No connected devices found

The password has & so maybe that doesn't allow it to pass without the quotes. But the quotes don't bother me.

ubee1 This is the first screen I see when I enter 192.168.0.1 (main.asp)

ubee2 This is the dialog I get when I click login link. (RgSwInfo.asp)

StevenLooman commented 4 years ago

The saga continues, can you update pyubee and try again?

Hukuma1 commented 4 years ago
DEBUG:pyubee:Checking if session is active
DEBUG:pyubee:HTTP GET: http://192.168.0.1/main.asp
Traceback (most recent call last):
  File "/usr/local/bin/pyubee", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__main__.py", line 42, in main
    if not ubee.session_active():
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__init__.py", line 403, in session_active
    response = self._get(url)
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__init__.py", line 323, in _get
    for key, value in self._authenticator_headers:
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__init__.py", line 514, in _authenticator_headers
    return self.authenticator.headers
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__init__.py", line 129, in headers
    user_pass = bytes(self._username + ':' + self._password, "utf-8")
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

I think we're super close? :)

StevenLooman commented 4 years ago

Fixed the error. Please update and try again.

StevenLooman commented 4 years ago

Forgot to commit something. Please update and try again.

Hukuma1 commented 4 years ago
DEBUG:pyubee:Checking if session is active
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgSwInfo.asp
DEBUG:pyubee.traffic:Sending request:
DEBUG:pyubee.traffic:  HTTP GET http://192.168.0.1/RgSwInfo.asp
DEBUG:pyubee.traffic:  Header: Host: 192.168.0.1
DEBUG:pyubee:Response status code: 401
DEBUG:pyubee.traffic:Received response:
DEBUG:pyubee.traffic:  Status: 401, Reason: Unauthorized
DEBUG:pyubee.traffic:  Header: Content-type: text/html
DEBUG:pyubee.traffic:  Header: WWW-Authenticate: Basic realm="Ubee"
DEBUG:pyubee.traffic:  Header: Connection: close
DEBUG:pyubee.traffic:  Header: Pragma: no-cache
DEBUG:pyubee.traffic:  Data: '<html><head><title>HTTP 401 - Unauthorized</title></head><body><h4>HTTP 401 - Unauthorized</h4><p>Authorization is required to access the configuration server.<p>You must enter the correct username and/or password.</body></html>\r\n'
DEBUG:pyubee:Logging in
DEBUG:pyubee:Checking if session is active
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgSwInfo.asp
Traceback (most recent call last):
  File "/usr/local/bin/pyubee", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__main__.py", line 43, in main
    if not ubee.login():
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__init__.py", line 437, in login
    return self.session_active()
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__init__.py", line 408, in session_active
    response = self._get(url)
  File "/usr/local/lib/python3.7/dist-packages/pyubee/__init__.py", line 328, in _get
    for key, value in self._authenticator_headers:
ValueError: too many values to unpack (expected 2)
StevenLooman commented 4 years ago

Again please.

StevenLooman commented 4 years ago

Be sure to redact the line with Header: Authorization: Basic.

StevenLooman commented 4 years ago

One last time, update and try again?

StevenLooman commented 4 years ago

It tries to login multiple times?

How so?

Hukuma1 commented 4 years ago

This is what I get without -t flag. Right before it shows all the devices. But either way, it works!! Thank you very much for adding it! :)

root@DietPi:~# pyubee -m DDW36C -d 192.168.0.1 admin "XXXXXXX"
DEBUG:pyubee:Checking if session is active
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgSwInfo.asp
DEBUG:pyubee:Response status code: 401
DEBUG:pyubee:Logging in
DEBUG:pyubee:Checking if session is active
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgSwInfo.asp
DEBUG:pyubee:Response status code: 200
DEBUG:pyubee:Did not find login page, session active
DEBUG:pyubee:Getting list of connected lan devices
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RgDhcp.asp
DEBUG:pyubee:Response status code: 200

Auto detect works as well in case that was in question too.

root@DietPi:~# pyubee -d 192.168.0.1 admin "XXXXXXXXXX"
DEBUG:pyubee:Detecting model
DEBUG:pyubee:HTTP GET: http://192.168.0.1/RootDevice.xml
DEBUG:pyubee:Response status code: 200
DEBUG:pyubee:Detected model: DDW36C
StevenLooman commented 4 years ago

Can you release 0.10 to PyPI, @mzdrale? Everything should be ready with regard to this repository.

mzdrale commented 4 years ago

I will release new version later tonight or tomorrow during the day. Thanks guys for working on this!

mzdrale commented 4 years ago

Version 0.10 released. @StevenLooman could you create Home Assistant PR or let me know if you want me to do that?

StevenLooman commented 4 years ago

Thank you @mzdrale. If you have the time, please make a Home Assistant PR.

mzdrale commented 4 years ago

Home Assistant PR: #32934