Home > Software engineering >  Consult WSAIoctl (.. That SIO_RCVALL) network monitoring, back to 10022
Consult WSAIoctl (.. That SIO_RCVALL) network monitoring, back to 10022

Time:11-09

RecSocket=socket (AF_INET SOCK_RAW, IPPROTO_IP);//WSASocket
If (recSocket==INVALID_SOCKET)
{
PrintInfo (" \ r \ nsocket () error: % d ", recSocket);
: : WSACleanup ();
NNetOK=1;
The return - 2;
}

//the setsockopt (); . Set the IP header

Char hname [256].
Struct hostent * pHost;
Sockaddr_in addr.

If (gethostname (hname, sizeof (hname)) & lt; 1)
{
PrintInfo (" \ r \ ngethostname () error ");
Closesocket (recSocket);
RecSocket=INVALID_SOCKET;
: : WSACleanup ();
NNetOK=1;
The return - 3;
}
The else
{
PHost=gethostbyname (hname);
Addr. Sin_addr=* (in_addr *) pHost - & gt; H_addr_list [0].
Addr. Sin_family=AF_INET;
Addr. Sin_port=htons (1234);//& gt; In 1024, IP layer can fill any values

If (bind (recSocket, (struct sockaddr *) & amp; Addr, sizeof (addr))==SOCKET_ERROR)
{
PrintInfo (" \ r \ nbind () error ");
Closesocket (recSocket);
RecSocket=INVALID_SOCKET;
: : WSACleanup ();
NNetOK=1;
The return - 4;
}


# define SIO_RCVALL (IOC_IN | IOC_VENDOR | 1)
U_long the sio;
DWORD value;
If (WSAIoctl (recSocket SIO_RCVALL, & amp; The sio, sizeof (the sio), NULL, 0, & amp; Value, NULL, NULL)==SOCKET_ERROR)
{
front all no problem, execution to this step wrong, wrong is 10022 below, system for Win7_64, but already set the administrator rights, should be no problem!

Int err=WSAGetLastError ();


PrintInfo (" \ r \ nWSAIoctl () error: % d ", err);
Closesocket (recSocket);
RecSocket=INVALID_SOCKET;
: : WSACleanup ();
NNetOK=1;
Return to 5;
}
}

CodePudding user response:

Security restrictions? Windows underlying RAW packets of actual combat

CodePudding user response:


Do you want to raw socket, recv all sniffing all packages?
Also allows the xp era, later, the system should be banned,

Don't want to sniff, be about to use Winpcap.

CodePudding user response:

refer to the second floor smwhotjay response:

Do you want to raw socket, recv all sniffing all packages?
Also allows the xp era, later, the system should be banned,

To sniff, using Winpcap.

Set to the administrator privileges or no problem, and no error when open a socket,

CodePudding user response:

reference 1st floor zgl7903 response:
security restrictions? Windows underlying RAW packets of actual combat

Has the problem, but is set to the administrator rights with respect to OK, and if there is the problem I remember should be open socket is failed, don't know whether that is,

CodePudding user response:

WSAIoctl Function there are instructions in the document
WSAEINVAL
The dwIoControlCode tells them The parameter is not a valid command, or a specified input parameter is not acceptable, or The command is not applicable to The type of socket specified.


CodePudding user response:

reference 5 floor zgl7903 reply:
WSAIoctl Function of the instructions are in the document
WSAEINVAL
The dwIoControlCode tells them The parameter is not a valid command, or a specified input parameter is not acceptable, or The command is not applicable to The type of socket specified.

It is said that the original socket SIO_RCVALL can't use? Under XP it with no problem, but under the Windows 7 out of the question, because the permissions?
I have already changed to manager access, also can open a socket,

CodePudding user response:

Is not only a user permissions, should is to have done a limits the system kernel, and ordinary RAW or operation, such as ping
SIO_RCVALL no statement in the MSDN documentation, even does not support can be repaired before the BUG

CodePudding user response:

I also met this problem, a pit, the # include & lt; Thread. H> Comments, or will this code, encapsulated into a single CPP file,

CodePudding user response:

Good MSDN,
Upstairs has talked about
Raw socket is not allowed to use, after Windows 7 contain
Sniffer, and send the original frame using winpcap
  • Related