5 WHOIS CODE

This chapter provides source code examples for querying WHOIS systems so it can be used as a reference as well as an opportunity to provide a step-by-step tutorial. Deploying and executing these programs may require C/C++, Perl, or other coding skills. The basics of coding and the tools required are not covered here; rather, we focus on the components of the code that apply to WHOIS. The full source code is provided at the end and through links along with recommendations for compliers and tutorials. Editing, compiling, and deploying code are not covered at length. Concepts like string handling, pointers, functions, and data structures may be referenced but not detailed.

5.1 AUTOMATING WHOIS WITH BATCHING AND SCRIPTING

There are a variety of ways to perform lookups on large lists of domains or addresses. Conducting mass searches manually is not practical for large system operations or on-the-fly analysis. To handle large lists, we need to understand batching, looping, iteration and recursion.

5.1.1 DiG Example

In DiG using the –f switch allows for the passing of a list in a file to the process. This is a built-in option for DiG that opens a designated file and runs each line against DiG. If we use

dig –f domainlist.txt >>digout.txt

and the file domainlist.txt contains the entries:

  • google.com
  • yahoo.com
  • bing.com

the process will call for the DNS records of all these domains and dump the results to a file called “digout.txt.” See the sections on using ...

Get WHOIS Running the Internet: Protocol, Policy, and Privacy now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.