Saturday, 29 May 2010

Downloading content to modify

My previous post showed how I setup Apache and Squid to serve updated pages, but as of yet nothing has been modified. Assuming Apache and Squid are working as described, the next stage is to download some content, inspect and modify it.

When accessing Viera Cast via the proxy, all content will just be proxied directly to Panasonic servers, this is because we have no local copies. Have a look at /var/log/squid/mirror_and_redirect.log and you will see what files were served by our script. The first you will see (on a European device) will be This is the start page.

Try and access this from your browser and you will see a 404 Not Found error page. The servers expect your browser (or rather the device) to send a user agent to identify it as a Panasonic device. This is where the useragent.log we configured comes in. Look at /var/log/squid/useragent.log and you will see a big list of gobbledigook. These are seemingly random strings of characters which change with every file. Thankfully we don't need to know what they say, we can it seems choose any one of those strings and "spoof" a Panasonic device.

This bit is optional - it just demonstrates that the User Agent string works. If you have Firefox, install User Agent Switcher. Create a "test" user agent and paste any one of those strings into the user agent. Try again to browse to your home-screen.js and you will see JavaScript!

Now that you know the user agent works, we need to download the home-screen.js to our server to modify. Create a script (and make it executable) somewhere called containing the following (on one line): -

wget --directory-prefix /var/www -t 1 -nc -xU "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"$1

Replace the XXXXXXX with one of your User Agent strings from useragent.log.

Now run data/home-screen.js

You will see it download the file to /var/www/

If you access Viera Cast from your device now, you will see from your mirror_and_redirect.log that it served up the local version instead i.e. http://localhost/

In my next post I'll cover some basic modifications.

No comments:

Post a Comment