View Single Post
Old 11-17-2010, 05:15 AM   #1
vdp
Enthusiast
vdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watchvdp is clearly one to watch
 
Posts: 45
Karma: 10842
Join Date: Aug 2010
Device: Kindle DXG
KindleTERM - a SSH client kindlet

Hi,

I wrote a quick and dirty hack based on the MidpSSH J2ME SSH/telnet client, to make it run on Kindle. Well, I am somewhat hesitant on the 'quick' part, since it took me a good amount of time during the last 3 weeks, but it is certainly dirty . You can find the git repo on GitHub.

Thanks to Andrew de Quincey for making possible writing kindlets without the highly restricted Amazon development kit.

I've only had the opportunity to test it on my Kindle DXG, so I don't know how well it performs on other models.

I will describe the installation process in case someone is willing to try it.

The usual disclaimer applies: You should not take the steps described below unless you are comfortable about messing with your device and potentially bricking it. DO IT ON YOUR OWN RISK - if something goes wrong I will probably not be able to help you.

1) Copy the developer.keystore in /var/local/java/keystore directory. I wanted to use the AdQ's keystore used for KIF but unfortunatelly Ant's signjar task fails with message:

Code:
[signjar] jarsigner: Certificate chain not found for: dkadq.  dkadq must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.
I am not all that familiar with the Java keystores so I am not sure yet what the problem is.
If someone have an idea how to fix it you are wellcome.

2) The Kindle framework's sandbox should be relaxed somewhat to allow SSH connections.
In /opt/amazon/ebook/security/external.policy after "grant signedBy "Kindlet" {" add the lines
Code:
permission java.net.SocketPermission "localhost:1024-", "accept, connect, listen";
permission java.net.SocketPermission "192.168.2.1", "connect, accept";
permission java.net.SocketPermission "localhost", "connect, accept";
These changes permit connections to the kindlet, and from the kindlet to the localhost and usbnet host ip. Perhaps here is the place to say (as already mentioned by others on this forum) that the Amazon 3G access should be considered privilege rather than right, so I will not support any attempts to exploit the free 3G.

3) Copy the KindleTERM.azw2 to the 'documents' directory.

Known bugs and limitations:

- I am not sure if this is the case if you only make connections to the kindle (localhost), but I discovered that the connections from Kindle to other hosts are automatically disconnected after 2 or so minutes. If you want to prevent this you should stop netwatchd daemon.
Code:
/etc/init.d/netwatchd stop
- MidpSSH tries to emulate a DEC vt320 terminal. It seems that it is not that common type of terminal so neither my Ubuntu 9.04 nor the Kindle have a terminfo description. I tried different terminfo files (e.g. the one from http://www.sunmanagers.org/archives/1995/1561.html) none of them work as it should for example in VIM. Don't know if the reason is the imperfect emulation in terminal.VT320 class, the way I use it in kindle.KindleTerminal or terminfo entries needs tweaking. Every help on this issue is very wellcome.

- Key events handling is far from perfect. For example there is still no way to emulate "TAB" on the device's keyboard. It should be trivial to fix though. I implemented also a "remote keyboard" feature - the kindlet listens to port 3333 for key events. On the host machine you can start:
Code:
java -cp KindleTERM.azw2 kindle.RemoteKeyboard
and the keys you press when it's window is on focus are relayed to the kindlet.
It needs a java property file, named remote_keyboard.properties in the current working directory:
Code:
host 192.168.2.2
port 3333
This feature is a potential security hole if you use it on a WiFi-enabled Kindle, so you should change your firewall accordingly.

- If you choose to save session info it is saved in plain text in the kindlet's 'work' directory so it is a security risk also.

Last edited by ixtab; 10-09-2013 at 05:02 AM.
vdp is offline   Reply With Quote