PDA

View Full Version : Kaid Control Pad update?


hgouveia
2006-07-27, 16:29
hello i´ve download the last version of XBMC and the kaid control pad it doesnt running anymore. are there a new version of the script to work with newer xbmc? or how to fix that?
thanks. :)

Joyal.

Nuka1195
2006-07-28, 04:15
It should still work. What's it not doing?

hgouveia
2006-07-28, 05:10
well it said "running" but nothing happens. i looked the file info and appears
some errors..

Pad setting missing or file corrupt..

my display = windowoverlay()
attribute error: 'windowoverlay' object has no attribute

something with python24.zlib

i tried with an older xbmc and works fine. but with the newest XBMC it doesnt works.

HarshReality
2006-07-28, 05:24
Maybe if you typed the errors here......

hgouveia
2006-07-28, 06:07
http://joyal.redfutura.net/Archivos/Kpad/screenshot000.jpg
http://joyal.redfutura.net/Archivos/Kpad/screenshot001.jpg
http://joyal.redfutura.net/Archivos/Kpad/screenshot002.jpg
http://joyal.redfutura.net/Archivos/Kpad/screenshot003.jpg

Nuka1195
2006-07-28, 17:51
did you edit the \extras\PadFile.xml?

load \extras\PadFile.xml in internet explorer and see if it tells you what line is corrupt.

hgouveia
2006-07-29, 03:37
it dosent tell anything.. here its the padfile.xml. i didnt touch any file. i download from xbmcscript, and put it in scripts folder thats all.

<?xml version="1.0" encoding="UTF-8" ?>
- <settings name="Kaid Control Pad">
- <setting type="string" id="ScriptTitle">
<value>Kaid Control Pad</value>
</setting>
- <setting type="string" id="PadImageName">
<value>panel2.png</value>
</setting>
- <setting type="string" id="PadMoveName">
<value>PadPosArrows.png</value>
</setting>
- <setting type="int" id="padSize">
<value>0</value>
</setting>
- <setting type="int" id="imageSizeW">
<value>505</value>
</setting>
- <setting type="int" id="imageSizeH">
<value>450</value>
</setting>
- <setting type="int" id="imageBorderLeftW">
<value>25</value>
</setting>
- <setting type="int" id="imageBorderRightW">
<value>80</value>
</setting>
- <setting type="int" id="imageBorderTopH">
<value>61</value>
</setting>
- <setting type="int" id="imageBorderBottomH">
<value>57</value>
</setting>
- <setting type="int" id="titleH">
<value>25</value>
</setting>
- <setting type="int" id="messageH">
<value>29</value>
</setting>
- <setting type="int" id="animate">
<value>3</value>
</setting>
- <setting type="float" id="slideSpeed">
<value>0.015</value>
</setting>
- <setting type="int" id="padOffsetX">
<value>35</value>
</setting>
- <setting type="int" id="padOffsetY">
<value>15</value>
</setting>
- <setting type="boolean" id="exitToKai">
<value>True</value>
</setting>
- <setting type="list" id="menu_items">
<value>Restart Kai Daemon</value>
<value>Stop Kai Daemon</value>
<value>Upload/Start Kai Daemon</value>
<value>Download Kai Files From Web</value>
<value>Reboot Router</value>
<value>Close Pad</value>
</setting>
- <setting type="list" id="config_items">
<value>Change router IP</value>
<value>Change router password</value>
<value>Change router firmware</value>
<value>Change sniff device</value>
<value>Change upload method</value>
<value>Change http upload path to xbox</value>
<value>Change ftp upload path to xbox</value>
<value>Change xbox username</value>
<value>Change xbox password</value>
<value>Change pad title</value>
<value>Change pad size</value>
<value>Change pad position</value>
<value>Change animation style</value>
</setting>
- <setting type="list" id="error_msg">
<value>ERROR:</value>
<value>Couldn't open kaid.conf file!</value>
<value>Communicating with router!</value>
<value>Kai not installed on router!</value>
<value>Kai daemon not running!</value>
<value>Kai not installed on xbox!</value>
<value>Downloading kai software from web!</value>
<value>Patching kaid.conf file!</value>
<value>Saving config settings!</value>
<value>Saving pad settings!</value>
<value>Saving config and pad settings!</value>
<value>Invalid router firmware entry!</value>
<value>Invalid upload method entry!</value>
<value>Invalid animation style entry!</value>
<value>Invalid http upload path!</value>
<value>Invalid ftp upload path!</value>
</setting>
- <setting type="list" id="info_msg">
<value>Checking if kai is installed on xbox...</value>
<value>Checking if kaid is installed</value>
<value>Checking if kaid.conf is installed</value>
<value>Checking if kai daemon is running</value>
<value>Starting kai daemon</value>
<value>Stopping kai daemon</value>
<value>Uploading kai software to router</value>
<value>Executing gunzip / chmod</value>
<value>Downloading kai software from web...</value>
<value>Rebooting router</value>
<value>Patching kaid.conf file...</value>
<value>Saving configuration settings...</value>
<value>Saving pad configuration settings...</value>
</setting>
- <setting type="list" id="user_msg">
<value>Press title/white to change settings.</value>
<value>Press title/white to save settings.</value>
<value>Press select to keep position.</value>
</setting>
- <setting type="list" id="keyboard_msg">
<value>Your routers IP address.</value>
<value>Your routers password.</value>
<value>(Firmware message here)</value>
<value>Your xbox ftp username</value>
<value>Your xbox ftp password</value>
<value>Upload kai method: 0 = http, 1 = ftp</value>
<value>http path to kai on the xbox. (i.e. /kaid/)</value>
<value>ftp path to kai on the xbox. (i.e. /e/xbmc/web/kaid/)</value>
<value>Sniff device: eth0, en0, br0, vlan0...</value>
<value>Script Title</value>
<value>0=None, 1=R, 2=L, 3=B, 4=T, 5=BR, 6=TL, 7=BL, 8=TR</value>
</setting>
- <setting type="list" id="status_msg1">
<value>Status Kaid:</value>
<value>Running</value>
<value>NOT Running</value>
<value>Check Config File</value>
</setting>
- <setting type="list" id="status_msg2">
<value>Status Router:</value>
<value>Unknown</value>
<value>Kai NOT Installed</value>
<value>Check Config File</value>
</setting>
- <setting type="list" id="status_msg3">
<value>Status Xbox:</value>
<value>Kai Installed</value>
<value>Kai NOT Installed</value>
<value>Check Config File</value>
</setting>
</settings>

