基于代理监控外网访问小软件

本 设计针对网站的访问和特定文件夹的操作进行记录。对网站的访问的审计记录涉及到访问的主机,时间,请求参数等。对文件的记录主要涉及添加,删除,修改,重 命名等。本程序是基于C#,VS2010开发。使用步骤:打开软件,点击“监控”之后,软件工作。此时所有对外网访问的HTTP请求都会被记录。点击文件 操作审计标签,则进行文件的审计。

1)在网站访问监控方面:使用FiddlerCore客户端代理处理HTTP协议,经过处理之后,监控到浏览器对外部网站的每一个请求,记录,分析请求之后呈现到用户界面中。

    2)文件监控只是实现了FileSystemWatcher类,针对用户选择的文件夹和文件类型来监控,可以对特定的文件监控(打开,删除,修改,重命名等操作)。有图有真相!需要下载:载:http://download.csdn.net/source/3366745

 /// <summary>
        /// 开始对访问的网站进行分析
        /// </summary>
        public void startFidder()
        {
            //通知事件委托
            Fiddler.FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA) 
            { 
                AddMessageform("OnNotification is "+oNEA.NotifyString+"/n");
            };
            //记录日志事件委托
            Fiddler.FiddlerApplication.Log.OnLogString += delegate(object sender, LogEventArgs oLEA) 
            {
                AddMessageform("OnLogString is "+oLEA.LogString+"/n");
            };
 
            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
            {                
                //此处可以对请求和响应进行响应的修改和处理
               
                AddMessageform("请求的相应为: "+oS.fullUrl + "/n");
                HostStatistical(oS);                
                oS.bBufferResponse = true;
            };
 
            Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) 
            {
                //Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
                AddMessageform("请求序号为:"+oS.id+"响应的状态码为:"+oS.responseCode+"服务器返回的URL地址为:"+oS.fullUrl);
                HostStatistical(oS);
               
                //oS.utilDecodeResponse(); oS.utilReplaceInResponse("Microsoft", "Bayden");
            };

            Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS) 
            {
                HttpSession hs = new HttpSession(oS);
                Sessions.Add(hs);
                AddMessageform("/n最终的会话信息:/t" + oS.fullUrl + "/n");
                HostStatistical(oS);
                  
            };
                                               
            Fiddler.CONFIG.IgnoreServerCertErrors = false;
             
            // 可以对HTTPS信息进行监控,但是需要使用到MakeCert.exe文件放置呆应用程序的文件夹中           
            Fiddler.FiddlerApplication.Startup(8877, true, true);//程序运行时,自动将浏览器设定为此端口,以便监控系统侦听          
 
            // Wait Forever for the user to hit CTRL+C.  
            // BUG BUG: Doesn't properly handle shutdown of Windows, etc.
            Object forever = new Object();
            lock (forever)
            {
                System.Threading.Monitor.Wait(forever);
            }
           
        }
      /// <summary>
      /// 对访问主机的统计
      /// </summary>
      /// <param name="os"></param>
        public void HostStatistical(Fiddler.Session os)
        {
            string host = string.Empty;
            string[] tempArray = os.hostname.Split('/');//os.hostname格式为:http://www.baidu.com/id/china/my.php 
            host = tempArray[0];
            if (tempArray.Length>2)
            {
                 host = tempArray[2];//tempArray[0]="http:",tempArray[1]="",tempArray[2]=www.baidu.com
            }
            
            if (!hashSite.ContainsKey(host))
            {
                hashSite.Add(host, 1);//key为主机,value为访问次数
            }
            else
            {
                int count = Convert.ToInt32(hashSite[host].ToString());
                hashSite.Remove(host);
                hashSite.Add(host, count + 1);
            }
        }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值