本文介绍了C#如何为WebRequest的伪造IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有asp.net网站主办,我提出的WebRequest发布的数据,并得到响应。该网站有IP过滤。我想欺骗发送者的IP地址用于测试目的。是否有可能以编程方式做到这一点还是我不得不使用任何工具。

I have asp.net website hosted and I am making WebRequest to post data and get response. The website is having IP filtering. I want to spoof sender IP address for testing purpose. Is it possible to do it programmatically or I have to use any tool.

public string GetResponse(string request)
{
    lock (Obj)
    {
        request = request + _dataControlInfo.SendEndingWith;
        Logger.Info(request);
        var req = (HttpWebRequest)WebRequest.Create(_serviceUrl);
        req.Headers.Add("SOAPAction", "\"\"");
        req.ContentType = "text/xml;charset=\"utf-8\"";
        req.Accept = "text/xml";
        req.Method = "POST";
        var stm = req.GetRequestStream();
        var bytes = UtfEncoding.StringToUtf8ByteArray(request);
        stm.Write(bytes, 0, bytes.Length);
        stm.Close();
        var resp = req.GetResponse();
        var stmr = new StreamReader(resp.GetResponseStream());
        var strResponseXml = stmr.ReadToEnd();
        Logger.Info(strResponseXml);
        return strResponseXml;
    }
}

请指定任何可能性。

推荐答案

您要找的是这是WinPcap的一个.NET端口..它可以让你做,这是你谈论。你的想法,唯一的问题是,你将无法获得回应。您可以发送请求,但是如果你没有一个正确的返回地址,然后请求将在interwebs丢失。

What your looking for is SharpPCap which is a .NET port of WinPCap.. it allows you to do IP Spoofing, which is what your talking about. The only problem with your idea is that you wont be able to get a response back. You can send requests out, but if you dont have a proper return address then the request will be lost in the interwebs.

修改

要做到这一点yoruself瓦特/出库的帮助,你需要自己构建的原始数据包。这已经回答了。

To do this yoruself w/out the help of a library you will need to construct the raw packets yourself. This has been answered here.

这篇关于C#如何为WebRequest的伪造IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:01
查看更多