Я на стороне компьютера пытаюсь принять пакет.
CODE
private void buttonStart_Click(object sender, EventArgs e)
{
if (comboBoxInterfaces.SelectedIndex == -1)
{
MessageBox.Show("Select an Interface to capture the packets.", "WIFI Sniffer",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
if (!continue_capturing)
{
//Start capturing the packets...
buttonStart.Text = "&Stop";
continue_capturing = 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
mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
//Bind the socket to the selected IP address
mainSocket.Bind(new IPEndPoint(IPAddress.Parse(comboBoxInterfaces.SelectedItem.ToString()), 0));
//Set the socket options
mainSocket.SetSocketOption(SocketOptionLevel.IP, //Applies only to IP packets
SocketOptionName.HeaderIncluded, //Set the include the header
true); //option to true
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(byte_data, 0, byte_data.Length, SocketFlags.None,
new AsyncCallback(OnReceive), null);
}
else
{
buttonStart.Text = "&Start";
continue_capturing = false;
//To stop capturing the packets close the socket
mainSocket.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "MJsniffer", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
{
if (comboBoxInterfaces.SelectedIndex == -1)
{
MessageBox.Show("Select an Interface to capture the packets.", "WIFI Sniffer",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
if (!continue_capturing)
{
//Start capturing the packets...
buttonStart.Text = "&Stop";
continue_capturing = 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
mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
//Bind the socket to the selected IP address
mainSocket.Bind(new IPEndPoint(IPAddress.Parse(comboBoxInterfaces.SelectedItem.ToString()), 0));
//Set the socket options
mainSocket.SetSocketOption(SocketOptionLevel.IP, //Applies only to IP packets
SocketOptionName.HeaderIncluded, //Set the include the header
true); //option to true
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(byte_data, 0, byte_data.Length, SocketFlags.None,
new AsyncCallback(OnReceive), null);
}
else
{
buttonStart.Text = "&Start";
continue_capturing = false;
//To stop capturing the packets close the socket
mainSocket.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "MJsniffer", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Но я вижу только TCP/UDP пакеты.
я так понимаю у меня сокет настроен неправильно. я пробовал менять SocketType и ProtocolType некоторые опции не возвращают никаких пакетов некоторые генерируют исключения. также менял SocketOptionLevel - тот же результат. может кто нибудь имел дело с приемом биконов?