헤더가 활성화 된 원시 소켓에서 들어오는 패킷을 읽으려고합니다. CodeProject의 MJsniffer와 같은 다른 프로젝트를 보면 내가 원하는 모든 것을 읽을 수있는 자신 만의 코드를 만들 수있었습니다. 문제 : 나는 나가는 정보 만 검색하고 있습니다. 다음은 원시 소켓을 초기화하려면 코드가있어, 처리 코드는 64 비트, 나는 전체 관리 권한이 C#의 IP 프로토콜에서 원시 소켓을 사용하여 들어오는 패킷 읽기
// Resolve the host name or IP address to am IPHostEntry instance
IPHostEntry hIPHostEntry = Dns.GetHostEntry(Dns.GetHostName());
// Initialize a new instance of the Socket class.
Socket hSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Unspecified); // IP is possible.
// Bind the socket to each resolved IP address.
foreach (IPAddress hIPAddress in hIPHostEntry.AddressList) try { hSocket.Bind(new IPEndPoint(hIPAddress, 0)); } catch(Exception) { continue; }
// Configure the incoming socket to accept all the required information.
hSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
// Configure the incoming socket to receive all the required information.
hSocket.IOControl(IOControlCode.ReceiveAll, BitConverter.GetBytes(1), BitConverter.GetBytes(1));
// Return the configured socket.
return hSocket;
내가 소켓을 얻기 위해이 코드를 수정하는 방법, 윈도우 7에서 실행 ..이 시점에서 무관 들어오는 패킷을 읽을 수 있습니까? 나가는 것이 좋고, 나는 그것도 필요하지만, 나는 또한 들어오는 패킷을 절대적으로 필요로한다.
P .: 사용자가 강제로 WinPcap을 설치하고 싶지 않습니다. 나는 캡쳐 또는 스푸핑이나 다른 것을 원하지 않습니다. 단지 읽어야합니다. 가능해야합니다.
공유해 주셔서 감사합니다. 그것은 특별히 지금 당장 도움이되지는 않지만, 미래에 대한, 그리고이 질문에 걸린 다른 사람들을위한 좋은 지식입니다. –