• Publicidad

PasteBin Downloader 0.1

¿Estás desarrollando un proyecto, o piensas hacerlo? Pon aquí tu propuesta, lo más seguro es que alguien esté interesado en ayudarte.

PasteBin Downloader 0.1

Notapor BigBear » 2013-07-20 16:58 @748

Un simple script en Perl para bajar códigos de Pastebin.

Pueden bajar solo uno o hacer que el programa busque enlaces de pastebin en una página y bajarlos a todos.

El código:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!usr/bin/perl
  2. #PasteBin Downloader 0.1
  3. #Coded By Doddy H
  4.  
  5. use LWP::UserAgent;
  6. use URI::Split qw(uri_split);
  7. use HTML::LinkExtor;
  8.  
  9. my $nave = LWP::UserAgent->new;
  10. $nave->agent(
  11. "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12"
  12. );
  13. $nave->timeout(10);
  14.  
  15. my $se = "downloads_pastebin";
  16.  
  17. unless ( -d $se ) {
  18.     mkdir( $se, "777" );
  19. }
  20.  
  21. chdir $se;
  22.  
  23. print "\n-- == PasteBin Downloader 0.1 == --\n";
  24.  
  25. unless ( $ARGV[0] and $ARGV[1] ) {
  26.     print "\n[+] Sintax : $0 < -single / -page > <url>\n";
  27. }
  28. else {
  29.     print "\n[+] Searching ...\n";
  30.     if ( $ARGV[0] eq "-single" ) {
  31.         download_this( $ARGV[1] );
  32.     }
  33.     if ( $ARGV[0] eq "-page" ) {
  34.         download_all( $ARGV[1] );
  35.     }
  36. }
  37.  
  38. print "\n(C) Doddy Hackman 2013\n";
  39.  
  40. sub download_all {
  41.  
  42.     my $page = shift;
  43.  
  44.     my $code = toma($page);
  45.     chomp $code;
  46.  
  47.     my @links_all = repes( get_links($code) );
  48.  
  49.     for my $page_down (@links_all) {
  50.         download_this($page_down);
  51.     }
  52.  
  53. }
  54.  
  55. sub download_this {
  56.  
  57.     my $page   = shift;
  58.     my $titulo = "";
  59.     my $num    = "";
  60.  
  61.     print "\n[+] Checking : $page\n";
  62.  
  63.     my $code = toma($page);
  64.  
  65.     if ( $page =~ /http:\/\/(.*)\/(.*)/ ) {
  66.         $num = $2;
  67.  
  68.         if ( $code =~ /<div class="paste_box_line1" title="(.*)">/ ) {
  69.             $titulo = $1;
  70.  
  71.             print "[+] Downloading : http://pastebin.com/download.php?i=$num\n";
  72.  
  73.             if (
  74.                 download(
  75.                     "http://pastebin.com/download.php?i=$num",
  76.                     $titulo . ".txt"
  77.                 )
  78.               )
  79.             {
  80.                 print "[+] File Downloaded !\n";
  81.             }
  82.             else {
  83.                 print "[-] Error\n";
  84.             }
  85.  
  86.         }
  87.     }
  88.  
  89. }
  90.  
  91. sub download {
  92.  
  93.     if ( $nave->mirror( $_[0], $_[1] ) ) {
  94.         if ( -f $_[1] ) {
  95.             return true;
  96.         }
  97.     }
  98. }
  99.  
  100. sub repes {
  101.     my @limpio;
  102.     foreach $test (@_) {
  103.         push @limpio, $test unless $repe{$test}++;
  104.     }
  105.     return @limpio;
  106. }
  107.  
  108. sub toma {
  109.     return $nave->get( $_[0] )->content;
  110. }
  111.  
  112. sub get_links {
  113.  
  114.     $test = HTML::LinkExtor->new( \&agarrar )->parse( $_[0] );
  115.     return @links;
  116.  
  117.     sub agarrar {
  118.         my ( $a, %b ) = @_;
  119.         push( @links, values %b );
  120.     }
  121. }
  122.  
  123. #The End ?
  124.  
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Re: PasteBin Downloader 0.1

Notapor explorer » 2013-07-20 18:09 @798

JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: PasteBin Downloader 0.1

Notapor BigBear » 2013-07-20 20:09 @881

¡Nooo...! Yo que pensé que había sido una idea original... :D
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818


Volver a Proyectos

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado

cron