通过在 .Net (C#) 中编码来阻止计算机上的任何 IP
我正在研究一种在《现代战争 2》中踢作弊者的方法(当你是主持人时)。我已经能够使用 winpcap 嗅探包来识别玩家名称及其 IP。
我需要一种方法来阻止所有流量(或仅阻止到我的计算机的目标 IP UDP 流量)。因此玩家将会超时/滞后。
有谁知道有一个可用的库可以让我轻松地做到这一点。我可以采用困难的方式来完成此操作,安装 Windows DDK 并在 C++ 中乱搞以创建低级 NDIS 驱动程序,但对 C++ 非常生疏,并且为此编译模板代码时出现所有典型的编译问题,我更喜欢一些为此准备好编码库。
或者也许有人有更好的想法?
解决方案:使用Windows 防火墙。简单的 API 可动态创建和删除规则。 任何方式关闭“互联网” windows 使用 c#?
并且一个测试程序现在可以执行此操作。我把 2 个人踢出了游戏。
I am playing around with a way to kick cheaters in Modern Warfare 2 (when you are the host). I have been able to use winpcap to sniff packages to identify the player names and their IPs.
I need a way to block all traffic (or just the target IPs UDP traffic to my machine). Hence the player will timeout/lagout.
Does anyone know of an available library that lets me do this easily. I could go about doing this the hard way and install Windows DDK and mess around in C++ to create a low level NDIS driver, but being überly rusty on C++ and all the typical compile issues that comes when compiling template code for this, I prefer some ready coded library for this.
Or maybe someone has a better idea that would work?
Solution: Use Windows Firewall. Easy API to create and remove rules on the fly.
Any way to turn the "internet off" in windows using c#?
And a a test program that does this now works. I kicked 2 people out of the game.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否运行防火墙?也许您可以使用防火墙的 API 来拒绝来自违规主机的连接请求。例如,“具有高级安全性的 Windows 防火墙”API 可能是在很多电脑上都可以使用。
Are you running a firewall? Maybe you could use the firewall's API to reject connection requests from the offending host. For example, the "Windows Firewall with Advanced Security" API is probably available on a lot of PCs.
您应该能够将该 IP 的无效条目放入 Windows Hosts 文件中。这里有一些可能适合您的 C# 代码。这个地方讨论了一种使用IPSec过滤IP地址的方法。但它非常手动。过程如下:
在本地安全设置/IP 安全策略下
如果您能弄清楚如何在 C# 中执行此操作,那么您就是赢家。
You should be able to put an invalid entry for that IP into the Windows Hosts file. Here's some C# code that might work for you.This place discusses a way to use IPSec to filter IP addresses. It's very manual though. Here's the process:
Under Local Security Settings / IP Security Policies
If you could figure out how to do that in C#, you're a winner.