hgouveia
2006-08-03, 05:37
any help here? :confused2:

Nuka1195
2006-08-03, 16:36
There's really no reason for it not to work. Download it from xbmcscripts.com again and see if that works. If it doesn't I can send you what I'm using. I made a couple fixes, but nothing that prevented it from running.

hgouveia
2006-08-04, 06:19
:( i have Download it from xbmcscripts.com again and it doesn't works. :(

:D could you please send me to my email. or a link where to download the working version. thz. :)

dhgouveiahotmail.com
joyal182@yahoo.com

aHorseofCourse
2006-08-04, 07:34
Thought I should chime in and say the script no longer works for me either. I haven't had time to try to debug it. All I can tell you is it won't launch at all.

Nuka1195
2006-08-04, 15:00
You probably don't have _xmlplus installed. Either find that and install it in system/python/lib or the extras folder. I'll upload the newest version to xbmcscripts.com, it'll probably take a few days though. I'll include _xmlplus with it.

aHorseofCourse
2006-08-05, 01:04
Yep, that did it:-) Placed the unzipped _xmlplus folder into the script's Extras folder and everything is working again.
Thanks, Nuka.

hgouveia
2006-08-05, 05:36
I did it Placed the unzipped _xmlplus folder too into the script's Extras folder and still not working for me. i've XBMC-CVS_2006-07-25-T3CH

Nuka1195
2006-08-05, 05:46
check xbmcscripts.com, the new version is up now.

SleepyP
2006-08-05, 06:00
how does this script compare with the KAI gui built into XBMC? i'm not happy with the built in GUI in its current state.

Nuka1195
2006-08-05, 06:24
The script isn't the same thing.

It just starts and stops the kai daemon on your router.

hgouveia
2006-08-05, 06:42
well. i downloaded the script. and finally works. but. other error comes. it said CfgFile.xml invalid or missing . i put my router ip. and the firmware version too..

http://joyal.redfutura.net/Archivos/Kpad/screenshot004.jpg

Nuka1195
2006-08-05, 06:49
did you change your password?

hgouveia
2006-08-05, 06:51
yes.. i put the password that i used for the router ..

hgouveia
2006-08-05, 06:57
i see. that you are online now.. do you have Msn Messenger for talk about this. and resolve this problem :), here is my msn. dhgouveia@hotmail.com

Nuka1195
2006-08-05, 07:26
did you edit it manually or by pressing the white button and did you save it by pressing the white button.

It sounds like the changes are not saving.

hgouveia
2006-08-05, 14:19
i did press the white button and when i finish to configure all. i press the white button again to saves changes

Nuka1195
2006-08-05, 17:21
The only time you should get that message is if the IP or password is wrong.

Edit CfgFile.xml manually and see if that works.

hgouveia
2006-08-06, 00:11
the same... i have a Linksys WRT54GL with Firmware: DD-WRT v23 SP1 Final (05/16/06) std. and the router ip its 192.168.0.1 i put all in the CfgFile.xml and the same thing..

Nuka1195
2006-08-06, 00:18
self.COMMAND_RETURN = (self.open("http://" + router_ip + "/apply.cgi", parameter))

Look down about line 298 and change that line with the above. Make sure the indentation stays the same.

