All Projects → Badcow → Dns

Badcow / Dns

Licence: mit
The aim of this project is to create abstract object representations of DNS records in PHP. The project consists of various classes representing DNS objects (such as Zone, ResourceRecord, and various RData types), a parser to convert BIND style text files to the PHP objects, and builders to create aesthetically pleasing BIND records.

Labels

Projects that are alternatives of or similar to Dns

Redirect.center
Redirect domains using DNS only
Stars: ✭ 185 (-14.35%)
Mutual labels:  dns
Nsd
The NLnet Labs Name Server Daemon (NSD) is an authoritative, RFC compliant DNS nameserver.
Stars: ✭ 197 (-8.8%)
Mutual labels:  dns
Ts Dns
Telescope DNS,简单易用的DNS分组/转发器
Stars: ✭ 205 (-5.09%)
Mutual labels:  dns
Alfred Network Workflow
Show and change your network settings
Stars: ✭ 186 (-13.89%)
Mutual labels:  dns
Rethink App
DNS over HTTPS / DNS over Tor / DNSCrypt client, firewall, and connection tracker for Android.
Stars: ✭ 188 (-12.96%)
Mutual labels:  dns
Knot Resolver
Knot Resolver - resolve DNS names like it's 2021
Stars: ✭ 200 (-7.41%)
Mutual labels:  dns
Dns Heaven
Fixes stupid macOS DNS stack (/etc/resolv.conf)
Stars: ✭ 182 (-15.74%)
Mutual labels:  dns
Stacks Blockchain
The Stacks 2.0 blockchain implementation
Stars: ✭ 2,549 (+1080.09%)
Mutual labels:  dns
Polaris Gslb
A free, open source GSLB (Global Server Load Balancing) solution.
Stars: ✭ 193 (-10.65%)
Mutual labels:  dns
Pdlist
A passive subdomain finder
Stars: ✭ 204 (-5.56%)
Mutual labels:  dns
Dnsautorebinding
ssrf、ssrfIntranetFuzz、dnsRebinding、recordEncode、dnsPoisoning、Support ipv4/ipv6
Stars: ✭ 188 (-12.96%)
Mutual labels:  dns
Laitos
Top geek's chindogu - personal assistant over satellite/telephone/SMS/chatbot, plus web infrastructure servers (web & mail, ad-free DNS, web proxy, SNMP, etc)
Stars: ✭ 191 (-11.57%)
Mutual labels:  dns
Django Oms
加强版运维系统,集成工单、发布、监控、管理dns、saltstack
Stars: ✭ 201 (-6.94%)
Mutual labels:  dns
Dnsblast
A simple and stupid load testing tool for DNS resolvers
Stars: ✭ 185 (-14.35%)
Mutual labels:  dns
Maradns
MaraDNS: A small open-source DNS server | 2020 updates: Lua and blocklist support, etc.
Stars: ✭ 206 (-4.63%)
Mutual labels:  dns
Dns Java
DNS wrapper library that provides SRV lookup functionality
Stars: ✭ 183 (-15.28%)
Mutual labels:  dns
Bind9
Mirror of https://gitlab.isc.org/isc-projects/bind9, please submit issues and PR/MRs in the GitLab.
Stars: ✭ 197 (-8.8%)
Mutual labels:  dns
Gorecon
Gorecon is a All in one Reconnaissance Tool , a.k.a swiss knife for Reconnaissance , A tool that every pentester/bughunter might wanna consider into their arsenal
Stars: ✭ 208 (-3.7%)
Mutual labels:  dns
Pdns
PowerDNS Authoritative, PowerDNS Recursor, dnsdist
Stars: ✭ 2,575 (+1092.13%)
Mutual labels:  dns
Swan
Swan stands for Stuff We All Need. Unosquare's collection of C# extension methods and classes.
Stars: ✭ 202 (-6.48%)
Mutual labels:  dns

Badcow DNS Library

The aim of this project is to create abstract object representations of DNS records in PHP. The project consists of various classes representing DNS objects (such as Zone, ResourceRecord, and various RData types), a parser to convert BIND style text files to the PHP objects, and builders to create aesthetically pleasing BIND records.

The library can parse and encode DNS messages enabling developers to create DNS client/server platforms in pure PHP.

Build Status

Build Status: PHP 7 Build Status: PHP 8

