Questions about this topic? Sign up to ask in the talk tab.

Kolkata

From NetSec
Revision as of 20:37, 27 April 2012 by User (Talk | contribs) (Created page with "<syntaxhighlight lang="perl"> #!/usr/bin/perl # @url http://www.blackhatacademy.org/ # @author fxm+hats use strict; use LWP::Simple; use Getopt::Long; use YAML::XS; use LWP::Us...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<syntaxhighlight lang="perl">

  1. !/usr/bin/perl
  2. @url http://www.blackhatacademy.org/
  3. @author fxm+hats

use strict; use LWP::Simple; use Getopt::Long; use YAML::XS; use LWP::UserAgent; use HTTP::Request; use HTTP::Response; use Digest::MD5 qw(md5_hex); use Data::Dumper;

my $opts; my %tree; my $sigtree = \%tree; my $sigdir = '/home/fxm/Desktop/Code/appscan/sigs';

my $custom = undef; my $debug = 0;

&check_args; &load_sigs;

my $digestobj = Digest::MD5->new; my $ua = new LWP::UserAgent;

  1. my $content;
  2. $ua->agent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10");
  3. my $req = new HTTP::Request GET => "$fullurl";
  4. my $res = $ua->request($req);
  5. if ($res->is_error) {
  6. print $res->status_line;
  7. }
  8. if ($res->is_success) {
  9. $content = $res->content;
  10. my $md5 = $digestobj->add("$content");
  11. my $final = $md5->hexdigest;
  12. print "MD5:\t\t$final\n";
  13. print "Version:\t$ver_hash{$final}\n\n";
  14. }


sub load_sigs {

 if (defined $custom && -f "$sigdir/$custom.yml")
 {
   print "Loaded custom profile $custom\n";
   $sigtree->{$custom} = YAML::XS::LoadFile("$sigdir/$custom.yml");
 } else {
   opendir(SIGDIR, "$sigdir") or die $!;
   my @fingerprints = grep {
     /\.yml$/
     && -f "$sigdir/$_"
   } readdir(SIGDIR);
   foreach my $yf (@fingerprints)
   {
     my $yfname = $yf;
     $yfname =~ s/\.yml//;
     $sigtree->{$yfname} = YAML::XS::LoadFile("$sigdir/$yf");
     printf "Loaded '%s' (%s)\n", $sigtree->{$yfname}->{'app_name'}, $yf;
   }
 }
 closedir(SIGDIR);

}

sub check_args {

 $opts = GetOptions(
   "custom=s"	=> \$custom,
   "debug"	=> \$debug
 );

}

print Dumper $sigtree; </syntaxhighlight>