/DNSTool

Primary LanguagePython

This README.md is mostly generated by ChatGPT

DNS Resolve Tool

DNS Resolve Tool is a command-line tool for DNS resolution, capable of performing both forward and reverse DNS lookups, and supporting various DNS query methods. The tool also allows you to save results in different file formats such as JSON, XML, CSV, and plain text.

Key Features

  • Forward DNS resolution: Query IP addresses based on hostnames.
  • Reverse DNS resolution: Query hostnames based on IP addresses.
  • Supports multiple DNS query methods: including nslookup, dig, host, and socket.
  • Allows custom DNS server specification.
  • Formatted result output: Supports JSON, XML, CSV, and plain text formats.
  • Cross-platform support: Runs on both Windows and Linux operating systems.

Usage

Install Dependencies

This tool requires Python 3.3 or higher. Please ensure that you have a compatible version of Python installed on your system.

If you got the right version, you do not need to install any additional libraries.

Command-line Options

usage: DNSTool.py [-h] [-r] -i INPUT [-o OUTPUT] [-f {nslookup,host,dig,socket}] [-s SERVER]

DNS Resolve Tool

options:
  -h, --help            show this help message and exit
  -r, --reverse         Reverse DNS resolution, or default ro forward resolution
  -i INPUT, --input INPUT
                        Input ip/host list file
  -o OUTPUT, --output OUTPUT
                        default result.json
  -f {nslookup,host,dig,socket}, --function {nslookup,host,dig,socket}
                        which function to use, default dig
  -s SERVER, --server SERVER
                        DNSServer

Example Usage

  1. Forward DNS resolution:
python dns_resolve.py -i hosts.txt -o results.json -f dig -s 8.8.8.8 

the hosts.txt like

a.com
b.com
c.com
  1. Reverse DNS resolution:
python dns_resolve.py -r -i ips.txt -o results.xml -f nslookup -s 8.8.8.8

the ips.txt like

1.1.1.1
2.2.2.2
3.3.3.3

Output Formats

  • JSON format example:
{
    "1.1.1.1": [
        "one.one.one.one"
    ],
    "8.8.8.8": [
        "dns.google"
    ],
    "123.123.123.132": []
}
  • XML format example:
<?xml version="1.0" ?>
<data>
	<ip address="1.1.1.1">
		<hostname>one.one.one.one</hostname>
	</ip>
	<ip address="8.8.8.8">
		<hostname>dns.google</hostname>
	</ip>
	<ip address="123.123.123.132"/>
</data>
  • CSV format example:
IP Address,Hostnames 
93.184.216.34,example.com 
172.217.168.174,google.com 
192.0.66.2,openai.org
  • Plain text format example:
example.com: 93.184.216.34
google.com: 172.217.168.174
openai.org: 192.0.66.2, 192.0.66.128 

Notes

  • Ensure that the required dependencies are installed on your system (see the "Install Dependencies" section).
  • When performing reverse DNS resolution, provide an input file containing a list of IP addresses.
  • By default, the output file will be saved in JSON format. If you need a different format, use the -o option to specify the output file name and format.

Author

just me.

If you encounter any issues or have any suggestions while using the tool, feel free to contact me.