当前位置:编程学习 > C#/ASP.NET >>

求数据包抓取、解析、修改、恢复、转发方法

想要抓取网络数据包,然后对取到数据包进行解析,修改数据包的目标地址(IP和MAC)和源地址(IP和MAC)等,在根据新地址进行二次转发,大家有什么好的方法和建议呢,C#能实现吗?现在我们用SharpPcap可以抓取、解析,但无法发送和接收,请大侠指点,谢谢了! --------------------编程问答-------------------- 这个已经超出了软件的范畴,目前能做到的也只是拦截窃取数据包,不可能修改再发送,而且数据包都是有加密和验证的 --------------------编程问答--------------------
#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
--------------------编程问答-------------------- 学习学习 --------------------编程问答-------------------- 抓包工具

http://baike.baidu.com/view/2188981.htm
http://www.cr173.com/soft/5937.html
http://www.softbar.com/iptool.html --------------------编程问答-------------------- 谢谢了,另外想问下
有没有解析协议的工具呢,如ftp,p2p,https等,或者在数据包中确认是用哪些软件工具,如迅雷下载、网页另存为下载的

引用 4 楼 liuchaolin 的回复:
抓包工具

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

--------------------编程问答-------------------- 不能修改吧。。 --------------------编程问答-------------------- 抓包必备工具...

wpe ccp eg 全名忘记了 反正是这3个组合起来用 可以实现这样功能

like this:

网络游戏 背包里有500元宝 然后刚吃的时候 截取封包 然后吃完了 在截取

然后 你帐户里就多了500

然后把刚刚保存的数据发送  于是 又多了500

玩CF跟传奇的时候用过.相当好...
--------------------编程问答-------------------- http://url.cn/FpJW5g

N年前的 在网盘里找到的 不知道现在可以不可以   --------------------编程问答--------------------
引用 1 楼 liuchaolin 的回复:
这个已经超出了软件的范畴,目前能做到的也只是拦截窃取数据包,不可能修改再发送,而且数据包都是有加密和验证的

目前我们在使用SharpPcap是可以抓包、修改、转发的,只是修改的时候IP包检验错误,导致转发失败,有谁知道如何更新校验和的。先谢过了。 --------------------编程问答-------------------- 你用c#做这个不合适吧,就算你真做出来了,效率也是一个大问题啊,
做这种底层的还是建议c/c++


抓包工具可以看下这个
ethernet 抓包工具 --------------------编程问答-------------------- 楼上列位对抓包都有,酱油收获大 --------------------编程问答-------------------- 除
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,