hgouveia
2006-08-06, 00:43
the same... :(

Nuka1195
2006-08-06, 00:56
what firmware selection do you have set?

hgouveia
2006-08-06, 01:02
3 DD-wrt.

Nuka1195
2006-08-06, 01:06
http://192.168.0.1/Command.asp

type that in your browsers address bar and enter your password. Then view source and paste that text at pastebin and post the link.

hgouveia
2006-08-06, 01:18
it opens the page. but it does not show anything.

Nuka1195
2006-08-06, 01:19
view/source in internet explorer

hgouveia
2006-08-06, 01:23
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

Nuka1195
2006-08-06, 01:25
do you have a run command somewhere in administration?

if you do run a command then view that source.

Maybe try 0-sveasoft for firmware.

hgouveia
2006-08-06, 01:47
i try with 0 sveasoft and nothing. and about the command. i havent run commands, i have the router with the default setting. the only change is it a static dchp for the xbox and the kaid enable.

Nuka1195
2006-08-06, 02:11
I don't know then, you say it use to work? Did you change firmware?

Have you changed your password. The get method, which is what the script uses only allows for ascii characters.

I can't tell without the source from Command.asp. It's case sensitive maybe command.asp.

There really is no reason for it not to work now. You could try the other firmware options. I though DD-wrt moved to an open-wrt variant, but I'm not sure.

Edit: by the way if your using the built-in kai, this script probably won't work for you since the location is different.

hgouveia
2006-08-06, 02:22
yes i change the password. for joyal. and a put the command.asp and the source is the same with Command.asp when i said it works. a refer that the program runs before and with the last xbmc it didnt, with you fixed to the kaid control pad its runs now. but i havent configure before becacuse i had the original firmware, when a update everthing. its when i tried to use the control pad. because i have to reset the kaid engine in the router every time that a want to use it.

Nuka1195
2006-08-06, 02:43
I've never used that firmware and only put th DD-wrt settings in for someone else who was trying to get it to work. I don't remember if he ever got it to work.

Sorry I don't know why it doesn't work.

All I can tell you is to try the other firmware choices 1 and 2 and see if you at least get a connection.

hgouveia
2006-08-06, 06:33
i tried with all firmware setting and the same. dont worry. thank for everything. i hope in the new version of the dd-wrt fix the kaid engine and i hasnt to reset everytime that i want to used. thank again.

Big_Whoopin
2006-11-29, 05:29
I may have found something. Between DD-WRT v23 and DD-WRT v23 SP1 there was a change in the way the command shell web page works. It appears that you can no longer just pass parms to the apply.cgi page, but now need to pass them to Diagnostics.asp. Unfortunately updating apply.cgi to Diagnostics.asp in default.py does not seem to be the only step. It appears some new parsing routines need to be worked out to extract the data that is the feedback Kaid Control Pad requires.

I've passed the string "ping_ip=%2Ftmp%2Fkaid+-V&ping_times=1&change_action=gozila_cgi&submit_type=start&submit_button=Ping&action=Apply" (what appears to be the initial "does anything answer" test of the script) to apply.cgi in v23 and Diagnostics.asp in v23 SP1, v23 SP2 and the 09/11/06 v24 beta. The output is linked here (http://www.powco.net/files/DD-WRT%20command%20output.zip). Hopefully this will help to make some headway on this problem.

I've also come up with a workaround for the "web fetch" problem, I'll be posting a new thread for that momentarily.

-Whoopin'

Big_Whoopin
2006-12-01, 05:13
Ok, I was off in my assumptions (although additional parsing logic may be needed) but I'm learning along the way. I opened up a trace from my computer to the router, sniffing the packets sent as I manually went to the diagnostics page and ran the /tmp/kaid command. I found that the reason the apply.cgi is failing is because with DD-WRT v23 SP1 and above the form no longer uses the GET method, it now uses POST. So KCP needs to be updated to allow for this. Anyone know if the code already included supports this, and what needs to be changed to handle it? Then we should get back the info we need and can move on to parsing mods if required. Here's the data captured by Ethereal when I ran the command.
Frame 4 (710 bytes on wire, 710 bytes captured)
Arrival Time: Nov 30, 2006 19:04:34.385051000
Time delta from previous packet: 0.000686000 seconds
Time since reference or first frame: 0.000686000 seconds
Frame Number: 4
Packet Length: 710 bytes
Capture Length: 710 bytes
Protocols in frame: eth:ip:tcp:http:data-text-lines
Coloring Rule Name: Checksum Errors
Coloring Rule String: edp.checksum_bad==1 || ip.checksum_bad==1 || tcp.checksum_bad || udp.checksum_bad
Ethernet II, Src: AbitComp_5b:e4:ed (00:50:8d:5b:e4:ed), Dst: 00:18:f8:41:d9:4e (00:18:f8:41:d9:4e)
Destination: 00:18:f8:41:d9:4e (00:18:f8:41:d9:4e)
Address: 00:18:f8:41:d9:4e (00:18:f8:41:d9:4e)
.... ...0 .... .... .... .... = Multicast: This is a UNICAST frame
.... ..0. .... .... .... .... = Locally Administrated Address: This is a FACTORY DEFAULT address
Source: AbitComp_5b:e4:ed (00:50:8d:5b:e4:ed)
Address: AbitComp_5b:e4:ed (00:50:8d:5b:e4:ed)
.... ...0 .... .... .... .... = Multicast: This is a UNICAST frame
.... ..0. .... .... .... .... = Locally Administrated Address: This is a FACTORY DEFAULT address
Type: IP (0x0800)
Internet Protocol, Src: 192.168.1.100 (192.168.1.100), Dst: 192.168.1.1 (192.168.1.1)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 696
Identification: 0x4591 (17809)
Flags: 0x04 (Don't Fragment)
0... = Reserved bit: Not set
.1.. = Don't fragment: Set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 128
Protocol: TCP (0x06)
Header checksum: 0x2ef9 [correct]
Good: True
Bad : False
Source: 192.168.1.100 (192.168.1.100)
Destination: 192.168.1.1 (192.168.1.1)
Transmission Control Protocol, Src Port: 2788 (2788), Dst Port: http (80), Seq: 1, Ack: 1, Len: 656
Source port: 2788 (2788)
Destination port: http (80)
Sequence number: 1 (relative sequence number)
Next sequence number: 657 (relative sequence number)
Acknowledgement number: 1 (relative ack number)
Header length: 20 bytes
Flags: 0x0018 (PSH, ACK)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...1 .... = Acknowledgment: Set
.... 1... = Push: Set
.... .0.. = Reset: Not set
.... ..0. = Syn: Not set
.... ...0 = Fin: Not set
Window size: 65535
Checksum: 0x8660 [incorrect, should be 0x5d76]
Hypertext Transfer Protocol
POST /apply.cgi HTTP/1.1\r\n
Request Method: POST
Request URI: /apply.cgi
Request Version: HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\r\n
Referer: http://192.168.1.1/Diagnostics.asp\r\n
Accept-Language: en-us\r\n
Content-Type: application/x-www-form-urlencoded\r\n
UA-CPU: x86\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)\r\n
Host: 192.168.1.1\r\n
Content-Length: 135\r\n
Connection: Keep-Alive\r\n
Cache-Control: no-cache\r\n
Authorization: Basic cm9vdDphZG1pbg==\r\n
Credentials: root:xxxxxxxxxxxxxxx
\r\n
Line-based text data: application/x-www-form-urlencoded
action=Apply&submit_button=Ping&submit_type=start&change_action=gozila_cgi&ping_times=1&next_page=Diagnostics.asp&ping_ip=%2Ftmp%2Fkaid
Hypertext Transfer Protocol
\r\n
Nuka, hoping you can jump in and make something of this. I'm able to run testing with XBMC and DD-WRT v24, capture packets and do minor tweaking (like changing strings) in the python script but I've got no idea how to change this over to POST, much less how to do it properly by referencing the defined firmware variables. If I could get pointed in the direction of where the parsing is handled (which I think I've found, the findx settings and where they're used in the .py) I should be able to help troubleshoot that.

Let's get this working on DD-WRT again!

-Whoopin'

Nuka1195
2006-12-01, 06:30
the code for post and get are in the script.

What i would need is an output from manually running a command in diagnostics. so run an 'ls', then view the source and post the result.

The routine for parsing the result is a simple crude open, read and find, not proper html parsing, but it works so I never changed it. If you want to play around that's where you should start.

Big_Whoopin
2006-12-01, 15:27
Since in my traces from KCP to the router I saw two GET attempts (one without authorization and after failure one with) before reporting failure to XBMC but no POST attempt I assumed KCP wasn't prepared to try it. The output in response to an authorized GET attempt is the empty page which hgouveia had posted the source for earlier. Below is the output from going to the diagnostics page and running the command /tmp/kaid, the first command that KCP attempts and the same POST request I listed above.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="lang_pack/english.js"></script>
<script type="text/javascript" src="lang_pack/language.js"></script>

<link type="text/css" rel="stylesheet" href="style/elegant/style.css" />
<!--[if IE]><link type="text/css" rel="stylesheet" href="style/elegant/style_ie.css" /><![endif]-->
<title>WRT54G - Diagnostics</title>
<script type="text/javascript">
document.title = "WRT54G" + diag.titl;
function to_submit(F, I) {
if(!valid(F, I)) return;
F.submit_type.value = I;
F.submit_button.value = "Ping";
F.change_action.value = "gozila_cgi";

if (I == "start")
F.ping.value = sbutton.cmd;
else if (I == "startup")
F.startup.value = sbutton.saving;
else if (I == "firewall")
F.startup.value = sbutton.saving;

apply(F);
}
function valid(F,I) {
if(I == "start" && F.ping_ip.value == ""){
alert(errmsg.err12);
F.ping_ip.focus();
return false;
}
return true;
}
</script>
</head>
<body class="gui">

<div id="wrapper">
<div id="content">
<div id="header">
<div id="logo"><h1>DD-WRT Control Panel</h1></div>
<div id="menu">

<div id="menuMain">
<ul id="menuMainList">
<li><a href="index.asp"><script type="text/javascript">Capture(bmenu.setup)</script></a></li>
<li><a href="Wireless_Basic.asp"><script type="text/javascript">Capture(bmenu.wireless)</script></a></li>
<li><a href="Firewall.asp"><script type="text/javascript">Capture(bmenu.security)</script></a></li>
<li><a href="Filters.asp"><script type="text/javascript">Capture(bmenu.accrestriction)</script></a></li>
<li><a href="Forward.asp"><script type="text/javascript">Capture(bmenu.applications)</script></a></li>

<li class="current"><span><script type="text/javascript">Capture(bmenu.admin)</script></span>
<div id="menuSub">
<ul id="menuSubList">
<li><a href="Management.asp"><script type="text/javascript">Capture(bmenu.adminManagement)</script></a></li>
<li><a href="Hotspot.asp"><script type="text/javascript">Capture(bmenu.adminHotspot)</script></a></li>
<li><a href="Services.asp"><script type="text/javascript">Capture(bmenu.adminServices)</script></a></li>
<li><a href="Alive.asp"><script type="text/javascript">Capture(bmenu.adminAlive)</script></a></li>

<li><a href="Log.asp"><script type="text/javascript">Capture(bmenu.adminLog)</script></a></li>
<li><span><script type="text/javascript">Capture(bmenu.adminDiag)</script></span></li>
<li><a href="Wol.asp"><script type="text/javascript">Capture(bmenu.adminWol)</script></a></li>
<li><a href="Factory_Defaults.asp"><script type="text/javascript">Capture(bmenu.adminFactory)</script></a></li>
<li><a href="Upgrade.asp"><script type="text/javascript">Capture(bmenu.adminUpgrade)</script></a></li>
<li><a href="config.asp"><script type="text/javascript">Capture(bmenu.adminBackup)</script></a></li>

</ul>
</div>
</li>
<li><a href="Status_Router.asp"><script type="text/javascript">Capture(bmenu.statu)</script></a></li>
</ul>
</div>
</div>

</div>
<div id="main">

<div id="contents">
<form name="ping" action="apply.cgi" method="post" >
<input type="hidden" name="action" value="Apply" />
<input type="hidden" name="submit_button" value="Ping" />
<input type="hidden" name="submit_type" value="start" />
<input type="hidden" name="change_action" value="gozila_cgi" />
<input type="hidden" name="ping_times" value="1" />
<input type="hidden" name="next_page" value="Diagnostics.asp" />
<h2><script type="text/javascript">Capture(diag.h2)</script></h2>

<fieldset>
<legend><script type="text/javascript">Capture(diag.legend)</script></legend>
<div class="setting">
<div class="label"><script type="text/javascript">Capture(diag.cmd)</script></div>

<textarea id="ping_ip" name="ping_ip" rows="6" cols="40" style="font-family:Courier, Courier New">/tmp/kaid</textarea>
</div>
<script type="text/javascript">
var table = new Array( "sh: eval: 1: /tmp/kaid: not found"
);
if(table.length > 0 && location.href.indexOf("Diagnostics.asp") == -1) {
document.write("<br /><pre style=\"margin:0\">" + table.join("\n") + "</pre>");
}
</script>
</fieldset><br />

<!--
<fieldset>
<legend><script type="text/javascript">Capture(diag.startup)</script></legend>
<pre id="startup" style="margin:0"></pre><br />
<div class="center">
<script type="text/javascript">document.write("<input type=\"button\" name=\"button_start\" value=\"" + sbutton.cptotext + "\" onclick=\"this.form.ping_ip.value = document.getElementById('startup').firstChild.data \" />")</script>
</div>
</fieldset><br />
-->

<!--
<fieldset>
<legend><script type="text/javascript">Capture(diag.firewall)</script></legend>
<pre id="firewall" style="margin:0"></pre><br />
<div class="center">
<script type="text/javascript">document.write("<input type=\"button\" name=\"button_firewall\" value=\"" + sbutton.cptotext + "\" onclick=\"this.form.ping_ip.value = document.getElementById('firewall').firstChild.dat a\" />")</script>
</div>
</fieldset><br />
-->

<div class="submitFooter">
<script type="text/javascript">document.write("<input type=\"button\" name=\"ping\" value=\"" + sbutton.runcmd + "\" onclick=\"to_submit(this.form, 'start')\" />")</script>
<script type="text/javascript">document.write("<input type=\"button\" name=\"startup\" value=\"" + sbutton.startup + "\" onclick=\"to_submit(this.form, 'startup')\" />")</script>
<script type="text/javascript">document.write("<input type=\"button\" name=\"firewall\" value=\"" + sbutton.firewall + "\" onclick=\"to_submit(this.form, 'firewall')\" />")</script>

</div>
</form>
</div>
</div>
<div id="helpContainer">
<div id="help">
<div><h2><script type="text/javascript">Capture(share.help)</script></h2></div>
<dl>
<dt class="term"><script type="text/javascript">Capture(diag.cmd)</script>:</dt>
<dd class="definition"><script type="text/javascript">Capture(hdiag.right2)</script></dd>
</dl><br />
<a href="javascript:openHelpWindow('HDiagnostics.asp');"><script type="text/javascript">Capture(share.more)</script></a>

</div>
</div>
<div id="floatKiller"></div>
<div id="statusInfo">
<div class="info"><script type="text/javascript">Capture(share.firmware)</script>: <script type="text/javascript">document.write("<a title=\"" + share.about + "\" href=\"javascript:openAboutWindow()\">DD-WRT v24 Beta (09/10/06) std</a>");</script></div>
<div class="info"><script type="text/javascript">Capture(share.time)</script>: 08:10:50 up 9 min, load average: 0.22, 0.13, 0.08</div>
<div class="info">WAN IP: 192.168.99.169</div>
</div>

</div>
</div>

</body>
</html>-Whoopin'

Big_Whoopin
2006-12-01, 15:28
And here is the output from an ls command<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="lang_pack/english.js"></script>
<script type="text/javascript" src="lang_pack/language.js"></script>

<link type="text/css" rel="stylesheet" href="style/elegant/style.css" />
<!--[if IE]><link type="text/css" rel="stylesheet" href="style/elegant/style_ie.css" /><![endif]-->
<title>WRT54G - Diagnostics</title>
<script type="text/javascript">
document.title = "WRT54G" + diag.titl;
function to_submit(F, I) {
if(!valid(F, I)) return;
F.submit_type.value = I;
F.submit_button.value = "Ping";
F.change_action.value = "gozila_cgi";

if (I == "start")
F.ping.value = sbutton.cmd;
else if (I == "startup")
F.startup.value = sbutton.saving;
else if (I == "firewall")
F.startup.value = sbutton.saving;

apply(F);
}
function valid(F,I) {
if(I == "start" && F.ping_ip.value == ""){
alert(errmsg.err12);
F.ping_ip.focus();
return false;
}
return true;
}
</script>
</head>
<body class="gui">

<div id="wrapper">
<div id="content">
<div id="header">
<div id="logo"><h1>DD-WRT Control Panel</h1></div>
<div id="menu">

<div id="menuMain">
<ul id="menuMainList">
<li><a href="index.asp"><script type="text/javascript">Capture(bmenu.setup)</script></a></li>
<li><a href="Wireless_Basic.asp"><script type="text/javascript">Capture(bmenu.wireless)</script></a></li>
<li><a href="Firewall.asp"><script type="text/javascript">Capture(bmenu.security)</script></a></li>
<li><a href="Filters.asp"><script type="text/javascript">Capture(bmenu.accrestriction)</script></a></li>
<li><a href="Forward.asp"><script type="text/javascript">Capture(bmenu.applications)</script></a></li>

<li class="current"><span><script type="text/javascript">Capture(bmenu.admin)</script></span>
<div id="menuSub">
<ul id="menuSubList">
<li><a href="Management.asp"><script type="text/javascript">Capture(bmenu.adminManagement)</script></a></li>
<li><a href="Hotspot.asp"><script type="text/javascript">Capture(bmenu.adminHotspot)</script></a></li>
<li><a href="Services.asp"><script type="text/javascript">Capture(bmenu.adminServices)</script></a></li>
<li><a href="Alive.asp"><script type="text/javascript">Capture(bmenu.adminAlive)</script></a></li>

<li><a href="Log.asp"><script type="text/javascript">Capture(bmenu.adminLog)</script></a></li>
<li><span><script type="text/javascript">Capture(bmenu.adminDiag)</script></span></li>
<li><a href="Wol.asp"><script type="text/javascript">Capture(bmenu.adminWol)</script></a></li>
<li><a href="Factory_Defaults.asp"><script type="text/javascript">Capture(bmenu.adminFactory)</script></a></li>
<li><a href="Upgrade.asp"><script type="text/javascript">Capture(bmenu.adminUpgrade)</script></a></li>
<li><a href="config.asp"><script type="text/javascript">Capture(bmenu.adminBackup)</script></a></li>

</ul>
</div>
</li>
<li><a href="Status_Router.asp"><script type="text/javascript">Capture(bmenu.statu)</script></a></li>
</ul>
</div>
</div>

</div>
<div id="main">

<div id="contents">
<form name="ping" action="apply.cgi" method="post" >
<input type="hidden" name="action" value="Apply" />
<input type="hidden" name="submit_button" value="Ping" />
<input type="hidden" name="submit_type" value="start" />
<input type="hidden" name="change_action" value="gozila_cgi" />
<input type="hidden" name="ping_times" value="1" />
<input type="hidden" name="next_page" value="Diagnostics.asp" />
<h2><script type="text/javascript">Capture(diag.h2)</script></h2>

<fieldset>
<legend><script type="text/javascript">Capture(diag.legend)</script></legend>
<div class="setting">
<div class="label"><script type="text/javascript">Capture(diag.cmd)</script></div>

<textarea id="ping_ip" name="ping_ip" rows="6" cols="40" style="font-family:Courier, Courier New">ls</textarea>
</div>
<script type="text/javascript">
var table = new Array( "bin"
,"dev"
,"etc"
,"jffs"
,"lib"
,"mmc"
,"mnt"
,"opt"
,"proc"
,"sbin"
,"tmp"
,"usr"
,"var"
,"www"
);
if(table.length > 0 && location.href.indexOf("Diagnostics.asp") == -1) {
document.write("<br /><pre style=\"margin:0\">" + table.join("\n") + "</pre>");
}
</script>
</fieldset><br />

<!--
<fieldset>
<legend><script type="text/javascript">Capture(diag.startup)</script></legend>
<pre id="startup" style="margin:0"></pre><br />
<div class="center">
<script type="text/javascript">document.write("<input type=\"button\" name=\"button_start\" value=\"" + sbutton.cptotext + "\" onclick=\"this.form.ping_ip.value = document.getElementById('startup').firstChild.data \" />")</script>
</div>
</fieldset><br />
-->

<!--
<fieldset>
<legend><script type="text/javascript">Capture(diag.firewall)</script></legend>
<pre id="firewall" style="margin:0"></pre><br />
<div class="center">
<script type="text/javascript">document.write("<input type=\"button\" name=\"button_firewall\" value=\"" + sbutton.cptotext + "\" onclick=\"this.form.ping_ip.value = document.getElementById('firewall').firstChild.dat a\" />")</script>
</div>
</fieldset><br />
-->

<div class="submitFooter">
<script type="text/javascript">document.write("<input type=\"button\" name=\"ping\" value=\"" + sbutton.runcmd + "\" onclick=\"to_submit(this.form, 'start')\" />")</script>
<script type="text/javascript">document.write("<input type=\"button\" name=\"startup\" value=\"" + sbutton.startup + "\" onclick=\"to_submit(this.form, 'startup')\" />")</script>
<script type="text/javascript">document.write("<input type=\"button\" name=\"firewall\" value=\"" + sbutton.firewall + "\" onclick=\"to_submit(this.form, 'firewall')\" />")</script>

</div>
</form>
</div>
</div>
<div id="helpContainer">
<div id="help">
<div><h2><script type="text/javascript">Capture(share.help)</script></h2></div>
<dl>
<dt class="term"><script type="text/javascript">Capture(diag.cmd)</script>:</dt>
<dd class="definition"><script type="text/javascript">Capture(hdiag.right2)</script></dd>
</dl><br />
<a href="javascript:openHelpWindow('HDiagnostics.asp');"><script type="text/javascript">Capture(share.more)</script></a>

</div>
</div>
<div id="floatKiller"></div>
<div id="statusInfo">
<div class="info"><script type="text/javascript">Capture(share.firmware)</script>: <script type="text/javascript">document.write("<a title=\"" + share.about + "\" href=\"javascript:openAboutWindow()\">DD-WRT v24 Beta (09/10/06) std</a>");</script></div>
<div class="info"><script type="text/javascript">Capture(share.time)</script>: 08:16:43 up 15 min, load average: 0.00, 0.02, 0.04</div>
<div class="info">WAN IP: 192.168.99.169</div>
</div>

</div>
</div>

</body>
</html>Daignosis?

-Whoopin'

Big_Whoopin
2006-12-02, 01:40
the code for post and get are in the script.Ok, I'm not saying you're wrong here... with my knowledge of Python I'm in no position to make such challenges. (and I definately don't want to piss you off because I need help here!) But in the packet captures I'm running between my Xbox and the WRT I'm not seeing any POST requests. Two GETs (entries 4 and 13) then from the info received the script says invalid config file. (same config that works on DD-WRT v23, so it's good.) Maybe there is something I'm missing, but this is the package as downloaded from xbmcscripts. Here are the caps from Ethereal, 192.168.1.101 is the Xbox and 192.168.1.1 is the router.
No. Time Source Destination Protocol Info
1 0.000000 192.168.1.101 192.168.1.1 TCP 1034 > http [SYN] Seq=0 Len=0 MSS=1304
2 0.001027 192.168.1.1 192.168.1.101 TCP http > 1034 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
3 0.001029 192.168.1.101 192.168.1.1 TCP 1034 > http [ACK] Seq=1 Ack=1 Win=64512 Len=0
4 0.001152 192.168.1.101 192.168.1.1 HTTP GET /apply.cgi?ping_ip=%2Ftmp%2Fkaid+-V&ping_times=1&change_action=gozila_cgi&submit_type=start&submit_button=Ping&action=Apply HTTP/1.0
5 0.001786 192.168.1.1 192.168.1.101 TCP http > 1034 [ACK] Seq=1 Ack=192 Win=6432 Len=0
6 0.005626 192.168.1.1 192.168.1.101 HTTP HTTP/1.0 401 Unauthorized (text/html)
7 0.005679 192.168.1.101 192.168.1.1 TCP 1034 > http [ACK] Seq=192 Ack=376 Win=64137 Len=0
8 0.007033 192.168.1.1 192.168.1.101 TCP http > 1034 [FIN, ACK] Seq=376 Ack=192 Win=6432 Len=0
9 0.007075 192.168.1.101 192.168.1.1 TCP 1034 > http [ACK] Seq=192 Ack=377 Win=64137 Len=0
10 0.036573 192.168.1.101 192.168.1.1 TCP 1035 > http [SYN] Seq=0 Len=0 MSS=1304
11 0.037180 192.168.1.1 192.168.1.101 TCP http > 1035 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460
12 0.037237 192.168.1.101 192.168.1.1 TCP 1035 > http [ACK] Seq=1 Ack=1 Win=64512 Len=0
13 0.038228 192.168.1.101 192.168.1.1 HTTP GET /apply.cgi?ping_ip=%2Ftmp%2Fkaid+-V&ping_times=1&change_action=gozila_cgi&submit_type=start&submit_button=Ping&action=Apply HTTP/1.0
14 0.038861 192.168.1.1 192.168.1.101 TCP http > 1035 [ACK] Seq=1 Ack=231 Win=5840 Len=0
15 0.043801 192.168.1.1 192.168.1.101 HTTP HTTP/1.0 200 Ok
16 0.043838 192.168.1.101 192.168.1.1 TCP 1035 > http [ACK] Seq=231 Ack=171 Win=64342 Len=0
17 0.044419 192.168.1.1 192.168.1.101 TCP http > 1035 [FIN, ACK] Seq=171 Ack=231 Win=5840 Len=0
18 0.044455 192.168.1.101 192.168.1.1 TCP 1035 > http [ACK] Seq=231 Ack=172 Win=64342 Len=0
19 0.046758 192.168.1.101 192.168.1.1 TCP 1034 > http [RST, ACK] Seq=192 Ack=377 Win=0 Len=0These same capture settings pick up the POST request from my PC if I change the listen IP address to the comp's IP, so if XBMC was sending it then it should have been captured. The WRT is now running the DD-WRT v23 SP3 beta that hit this morning. I've also tried telling KCP to use the different firmware settings (all 0-3) and haven't seen anything different, at least on screen. I haven't packed sniffed with the alternate firmware settings.

-Whoopin'

Big_Whoopin
2006-12-02, 21:20
Figured out the post part. Compared KCP to the original WRTKaidCommander and found differences on the HTTP string.KCP:
self.open("http://" + router_ip + "/apply.cgi?"+ parameter)

WKC:
self.open("http://"+router_ip+"/apply.cgi", parameter)
If I remove the question mark after apply.cgi and also change the plus symbol before "parameter" to a comma the script now performs a POST operation. Progress!

Unfortunately, still not working.

It seems that when the script runs a GET process it first receives back a 401 unauthorized message. It then GETs again but passing login credentials and receives back a 200 Ok packet. Once I've made the updates to trigger a POST operation I don't get either of these. I can see in the packet that credentials are not being passed, I'm wondering if maybe on a POST operation there is no 401 response? I can't think of a way to recreate this non-logged in POST from my browser, so I can't confirm if the response would be the same. Is there a way to trigger the urllib to pass the credentials on first request?

I also noticed that the newer versions of DD-WRT send a next_page=Diagnostics.asp string in the POST. I've added that to the version of the script I am working with but it hasn't changed anything.

-Whoopin'

Nuka1195
2006-12-02, 22:55
you are ambitious :)

Are you saying the new DD-wrt is using a redirect, if so here is some code from the accuweather script. I don't have time to play with it now, but I'm sure you can edit as needed.


request = urllib2.Request(self.codeURL + location)
opener = urllib2.build_opener()
usock = opener.open(request)
htmlSource = usock.read()
usock.close()

Big_Whoopin
2006-12-03, 01:07
I sometimes think of it as "stupidly determined." :D

Not sure what to make of the code you posted, as I'm still at the point where I'm just having a hard time following the logic of python scripts let alone understand what each line is *doing*. Interesting to see that the Accuweather script uses urllib2 tho. From the packet monitoring I've done I think the wall I'm currently up against is that DD-WRT isn't kicking back a 401 error to trigger urllib to try again with credentials. Based on what I've read of urllib on the python.org website this is the logic the lib uses. If I capture all http packets between XBMC and the WRT I'll only see the one POST from XBMC and no reply from the WRT. This isn't working the same as when it does a GET, which is the one GET followed by a 401 reply, then the second authorized GET followed by a 200 reply, then the HTML output. I've posed the question on the DD-WRT forums (http://www.dd-wrt.com/phpBB2/viewtopic.php?t=7996) looking to find out if anyone knows if the 401 error is missing from the POST method of using apply.cgi or if it is normal in form submission that an unauthorized POST just gets no response at all. If it is the former hopefully it is something that Brainslayer can correct in the next beta release of v23 SP3 or v24, but if it is the latter then there is work to be done in the KCP script.

