403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.70.189.139
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/libnet-dns-perl/examples/demo/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/libnet-dns-perl/examples/demo/axfr
#!/usr/bin/perl
# $Id: axfr 1815 2020-10-14 21:55:18Z willem $

use strict;
use warnings;
use vars qw($opt_f $opt_q $opt_s $opt_D);
use File::Basename;
use Getopt::Std;
use Net::DNS;
use Storable;

#------------------------------------------------------------------------------
# Read any command-line options and check syntax.
#------------------------------------------------------------------------------

getopts("fqsD:");

die "Usage: ", basename($0), " [ -fqs ] [ -D directory ] [ \@nameserver ] zone\n"
	unless (@ARGV >= 1) && (@ARGV <= 2);

#------------------------------------------------------------------------------
# Get the nameserver (if specified) and set up the zone transfer directory
# hierarchy.
#------------------------------------------------------------------------------

my $nameserver = ($ARGV[0] =~ /^@/) ? shift @ARGV : "";
$nameserver =~ s/^@//;

my $zone = shift @ARGV;
my $basedir = defined $opt_D ? $opt_D : $ENV{"HOME"} . "/.dns-zones";
my $zonedir = join("/", reverse(split(/\./, $zone)));
my $zonefile = $basedir . "/" . $zonedir . "/axfr";

# Don't worry about the 0777 permissions here - the current umask setting
# will be applied.
unless (-d $basedir) {
	mkdir($basedir, 0777) or die "can't mkdir $basedir: $!\n";
}

my $dir = $basedir;
my $subdir;
foreach my $subdir (split(m#/#, $zonedir)) {
	$dir .= "/" . $subdir;
	unless (-d $dir) {
		mkdir($dir, 0777) or die "can't mkdir $dir: $!\n";
	}
}

#------------------------------------------------------------------------------
# Get the zone.
#------------------------------------------------------------------------------

my $res = Net::DNS::Resolver->new;
$res->nameservers($nameserver) if $nameserver;

my (@zone, $zoneref);

if (-e $zonefile && !defined $opt_f) {
	$zoneref = retrieve($zonefile) || die "couldn't retrieve zone from $zonefile: $!\n";

	#----------------------------------------------------------------------
	# Check the SOA serial number if desired.
	#----------------------------------------------------------------------

	if (defined $opt_s) {
		my($serial_file, $serial_zone);

		my $rr;
		foreach my $rr (@$zoneref) {
			if ($rr->type eq "SOA") {
				$serial_file = $rr->serial;
				last;
			}
		}
		die "no SOA in $zonefile\n" unless defined $serial_file;

		my $soa = $res->query($zone, "SOA");
		die "couldn't get SOA for $zone: ", $res->errorstring, "\n"
			unless defined $soa;

		foreach my $rr ($soa->answer) {
			if ($rr->type eq "SOA") {
				$serial_zone = $rr->serial;
				last;
			}
		}

		if ($serial_zone != $serial_file) {
			$opt_f = 1;
		}
	}
} else {
	$opt_f = 1;
}

if (defined $opt_f) {
	@zone = $res->axfr($zone);
	die "couldn't transfer zone: ", $res->errorstring, "\n" unless @zone;
	store \@zone, $zonefile or die "couldn't store zone to $zonefile: $!\n";
	$zoneref = \@zone;
}

#------------------------------------------------------------------------------
# Print the records in the zone.
#------------------------------------------------------------------------------

unless ($opt_q) {
	$_->print for @$zoneref
}

__END__

=head1 NAME

axfr - Perform a DNS zone transfer

=head1 SYNOPSIS

B<axfr> S<[ B<-fqs> ]> S<[ B<-D> I<directory> ]> S<[ B<@>I<nameserver> ]>
I<zone>

=head1 DESCRIPTION

B<axfr> performs a DNS zone transfer, prints each record to the standard
output, and stores the zone to a file.  If the zone has already been
stored in a file, B<axfr> will read the file instead of performing a
zone transfer.

Zones will be stored in a directory hierarchy.  For example, the
zone transfer for foo.bar.com will be stored in the file
$HOME/.dns-zones/com/bar/foo/axfr.  The directory can be changed
with the B<-D> option.

This programs requires that the Storable module be installed.

=head1 OPTIONS

=over 4

=item B<-f>

Force a zone transfer, even if the zone has already been stored
in a file.

=item B<-q>

Be quiet -- don't print the records from the zone.

=item B<-s>

Perform a zone transfer if the SOA serial number on the nameserver
is different than the serial number in the zone file.

=item B<-D> I<directory>

Store zone files under I<directory> instead of the default directory
(see L<"FILES">).

=item B<@>I<nameserver>

Query I<nameserver> instead of the default nameserver.

=back

=head1 FILES

=over 4

=item B<$HOME/.dns-zones>

Default directory for storing zone files.

=back

=head1 AUTHOR

Michael Fuhr <[email protected]>

=head1 SEE ALSO

L<perl(1)>, L<check_soa>, L<check_zone>, L<mresolv>, L<mx>, L<perldig>,
L<Net::DNS>, L<Storable>

=cut

Youez - 2016 - github.com/yon3zu
LinuXploit