pax_global_header00006660000000000000000000000064144570454240014523gustar00rootroot0000000000000052 comment=6ba17dae59f0640feac319c0d282f274861e73b1 dnsrecon-1.1.5/000077500000000000000000000000001445704542400133425ustar00rootroot00000000000000dnsrecon-1.1.5/.gitattributes000066400000000000000000000012521445704542400162350ustar00rootroot00000000000000# Set the default behavior, which is to have git automatically determine # whether a file is a text or binary, unless otherwise specified. * text=auto # Basic .gitattributes for a python repo. # Source files # ============ *.pxd text diff=python *.py text diff=python *.py3 text diff=python *.pyw text diff=python *.pyx text diff=python # Binary files # ============ *.db binary *.p binary *.pkl binary *.pyc binary *.pyd binary *.pyo binary # Note: .db, .p, and .pkl files are associated with the python modules # ``pickle``, ``dbm.*``, # ``shelve``, ``marshal``, ``anydbm``, & ``bsddb`` # (among others). dnsrecon-1.1.5/.github/000077500000000000000000000000001445704542400147025ustar00rootroot00000000000000dnsrecon-1.1.5/.github/ISSUE_TEMPLATE/000077500000000000000000000000001445704542400170655ustar00rootroot00000000000000dnsrecon-1.1.5/.github/ISSUE_TEMPLATE/issue-template.md000066400000000000000000000014141445704542400223500ustar00rootroot00000000000000--- name: Issue Template about: A template for new issues. title: "[Bug|Feature Request|Other] Short Description of Issue" labels: '' --- **Feature Request or Bug or Other** Feature Request | Bug | Other **Describe the feature request or bug or other** A clear and concise description of what the bug, feature request, or other request is. **To Reproduce** Steps to reproduce the behaviour: 1. Run tool like this: '...' 2. See error **Expected behaviour** A clear and concise description of what you expected to happen. **Screenshots** If possible please add screenshots to help explain your problem. **System Information (System that tool is running on):** - OS: [e.g. Windows10] - Version [e.g. 2.7] **Additional context** Add any other context about the problem here.dnsrecon-1.1.5/.github/dependabot.yml000066400000000000000000000005441445704542400175350ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: github-actions directory: "/" schedule: interval: daily timezone: Europe/London - package-ecosystem: pip directory: "/" schedule: interval: daily timezone: Europe/London open-pull-requests-limit: 10 target-branch: master allow: - dependency-type: direct - dependency-type: indirectdnsrecon-1.1.5/.github/workflows/000077500000000000000000000000001445704542400167375ustar00rootroot00000000000000dnsrecon-1.1.5/.github/workflows/DNSrecon.yml000066400000000000000000000017621445704542400211430ustar00rootroot00000000000000name: DNSrecon CI on: push: branches: - '*' pull_request: branches: - '*' jobs: Python: runs-on: ${{ matrix.os }} strategy: max-parallel: 8 matrix: os: [ubuntu-latest, macos-latest] python-version: [3.7, 3.8, 3.9, 3.10.9] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | pip install --upgrade pip pip install -r requirements.txt - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-line-length=127 --statistics - name: Run pytest tests run: | python3 -m pytest . dnsrecon-1.1.5/.github/workflows/codeql-analysis.yml000066400000000000000000000044711445704542400225600ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ master ] pull_request: # The branches below must be a subset of the branches above branches: [ master ] schedule: - cron: '42 19 * * 1' jobs: analyze: name: Analyze runs-on: ubuntu-latest strategy: fail-fast: false matrix: language: [ 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - name: Checkout repository uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v2 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 dnsrecon-1.1.5/.github/workflows/dockerci.yml000066400000000000000000000003701445704542400212450ustar00rootroot00000000000000name: DNSrecon Docker Image CI on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build the Docker image run: docker build . --file Dockerfile --tag dnsrecon:$(date +%s)dnsrecon-1.1.5/.gitignore000066400000000000000000000000401445704542400153240ustar00rootroot00000000000000*.idea/ *.orig *.pyc *.pyo venv/dnsrecon-1.1.5/.lgtm.yml000066400000000000000000000002121445704542400151010ustar00rootroot00000000000000queries: - exclude: py/import-and-import-from - exclude: py/polluting-import extraction: python: python_setup: version: 3dnsrecon-1.1.5/Changelog.md000066400000000000000000000145121445704542400155560ustar00rootroot00000000000000## Version 0.8.14 **Date: 11/19/18** **Changes:** - Fixed AXFR issue - Support for querying via TCP. - Better handling of no NameServer error. ## Version 0.8.13 **Date: 4/30/18** **Changes:** - Fixed typos - Certificate Transparency logs consists a lot of domain information via Crt.sh thanks to @ginta1337 ## Version 0.8.12 **Date: 12/12/17** **Changes:** - Removed AXFR from std enumeration type unless -a is specified. - Fixed processing of TXT records. ## Version 0.8.11 **Date: 10/23/17** **Changes:** - Bug fix for python 3.6.x and the Google enumeration type. - Merged PR for Bing support. - Fixed issue when doing zone walks on servers without a SOA record. ## Version 0.8.9 ### Date: 1/14/14 ### Changes: - Bug fixes. ## Version 0.8.8 - Minor bug fixes in parsing tool and dnsrecon. ### Date: 4/14/14 ### Changes: - Support for saving results to a JSON file. - Bug fixes for: - Parsing SPF and TXT records when saving to XML, CSV and SQLite3. - Filtering of wildcard records when brute forcing a forward lookup zone. - Several typos and misspelled words. ## Version 0.8.5 ### Date: 5/25/13 ### Changes: - Changed the way IP ranges are handled. - Greatly improved speed and memory use in a reverse lookup of large networks. ## Version 0.8.4 ### Date: 5/19/13 ### Changes: - Improved Whois parsing for ranges and organization. - Better Whois record and request handling for RIPE and APNIC. - Several bug fixes. - Added print messages when saving output to files. ## Version 0.8.1 ### Changes: - Improved DNSEC zone walk. - Several bug fixes for exporting data and parsing records in zone transfers. - DigiNinja Edition for all his hard work in making dnsrecon better. ## Version 0.7.8 ### Date: 7/8/12 ### Changes: - CSV files now have a proper header for better parsing on tools that support them like Excel and PowerShell. - Windows System Console printing is now managed properly. - CNAME records are now saved in SQLite3 and CSV output. - Fixed an error when performing zone transfers due to improper indent. - Fixed mislabeling of -c option in the help message. - If a range or CIDR is provided and no scan type is given, dnsrecon will perform a reverse lookup against it. When other types are given, the rvl type will be appended to the list automaticaly. - Improved NSEC type detection to eliminate possible false positives. - Added processing of LOC, NAPTR, CERT and RP records of zone transfers returned. Proper information saved on XML output with proper field names in the attributes for these. - Fixes on Google enumeration parsing. - Fixed several typos. - Better handling and canceling of threaded tasks. ## Version 0.7.3 ### Date: 5/2/12 ### Changes: - Fixes for Python 3 compatibility. - Fixed key values when saving results to XML and CSV. ## Version 0.7.0 ### Date: 3/2/12 ### Changes: - Fixes to zonewalk option. - Query for _domainkey record in standard enumeration. ## Version 0.6.8 ### Date: 2/15/12 ### Changes: - Added tool folder with Python script for parsing results in XML and CSV format. - Added the ability to filter and extract hostnames and subdomains. - Added Metasploit plugin for importing into Metasploit the CSV and XML results in a very fast manner using Nokogiri for XML. It will add hosts, notes for hostnames and service entries. -Improvements on the zone transfer code: - Handling of zones with no NS records. - Proper parsing of PTR records in returned zones. - De-duplication of NS records IP addresses. - Provide additional info on failure. - Provide more info on actions being taken. - Bug fixes reported by users at RandomStorm and by Robin Wood. - Zone walking has been greatly improved including the accuracy of the results and the formatting to extract the information in a manner more useful for a pentester. ## Version 0.6.6 ### Date: 1/20/12 ### Changes: - Does not for a Origin Check for zones transferred since some admin may have configured their zones without NS servers as experienced by a user. - Handles exception if NS records cannot be resolved when performing a zone transfer test. - Will always ??? for a test for the SOA and test it for zone transfer. - Fixed a problem when generating an XML file from a zone transfer with the new parsing method. Info type was added to the XML output. ## Version 0.6.5 ### Date: 1/16/12 ### Changes: - Fixed problem with get_ns. - Python 3.2 support. - Color printing of messages like Metasploit. - New library for printing color messages. - Improved parsing of records when there is a zone transfer. ## Version 0.6.1 ### Date: 1/14/12 ### Changes: - IPv6 support for ranges in reverse lookup. - Enhanced parsing of SPF records ranges to cover includes and IPv6. - Specific host query for TXT RR. - Better handling and logging of TXT and SPF RR. - Started changes for Python 3.x compatibility. - Filtering of wildcard records when saving brute force results. - Show found records after brute force of domain is finished. - Manage Ctrl-c when doing a brute force and save results for those records found. - Corrected several spelling errors. ## Version 0.6 ### Date: 1/11/12 ### Changes: - Removed mDNS enumeration due to the pybonjour library has been abandoned and faster ways are available to achieve enumeration of mDNS records in a sub-net. - Removed unused variables. - Applied changes for PEP8 compliance. - Added comma delimited value to a file for the results. ## Version 0.5.1 ### Date: 1/8/12 ### Changes: - Additional fixes for XML formatting. - Ability to end a zonewalk with Ctrl-c and not lose data. - Initial Metasploit plug-in to be able to import data from XML file generated by dnsrecon. ## Version 0.5 ### Date: 1/8/12 ### Changes: - Will check in standard enumeration if DNSSEC is configured for the zone by checking for DNSKEY records and checking if the zone is configured as NSEC or NSEC3. - With the get_ip() method it will also check for CNAME records and add those to the list found hosts. - Will perform a DNSSEC zonewalk if NSEC records are available. It currently identifies A, AAAA, CNAME, NS and SRV records. For any other, it will just print the RDATA info. - General record resolver method added. - Changes to the options. Known Issues: - For some reason, the Python getopt is not parsing the options correctly in some cases. Considering changing to optparse even if it is more complicated to manage. - When running Python 3.x the Whois query does not show the organization. dnsrecon-1.1.5/Dockerfile000066400000000000000000000004661445704542400153420ustar00rootroot00000000000000FROM python:alpine3.18 WORKDIR /app COPY . /app RUN apk add --no-cache build-base libffi-dev libxml2-dev libxslt-dev RUN /usr/local/bin/python -m pip install --upgrade pip RUN /usr/local/bin/python --version RUN pip3 install --no-cache-dir -r requirements.txt RUN chmod +x *.py ENTRYPOINT ["/app/dnsrecon.py"] dnsrecon-1.1.5/LICENSE000066400000000000000000000432721445704542400143570ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Copyright (C) 2021 Carlos Perez The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. dnsrecon-1.1.5/README.md000066400000000000000000000016651445704542400146310ustar00rootroot00000000000000 # DNSRecon DNSRecon is a Python port of a Ruby script that I wrote to learn the language and about DNS in early 2007. This time I wanted to learn about Python and extend the functionality of the original tool and in the process re-learn how DNS works and how could it be used in the process of a security assessment and network troubleshooting. This script provides the ability to perform: * Check all NS Records for Zone Transfers. * Enumerate General DNS Records for a given Domain (MX, SOA, NS, A, AAAA, SPF and TXT). * Perform common SRV Record Enumeration. * Top Level Domain (TLD) Expansion. * Check for Wildcard Resolution. * Brute Force subdomain and host A and AAAA records given a domain and a wordlist. * Perform a PTR Record lookup for a given IP Range or CIDR. * Check a DNS Server Cached records for A, AAAA and CNAME Records provided a list of host records in a text file to check. # Python Version DNSRecon requires python3.6+ dnsrecon-1.1.5/dnsrecon.py000077500000000000000000000002101445704542400155230ustar00rootroot00000000000000#!/usr/bin/env python3 # Note: This script runs dnsrecon from dnsrecon import __main__ if __name__ == '__main__': __main__.main() dnsrecon-1.1.5/dnsrecon/000077500000000000000000000000001445704542400151555ustar00rootroot00000000000000dnsrecon-1.1.5/dnsrecon/__init__.py000066400000000000000000000001451445704542400172660ustar00rootroot00000000000000import pkg_resources def version() -> str: return pkg_resources.require("dnsrecon")[0].version dnsrecon-1.1.5/dnsrecon/__main__.py000066400000000000000000000001031445704542400172410ustar00rootroot00000000000000from .cli import main if __name__ == '__main__': exit(main()) dnsrecon-1.1.5/dnsrecon/cli.py000077500000000000000000002475761445704542400163260ustar00rootroot00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- # DNSRecon # # Copyright (C) 2021 Carlos Perez # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; Applies version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA __version__ = '1.1.5' __author__ = 'Carlos Perez, Carlos_Perez@darkoperator.com' __doc__ = """ DNSRecon http://www.darkoperator.com by Carlos Perez, Darkoperator requires dnspython http://www.dnspython.org/ requires netaddr https://github.com/drkjam/netaddr/ """ from argparse import ArgumentParser, RawTextHelpFormatter import os from string import ascii_letters, digits import sqlite3 import datetime import netaddr from random import SystemRandom from xml.dom import minidom from xml.etree import ElementTree from xml.etree.ElementTree import Element import dns.message import dns.query import dns.rdatatype import dns.resolver import dns.reversename import dns.zone import dns.rdata import dns.flags import json from dns.dnssec import algorithm_to_text from dnsrecon.lib.crtenum import scrape_crtsh from dnsrecon.lib.bingenum import * from dnsrecon.lib.yandexenum import * from dnsrecon.lib.whois import * from dnsrecon.lib.dnshelper import DnsHelper from dnsrecon.lib.msf_print import * from concurrent import futures # Global Variables for Brute force Threads brtdata = [] CONFIG = { "disable_check_recursion": False, "disable_check_bindversion": False } # Function Definitions # ------------------------------------------------------------------------------- def process_range(arg): """ Function will take a string representation of a range for IPv4 or IPv6 in CIDR or Range format and return a list of IPs. """ ip_list = [] ranges_raw_list = list(set(arg.strip().split(","))) for entry in ranges_raw_list: try: range_vals = [] if re.match(r"\S*/\S*", entry): ip_list.append(IPNetwork(entry)) elif re.match(r"\S*-\S*", entry): range_vals.extend(entry.split("-")) if len(range_vals) == 2: ip_list.append(IPRange(range_vals[0], range_vals[1])) else: print_error(f"Range: {entry} provided is not valid") except Exception: print(Exception) print_error(f"Range: {entry} provided is not valid") return ip_list def process_spf_data(res, data): """ This function will take the text info of a TXT or SPF record, extract the IPv4, IPv6 addresses and ranges, request process include records and return a list of IP Addresses for the records specified in the SPF Record. """ # Declare lists that will be used in the function. ipv4 = [] ipv6 = [] includes = [] ip_list = [] # check first if it is a sfp record if not re.search(r"v=spf", data): return # Parse the record for IPv4 Ranges, individual IPs and include TXT Records. ipv4.extend(re.findall(r"ip4:(\S*)", "".join(data))) ipv6.extend(re.findall(r"ip6:(\S*)", "".join(data))) # Create a list of IPNetwork objects. for ip in ipv4: for i in IPNetwork(ip): ip_list.append(i) for ip in ipv6: for i in IPNetwork(ip): ip_list.append(i) # Extract and process include values. includes.extend(re.findall(r"include:(\S*)", "".join(data))) for inc_ranges in includes: for spr_rec in res.get_txt(inc_ranges): spf_data = process_spf_data(res, spr_rec[2]) if spf_data is not None: ip_list.extend(spf_data) # Return a list of IP Addresses return [str(ip) for ip in ip_list] def expand_cidr(cidr_to_expand): """ Function to expand a given CIDR and return an Array of IP Addresses that form the range covered by the CIDR. """ return IPNetwork(cidr_to_expand) def expand_range(startip, endip): """ Function to expand a given range and return an Array of IP Addresses that form the range. """ return IPRange(startip, endip) def range2cidr(ip1, ip2): """ Function to return the maximum CIDR given a range of IP's """ r1 = IPRange(ip1, ip2) return str(r1.cidrs()[-1]) def write_to_file(data, target_file): """ Function for writing returned data to a file """ with open(target_file, "w") as fd: fd.write(data) def generate_testname(name_len, name_suffix): """ This function easily allows to generate a testname to be used within the wildcard resolution and the NXDOMAIN hijacking checks """ testname = SystemRandom().sample( ascii_letters + digits, name_len) return "".join(testname) + "." + name_suffix def check_wildcard(res, domain_trg): """ Function for checking if Wildcard resolution is configured for a Domain """ testname = generate_testname(12, domain_trg) ips = res.get_a(testname) if not ips: return None wildcard_set = set() print_debug("Wildcard resolution is enabled on this domain") for ip in ips: print_debug(f"It is resolving to {ip[2]}") wildcard_set.add(ip[2]) print_debug("All queries will resolve to this list of addresses!!") return wildcard_set def check_nxdomain_hijack(nameserver): """ Function for checking if a name server performs NXDOMAIN hijacking """ testname = generate_testname(20, "com") res = dns.resolver.Resolver(configure=False) res.nameservers = [nameserver] res.timeout = 5.0 address = [] for record_type in ('A', 'AAAA'): try: answers = res.resolve(testname, record_type, tcp=True) except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.exception.Timeout, dns.resolver.NoAnswer, socket.error, dns.query.BadResponse): continue if answers: for ardata in answers.response.answer: for rdata in ardata: if rdata.rdtype == 5: target_ = rdata.target.to_text() if target_.endswith('.'): target_ = target_[:-1] address.append(target_) else: address.append(rdata.address) if not address: return False addresses = ", ".join(address) print_error(f"Nameserver {nameserver} performs NXDOMAIN hijacking") print_error(f"It resolves nonexistent domains to {addresses}") print_error("This server has been removed from the name server list!") return True def brute_tlds(res, domain, verbose=False, thread_num=None): """ This function performs a check of a given domain for known TLD values. prints and returns a dictionary of the results. """ global brtdata brtdata = [] # https://en.wikipedia.org/wiki/Country_code_top-level_domain#Types # https://www.iana.org/domains # Taken from http://data.iana.org/TLD/tlds-alpha-by-domain.txt itld = ['arpa'] # Generic TLD gtld = ['aaa', 'aarp', 'abarth', 'abb', 'abbott', 'abbvie', 'abc', 'able', 'abogado', 'abudhabi', 'academy', 'accenture', 'accountant', 'accountants', 'aco', 'actor', 'ads', 'adult', 'aeg', 'aetna', 'afl', 'africa', 'agakhan', 'agency', 'aig', 'airbus', 'airforce', 'airtel', 'akdn', 'alfaromeo', 'alibaba', 'alipay', 'allfinanz', 'allstate', 'ally', 'alsace', 'alstom', 'amazon', 'americanexpress', 'americanfamily', 'amex', 'amfam', 'amica', 'amsterdam', 'analytics', 'android', 'anquan', 'anz', 'aol', 'apartments', 'app', 'apple', 'aquarelle', 'arab', 'aramco', 'archi', 'army', 'art', 'arte', 'asda', 'associates', 'athleta', 'attorney', 'auction', 'audi', 'audible', 'audio', 'auspost', 'author', 'auto', 'autos', 'avianca', 'aws', 'axa', 'azure', 'baby', 'baidu', 'banamex', 'bananarepublic', 'band', 'bank', 'bar', 'barcelona', 'barclaycard', 'barclays', 'barefoot', 'bargains', 'baseball', 'basketball', 'bauhaus', 'bayern', 'bbc', 'bbt', 'bbva', 'bcg', 'bcn', 'beats', 'beauty', 'beer', 'bentley', 'berlin', 'best', 'bestbuy', 'bet', 'bharti', 'bible', 'bid', 'bike', 'bing', 'bingo', 'bio', 'black', 'blackfriday', 'blockbuster', 'blog', 'bloomberg', 'blue', 'bms', 'bmw', 'bnpparibas', 'boats', 'boehringer', 'bofa', 'bom', 'bond', 'boo', 'book', 'booking', 'bosch', 'bostik', 'boston', 'bot', 'boutique', 'box', 'bradesco', 'bridgestone', 'broadway', 'broker', 'brother', 'brussels', 'build', 'builders', 'business', 'buy', 'buzz', 'bzh', 'cab', 'cafe', 'cal', 'call', 'calvinklein', 'cam', 'camera', 'camp', 'canon', 'capetown', 'capital', 'capitalone', 'caravan', 'car', 'cards', 'care', 'career', 'careers', 'cars', 'casa', 'case', 'cash', 'casino', 'catering', 'catholic', 'cba', 'cbn', 'cbre', 'cbs', 'center', 'ceo', 'cern', 'cfa', 'cfd', 'chanel', 'channel', 'charity', 'chase', 'chat', 'cheap', 'chintai', 'christmas', 'chrome', 'church', 'cipriani', 'circle', 'cisco', 'citadel', 'citic', 'citi', 'city', 'cityeats', 'claims', 'cleaning', 'click', 'clinic', 'clinique', 'clothing', 'cloud', 'club', 'clubmed', 'coach', 'codes', 'coffee', 'college', 'cologne', 'comcast', 'com', 'commbank', 'community', 'company', 'compare', 'computer', 'comsec', 'condos', 'construction', 'consulting', 'contact', 'contractors', 'cookingchannel', 'cooking', 'cool', 'corsica', 'country', 'coupon', 'coupons', 'courses', 'cpa', 'creditcard', 'credit', 'creditunion', 'cricket', 'crown', 'crs', 'cruise', 'cruises', 'cuisinella', 'cymru', 'cyou', 'dabur', 'dad', 'dance', 'data', 'date', 'dating', 'datsun', 'day', 'dclk', 'dds', 'deal', 'dealer', 'deals', 'degree', 'delivery', 'dell', 'deloitte', 'delta', 'democrat', 'dental', 'dentist', 'desi', 'design', 'dev', 'dhl', 'diamonds', 'diet', 'digital', 'direct', 'directory', 'discount', 'discover', 'dish', 'diy', 'dnp', 'docs', 'doctor', 'dog', 'domains', 'dot', 'download', 'drive', 'dtv', 'dubai', 'dunlop', 'dupont', 'durban', 'dvag', 'dvr', 'earth', 'eat', 'eco', 'edeka', 'education', 'email', 'emerck', 'energy', 'engineer', 'engineering', 'enterprises', 'epson', 'equipment', 'ericsson', 'erni', 'esq', 'estate', 'etisalat', 'eurovision', 'eus', 'events', 'exchange', 'expert', 'exposed', 'express', 'extraspace', 'fage', 'fail', 'fairwinds', 'faith', 'family', 'fan', 'fans', 'farmers', 'farm', 'fashion', 'fast', 'fedex', 'feedback', 'ferrari', 'ferrero', 'fiat', 'fidelity', 'fido', 'film', 'final', 'finance', 'financial', 'fire', 'firestone', 'firmdale', 'fish', 'fishing', 'fit', 'fitness', 'flickr', 'flights', 'flir', 'florist', 'flowers', 'fly', 'food', 'foodnetwork', 'foo', 'football', 'ford', 'forex', 'forsale', 'forum', 'foundation', 'fox', 'free', 'fresenius', 'frl', 'frogans', 'frontdoor', 'frontier', 'ftr', 'fujitsu', 'fund', 'fun', 'furniture', 'futbol', 'fyi', 'gal', 'gallery', 'gallo', 'gallup', 'game', 'games', 'gap', 'garden', 'gay', 'gbiz', 'gdn', 'gea', 'gent', 'genting', 'george', 'ggee', 'gift', 'gifts', 'gives', 'giving', 'glass', 'gle', 'global', 'globo', 'gmail', 'gmbh', 'gmo', 'gmx', 'godaddy', 'gold', 'goldpoint', 'golf', 'goodyear', 'goog', 'google', 'goo', 'gop', 'got', 'grainger', 'graphics', 'gratis', 'green', 'gripe', 'grocery', 'group', 'guardian', 'gucci', 'guge', 'guide', 'guitars', 'guru', 'hair', 'hamburg', 'hangout', 'haus', 'hbo', 'hdfcbank', 'hdfc', 'healthcare', 'health', 'help', 'helsinki', 'here', 'hermes', 'hgtv', 'hiphop', 'hisamitsu', 'hitachi', 'hiv', 'hkt', 'hockey', 'holdings', 'holiday', 'homedepot', 'homegoods', 'homesense', 'homes', 'honda', 'horse', 'hospital', 'host', 'hosting', 'hoteles', 'hotels', 'hot', 'hotmail', 'house', 'how', 'hsbc', 'hughes', 'hyatt', 'hyundai', 'ibm', 'icbc', 'ice', 'icu', 'ieee', 'ifm', 'ikano', 'imamat', 'imdb', 'immobilien', 'immo', 'inc', 'industries', 'infiniti', 'info', 'ing', 'ink', 'institute', 'insurance', 'insure', 'international', 'intuit', 'investments', 'ipiranga', 'irish', 'ismaili', 'istanbul', 'ist', 'itau', 'itv', 'jaguar', 'java', 'jcb', 'jeep', 'jetzt', 'jewelry', 'jio', 'jll', 'jmp', 'jnj', 'joburg', 'jot', 'joy', 'jpmorgan', 'jprs', 'juegos', 'juniper', 'kaufen', 'kddi', 'kerryhotels', 'kerrylogistics', 'kerryproperties', 'kfh', 'kia', 'kids', 'kim', 'kinder', 'kindle', 'kitchen', 'kiwi', 'koeln', 'komatsu', 'kosher', 'kpmg', 'kpn', 'krd', 'kred', 'kuokgroup', 'kyoto', 'lacaixa', 'lamborghini', 'lamer', 'lancaster', 'lancia', 'land', 'landrover', 'lanxess', 'lasalle', 'latino', 'lat', 'latrobe', 'law', 'lawyer', 'lds', 'lease', 'leclerc', 'lefrak', 'legal', 'lego', 'lexus', 'lgbt', 'lidl', 'lifeinsurance', 'life', 'lifestyle', 'lighting', 'like', 'lilly', 'limited', 'limo', 'lincoln', 'linde', 'link', 'lipsy', 'live', 'living', 'llc', 'llp', 'loan', 'loans', 'locker', 'locus', 'lol', 'london', 'lotte', 'lotto', 'love', 'lplfinancial', 'lpl', 'ltda', 'ltd', 'lundbeck', 'luxe', 'luxury', 'macys', 'madrid', 'maif', 'maison', 'makeup', 'management', 'mango', 'man', 'map', 'marketing', 'market', 'markets', 'marriott', 'marshalls', 'maserati', 'mattel', 'mba', 'mckinsey', 'media', 'med', 'meet', 'melbourne', 'meme', 'memorial', 'men', 'menu', 'merckmsd', 'miami', 'microsoft', 'mini', 'mint', 'mit', 'mitsubishi', 'mlb', 'mls', 'mma', 'mobile', 'mobi', 'moda', 'moe', 'moi', 'mom', 'monash', 'money', 'monster', 'mormon', 'mortgage', 'moscow', 'moto', 'motorcycles', 'movie', 'mov', 'msd', 'mtn', 'mtr', 'music', 'mutual', 'nab', 'nagoya', 'natura', 'navy', 'nba', 'nec', 'netbank', 'netflix', 'net', 'network', 'neustar', 'new', 'news', 'nextdirect', 'next', 'nexus', 'nfl', 'ngo', 'nhk', 'nico', 'nike', 'nikon', 'ninja', 'nissan', 'nissay', 'nokia', 'northwesternmutual', 'norton', 'now', 'nowruz', 'nowtv', 'nra', 'nrw', 'ntt', 'nyc', 'obi', 'observer', 'office', 'okinawa', 'olayangroup', 'olayan', 'oldnavy', 'ollo', 'omega', 'one', 'ong', 'online', 'onl', 'ooo', 'open', 'oracle', 'orange', 'organic', 'org', 'origins', 'osaka', 'otsuka', 'ott', 'ovh', 'page', 'panasonic', 'paris', 'pars', 'partners', 'parts', 'party', 'passagens', 'pay', 'pccw', 'pet', 'pfizer', 'pharmacy', 'phd', 'philips', 'phone', 'photography', 'photo', 'photos', 'physio', 'pics', 'pictet', 'pictures', 'pid', 'ping', 'pink', 'pin', 'pioneer', 'pizza', 'place', 'play', 'playstation', 'plumbing', 'plus', 'pnc', 'pohl', 'poker', 'politie', 'porn', 'pramerica', 'praxi', 'press', 'prime', 'prod', 'productions', 'prof', 'progressive', 'promo', 'properties', 'property', 'protection', 'prudential', 'pru', 'pub', 'pwc', 'qpon', 'quebec', 'quest', 'racing', 'radio', 'read', 'realestate', 'realtor', 'realty', 'recipes', 'red', 'redstone', 'redumbrella', 'rehab', 'reisen', 'reise', 'reit', 'reliance', 'ren', 'rentals', 'rent', 'repair', 'report', 'republican', 'restaurant', 'rest', 'review', 'reviews', 'rexroth', 'richardli', 'rich', 'ricoh', 'ril', 'rio', 'rip', 'rocher', 'rocks', 'rodeo', 'rogers', 'room', 'rsvp', 'rugby', 'ruhr', 'run', 'rwe', 'ryukyu', 'saarland', 'safe', 'safety', 'sakura', 'sale', 'salon', 'samsclub', 'samsung', 'sandvikcoromant', 'sandvik', 'sanofi', 'sap', 'sarl', 'sas', 'save', 'saxo', 'sbi', 'sbs', 'sca', 'scb', 'schaeffler', 'schmidt', 'scholarships', 'school', 'schule', 'schwarz', 'science', 'scot', 'search', 'seat', 'secure', 'security', 'seek', 'select', 'sener', 'services', 'seven', 'sew', 'sex', 'sexy', 'sfr', 'shangrila', 'sharp', 'shaw', 'shell', 'shia', 'shiksha', 'shoes', 'shopping', 'shop', 'shouji', 'show', 'showtime', 'silk', 'sina', 'singles', 'site', 'skin', 'ski', 'skype', 'sky', 'sling', 'smart', 'smile', 'sncf', 'soccer', 'social', 'softbank', 'software', 'sohu', 'solar', 'solutions', 'song', 'sony', 'soy', 'space', 'spa', 'sport', 'spot', 'srl', 'stada', 'staples', 'star', 'statebank', 'statefarm', 'stcgroup', 'stc', 'stockholm', 'storage', 'store', 'stream', 'studio', 'study', 'style', 'sucks', 'supplies', 'supply', 'support', 'surf', 'surgery', 'suzuki', 'swatch', 'swiss', 'sydney', 'systems', 'tab', 'taipei', 'talk', 'taobao', 'target', 'tatamotors', 'tatar', 'tattoo', 'taxi', 'tax', 'tci', 'tdk', 'team', 'technology', 'tech', 'temasek', 'tennis', 'teva', 'thd', 'theater', 'theatre', 'tiaa', 'tickets', 'tienda', 'tiffany', 'tips', 'tires', 'tirol', 'tjmaxx', 'tjx', 'tkmaxx', 'tmall', 'today', 'tokyo', 'tools', 'top', 'toray', 'toshiba', 'total', 'tours', 'town', 'toyota', 'toys', 'trade', 'trading', 'training', 'travelchannel', 'travelersinsurance', 'travelers', 'trust', 'trv', 'tube', 'tui', 'tunes', 'tushu', 'tvs', 'ubank', 'ubs', 'unicom', 'university', 'uno', 'uol', 'ups', 'vacations', 'vana', 'vanguard', 'vegas', 'ventures', 'verisign', 'versicherung', 'vet', 'viajes', 'video', 'vig', 'viking', 'villas', 'vin', 'vip', 'virgin', 'visa', 'vision', 'viva', 'vivo', 'vlaanderen', 'vodka', 'volkswagen', 'volvo', 'vote', 'voting', 'voto', 'voyage', 'vuelos', 'wales', 'walmart', 'walter', 'wanggou', 'wang', 'watches', 'watch', 'weatherchannel', 'weather', 'webcam', 'weber', 'website', 'wedding', 'wed', 'weibo', 'weir', 'whoswho', 'wien', 'wiki', 'williamhill', 'windows', 'wine', 'winners', 'win', 'wme', 'wolterskluwer', 'woodside', 'works', 'work', 'world', 'wow', 'wtc', 'wtf', 'xbox', 'xerox', 'xfinity', 'xihuan', 'xin', 'xn--11b4c3d', 'xn--1ck2e1b', 'xn--1qqw23a', 'xn--30rr7y', 'xn--3bst00m', 'xn--3ds443g', 'xn--3pxu8k', 'xn--42c2d9a', 'xn--45q11c', 'xn--4gbrim', 'xn--55qw42g', 'xn--55qx5d', 'xn--5su34j936bgsg', 'xn--5tzm5g', 'xn--6frz82g', 'xn--6qq986b3xl', 'xn--80adxhks', 'xn--80aqecdr1a', 'xn--80asehdb', 'xn--80aswg', 'xn--8y0a063a', 'xn--9dbq2a', 'xn--9et52u', 'xn--9krt00a', 'xn--b4w605ferd', 'xn--bck1b9a5dre4c', 'xn--c1avg', 'xn--c2br7g', 'xn--cck2b3b', 'xn--cckwcxetd', 'xn--cg4bki', 'xn--czr694b', 'xn--czrs0t', 'xn--czru2d', 'xn--d1acj3b', 'xn--eckvdtc9d', 'xn--efvy88h', 'xn--fct429k', 'xn--fhbei', 'xn--fiq228c5hs', 'xn--fiq64b', 'xn--fjq720a', 'xn--flw351e', 'xn--fzys8d69uvgm', 'xn--g2xx48c', 'xn--gckr3f0f', 'xn--gk3at1e', 'xn--hxt814e', 'xn--i1b6b1a6a2e', 'xn--imr513n', 'xn--io0a7i', 'xn--j1aef', 'xn--jlq480n2rg', 'xn--jvr189m', 'xn--kcrx77d1x4a', 'xn--kput3i', 'xn--mgba3a3ejt', 'xn--mgba7c0bbn0a', 'xn--mgbaakc7dvf', 'xn--mgbab2bd', 'xn--mgbca7dzdo', 'xn--mgbi4ecexp', 'xn--mgbt3dhd', 'xn--mk1bu44c', 'xn--mxtq1m', 'xn--ngbc5azd', 'xn--ngbe9e0a', 'xn--ngbrx', 'xn--nqv7fs00ema', 'xn--nqv7f', 'xn--nyqy26a', 'xn--otu796d', 'xn--p1acf', 'xn--pssy2u', 'xn--q9jyb4c', 'xn--qcka1pmc', 'xn--rhqv96g', 'xn--rovu88b', 'xn--ses554g', 'xn--t60b56a', 'xn--tckwe', 'xn--tiq49xqyj', 'xn--unup4y', 'xn--vermgensberater-ctb', 'xn--vermgensberatung-pwb', 'xn--vhquv', 'xn--vuq861b', 'xn--w4r85el8fhu5dnra', 'xn--w4rs40l', 'xn--xhq521b', 'xn--zfr164b', 'xyz', 'yachts', 'yahoo', 'yamaxun', 'yandex', 'yodobashi', 'yoga', 'yokohama', 'youtube', 'you', 'yun', 'zappos', 'zara', 'zero', 'zip', 'zone', 'zuerich'] # Generic restricted TLD grtld = ['biz', 'name', 'pro'] # Sponsored TLD stld = ['aero', 'asia', 'cat', 'coop', 'edu', 'gov', 'int', 'jobs', 'mil', 'museum', 'post', 'tel', 'travel', 'xxx'] # Country Code TLD cctld = ['ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cw', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'ss', 'st', 'su', 'sv', 'sx', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'xn--2scrj9c', 'xn--3e0b707e', 'xn--3hcrj9c', 'xn--45br5cyl', 'xn--45brj9c', 'xn--4dbrk0ce', 'xn--54b7fta0cc', 'xn--80ao21a', 'xn--90a3ac', 'xn--90ae', 'xn--90ais', 'xn--clchc0ea0b2g2a9gcd', 'xn--d1alf', 'xn--e1a4c', 'xn--fiqs8s', 'xn--fiqz9s', 'xn--fpcrj9c3d', 'xn--fzc2c9e2c', 'xn--gecrj9c', 'xn--h2breg3eve', 'xn--h2brj9c8c', 'xn--h2brj9c', 'xn--j1amh', 'xn--j6w193g', 'xn--kprw13d', 'xn--kpry57d', 'xn--l1acc', 'xn--lgbbat1ad8j', 'xn--mgb9awbf', 'xn--mgba3a4f16a', 'xn--mgbaam7a8h', 'xn--mgbah1a3hjkrd', 'xn--mgbai9azgqp6j', 'xn--mgbayh7gpa', 'xn--mgbbh1a71e', 'xn--mgbbh1a', 'xn--mgbc0a9azcg', 'xn--mgbcpq6gpa1a', 'xn--mgberp4a5d4ar', 'xn--mgbgu82a', 'xn--mgbpl2fh', 'xn--mgbtx2b', 'xn--mgbx4cd0ab', 'xn--mix891f', 'xn--node', 'xn--o3cw4h', 'xn--ogbpf8fl', 'xn--p1ai', 'xn--pgbs0dh', 'xn--q7ce6a', 'xn--qxa6a', 'xn--qxam', 'xn--rvc1e0am3e', 'xn--s9brj9c', 'xn--wgbh1c', 'xn--wgbl6a', 'xn--xkc2al3hye2a', 'xn--xkc2dl3a5ee0h', 'xn--y9a3aq', 'xn--yfro4i67o', 'xn--ygbi2ammx', 'ye', 'yt', 'za', 'zm', 'zw'] domain_main = domain.split(".")[0] # Let the user know how long it could take all_tlds_len = len(itld) + len(gtld) + len(grtld) + len(stld) + len(cctld) duration = time.strftime('%H:%M:%S', time.gmtime(all_tlds_len / 3)) print_status(f"The operation could take up to: {duration}") total_tlds = list(set(itld + gtld + grtld + stld)) if verbose: for tld in total_tlds: print_status(f'Trying: {domain_main}.{tld}') for cc in cctld: print_status(f'Trying: {domain_main}.{cc}') for cc, tld in zip(cctld, total_tlds): print_status(f'Trying: {domain_main}.{cc}.{tld}') found_tlds = [] try: with futures.ThreadPoolExecutor(max_workers=thread_num) as executor: future_results = {**{executor.submit(res.get_ip, f'{domain_main}.{tld}'): tld for tld in total_tlds}, **{executor.submit(res.get_ip, f'{domain_main}.{cc}'): cc for cc in cctld}, **{executor.submit(res.get_ip, f'{domain_main}.{cc}.{tld}'): (cc, tld) for (cc, tld) in zip(cctld, total_tlds)}} # Display logs as soon as a thread is finished for future in futures.as_completed(future_results): res = future.result() for type_, name_, addr_ in res: if type_ in ['A', 'AAAA']: print_good(f"\t {type_} {name_} {addr_}") found_tlds.append([{"type": type_, "name": name_, "address": addr_}]) print_good(f"{len(found_tlds)} Records Found") except Exception as e: print_error(e) return found_tlds def brute_srv(res, domain, verbose=False, thread_num=None): """ Brute-force most common SRV records for a given Domain. Returns an Array with records found. """ global brtdata brtdata = [] returned_records = [] srvrcd = [ '_gc._tcp.', '_kerberos._tcp.', '_kerberos._udp.', '_ldap._tcp.', '_test._tcp.', '_sips._tcp.', '_sip._udp.', '_sip._tcp.', '_aix._tcp.', '_aix._tcp.', '_finger._tcp.', '_ftp._tcp.', '_http._tcp.', '_nntp._tcp.', '_telnet._tcp.', '_whois._tcp.', '_h323cs._tcp.', '_h323cs._udp.', '_h323be._tcp.', '_h323be._udp.', '_h323ls._tcp.', '_https._tcp.', '_h323ls._udp.', '_sipinternal._tcp.', '_sipinternaltls._tcp.', '_sip._tls.', '_sipfederationtls._tcp.', '_jabber._tcp.', '_xmpp-server._tcp.', '_xmpp-client._tcp.', '_imap.tcp.', '_certificates._tcp.', '_crls._tcp.', '_pgpkeys._tcp.', '_pgprevokations._tcp.', '_cmp._tcp.', '_svcp._tcp.', '_crl._tcp.', '_ocsp._tcp.', '_PKIXREP._tcp.', '_smtp._tcp.', '_hkp._tcp.', '_hkps._tcp.', '_jabber._udp.', '_xmpp-server._udp.', '_xmpp-client._udp.', '_jabber-client._tcp.', '_jabber-client._udp.', '_kerberos.tcp.dc._msdcs.', '_ldap._tcp.ForestDNSZones.', '_ldap._tcp.dc._msdcs.', '_ldap._tcp.pdc._msdcs.', '_ldap._tcp.gc._msdcs.', '_kerberos._tcp.dc._msdcs.', '_kpasswd._tcp.', '_kpasswd._udp.', '_imap._tcp.', '_imaps._tcp.', '_submission._tcp.', '_pop3._tcp.', '_pop3s._tcp.', '_caldav._tcp.', '_caldavs._tcp.', '_carddav._tcp.', '_carddavs._tcp.', '_x-puppet._tcp.', '_x-puppet-ca._tcp.', '_autodiscover._tcp.'] try: with futures.ThreadPoolExecutor(max_workers=thread_num) as executor: if verbose: for srvtype in srvrcd: srvtype_domain = srvtype + domain print_status(f"Trying {srvtype_domain}...") future_results = {executor.submit(res.get_srv, srvtype + domain): srvtype for srvtype in srvrcd} # Display logs as soon as a thread is finished for future in futures.as_completed(future_results): res = future.result() for type_, name_, target_, addr_, port_, priority_ in res: returned_records.append({"type": type_, "name": name_, "target": target_, "address": addr_, "port": port_}) print_good(f"\t {type_} {name_} {target_} {addr_} {port_}") except Exception as e: print_error(e) if len(returned_records) > 0: print_good(f"{len(returned_records)} Records Found") else: print_error(f"No SRV Records Found for {domain}") return returned_records def brute_reverse(res, ip_list, verbose=False, thread_num=None): """ Reverse look-up brute force for given CIDR example 192.168.1.1/24. Returns an Array of found records. """ global brtdata brtdata = [] returned_records = [] for i in range(len(ip_list)): start_ip = ip_list[i][0] end_ip = ip_list[i][-1] print_status("Performing Reverse Lookup from {0} to {1}".format(start_ip, end_ip)) # Resolve each IP in a separate thread in groups of 255 hosts. ip_range = range(len(ip_list[i]) - 1) ip_group_size = 255 for ip_group in [ip_range[j:j + ip_group_size] for j in range(0, len(ip_range), ip_group_size)]: try: if verbose: for x in ip_group: ipaddress = str(ip_list[x]) print_status(f"Trying {ipaddress}") with futures.ThreadPoolExecutor(max_workers=thread_num) as executor: future_results = {executor.submit(res.get_ptr, str(ip_list[i][x])): x for x in ip_group} # Display logs as soon as a thread is finished for future in futures.as_completed(future_results): res_ = future.result() for type_, name_, addr_ in res_: returned_records.append([{'type': type_, 'name': name_, 'address': addr_}]) print_good(f"\t {type_} {name_} {addr_}") except Exception as e: print_error(e) print_good(f"{len(returned_records)} Records Found") return returned_records def brute_domain(res, dictfile, dom, filter_=None, verbose=False, ignore_wildcard=False, thread_num=None): """ Main Function for domain brute forcing """ global brtdata brtdata = [] # Check if wildcard resolution is enabled wildcard_set = check_wildcard(res, dom) if wildcard_set and not ignore_wildcard: print_status("Do you wish to continue? [Y/n]") i = input().lower().strip() if i not in ['y', 'yes']: print_error("Domain bruteforcing aborted.") return None found_hosts = [] # Check if Dictionary file exists if os.path.isfile(dictfile): with open(dictfile) as fd: targets = [f"{line.strip()}.{dom.strip()}" for line in fd] if verbose: for target in targets: print_status(f"Trying {target}") with futures.ThreadPoolExecutor(max_workers=thread_num) as executor: future_results = {executor.submit(res.get_ip, target): target for target in targets} # Display logs as soon as a thread is finished for future in futures.as_completed(future_results): res = future.result() for type_, name_, address_or_target_ in res: print_and_append = False found_dict = {"type": type_, "name": name_} if type_ in ['A', 'AAAA']: # Filter Records if filtering was enabled if filter_: if not wildcard_set or address_or_target_ not in wildcard_set: print_and_append = True found_dict["address"] = address_or_target_ else: print_and_append = True found_dict["address"] = address_or_target_ elif type_ == 'CNAME': print_and_append = True found_dict["target"] = address_or_target_ if print_and_append: print_good(f"\t {type_} {name_} {address_or_target_}") found_hosts.append(found_dict) brtdata.append(res) print_good(f"{len(found_hosts)} Records Found") return found_hosts def in_cache(res, dict_file, ns): """ Function for Cache Snooping, it will check a given NS server for specific type of records for a given domain are in it's cache. """ found_records = [] with open(dict_file) as f: for zone in f: dom_to_query = zone.strip() query = dns.message.make_query(dom_to_query, dns.rdatatype.A, dns.rdataclass.IN) query.flags ^= dns.flags.RD answer = res.query(query, ns) for an in answer.answer: for rcd in an: if rcd.rdtype not in [1, 5]: continue found_record = {"name": an.name, "ttl": an.ttl} status = f"\tName: {an.name} TTL: {an.ttl} " if rcd.rdtype == 1: found_record["type"] = "A" found_record["address"] = rcd.address status += f"Address: {rcd.address} Type: A" elif rcd.rdtype == 5: found_record["type"] = "CNAME" found_record["target"] = rcd.target status += f"Target: {rcd.target} Type: CNAME" print_status(status) found_records.append(found_record) return found_records def se_result_process(res, se_entries): """ This function processes the results returned from a Search Engine and does an A and AAAA query for the IP of the found host. Prints and returns a dictionary with all the results found. """ if not se_entries: return None resolved_se_entries = [] for se_entry in se_entries: for type_, name_, address_or_target_ in res.get_ip(se_entry): if type_ not in ['A', 'CNAME']: continue print_status(f"\t {type_} {name_} {address_or_target_}") resolved_se_entry = {"type": type_, "name": name_} if type_ == 'A': resolved_se_entry["address"] = address_or_target_ elif type_ == 'CNAME': resolved_se_entry["target"] = address_or_target_ resolved_se_entries.append(resolved_se_entry) print_good(f"{len(resolved_se_entries)} Records Found") return resolved_se_entries def get_whois_nets_iplist(ip_list): """ This function will perform whois queries against a list of IP's and extract the net ranges and if available the organization list of each and remover any duplicate entries. """ seen = {} idfun = repr found_nets = [] for ip in ip_list: if ip != "no_ip": # Find appropriate Whois Server for the IP whois_server = get_whois(ip) # If we get a Whois server Process get the whois and process. if whois_server: whois_data = whois(ip, whois_server) arin_style = re.search("NetRange", whois_data) ripe_apic_style = re.search("netname", whois_data) if arin_style or ripe_apic_style: net = get_whois_nets(whois_data) if net: for network in net: org = get_whois_orgname(whois_data) found_nets.append({"start": network[0], "end": network[1], "orgname": "".join(org)}) else: for line in whois_data.splitlines(): recordentrie = re.match(r"^(.*)\s\S*-\w*\s\S*\s(\S*\s-\s\S*)", line) if recordentrie: org = recordentrie.group(1) net = get_whois_nets(recordentrie.group(2)) for network in net: found_nets.append({"start": network[0], "end": network[1], "orgname": "".join(org)}) # Remove Duplicates return [seen.setdefault(idfun(e), e) for e in found_nets if idfun(e) not in seen] def whois_ips(res, ip_list): """ This function will process the results of the whois lookups and present the user with the list of net ranges found and ask the user if he wishes to perform a reverse lookup on any of the ranges or all the ranges. """ found_records = [] print_status("Performing Whois lookup against records found.") list_whois = get_whois_nets_iplist(unique(ip_list)) if len(list_whois) > 0: print_status("The following IP Ranges were found:") for i in range(len(list_whois)): print_status( "\t {0} {1}-{2} {3}".format(str(i) + ")", list_whois[i]["start"], list_whois[i]["end"], list_whois[i]["orgname"])) print_status("What Range do you wish to do a Reverse Lookup for?") print_status("number, comma separated list, a for all or n for none") val = sys.stdin.readline()[:-1] answer = str(val).split(",") if "a" in answer: for i in range(len(list_whois)): print_status("Performing Reverse Lookup of range {0}-{1}".format(list_whois[i]['start'], list_whois[i]['end'])) found_records.append(brute_reverse(res, expand_range(list_whois[i]['start'], list_whois[i]['end']))) elif "n" in answer: print_status("No Reverse Lookups will be performed.") else: for a in answer: net_selected = list_whois[int(a)] print_status(net_selected['orgname']) print_status( "Performing Reverse Lookup of range {0}-{1}".format(net_selected['start'], net_selected['end'])) found_records.append(brute_reverse(res, expand_range(net_selected['start'], net_selected['end']))) else: print_error("No IP Ranges were found in the Whois query results") return found_records def prettify(elem): """ Return a pretty-printed XML string for the Element. """ rough_string = ElementTree.tostring(elem, 'utf-8') reparsed = minidom.parseString(rough_string) return reparsed.toprettyxml(indent=" ") def dns_record_from_dict(record_dict_list, scan_info, domain): """ Saves DNS Records to XML Given a a list of dictionaries each representing a record to be saved, returns the XML Document formatted. """ xml_doc = Element("records") for r in record_dict_list: elem = Element("record") if type(r) is not str: try: for k, v in r.items(): try: k = str(k) v = str(v) elem.attrib[k] = v except Exception: print_error("Could not convert key or value to unicode: '{0} = {1}'".format((repr(k)), (repr(v)))) print_error("In element: {0}".format(repr(elem.attrib))) continue xml_doc.append(elem) except AttributeError: continue scanelem = Element("scaninfo") scanelem.attrib["arguments"] = scan_info[0] scanelem.attrib["time"] = scan_info[1] xml_doc.append(scanelem) if domain is not None: domelem = Element("domain") domelem.attrib["domain_name"] = domain xml_doc.append(domelem) return prettify(xml_doc) def create_db(db): """ Function will create the specified database if not present and it will create the table needed for storing the data returned by the modules. """ # Connect to the DB con = sqlite3.connect(db) # Create SQL Queries to be used in the script make_table = """CREATE TABLE data ( serial integer Primary Key Autoincrement, domain TEXT(256), type TEXT(8), name TEXT(32), address TEXT(32), target TEXT(32), port TEXT(8), text TEXT(256), zt_dns TEXT(32) )""" # Set the cursor for connection con.isolation_level = None cur = con.cursor() # Connect and create table cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='data';") if cur.fetchone() is None: cur.execute(make_table) con.commit() else: pass def make_csv(data): csv_data = "Type,Name,Address,Target,Port,String\n" for record_tmp in data: record = record_tmp # make sure that we are working with a dictionary. if not isinstance(record, dict): # the representation of data[i] is a list of one dictionary # we want to exploit this dictionary record = record_tmp[0] type_ = record['type'].upper() csv_data += type_ + "," if type_ in ['PTR', 'A', 'AAAA', 'NS', 'SOA', 'MX']: if type_ in ['PTR', 'A', 'AAAA']: csv_data += record["name"] elif type_ == 'NS': csv_data += record["target"] elif type_ == 'SOA': csv_data += record["mname"] elif type_ == 'MX': csv_data += record["exchange"] csv_data += "," + record['address'] + ("," * 3) + "\n" elif type_ in ['TXT', 'SPF']: if 'zone_server' not in record: if type_ == 'SPF': csv_data += record["domain"] else: csv_data += record['name'] csv_data += ("," * 4) + "'{}'\n".format(record['strings']) elif type_ == 'SRV': items = [record["name"], record["address"], record["target"], record["port"]] csv_data += ",".join(items) + ",\n" elif type_ == 'CNAME': csv_data += record['name'] + ("," * 2) if 'target' in record: csv_data += record['target'] csv_data += ("," * 2) + "\n" else: # Handle not common records del record["type"] s = "; ".join([f"{k}={v}" for k, v in record.items()]) csv_data += ("," * 4) + f"'{s}'\n" return csv_data def write_json(jsonfile, data, scan_info): """ Function to write DNS Records SOA, PTR, NS, A, AAAA, MX, TXT, SPF and SRV to JSON file. """ scaninfo = {"type": "ScanInfo", "arguments": scan_info[0], "date": scan_info[1]} data.insert(0, scaninfo) json_data = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')) write_to_file(json_data, jsonfile) def write_db(db, data): """ Function to write DNS Records SOA, PTR, NS, A, AAAA, MX, TXT, SPF and SRV to DB. """ con = sqlite3.connect(db) # Set the cursor for connection con.isolation_level = None cur = con.cursor() # Normalize the dictionary data for n in data: if re.match(r'PTR|^[A]$|AAAA', n['type']): query = 'insert into data( domain, type, name, address ) ' + \ 'values( "%(domain)s", "%(type)s", "%(name)s","%(address)s" )' % n elif re.match(r'NS$', n['type']): query = 'insert into data( domain, type, name, address ) ' + \ 'values( "%(domain)s", "%(type)s", "%(target)s", "%(address)s" )' % n elif re.match(r'SOA', n['type']): query = 'insert into data( domain, type, name, address ) ' + \ 'values( "%(domain)s", "%(type)s", "%(mname)s", "%(address)s" )' % n elif re.match(r'MX', n['type']): query = 'insert into data( domain, type, name, address ) ' + \ 'values( "%(domain)s", "%(type)s", "%(exchange)s", "%(address)s" )' % n elif re.match(r'TXT', n['type']): query = 'insert into data( domain, type, text) ' + \ 'values( "%(domain)s", "%(type)s","%(strings)s" )' % n elif re.match(r'SPF', n['type']): query = 'insert into data( domain, type, text) ' + \ 'values( "%(domain)s", "%(type)s","%(strings)s" )' % n elif re.match(r'SRV', n['type']): query = 'insert into data( domain, type, name, target, address, port ) ' + \ 'values( "%(domain)s", "%(type)s", "%(name)s" , "%(target)s", "%(address)s" ,"%(port)s" )' % n elif re.match(r'CNAME', n['type']): query = 'insert into data( domain, type, name, target ) ' + \ 'values( "%(domain)s", "%(type)s", "%(name)s" , "%(target)s" )' % n else: # Handle not common records t = n['type'] del n['type'] record_data = "".join(['%s=%s,' % (key, value) for key, value in n.items()]) records = [t, record_data] query = "insert into data(domain,type,text) values (\"%(domain)\", '" + \ records[0] + "','" + records[1] + "')" # Execute Query and commit cur.execute(query) con.commit() def get_nsec_type(domain, res): target = "0." + domain answer = get_a_answer(res, target, res._res.nameservers[0], res._res.timeout) for a in answer.authority: if a.rdtype == 50: return "NSEC3" elif a.rdtype == 47: return "NSEC" def dns_sec_check(domain, res): """ Check if a zone is configured for DNSSEC and if so if NSEC or NSEC3 is used. """ try: answer = res.resolve(domain, 'DNSKEY', res._res.nameservers[0]) print_status("DNSSEC is configured for {0}".format(domain)) nsectype = get_nsec_type(domain, res) print_status("DNSKEYs:") for rdata in answer: if rdata.flags == 256: key_type = "ZSK" if rdata.flags == 257: key_type = "KSk" print_status("\t{0} {1} {2} {3}".format(nsectype, key_type, algorithm_to_text(rdata.algorithm), dns.rdata._hexify(rdata.key))) except dns.resolver.NXDOMAIN: print_error(f"Could not resolve domain: {domain}") sys.exit(1) except dns.resolver.NoNameservers: print_error(f"All nameservers failed to answer the DNSSEC query for {domain}") except dns.exception.Timeout: print_error("A timeout error occurred please make sure you can reach the target DNS Servers") print_error("directly and requests are not being filtered. Increase the timeout from {0} second".format( res._res.timeout)) print_error("to a higher number with --lifetime