Dynamically Responding to Query Packets

Learn how to dynamically generate DNS response packets to match requests.

Introduction

Previously, we successfully crafted DNS replies that are designed to match a particular query. However, this has been in a largely static context, reading packets from a file and printing the responses to the terminal or a packet capture file.

However, to build a functioning honeypot server, we need to develop dynamic responses to queries. Request packets can contain a range of different field values, and a server needs to generate appropriate responses to each request.

Dynamically crafting packet eaders

When defining packet headers, we manually specified the values for source and destination IP addresses and ports. These values were based on what we saw within the headers of the request packet.

Since all of this information is included in a request packet, it’s available to the server that we’re writing. We just need to automate the process of extracting values from the request packet to include in the response.

Get hands-on with 1200+ tech skills courses.