Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 16 Mayo 2013, 19:21 pm



Título: [Perl] VirusTotal Scanner 0.1
Publicado por: BigBear en 16 Mayo 2013, 19:21 pm
Un simple script para scannear un archivo mediante el API de virustotal , la idea se me ocurrio cuando vi este script en python hecho por Sanko del foro Underc0de (http://underc0de.org/foro/python/file-and-process-vt-checker/).

Una imagen :

(http://doddyhackman.webcindario.com/images/scanvir.jpg)

Código
  1. #!usr/bin/perl
  2. #VirusTotal Scanner 0.1
  3. #Coded By Doddy H
  4. #ppm install http://www.bribes.org/perl/ppm/JSON.ppd
  5. #ppm install http://trouchelle.com/ppm/Digest-MD5-File.ppd
  6. #ppm install http://www.bribes.org/perl/ppm/Crypt-SSLeay.ppd
  7. #ppm install http://trouchelle.com/ppm/Color-Output.ppd
  8.  
  9. use JSON;
  10. use Digest::MD5::File qw(file_md5_hex);
  11. use LWP::UserAgent;
  12. use Color::Output;
  13. Color::Output::Init;
  14.  
  15. my $nave = LWP::UserAgent->new;
  16. $nave->agent(
  17. "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
  18. );
  19. $nave->timeout(5);
  20.  
  21. my $api_key = "yourapi"
  22.  ;    #Your API Key
  23.  
  24. head();
  25.  
  26. unless ( $ARGV[0] ) {
  27.    printear( "[+] Sintax : $0 <file to scan>", "text", "11", "5" );
  28.  
  29.    copyright();
  30.    exit(1);
  31. }
  32. else {
  33.  
  34.    unless ( -f $ARGV[0] ) {
  35.        printear( "\n[-] File Not Found\n", "text", "5", "5" );
  36.        copyright();
  37.    }
  38.  
  39.    my $md5 = file_md5_hex( $ARGV[0] );
  40.  
  41.    printear( "\n[+] Checking ...\n", "text", "7", "5" );
  42.  
  43.    my $code = tomar(
  44.        "https://www.virustotal.com/vtapi/v2/file/report",
  45.        { "resource" => $md5, "apikey" => $api_key }
  46.    );
  47.  
  48.    if ( $code =~ /"response_code": 0/ ) {
  49.        printear( "\n[+] Not Found\n", "text", "7", "5" );
  50.        exit(1);
  51.    }
  52.  
  53.    my $dividir = decode_json $code;
  54.  
  55.    printear( "[+] Getting data ...\n", "text", "7", "5" );
  56.  
  57.    printear( "[+] Scan ID : " . $dividir->{scan_id},     "text", "13", "5" );
  58.    printear( "[+] Scan Date : " . $dividir->{scan_date}, "text", "13", "5" );
  59.    printear( "[+] Permalink : " . $dividir->{permalink}, "text", "13", "5" );
  60.    printear(
  61.        "[+] Virus Founds : " . $dividir->{positives} . "/" . $dividir->{total},
  62.        "text", "13", "5"
  63.    );
  64.  
  65.    printear( "\n[+] Getting list ...\n", "text", "7", "5" );
  66.  
  67.    my %abrir = %{ $dividir->{scans} };
  68.  
  69.    for my $antivirus ( keys %abrir ) {
  70.  
  71.        if ( $abrir{$antivirus}{"result"} eq "" ) {
  72.            printear( "[+] " . $antivirus . " : Clean", "text", "11", "5" );
  73.        }
  74.        else {
  75.            printear(
  76.                "[+] " . $antivirus . " : " . $abrir{$antivirus}{"result"},
  77.                "text", "5", "5" );
  78.        }
  79.    }
  80.  
  81.    printear( "\n[+] Finished\n", "text", "7", "5" );
  82.    copyright();
  83.  
  84. }
  85.  
  86. sub head {
  87.    printear( "\n-- == VirusTotal Scanner 0.1 == --\n", "text", "13", "5" );
  88. }
  89.  
  90. sub copyright {
  91.    printear( "\n[+] Written By Doddy H", "text", "13", "5" );
  92.    exit(1);
  93. }
  94.  
  95. sub printear {
  96.    if ( $_[1] eq "text" ) {
  97.        cprint( "\x03" . $_[2] . $_[0] . "\x030\n" );
  98.    }
  99.    elsif ( $_[1] eq "stdin" ) {
  100.        if ( $_[3] ne "" ) {
  101.            cprint( "\x03" . $_[2] . $_[0] . "\x030" . "\x03" . $_[3] );
  102.            my $op = <stdin>;
  103.            chomp $op;
  104.            cprint("\x030");
  105.            return $op;
  106.        }
  107.    }
  108.    else {
  109.        print "error\n";
  110.    }
  111. }
  112.  
  113. sub tomar {
  114.    my ( $web, $var ) = @_;
  115.    return $nave->post( $web, [ %{$var} ] )->content;
  116. }
  117.  
  118. #The End ?
  119.  


Título: Re: [Perl] VirusTotal Scanner 0.1
Publicado por: Danyfirex en 16 Mayo 2013, 21:49 pm
Gracias muy bueno el código.  ;-)


PD: no escanea un archivo. Retorna el reporte de un archivo ya escaneado.

saludos


Título: Re: [Perl] VirusTotal Scanner 0.1
Publicado por: BigBear en 16 Mayo 2013, 22:23 pm
Gracias muy bueno el código.  ;-)


PD: no escanea un archivo. Retorna el reporte de un archivo ya escaneado.

saludos

si , me exprese mal.


Título: Re: [Perl] VirusTotal Scanner 0.1
Publicado por: Shell Root en 17 Mayo 2013, 06:44 am
La verdad no entiendo para que traduces algo de un lenguaje a otro...


Título: Re: [Perl] VirusTotal Scanner 0.1
Publicado por: BigBear en 17 Mayo 2013, 18:43 pm
La verdad no entiendo para que traduces algo de un lenguaje a otro...

si , es porque siempre me gusta programar en los lenguajes que conozco que son Perl,Python,Ruby,PHP,Delphi,C,Java y proximamente C#.