Spoofing the User Agent with Safari or Firefox

Tags: , , , , , ,
Posted 2344 Tage zuvor.

If you're a web designer or administrator and frequently have to access your own web pages, it is useful to hide your own requests from the web server's statistics generated by a tool like Awstats. For dial-up users it is common practice to ignore a subnet's IP range like this:

# File /etc/awstats/awstats.conf:
# ...
SkipHosts="REGEX[^123\.456\.]

However, if you are like me and you are with a popular ISP, this would not only filter out your own requests, but also a whole lot of other people's visits. It would be much more accurate to fingerprint your exact computer. The easiest way is through a genuine custom user agent string from your browser. I will first show you how to do this in Safari:

Safari: A genuine custom user agent string

Tools like Saft or Safari Enhancer will only let you choose from predefined browser strings like Mozilla or MSIE. It is not a good idea to filter by common browser names. This will do the magic:

$ defaults write com.apple.Safari CustomUserAgent "\"My user agent string\""

Quit Safari before you type that command and restart afterwards. Note: The escaped quotes are necessary! Check if it works for you by looking at your servers log files. It worked for me with Mac OS X 10.4.8 and Safari 2.0.4. Copy your old user agent string from your servers log and append some genuine characters at the end that no other user agent would use, i.e. 'itsme'.

Firefox

With Firefox, changing the user agent string is just to easy. In the address bar, enter about:config. Type useragent into the Filter field, then double click on the general.useragent.extra.firefox key and add your genuine string to it.

Set custom user agent in Firefox

In one last step, tell Awstats to ignore requests from that user agent to filter your computer from your Awstats statistics:

# File /etc/awstats/awstats.conf:
# ...
SkipUserAgents="REGEX[itsme$]"

You can now safely browse your web pages with whatever computer you have configured to be filtered, no matter of what IP address you have.

SubscribeSubscribe to this Feed

Save to: Del.icio.us Save to: Google Save to: Facebook Save to: StumbleUpon Save to: Slashdot Save to: Technorati



Comments [8]

  1. Lee Carré (http://carre.dyndns.org/) said 2201 Tage zuvor:

    Would it not be easier setting up a DynDNS account on your development PC, then telling AWStats to exclude that domain name – it would resolve it to get the IP, which is fine because it should always be updated by your DynDNS client.

    Obviously this is all assuming you can tell AWStats to exclude by DNS name.

  2. Niko (http://www.rubyrobot.org) said 2201 Tage zuvor:

    Seems like a smart idea if it does work, however you would be depending on a third party service.

  3. de beer () said 1746 Tage zuvor:

    You could also try the methods describe at http://dotdoh.com/?p=80 to change your Firefox’s Useragent string permanently

  4. zaxone (http://freearcadesonline.com) said 1632 Tage zuvor:

    Nice tip brother i did like you said and await the results.

    Thank you very much.

  5. Gadget News (http://www.mygadgetbee.com/) said 1624 Tage zuvor:

    DO you know similar agent for IE

  6. Gadget Coupons (http://www.reviewbackyard.com/) said 1624 Tage zuvor:

    nice user agent spoofing tip

  7. Sean Spencer () said 1553 Tage zuvor:

    Under preferences in Safari (on a mac at least…) under the advanced tab there is an option to “Show Develop Menu in toolbar.”

    If you select this, it adds a new area on your toolbar called “Develop.”

    Under it, you can go to “User Agent” and select from a list of predefined user agents or type in a custom user agent by choosing “other.”

    Hope this is helpful.

  8. robert (http://classic-carshow.com) said 1122 Tage zuvor:

    Great tip. I am developing a robot trap (for Bad robots that just use bandwidth) and being able to change my UA has been really useful

Don't even bother spamming, comments are moderated.
Textile-Hilfe