#!/usr/bin/perl # Simple script to submit files to CWSandbox # Written by: Jeremy Conway # Email: jeremy [at] sudosecure [dot] net # Date: 5 April 2008 use HTTP::Request::Common; require LWP::UserAgent; use Getopt::Long; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->agent('CWSandbox Submitter (http://sudosecure.net)'); push @{ $ua->requests_redirectable }, 'POST'; sub post_file{ my $badfile=$_; my $res = $ua->request(POST 'http://www.cwsandbox.org/?page=submit&action=verify', Content_Type => 'form-data', Content => [ notification => 'email', email => $email, upfile => ["$badfile"], ]); if ($res->is_success) { my @page = $res->content; my $id = ''; my $password = ''; for $line (@page){ $line =~ m/id=([0-9]*)?&password=([a-z]*)?\"/; $id = $1; $password = $2; } print $badfile . ": is being analyized. Check your email at $email for the report link.\n"; print "A direct link to the results: http://www.cwsandbox.org/?page=samdet&id=$id&password=$password\n"; } else { print $badfile . ": " . $res->status_line, "\n"; } } GetOptions( 'e=s' => \$email_flag, 'f=s{,}' => \@files, 'h' => \$help ) ; if($help or !$email_flag or !@files){ print "Usage: cwsandbox_submit.pl -e [email_address] -f [FILES]\n"; print "Submit files to CWSandbox.\n"; print "Example: ./cwsandbox_submit.pl -e my.email\@home.com -f file file1 file2\n"; print "\n\n -e EMAIL Address (required)"; print " \n -f File or files to submit"; print " \n -h Show usage\n\n"; print "Wildcard * can be used in the file option \"-f\"\n"; print "Report bugs to jeremy [at] sudosecure [dot] net\n"; exit; } $email = $email_flag; foreach (@files) { my $badfile= $_; if (-r $badfile){ post_file $badfile; } else { print $badfile . " does not exist\n"; } }