- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我正在使用的代码。这是我从网上得到的代码,他们说它工作正常。对此的评论也很好,但我不明白为什么它对我不起作用。还有一件事,我将此应用程序用作用户模式而不是管理员模式。
private void btnStart_Click(object sender, EventArgs e)
{
if (cmbInterfaces.Text == "")
{
MessageBox.Show("Select an Interface to capture the packets.", "MJsniffer",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
if (!bContinueCapturing)
{
//Start capturing the packets...
btnStart.Text = "&Stop";
bContinueCapturing = true;
//For sniffing the socket to capture the packets has to be a raw socket, with the
//address family being of type internetwork, and protocol being IP
Console.WriteLine("1");
mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Raw, ProtocolType.IP);
Console.WriteLine("2");
//Bind the socket to the selected IP address
mainSocket.Bind(new IPEndPoint(IPAddress.Parse(cmbInterfaces.Text), 0));
Console.WriteLine("3");
//Set the socket options
mainSocket.SetSocketOption(SocketOptionLevel.IP, //Applies only to IP packets
SocketOptionName.HeaderIncluded, //Set the include the header
true); //option to true
Console.WriteLine("4");
byte[] byTrue = new byte[4] {1, 0, 0, 0};
byte[] byOut = new byte[4]{1, 0, 0, 0}; //Capture outgoing packets
//Socket.IOControl is analogous to the WSAIoctl method of Winsock 2
mainSocket.IOControl(IOControlCode.ReceiveAll, //Equivalent to SIO_RCVALL constant
//of Winsock 2
byTrue,
byOut);
//Start receiving the packets asynchronously
mainSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None,
new AsyncCallback(OnReceive), null);
}
else
{
btnStart.Text = "&Start";
bContinueCapturing = false;
//To stop capturing the packets close the socket
mainSocket.Close ();
}
}
catch (SocketException ex)
{
Console.WriteLine("5");
MessageBox.Show(ex.Message, "MJsniffer", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
Console.WriteLine("6");
MessageBox.Show(ex.Message, "MJsniffer", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
最佳答案
And one more thing I am using this application as user mode not in a administrator mode.
这行不通。 following是为 Win32 api 编写的,但由于这是 .NET 向下调用的内容,因此同样适用:
To use a socket of type
SOCK_RAW
requires administrative privileges. Users running Winsock applications that use raw sockets must be a member of the Administrators group on the local computer, otherwise raw socket calls will fail with an error code ofWSAEACCES
. On Windows Vista and later, access for raw sockets is enforced at socket creation. In earlier versions of Windows, access for raw sockets is enforced during other socket operations.
(我的重点)
关于C# 套接字异常 : an attempt was made to access a socket in a way forbidden by its access permissions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15378876/
我第一次决定切换到 InnoDB 并尝试使用外键和其他 InnoDB 功能。 创建关系时,我应该只在一张表上声明它们吗?还是两个表? 例如,对于以下每种情况,您将在何处以及如何声明关系? 1 用户有很
老方法 当我以前在需要内容被搜索引擎索引的项目中异步加载页面时,我使用了一种非常简单的技术,那就是 Page $('#example').click(function(){
我目前正在为自己创建自己的自定义应用程序来编译 Java 文件。我的应用程序可以完美地编译 Java 文件,但现在我想开始为 Java 文件添加某种类型的测试(例如,我将一些变量传递给许多不同的文件
我需要建立从我的 iPhone 应用程序到客户服务器的 HTTPS 双向 SSL 连接。但是我没有看到任何安全的方式来将客户端证书传递给应用程序(这是一个电子银行应用程序,所以安全性确实是一个问题)。
我从事 Java 工作已经很长时间了,大约 6 个月前开始使用 Scala。我喜欢这门语言。我发现的一件事是,做事有多种方法。我不知道这是因为该语言的性质,还是因为它还很年轻并且在不断发展,习惯用法和
这是我所指的示例代码。 https://sites.google.com/site/ssljavaguide/example-code/2-way-ssl 我是否可以不设置与 keystore 相关的
我读过有关使用 MySQL AES_ENCRYPT/AES_DECRYPT(双向加密)不如使用 PHP - hash()(单向加密)安全的信息。 http://bytes.com/topic/php/
我正在进行一个路线选择项目,我需要使用道路类型和单向/双向交通信息填充道路网络。我想知道Tiger/Line道路数据集是否包含这样的数据。。我下载了加利福尼亚州的Tiger/Line道路数据集,但没有
我需要开发一个 iPad 应用程序,它应该管理两种方向模式(横向和纵向)。 根据 official Apple iOS documentation , 有 2 种方法可以继续。 -第一个包括在收到旋转
我正在训练一个 randomForest 模型,目的是保存它以进行预测(它将被下载并在外部上下文中使用)。我希望这个模型尽可能最小。 我读到有很多options和 packages减少模型的内存大小。
为什么将参数传递给匿名函数会影响结果?例如,下面的脚本将 a1 显示为 function(),将 a2 显示为数组。 var a1=(function(){return [1*2,2*2,3*2];}
我有一个 Python 列表: listx = [["a", 127, "Blue", 0], ["b", 127, "Red", 1], ["b", 127, "
在查看 Java 库时,特别是构造函数,我注意到字段通常会出于某种原因进行初始化和验证: public java.awt.Color(int r, int g, int b, int a) {
我想编写 Git 脚本。只创建一个 Unix 脚本是最好的方法吗? #!/bin/bashgit push origin master &&git checkout develop &&git mer
这个问题在这里已经有了答案: class or method alias in java (8 个回答) 去年关闭。 我有一个类的名称可能不必要地繁琐,其中包含许多我在其他地方使用的静态方法。 而不是
这个问题在这里已经有了答案: Best way to check function arguments? [closed] (14 个回答) Parameter validation, Best pr
在阅读我遇到的代码时,结构的以下定义和初始化: // header file struct foo{ char* name; int value; }; //Implementation file s
我正在使用多页表单方法在 Drupal 中开发一个自定义模块,并且我希望对步骤进行可视化。 步骤 1 > [_Step_2_] > 步骤 3 > 完成 商业规则: 他们总是能看到所有的步骤,以及他们现
Josh 的 answer 给我留下了深刻的印象关于客户端的“Angular 方式”和声明式风格。 但是你能帮我理解一下,怎么做吗: 我有一个单页应用程序,左侧是菜单栏,右侧是 div 容器。 当用户
Subversion 商店正在考虑改用 Mercurial,试图提前弄清楚开发人员的所有提示将是什么。这里有一个相当常见的用例,我不知道如何处理。 我正在研究一些较大的功能,我有一个重要的代码部分——
我是一名优秀的程序员,十分优秀!