SOLVED: Client/Server interaction and code injection notes.
Posted: Tue Apr 05, 2011 8:17 am
Excuse the scrabby format of this post; it is being written as I find things, rather than being an actual narrative. Whilst I've been waiting until I can get back upstairs to have a go at swapping disc images and version numbers, I've been having a poke about inside the tivo software from the comfort of my laptop..!
So ... Some notes on how 2.5.5 communicates with the server, EPG responses, etc.
On the TiVo end, operations seem to be run from /tvlib/tcl/tv/SvrResp.itcl
The http posts to /tivo-service/TCD411.cgi and /tivo-service/HServer.cgi (include the software version number, among other things.
The response to the latter includes a parameter SW_LIST=&url chksum#0x00..00|&url chksum#0x00..00 etc
Checksums can be omitted and SvrResp.itcl will cope.
On a standard daily call, this is a list of slices and scripts.. It can also include system messages, etc. The tivo connects to each URL in turn and fetches the files. (&url = GET from url, @url = POST url. See CmdStr.itcl)
Scripts end .runme, and come with a .sig file. These are run first before anything else is processed.
.sigs are the signature that is passed to the tivo crypto prog. if it doesn't pass, script is not executed
(SvrResp line 1280)
Crypto prog is /tvbin/crypto
Public key is at /tvlib/misc/service-v3-s.pub
(These are identical on my two networked tivos, but they share a history so this is not conclusive)
If slice files have .sigs they are checked against keyfiles, but no fault is raised if they do not have them.
So it seems "runme" scripts are the only downloaded things require signing.
Now. How to get something onto the tivo that can be run but is not signed.
If a file is downloaded that has the .bnd extension, it is unbundled first (line 1318)
The unbundle code (/tvlib/tcl/tv/unbundler.tcl) runs the file through cpio to do this. (line 47)
cpio supports absolute path names in the archive.
I think this means that by supplying a .bnd archive to the tivo that includes an absolute pathname it is possible to place a file anywhere on the tivo.
I have tested this by running cpio with the same parameters from the bash shell, dropping files into /var/tmp
Can anybody testing the replacement server construct a suitable bundle file and test this?
One complication is that cpio as it's used will not overwrite an existing file.
- unless it's newer?
However a file can be dropped into anywhere that scripts are run from.
My first thought was to just drop in an /etc/rc.d/rc.sysinit.author (as unmodified boxes will not have this) but / will not be writable. So need to find somewhere else that we can put a file that will be run at some point.
/var (and /proc) are the only partitions mounted writeable. Must be something else in there that scans and runs things!
Lots more scripts to peruse ... but has anybody else had a look at this side of things?
So ... Some notes on how 2.5.5 communicates with the server, EPG responses, etc.
On the TiVo end, operations seem to be run from /tvlib/tcl/tv/SvrResp.itcl
The http posts to /tivo-service/TCD411.cgi and /tivo-service/HServer.cgi (include the software version number, among other things.
The response to the latter includes a parameter SW_LIST=&url chksum#0x00..00|&url chksum#0x00..00 etc
Checksums can be omitted and SvrResp.itcl will cope.
On a standard daily call, this is a list of slices and scripts.. It can also include system messages, etc. The tivo connects to each URL in turn and fetches the files. (&url = GET from url, @url = POST url. See CmdStr.itcl)
Scripts end .runme, and come with a .sig file. These are run first before anything else is processed.
.sigs are the signature that is passed to the tivo crypto prog. if it doesn't pass, script is not executed
(SvrResp line 1280)
Crypto prog is /tvbin/crypto
Public key is at /tvlib/misc/service-v3-s.pub
(These are identical on my two networked tivos, but they share a history so this is not conclusive)
If slice files have .sigs they are checked against keyfiles, but no fault is raised if they do not have them.
So it seems "runme" scripts are the only downloaded things require signing.
Now. How to get something onto the tivo that can be run but is not signed.
If a file is downloaded that has the .bnd extension, it is unbundled first (line 1318)
The unbundle code (/tvlib/tcl/tv/unbundler.tcl) runs the file through cpio to do this. (line 47)
cpio supports absolute path names in the archive.
I think this means that by supplying a .bnd archive to the tivo that includes an absolute pathname it is possible to place a file anywhere on the tivo.
I have tested this by running cpio with the same parameters from the bash shell, dropping files into /var/tmp
Can anybody testing the replacement server construct a suitable bundle file and test this?
One complication is that cpio as it's used will not overwrite an existing file.
- unless it's newer?
However a file can be dropped into anywhere that scripts are run from.
My first thought was to just drop in an /etc/rc.d/rc.sysinit.author (as unmodified boxes will not have this) but / will not be writable. So need to find somewhere else that we can put a file that will be run at some point.
/var (and /proc) are the only partitions mounted writeable. Must be something else in there that scans and runs things!
Lots more scripts to peruse ... but has anybody else had a look at this side of things?