Showing posts with label cookies. Show all posts
Showing posts with label cookies. Show all posts

14 January 2008

Windows Vista: Really that Bad?

Many Vista users have been complaining about Vista's compatibility issues, battery life problems, and random other annoying features of Vista. I've come to dislike Vista almost as much as I dislike Macs. However, when I tried making the cookie copying article and some other stuff, I've come to realize maybe it isn't that bad.

Right after I wrote the article on secretly stealing cookies (See the article), I realized I never discussed what you can do if you have Windows Vista (and IE7 which comes installed). When I try to test out this program, first I find the cookies folder locked (gasp). Alright, so while I was at it, I tried another program that uses batch files to do some..umm..stuff. What the hell? I find out I don't have access again. What gives?

What I came to realize was that Vista's "least privileges" rule was actually "saving" my computer. While at the same time this property of Vista prevents users from opening a whole array of things without being bugged by the User Account Control (UAC), it also stops unwanted programs from executing scripts to access the registry or restricted folders.

Is it really that useful though? If you're an inexperienced user, maybe you'll read what UAC has to say the first couple times. Then you get accustomed to it and then click "Allow" every single time. What I found out was that Vista keeps a lot of things locked even UAC is turned off. So it might stop some people from doing stupid stuff but there's plenty of ways to get around this stuff.

Alright so Vista stopped me from doing some stuff. I figured out where the cookies were kept anyways without anything stopping me (see edit in IE Cookies: Yum!).

11 January 2008

IE Cookies: Yum!

Cookies are debated to be a dangerous thing. Website can track what you're doing whereas they also help you keep your cart in order when you shop online. So what are they? In this article, I'll show you one quick hack which will let you use someone elses cookies on your computer.

There's a couple things you should know about cookies first.
  1. Where they are located
  2. How to copy your cookies
  3. What is in a cookie
  4. What can you do with cookies (other than eat them)

1. Where Are They Located
Depending on the internet browser you have, your cookies are stored in different places. I'm only going to look at Internet Explorer and Mozilla Firefox.
  • Internet Explorer - %userprofile%\Cookies
  • Mozilla Firefox - %appdata%\Mozilla\Firefox\Profiles\[random number].default\cookies.txt
Note that whereas IE stores the cookies in a folder, Firefox stores it in one file.

EDIT: For Windows Vista with IE7, the cookies you can actually access are stored in a different location. They are in '%appdata%\Microsoft\Windows\Cookies'.

2. Copy Your Cookies
On Firefox, this is pretty simple. Just copy that 'cookies.txt' file and you're done. On IE, there are two ways. The easy way is to (this is using IE6) do File->Import and Export->Export Cookies and save the file. That will give you a cookies.txt file just like Firefox! If you want to copy to IE, just Import Cookies instead and pick the cookies file.

OK, so this wouldn't be an article without the hard and sneakier way. I started off learning the easy way before I wondered what else you could do if you just had the cookies folder. You start off by copying the 'Cookies' folder to a directory of your choice. If you try to paste this folder into some other another computer/user's folder, you find out a file called 'index.dat' can't be written! One solution to this is to logoff, and login as another user and then paste (to the first user). Ok, ok, that's a bit too annoying if you need to do that everytime. Before I teach the other way, there's some other stuff you should learn... (scroll to the bottom if you just want to know how)

3. What's in a Cookie
So you're looking at that exported cookie file from IE and wondering what the hell do all those numbers and other things mean. Here's the breakdown of all that stuff.

yahoo.com   TRUE   /   FALSE   2127949143  C  mg=1
  1. domain yahoo.com- what (the domain that) created the cookie
  2. flag TRUE- whether or not all machines in the domain can access this
  3. path /- place within the domain that has access
  4. secure FALSE- whether or not a secure connection is needed
  5. expiration 2127949143- when the cookie expires in epoch time (seconds since Jan. 1, 1970 00:00:00 GMT)
  6. name C- name of the cookie
  7. value mg=1- value of the cookie
Each cookie in the 'cookies.txt' file is seperated by a new line (or more sometimes). The Firefox 'cookies.txt' file looks a bit different because the "newline" character is different but don't worry about that.

4. What Can You Do With Cookies
The basics of what cookies are used for: shopping carts, tracking you (in good and bad ways), storing login information (for email, blogs, other websites), and a bunch of other stuff. You can copy your cookies if you're migrating from one internet browser to another.

Let's get back to copying then. Either just copy the folder, or create a .bat file to automate this. Just have:
'xcopy "%userprofile%\Cookies" "[destination]" \h \s \e'
in the file (where [destination] is replaced with the destination folder. So you've copied the Cookies folder (maybe even "sneakily" using the .bat file). How do you make a 'cookies.txt' file to use on another computer?

There's a freeware utility called IECookiesView (download) that will let you do this. Open IECV and go to File->'Select Cookies Folder' and find where you copied the cookies to.

Select all the cookies (Ctrl+A or Edit->'Select All Items') and then File->'Export to Netscape/Mozilla File'.

At first I thought this was all and tried to import using IE. Didn't work. So what was wrong? Two things: the file is exported with a different newline character (uses Unix LF carriage instead of Windows CRLF) and instead of using regular text in the files, it uses percent-encoding (which is just used in URLs..see the wiki).

Fix the first problem by downloading and installing Unix2Win (download), right-clicking the exported file from IECV and selecting 'Text Converter'->Unix2Windows. Cool..that was fairly easy.

EDIT: Alright, so I went back and found out you don't need to install Unix2Win. If you use my converter (see below), it will take care of everything. It will fix the newlines and the percent-encoding problem.

The next problem is a bit harder. Convert the the percent-encoded file to a normal text file. You can find an online solution or use mine. I made my own converter using Java (download). You have to use it from command prompt. Use 'java URL2UTF8 input output'. Perhaps you don't trust this file? If anyone wants to compile it on their own, I'll post up the source code too. If there are any errors that I haven't handled properly, please let me know. Ok, so maybe that wasn't hard for you either (it was for me...I tried searching on the web with no good results before I made it on my own).

Great, now you have the correct cookie text file and it actually works on IE (and Firefox too)!