想要抓取网络数据包,然后对取到数据包进行解析,修改数据包的目标地址(IP和MAC)和源地址(IP和MAC)等,在根据新地址进行二次转发,大家有什么好的方法和建议呢,C#能实现吗?现在我们用SharpPcap可以抓取、解析,但无法发送和接收,请大侠指点,谢谢了!

解决方案 »

  1.   

    #region 获取字符流
            /// <summary>
            /// 获取字符流
            /// </summary>
            //---------------------------------------------------------------------------------------------------------------
            // 示例:
            // System.Net.CookieContainer cookie = new System.Net.CookieContainer(); 
            // Stream s = HttpHelper.GetStream("http://ptlogin2.qq.com/getimage?aid=15000102&0.43878429697395826", cookie);
            // picVerify.Image = Image.FromStream(s);
            //---------------------------------------------------------------------------------------------------------------
            /// <param name="url">地址</param>
            /// <param name="cookieContainer">cookieContainer</param>
            public static Stream GetStream(string url, CookieContainer cookieContainer)
            {
                currentTry++;            HttpWebRequest httpWebRequest = null;
                HttpWebResponse httpWebResponse = null;            try
                {
                    httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
                    httpWebRequest.CookieContainer = cookieContainer;
                    httpWebRequest.ContentType = contentType;
                    httpWebRequest.ServicePoint.ConnectionLimit = maxTry;
                    httpWebRequest.Referer = url;
                    httpWebRequest.Accept = accept;
                    httpWebRequest.UserAgent = userAgent;
                    httpWebRequest.Method = "GET";                httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    Stream responseStream = httpWebResponse.GetResponseStream();
                    currentTry--;
                    return responseStream;
                }
                catch (Exception e)
                {
                    if (currentTry <= maxTry)
                    {
                        GetHtml(url, cookieContainer);
                    }                currentTry--;                if (httpWebRequest != null)
                    {
                        httpWebRequest.Abort();
                    } if (httpWebResponse != null)
                    {
                        httpWebResponse.Close();
                    }
                    return null;
                }
            }
            #endregion
      

  2.   

    抓包工具http://baike.baidu.com/view/2188981.htm
    http://www.cr173.com/soft/5937.html
    http://www.softbar.com/iptool.html
      

  3.   

    谢谢了,另外想问下
    有没有解析协议的工具呢,如ftp,p2p,https等,或者在数据包中确认是用哪些软件工具,如迅雷下载、网页另存为下载的
      

  4.   

    抓包必备工具...wpe ccp eg 全名忘记了 反正是这3个组合起来用 可以实现这样功能like this:网络游戏 背包里有500元宝 然后刚吃的时候 截取封包 然后吃完了 在截取然后 你帐户里就多了500然后把刚刚保存的数据发送  于是 又多了500玩CF跟传奇的时候用过.相当好...
      

  5.   

    http://url.cn/FpJW5gN年前的 在网盘里找到的 不知道现在可以不可以  
      

  6.   

    目前我们在使用SharpPcap是可以抓包、修改、转发的,只是修改的时候IP包检验错误,导致转发失败,有谁知道如何更新校验和的。先谢过了。
      

  7.   

    你用c#做这个不合适吧,就算你真做出来了,效率也是一个大问题啊,
    做这种底层的还是建议c/c++
    抓包工具可以看下这个
    ethernet 抓包工具