我已经看过并且看不到在这方面找到任何东西。
所以我有一台通过我的主电脑桥接的电脑,我将如何从我的主电脑拦截和编辑一个数据包(我知道它会发送到我的另一台电脑)?我知道如何拦截它,但我在编辑它时找不到任何东西。
我目前的代码是:
static void Main()
{
// Retrieve all capture devices
var devices = CaptureDeviceList.New();
var device = devices.FirstOrDefault(dev => dev.Description.ToLowerInvariant().Contains("intel(r)"));
// check device isn't null
if (device == null)
throw new NullReferenceException();
while(true)
{
// open device
device.Open();
var capture = device.GetNextPacket();
if (capture == null || capture.Data == null)
continue;
var packet = PacketDotNet.Packet.ParsePacket(capture.LinkLayerType, capture.Data);
var asciiz = Encoding.ASCII.GetString(capture.Data);
if (asciiz.ToLowerInvariant().Contains("xeraxic"))
{
asciiz = asciiz.Replace("<view>1</view>",
"<view>2</view>");
packet.PayloadPacket.PayloadPacket.PayloadData = Encoding.ASCII.GetBytes(asciiz);
Console.WriteLine("Modified Packet, fingers crossed");
}
// close device
device.Close();
}
}