[Perl] Simple Downloader 0.1

Iniciado por BigBear, Mayo 05, 2012, 09:18:24 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Mayo 05, 2012, 09:18:24 PM Ultima modificación: Marzo 14, 2015, 10:20:54 AM por Expermicid
Un simple script en perl para bajar archivos.

Código: perl

#!usr/bin/perl
#Simple downloader 0.1
#Coded By Doddy H

use LWP::UserAgent;
use URI::Split qw(uri_split);

my $nave = LWP::UserAgent->new;
$nave->agent(
"Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
);
$nave->timeout(20);

head();
unless ( $ARGV[0] ) {
    sintax();
}
else {
    now( $ARGV[0] );
}
copyright();

sub now {

    my ( $scheme, $auth, $path, $query, $frag ) = uri_split( $_[0] );

    if ( $path =~ /(.*)\/(.*)$/ ) {
        my $file = $2;
        print "\n[+] Downloading ....\n";
        if ( download( $_[0], $file ) ) {
            print "\n[+] File downloaded\n";
        }
        else {
            print "\n[-] Error\n";
        }
    }
}

sub sintax {
    print "\n[+] Sintax : $0 <url>\n";
}

sub head {
    print "\n-- == Simple Downloader == --\n\n";
}

sub copyright {
    print "\n\n(C) Doddy Hackman 2012\n\n";
    exit(1);
}

sub download {
    if ( $nave->mirror( $_[0], $_[1] ) ) {
        if ( -f $_[1] ) {
            return true;
        }
    }
}

#The End ?