Downloading Web Application Firewal (WAF) signatures to a webserver?

D

I recently encountered a problem where I had a Citrix NetScaler that, for security reasons, had no internet connection. It was located in the second DMZ and was intended to act as a second-hop server. A relatively large number of load balancers had been set up, along with the corresponding WAFs.

A Citrix Knowledge Base article explains exactly how to configure NetScaler itself so that it loads the signatures from another server; the question was, how do you get the signatures onto that server? I wrote a Perl script for this.

# download NetScaler signature files to a webserver. Tested with BSD and Windows
# (C) Johannes Norz 2026

#download the signature drfinition file
my ($filename) = "SignaturesMapping.xml";

download_file ("https://s3.amazonaws.com/NSAppFwSignatures/" . $filename, $filename) or die "Download fehlgeschlagen";

use XML::LibXML;

# parse the SignatureMapping file

my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($filename);

#all downloads have to go into the sigs subdirectory

chdir "sigs";

#we download all signature files

for my $node ($doc->findnodes('//sig_file')) {

# the name-file (containing the signatures)

my $name = $node->findvalue('./file');
$name =~ s{^sigs/}{};
download_file ("https://s3.amazonaws.com/NSAppFwSignatures/sigs/$name", $name) or die "Download of $file failed";

#the corresponding SHA file

my $sha1 = $node->findvalue('./sha1');
$sha1 =~ s{^sigs/}{};
download_file ("https://s3.amazonaws.com/NSAppFwSignatures/sigs/$sha1", $sha1) or die "Download of $sha1 failed";

#the corresponding digest file

my $digest = $node->findvalue('./digest');
$digest =~ s{^sigs/}{};
download_file ("https://s3.amazonaws.com/NSAppFwSignatures/sigs/$digest", $digest) or die "Download of $digest failed";
}

#-----------------------------

#the subfunction download loads the signatures from the webserver (i.e. https://s3.amazonaws.com/NSAppFwSignatures/sigs/)

sub download_file {
use LWP::UserAgent ();
my ($url, $filename) = @_;

my $ua = LWP::UserAgent->new(
timeout => 30,
agent => 'PerlDownloader/1.0',
);

my $response = $ua-> get($url,':content_file' => $filename);

if ($response->is_success) {
return 1;
}

warn "error downloading: " . $response->status_line . "\n";
return 0;
}

About the author

Johannes Norz

Johannes Norz is a Citrix Certified Citrix Technology Advocate (CTA), Citrix Certified Instructor (CCI) and Citrix Certified Expert on Application Delivery and Security (CCE-AppDS).

He frequently works for Citrix international Consulting Services and several education centres all around the globe.

Johannes lives in Austria. He had been borne in Innsbruck, a small city (150.000 inhabitants) in the middle of the most beautiful Austrian mountains (https://www.youtube.com/watch?v=UvdF145Lf2I)

Add comment

Last posts

Avalable categories