While I am learning bit by bit it is frustrating being in so far over my head. Sure, every now and then I'll hit the needle in the haystack (like figuring out why the script wasn't using POST) but it just leads to another, bigger haystack. Bleh.

-Whoopin'

Big_Whoopin
2006-12-03, 01:11
Does the accuweather script (or any other script that you are aware of) use POST to a site that requires authorization? If you could point me to one that does I could run it on my Xbox, capture the packets and see if it has a POST/401/POST/200 pattern. If so that nails DD-WRT as the culprit, lacking a 401 response.

-Whoopin'

Big_Whoopin
2006-12-04, 04:56
I think at this point that unless I find some basic python training I'm stuck. I'm sure it doesn't help that the code I'm looking at probably beyond entry-level. I've found an example that shows how to do automatic authentication with the urllib module but it isn't clear if this is the same "automatic" authentication that is already happening, automatic being that a 401 error comes through. And even if the code would do the test I would like to see, passing authentication on first POST/GET without waiting for the 401, I've got no idea how to put it in place. Does this code work any differently than the code in KCP? Copied from http://www.effbot.org/librarybook/urllib.htm
import urllib

class myURLOpener(urllib.FancyURLopener):
# read an URL, with automatic HTTP authentication

def setpasswd(self, user, passwd):
self.__user = user
self.__passwd = passwd

def prompt_user_passwd(self, host, realm):
return self.__user, self.__passwd

urlopener = myURLOpener()
urlopener.setpasswd("mulder", "trustno1")

fp = urlopener.open("http://www.secretlabs.com")
print fp.read()

-Whoopin'

Big_Whoopin
2006-12-05, 01:42
From http://docs.python.org/lib/module-urllib.html
"FancyURLopener subclasses URLopener providing default handling for the following HTTP response codes: 301, 302, 303, 307 and 401. "

I guess that nails the missing 401 as the cause of the failure when posting. Now I just need to either 1) get DD-WRT updated so that unauthorized use of apply.cgi returns a 401 error, or 2) get KCP updated to use a lib and class other than urllib.FancyURLopener that can pass authentication first go. Neither of these I can do on my own. I know each person's time is valuable, but can anyone jump in and help? Even if just to provide insight as to if it is possible to update KCP to a different lib capable of passing authentication to DD-WRT without first receiving a 401 error, and without breaking functionality for other kaid servers?

-Whoopin'

Nuka1195
2007-02-28, 08:17
I just did a rewite of KCP, it's now skinnable, language support and more modulized. It's also a little faster to check status. The only firmware settings i have complete is for Hyper-wrt(tofu/thibor 13)

This does require a newer build of XBMC, it uses the new progressbar in python.

You can grab a copy in the scripting svn. http://xbmc-scripting.googlecode.com/svn/trunk

Currently settings doesn't work, so you either need to edit the kcputil.py file or launch the script, then exit out and edit the q:\\userdata\\script_data\\KCP\\settings.txt file.

I'm interested in see if we can get this to work with DD-wrt and other firmware. I'll need a few things first.

In the routers web page, find where you can Run Command and do these:

ps
ls /path-to-kaid/kaid (successful and unsuccessful)
/path-to-kaid/kaid -V (successful and unsuccessful)

then view the source and post a link or better yet follow the below settings and replace with what is needed for DD-WRT or any firmware other than Hyper-WRT (thibor/tofu 13).


{
"url_form": "http://%s/apply.cgi?%s",
"wget_ftp_kaid": "wget ftp://%s:%s@%s/%s -O %s.gz",
"wget_ftp_kaid_conf": "wget ftp://%s:%s@%s/%s -O %s",
"wget_http_kaid": "wget http://%s/%s -O %s.gz",
"wget_http_kaid_conf": "wget http://%s/%s -O %s",
"method": "POST",
"bin_filename": "/tmp/kaid",
"conf_filename": "/tmp/kaid.conf",
"command_key": "command_cmd",
"form_data": { "submit_button": "Command", "submit_type": "start", "change_action": "gozila_cgi", "action": "Apply", "command_cmd": "" },
"ls_command": "ls %s",
"ps_command": "ps",
"kill_command": "killall -9 %s",
"run_command": "%s -s -c %s -d",
"finalize_command": "sleep 3;gunzip %s.gz;sleep 2;chmod +x %s",
"reboot_command": "/sbin/reboot",
"version_command": "%s -V",
"version_regex_pat": "var log = .*\\\\x0a\\\\x0a([0-9a-zA-Z]*)",
"version_command_failed": "not found",
"ls_command_failed": "No such file or directory"
}


The most important are "version_regex_pat" for parsing the version and the command failed values.

If anybody besides me still uses this and would like to get this working for another firmware, let me know.

HarshReality
2007-02-28, 18:57
I thought we had this going with custom settings in DD-WRT already or before Nuka... getting ready to update my router but will give it a try ;)

BigBossman
2007-03-15, 02:23
Hey Nuka1195, here is the results of the ps in DD-WRT v23 SP3 (03/04/07) std

PID Uid VmSize Stat Command
1 root 396 S /sbin/init noinitrd
2 root SW [keventd]
3 root SWN [ksoftirqd_CPU0]
4 root SW [kswapd]
5 root SW [bdflush]
6 root SW [kupdated]
11 root SW [mtdblockd]
14 root 312 S /sbin/watchdog
79 root 304 S resetbutton
113 root 428 S /usr/sbin/telnetd
129 root 304 S /sbin/wland
24824 root 388 S dnsmasq --conf-file /tmp/dnsmasq.conf
20462 root 316 S /tmp/ppp/redial 30
20464 root 452 S nas -P /tmp/nas.wl0lan.pid -H 34954 -l br0 -i eth1 -A
20468 root 1052 S httpd -p 80
31757 root 512 S /usr/sbin/pppd file /tmp/ppp/options.pppoe
31794 root 264 S igmprt ppp0
31795 root 368 S process_monitor
31865 root 280 S /usr/sbin/cron
7759 root 1036 S kaid -s -d -c /tmp/kaid.conf
7760 root 1036 S kaid -s -d -c /tmp/kaid.conf
7761 root 1036 S kaid -s -d -c /tmp/kaid.conf
7762 root 1036 S kaid -s -d -c /tmp/kaid.conf
7763 root 1036 S kaid -s -d -c /tmp/kaid.conf
7764 root 1036 S kaid -s -d -c /tmp/kaid.conf
7765 root 1036 S kaid -s -d -c /tmp/kaid.conf
7766 root 1036 S kaid -s -d -c /tmp/kaid.conf
7767 root 1036 S kaid -s -d -c /tmp/kaid.conf
7768 root 1036 S kaid -s -d -c /tmp/kaid.conf
7769 root 1036 S kaid -s -d -c /tmp/kaid.conf
7774 root 1036 S kaid -s -d -c /tmp/kaid.conf
7775 root 1036 S kaid -s -d -c /tmp/kaid.conf
7776 root 1036 S kaid -s -d -c /tmp/kaid.conf
12079 root 488 S sh -c alias ping='ping -c 3'; eval "ps" > /tmp/ping.l
12080 root 452 R ps

there seems to be a kaid.conf file in /tmp/kaid.conf and theres also one in /etc/kaid/kaid.cong

hope that helps

Nuka1195
2007-03-15, 03:00
the one in /etc/ i take it, is built in to the firmware.

What I need from the above, is for you to View source and post that. in internet explorer it's view/source not sure with other browsers

What i need if you want to use the builtin version:
1. the location of kaid if it's built in.


Also run the following, then do a view source and post those.
1. ls /tmp/kaid (with kaid not installed in /tmp/
2. /tmp/kaid -V (or wherever you have kaid installed)

I think that would do it.

BigBossman
2007-03-15, 19:27
Ok, here is the

ls source
http://pastebin.ca/396202

ls /etc/kaid
http://pastebin.ca/396207

ls /usr/sbin
http://pastebin.ca/396208

/usr/sbin/kaid -V
http://pastebin.ca/396212

HarshReality
2007-05-19, 03:19
Source hasnt been updated as yet... BB if you have this working can you send me a copy...

Nuka1195
2007-05-19, 04:09
i just committed a DD-WRT firmware settings, It'll be luck if it works, but give it a shot. I couldn't test it

HarshReality
2007-05-19, 07:25
Well.... Im using v23 sp 2 required minor alterations to some of your paths....

"bin_filename": "/usr/sbin/kaid",
"conf_filename": "/tmp/kaid.conf",