コード例 #1
0
ファイル: airpcap.c プロジェクト: Lexus89/wifi-arsenal
// Use PPI headers to obtain the different information for ri
// Use AirpcapConvertFrequencyToChannel() to get channel
// Add an option to give frequency instead of channel
int cygwin_sniff(void *buf, int len, struct rx_info *ri)
{
	UINT BytesReceived = 0;

	// Wait for the next packet
	// Maybe add an event packets to read
	// WaitForSingleObject(ReadEvent, INFINITE);

	// Read a packet
	if(AirpcapRead(airpcap_handle, buf, len, &BytesReceived))
		return (int)BytesReceived;

	return -1;
}
コード例 #2
0
ファイル: airpcap.c プロジェクト: 0x0mar/aircrack-ng
/**
 * Capture one packet
 * @param buf Buffer for the packet
 * @param len Length of the buffer
 * @param ri Receive information
 * @return -1 if failure or the number of bytes received
 */
int airpcap_sniff(void *buf, int len, struct rx_info *ri)
{
	// Use PPI headers to obtain the different information for ri
	// Use AirpcapConvertFrequencyToChannel() to get channel
	// Add an option to give frequency instead of channel
	UINT BytesReceived = 0;

	if (ri) {}
	// Wait for the next packet
	// Maybe add an event packets to read
	// WaitForSingleObject(ReadEvent, INFINITE);

	// Read a packet
	if(AirpcapRead(airpcap_handle, buf, len, &BytesReceived))
		return (int)BytesReceived;

	return -1;
}
コード例 #3
0
ファイル: AirPcap_AP.c プロジェクト: thanhtphung/cppware
////////////////////////////////////////////////////////////////////////
//						listenForProbeRequest
////////////////////////////////////////////////////////////////////////
// Listens for a probe request and sends the response.
//
// Params:	Ad - An open handle to a device.
//
// Returns - None.
////////////////////////////////////////////////////////////////////////
void listenForProbeRequest(PAirpcapHandle Ad)
{
	HANDLE ReadEvent;
	p_ppi_packet_header p_ppi;
	BYTE* PacketBuffer;
	UINT BytesReceived;

	//
	// Get the read event
	//
	if(!AirpcapGetReadEvent(Ad, &ReadEvent))
	{
		printf("Error getting the read event: %s\n", AirpcapGetLastError(Ad));
		AirpcapClose(Ad);
		exitApp(-1);
	}

	//
	// Allocate a 256k packet buffer
	//
	PacketBuffer = (BYTE*)malloc(PACKET_BUFFER_SIZE);
	if(!PacketBuffer)
	{
		printf("No memory for the packet buffer\n");
		AirpcapClose(Ad);
		exitApp(-1);
	}

	//
	// Everything is ok! 
	// Look for Probe Request
	//
	while (TRUE)
	{
	    // capture the packets
		if(!AirpcapRead(Ad, 
			PacketBuffer, 
			PACKET_BUFFER_SIZE, 
			&BytesReceived))
		{
			printf("Error receiving packets: %s\n", AirpcapGetLastError(Ad));
			free(PacketBuffer);
			AirpcapClose(Ad);
			exitApp(-1);
		}

		// Look for Echo Request. When found, take it from there.
		if(getProbeRequest(Ad, PacketBuffer, BytesReceived, &p_ppi))
		{
			sendProbeResponse(Ad, p_ppi);
		}

		// wait until some packets are available. This prevents polling and keeps the CPU low. 
		WaitForSingleObject(ReadEvent, WAIT_INTERVAL_MS);
	}

	//
	// Make sure we clean up after
	//
	free(PacketBuffer);

	//
	// Exit, printing the exit message
	//
	exitApp(0);
}