Hi,I intercepted all DNS messages but no response was received.Through Wireshark packet capturing, I found that the packet is incorrect.After comparing with the correct packets,I found an error byte--'2e',which should have been the length.
Here is my code:
Hi,I intercepted all DNS messages but no response was received.Through Wireshark packet capturing, I found that the packet is incorrect.After comparing with the correct packets,I found an error byte--'2e',which should have been the length. Here is my code:
void main() { HANDLE handle; unsigned char packet[65535]; UINT packet_len; WINDIVERT_ADDRESS addr; handle = WinDivertOpen("udp.DstPort == 53", WINDIVERT_LAYER_NETWORK, 0, 0); if (handle == INVALID_HANDLE_VALUE) { printf("WinDivertOpen error:", GetLastError()); return; } while (1) { if (!WinDivertRecv(handle, packet, sizeof(packet), &packet_len, &addr)) { printf("WinDivertRecv error:", GetLastError()); continue; } WinDivertHelperCalcChecksums(packet, packet_len, &addr, 0); WinDivertSend(handle, packet, packet_len, NULL, &addr); } }
Screenshot of Wireshark: