Skip to content

Instantly share code, notes, and snippets.

@bdwilson
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save bdwilson/a49bb459b48a7c1917b9 to your computer and use it in GitHub Desktop.

Select an option

Save bdwilson/a49bb459b48a7c1917b9 to your computer and use it in GitHub Desktop.
Zscaler Zulu Submission Script
#!/usr/bin/perl
# Zscaler Zulu submission tool.
# 10/30/2014 - [email protected]
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common qw(POST);
$ua= LWP::UserAgent->new;
$ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave => 1));
if (!$ARGV[0]) {
print "$0 <URL>\n";
exit;
}
$orig_url=$ARGV[0];
# get initial cookies
$req = HTTP::Request->new(GET => "http://zulu.zscaler.com");
$req->header('Referrer' => '');
$res = $ua->request($req);
if ($res->is_success) {
$data=$res->content;
if ($data =~/<meta content=\"([^\"]*)" name=\"csrf-token\"/) {
# grab CSRF auth token so our submission will be
# considered valid.
$auth_token=$1;
}
}
my %postdata = ( "submission[submission]" => "$orig_url",
"submission[user_agent]" => "ie7",
"authenticity_token" => "$auth_token");
$req = HTTP::Request->new;
$req = POST("http://zulu.zscaler.com/create", [%postdata]);
$req->header('Referrer' => 'http://zulu.zscaler.com');
$req->content_type('application/x-www-form-urlencoded');
$res = $ua->request($req);
if ($res->{"_content"}) {
$data = $res->content;
if ($data =~ /(http\:\/\/zulu.zscaler.com\/submission\/show[^\"]*)\"/) {
$url=$1;
$processing=1;
print "Processing $url ...\n";
sleep 10;
while($processing) {
print "Still processing ...\n";
$req = HTTP::Request->new(GET => "$url");
$res = $ua->request($req);
if ($res->is_success) {
$data=$res->content;
if ($data =~/Status.*finished</) {
$processing=0;
if ($data =~/text-align: center;color: ([^;]*);font-weight: bold;font-size: 350%;\"\>/) {
$color=$1;
if ($color eq "Green") {
$color="Benign";
} elsif ($color eq "Red") {
$color="Malicious";
}
}
if ($data =~ /70\%\;\"\>([^<]*)\</) {
$score=$1;
}
print "$orig_url : $color : $score\n";
exit;
}
}
sleep 10;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment