Thursday, September 29, 2016

Unit testing Fake IP Address for Website

We were trying to fake the IP Address for one of our website for different visitors. Such as if some one visits the site from Australia or New Zealand then site should redirect to au or Beefeaterbbq.co.nz respectively.
We were able to test the redirect for Australia quite easily as we were based in Australia but for New Zealand it was bit of hard work as we could not find any Proxies that could fake NZ IP address for us. After doing searching and bit of struggle i have figured out we can alter Fiddler script to fake request header.
Therefore, I was able to add one line to output IP Address of my choice to whatever site as long as Fiddler intercepts the call from browser. Below are the steps to add custom header and test the site.

Pre-requisite

  1. Fiddler 2
  2. Any Browser :>

Steps to Fake IP Addresses

  • Open Fiddler and goto Rules
  • Select Customize Rules - This will open the CustomRules.js file in notepad


  • Search for function OnBeforeRequest

static function OnBeforeRequest(oSession: Session) {


    • At the end of function add below line

    oSession.oRequest.headers.Add("X-Forwarded-For", "14.1.63.255");  // NZ IP Address, DNS name or IP address of target server


    • Save the file
    • Make sure on fiddler -> File (Menu) -> Capture Traffic is checked

    • Once you are done don't forget to remove your line from CustomRules.js

    No comments:

    Post a Comment