Monday, February 23, 2009

Using the Archos 605 browser without the plugin

I've owned an Archos 605 Wifi for several years, but have always been bugged that you need to buy plugins for such things as playing some file formats, and the web browser. The cinema plugins cost ~$20, while the broswer plugin costs the most at $30. I've been avoiding needing the cinema plugins by re-encoding my videos into a valid format, but I've been stuck for a way to get a working browser.

You can purchase these plugins either on your computer and install them onto the device, or you can buy them right on the device. To do that, you have to connect to a wireless network, then access the archos store through one of many links in the device's firmware.

The device opens the store, using opera...the browser you supposedly have to buy a plugin for. I've never actually seen a device with the browser plugin, so I don't know what kind of functionality you get with it, but if you can live without such things as bookmarks the built in browser seems fully functional. The trick is, Archos only allows you to visit certain pages (the archos store, several video pages specifically designed for the device), and these don't allow you to visit any other pages besides themselves. Also, the URL bar is missing. Essentially, you are stuck with these pages unless you buy the plugin.



To break out of this, I had to find a way to redirect traffic the device makes from archos.com to somewhere else, perhaps my own webserver. I had previously read a page that showed how to prank your neighbors who connect to your wireless network by flipping all their pictures on websites upside-down, or by directing all their traffic to kittenwar.com using iptables. Since my router is running dd-wrt, I can enter iptable commands directly into the firmware to achieve the same results.

I started by researching iptable commands, and found a page right on the dd-wrt website which demonstrated a list of commands. I wrote a single command to redirect archos.com traffic to my own personal webserver,
http://pjgat09.gotdns.com

iptables -t nat -I PREROUTING -p tcp -d archos.com -s 192.168.1.102
-j DNAT --to 69.177.224.219

(note: 192.168.1.102 is the ip my archos gets on my personal network, 69.177.224.219 is/was the ip of my webserver)

Success! Any time I tried to go to the archos store, I ended up at a 404 page on my server.

The next step was to figure out what document the archos is trying to access when it connects. Apparently the starting page is http://archos.com/storewifi/shortcuts/redirect.html?acc=3. I mimicked this on my server, and had a new homepage for my archos.

Next step was to solve the problem of not having an address bar. I added a simple form, and used javascript to load the page you enter. Problem solved. Check out the source for my page if you're interested: http://pjgat09.gotdns.com/storewifi/shortcuts/redirect.html



I now have a "fully" functional Opera browser, which I can actually access other webages with. Time to see what this thing can do.

First, YouTube: Fail. Apparently flash is not enabled in the built in browser, or without the plugin.



Next, Facebook: Partial Pass, It worked, but terribly slow.

How about the Acid 2 and 3 tests?

Acid 2: Full pass! Surprising, but it is Opera after all.



Acid 3: Fail, as the test so kindy told me.



A few other pages showed this browser isn't too bad. One thing that interested me was the "home" button on the right. This button used to take you to the archos content portal, where you could read news or watch videos. However, it stopped working after my iptables redirect.

After checking my webserver's access log, I saw the device is also trying to access a seperate xml file in addition to redirect.html. Apparently the "home" button is setup by the xml document, which allows me direct it anywhere I please.

The redirect page was even more interesting. It loads a javascript document, http://acp.archos.com/acppriv/archospipe.js. This code accesses what seems to be an archos specific javascript object, and allows you to read data from the device, including firmware version, remaining space, language and country. I've made a proof of concept html page to demo this: http://pjgat09.gotdns.com/acppriv/index.html. This page does nothing harmful to your device, but feel free to look at the source on your computer before loading it on your own device. If you apply this hack as shown, this is the page which will load when you click on the "home" button.

Among other things I have tried with this browser, I am able to upload any file in the filesystem, assuming I know its full path. Maybe this can be useful for further hacking, who knows. I am interested in hearing from people who do have the browser plugin, and knowing whats different from what I've done. Also if you get this working too, let me know!

Wednesday, February 18, 2009

Auto-pausing Virtual Machine

I've been using VirtualBox for a while to run Windows-only programs without restarting into one of my Windows installs. Lately I've been playing games (especially NES) in the virtual machine, with a result of high CPU usage, and plenty of heat.

I've started scaling back my CPU to half speed while using the virtual machine which solved the heat problem, but I was still at a loss about the CPU usage. I knew I could pause the machine when I'm not using it, but there are plenty of times where I go do other things and forget. I decided to find a way to make it automatically pause.

The best way I could think of to detect when I'm not using the virtual machine was to use the screen saver in Windows. A simple test confirmed it was possible to run any exe as a screen saver. I have directories from my host machine mounted inside Windows, so with a simple C program I could edit (or create) a file on my host machine that signals I'm not using the machine.

The next part is to make some kind of script check the file on a regular basis and pause the machine when needed. This script should also only run when the machine is running.

First the C code:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
FILE *outfile;

outfile = fopen("G:/virtual_box_pause.txt", "w");
if (NULL == outfile)
{
printf("ERROR: Cannot open (output) file)\n");
exit(EXIT_FAILURE);
}

fputc('1', outfile);
fputc('\n', outfile);

fclose(outfile);

exit(EXIT_SUCCESS);
}

This code writes a "1" into a file on the host machine, "virtual_box_pause.txt" when run. I compiled the code, renamed it with a .scr extension, and installed. That was step one.

Step two, a perl script to monitor the same file for changes:

#!/usr/bin/perl
use warnings;
use strict;

print "CPU scaling to 1.6GHz\n";
`cpufreq-selector -f 1600000`;

print "Starting Windows XP\n";
`VBoxManage startvm "Windows XP"`;

sleep 20;
my $state = `VBoxManage showvminfo "Windows XP" | grep State`;

print "Monitoring for paused state\n";

while ( !($state =~ /saved/) )
{
open PAUSE, "<", "~/virtual_box_pause.txt"; my $pause_value = <PAUSE>;
close PAUSE;
chomp $pause_value;

if ($pause_value == 1)
{
`VBoxManage controlvm "Windows XP" pause`;
open PAUSE, ">", "~/virtual_box_pause.txt";
print localtime() . " Pause command Sent\n";
print PAUSE "0";
close PAUSE;
}

sleep 5;
$state = `VBoxManage showvminfo "Windows XP" | grep State`;
}

print "Virtual machine no longer running\n";
print "CPU scaling to OnDemand\n";
`cpufreq-selector -g OnDemand`;

print "Exiting\n";

This code automatically scales back the CPU, watches to see if I shut down the machine, and pauses when need. When I shut down the machine, it brings the CPU back to regular speed before exiting.

After making these, I simply had to run the perl script when ever I wanted to use windows. I made a launcher on my desktop to do just that:

gnome-terminal -t "Windows XP" -x ~/virtual_box_pause.pl

Now I have a virtual machine which automatically pauses when not in use. To adjust the time delay, simply adjust your screen saver settings.

First post

Hey everybody. I finally decided to make a blog! I'm gonna mix computers with anything else I feel like throwing up. I'll put up ideas and projects I'm working on. Feel free to comment or help out!