fiddler Displays the server IP

72 views
Skip to first unread message

4705...@qq.com

unread,
Sep 1, 2017, 3:22:35 AM9/1/17
to Fiddler
fiddler added in the script

FiddlerObject.UI.lvSessions.AddBoundColumn ("ServerIP", 120, "X-HostIP");

Then you can display IP

If ip = "183.12.14.36"

Then it will show = Guangdong Shenzhen

Eric Lawrence

unread,
Sep 1, 2017, 5:22:39 PM9/1/17
to Fiddler
Yes, you can add the ServerIP to the Web Sessions list easily (via the script you show, or via using the newer Customize Columns context menu command.

I think you're asking whether you can add a column to Fiddler that shows the IP-Geolocation? In principle, yes, this is easy if you either have a database of IP Geolocations or have a webservice you can query for that information. I couldn't find a free one, which is why I didn't build this feature directly into Fiddler.

4705...@qq.com

unread,
Sep 1, 2017, 9:51:50 PM9/1/17
to Fiddler
I would like to be able to use this "http://www.ip138.com/ips1388.asp"WEB address to achieve

But I can not merge, you can help me see if feasible ~

thank you

4705...@qq.com

unread,
Sep 1, 2017, 10:11:27 PM9/1/17
to Fiddler

/// <summary>
      /// 通过IP得到IP所在地省市(Porschev)
      /// </summary>
      /// <param name="ip"></param>
      /// <returns></returns>
      public string GetAdrByIp(string ip)
      {
          string url = "http://www.cz88.net/ip/?ip=" + ip;
          string regStr = "(?<=<span\\s*id=\\\"cz_addr\\\">).*?(?=</span>)";
          //得到网页源码
          string html = GetHtml(url);
          Regex reg = new Regex(regStr, RegexOptions.None);
          Match ma = reg.Match(html);
          html = ma.Value;
          string[] arr = html.Split(' ');
          return arr[0];
      }
      /// <summary>
      /// 获取HTML源码信息(Porschev)
      /// </summary>
      /// <param name="url">获取地址</param>
      /// <returns>HTML源码</returns>
      public string GetHtml(string url)
      {
          string str = "";
          try
          {
              Uri uri = new Uri(url);
              WebRequest wr = WebRequest.Create(uri);
              Stream s = wr.GetResponse().GetResponseStream();
              StreamReader sr = new StreamReader(s, Encoding.Default);
              str = sr.ReadToEnd();
          }
          catch (Exception e)
          {
          }
          return str;
      }
      /// <summary>
      /// 得到真实IP以及所在地详细信息(Porschev)
      /// </summary>
      /// <returns></returns>
      public string GetIpDetails()
      {
          //设置获取IP地址和国家源码的网址
          string url = "http://www.ip138.com/ips8.asp";
          string regStr = "(?<=<td\\s*align=\\\"center\\\">)[^<]*?(?=<br/><br/></td>)";
          //IP正则
          string ipRegStr = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
          //IP地址
          string ip = string.Empty;
          //国家
          string country = string.Empty;
          //省市
          string adr = string.Empty;
          //得到网页源码
          string html = GetHtml(url);
          Regex reg = new Regex(regStr, RegexOptions.None);
          Match ma = reg.Match(html); html = ma.Value;
          Regex ipReg = new Regex(ipRegStr, RegexOptions.None);
          ma = ipReg.Match(html);
          //得到IP
          ip = ma.Value;
          int index = html.LastIndexOf(":") + 1;
          //得到国家
          country = html.Substring(index);
          adr = GetAdrByIp(ip);
          return "IP:" + ip + " 国家:" + country + " 省市:" + adr;
      }

4705...@qq.com

unread,
Sep 2, 2017, 11:36:16 PM9/2/17
to Fiddler
Which of the following is possible?
Reply all
Reply to author
Forward
0 new messages