Contents

  1. Example usage
  2. Example Output
  3. Supported Types
  4. Parsing BIND Records

Example usage

require_once '/path/to/vendor/autoload.php';

use Badcow\DNS\Classes;
use Badcow\DNS\Zone;
use Badcow\DNS\Rdata\Factory;
use Badcow\DNS\ResourceRecord;
use Badcow\DNS\AlignedBuilder;

$zone = new Zone('example.com.');
$zone->setDefaultTtl(3600);

$soa = new ResourceRecord;
$soa->setName('@');
$soa->setClass(Classes::INTERNET);
$soa->setRdata(Factory::Soa(
    'example.com.',
    'post.example.com.',
    '2014110501',
    3600,
    14400,
    604800,
    3600
));

$ns1 = new ResourceRecord;
$ns1->setName('@');
$ns1->setClass(Classes::INTERNET);
$ns1->setRdata(Factory::Ns('ns1.nameserver.com.'));

$ns2 = new ResourceRecord;
$ns2->setName('@');
$ns2->setClass(Classes::INTERNET);
$ns2->setRdata(Factory::Ns('ns2.nameserver.com.'));

$a = new ResourceRecord;
$a->setName('sub.domain');
$a->setRdata(Factory::A('192.168.1.42'));
$a->setComment('This is a local ip.');

$a6 = new ResourceRecord;
$a6->setName('ipv6.domain');
$a6->setRdata(Factory::Aaaa('::1'));
$a6->setComment('This is an IPv6 domain.');

$mx1 = new ResourceRecord;
$mx1->setName('@');
$mx1->setRdata(Factory::Mx(10, 'mail-gw1.example.net.'));

$mx2 = new ResourceRecord;
$mx2->setName('@');
$mx2->setRdata(Factory::Mx(20, 'mail-gw2.example.net.'));

$mx3 = new ResourceRecord;
$mx3->setName('@');
$mx3->setRdata(Factory::Mx(30, 'mail-gw3.example.net.'));

$zone->addResourceRecord($soa);
$zone->addResourceRecord($mx2);
$zone->addResourceRecord($ns1);
$zone->addResourceRecord($mx3);
$zone->addResourceRecord($a);
$zone->addResourceRecord($a6);
$zone->addResourceRecord($ns2);
$zone->addResourceRecord($mx1);

$builder = new AlignedBuilder();
echo $builder->build($zone);

Output

$ORIGIN example.com.
$TTL 3600
@            IN SOA  (
                     example.com.      ; MNAME
                     post.example.com. ; RNAME
                     2014110501        ; SERIAL
                     3600              ; REFRESH
                     14400             ; RETRY
                     604800            ; EXPIRE
                     3600              ; MINIMUM
                     )

; NS RECORDS
@            IN NS   ns1.nameserver.com.
@            IN NS   ns2.nameserver.com.

; A RECORDS
sub.domain      A    192.168.1.42; This is a local ip.

; AAAA RECORDS
ipv6.domain     AAAA ::1; This is an IPv6 domain.

; MX RECORDS
@               MX   10 mail-gw1.example.net.
@               MX   20 mail-gw2.example.net.
@               MX   30 mail-gw3.example.net.

The above is an example of the AlignedBuilder which creates records that are much more aesthetically pleasing. You can also use the flat ZoneBuilder, the output of which is below:

...
echo ZoneBuilder::build($zone);
$ORIGIN example.com.
$TTL 3600
@ IN SOA example.com. post.example.com. 2014110501 3600 14400 604800 3600
@ MX 20 mail-gw2.example.net.
@ IN NS ns1.nameserver.com.
@ MX 30 mail-gw3.example.net.
sub.domain A 192.168.1.42; This is a local ip.
ipv6.domain AAAA ::1; This is an IPv6 domain.
@ IN NS ns2.nameserver.com.
@ MX 10 mail-gw1.example.net.

Supported Types

All ubiquitous DNS types are supported. For full details on supported types see the Documentation.

Parsing BIND Records

BIND Records can be parsed into PHP objects using Badcow\DNS\Parser\Parser

$file = file_get_contents('/path/to/example.com.txt');
$zone = Badcow\DNS\Parser\Parser::parse('example.com.', $file); //Badcow Zone Object

Simple as that.

More examples can be found in the The Docs

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].