• Publicidad

SMF Manager 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.

SMF Manager 0.1

Notapor BigBear » 2012-12-07 13:10 @590

Traduccion a Perl (mega buggeada) del script que hizo Javier de PortalHacker para poder leer los mensajes privados y listar las categorías de un foro SMF.

El código:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!usr/bin/perl
  2. #SMF Manager 0.00001
  3. #Coded By Doddy H
  4.  
  5. #ppm install http://www.bribes.org/perl/ppm/HTML-Strip.ppd
  6.  
  7. use LWP::UserAgent;
  8. use HTTP::Cookies;
  9.  
  10. use HTML::Strip;
  11.  
  12. my $nave = LWP::UserAgent->new(
  13.     cookie_jar            => HTTP::Cookies->new(),
  14.     requests_redirectable => [],
  15.     timeout               => 5,
  16.     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.  
  20. print qq(
  21.   @@@   @     @  @@@@@    @     @                                  
  22.  @   @  @     @  @        @     @                                  
  23.  @      @@   @@  @        @@   @@                                  
  24.  @      @@   @@  @        @@   @@   @@@  @ @@   @@@   @@@@  @@@  @@
  25.   @@@   @ @ @ @  @@@@     @ @ @ @      @ @@  @     @ @   @ @   @ @
  26.      @  @ @ @ @  @        @ @ @ @   @@@@ @   @  @@@@ @   @ @@@@@ @
  27.      @  @  @  @  @        @  @  @  @   @ @   @ @   @ @   @ @     @
  28.  @   @  @  @  @  @        @  @  @  @   @ @   @ @   @ @   @ @   @ @
  29.   @@@   @     @  @        @     @   @@@@ @   @  @@@@  @@@@  @@@  @
  30.                                                          @        
  31.                                                      @@@@          
  32.  
  33. );
  34.  
  35. print "\n\n[+] Page : ";
  36. chomp( my $url = <stdin> );
  37.  
  38. print "\n[+] Username : ";
  39. chomp( my $usera = <stdin> );
  40.  
  41. print "\n[+] Password : ";
  42. chomp( my $passa = <stdin> );
  43.  
  44. ## Login
  45.  
  46. print "\n[+] Connecting ....\n\n";
  47.  
  48. my $code = $nave->post(
  49.     $url . "/index.php?action=login2",
  50.     {
  51.         "user"         => $usera,
  52.         "passwrd"      => $passa,
  53.         "cookielength" => "9000",
  54.         "hash_passwrd" => "",
  55.         "submit"       => "submit"
  56.     }
  57. );
  58.  
  59. if ( $code->is_redirect ) {
  60.  
  61.     #print $code->header('location'),"\n";
  62. }
  63. elsif ( $code->is_success ) {
  64.     print $code->as_string, "\n";
  65. }
  66. else {
  67.     print STDERR $code->status_line, "\n";
  68. }
  69.  
  70. my $code = toma( $url . "/SSI.php?ssi_function=welcome" );
  71.  
  72. if ( $code =~ /Hola, <strong>(.*)<\/strong>/ ) {
  73.     my $name = $1;
  74.     print "[+] Welcome $name\n";
  75. }
  76. else {
  77.     print "[-] Error\n";
  78. }
  79.  
  80. ##
  81.  
  82. while (1) {
  83.  
  84.     print "\n[+] Options\n\n";
  85.  
  86.     print "1 - See MP\n";
  87.     print "2 - Navegate\n";
  88.     print "3 - Exit\n";
  89.  
  90.     print "\n[+] Option : ";
  91.     chomp( my $op = <stdin> );
  92.  
  93.     if ( $op eq "3" ) {
  94.         exit(1);
  95.     }
  96.  
  97.     if ( $op eq "1" ) {
  98.  
  99.         print qq(
  100.  @     @  @@@@@
  101.  @     @  @    @
  102.  @@   @@  @    @
  103.  @@   @@  @    @
  104.  @ @ @ @  @@@@@
  105.  @ @ @ @  @    
  106.  @  @  @  @    
  107.  @  @  @  @    
  108.  @     @  @    
  109.  
  110. );
  111.  
  112.         mps($url);
  113.     }
  114.  
  115.     if ( $op eq "2" ) {
  116.         print qq(
  117.  @    @                                        
  118.  @@   @                                @      
  119.  @@   @                                @      
  120.  @ @  @   @@@  @   @  @@@   @@@@  @@@  @@  @@@
  121.  @ @  @      @ @   @ @   @ @   @     @ @  @   @
  122.  @  @ @   @@@@  @ @  @@@@@ @   @  @@@@ @  @@@@@
  123.  @   @@  @   @  @ @  @     @   @ @   @ @  @    
  124.  @   @@  @   @   @   @   @ @   @ @   @ @  @   @
  125.  @    @   @@@@   @    @@@   @@@@  @@@@  @  @@@
  126.                                @              
  127.                            @@@@                
  128.  
  129.  
  130. );
  131.  
  132.         my $chau2 = 0;
  133.  
  134.         while ( $chau2 eq 0 ) {
  135.  
  136.             print "\n[+] 1 - List Categories\n";
  137.             print "[+] 2 - Exit\n";
  138.  
  139.             print "\n[+] Option : ";
  140.             chomp( my $op = <stdin> );
  141.  
  142.             if ( $op eq "1" ) {
  143.  
  144.                 print "\n[+] Searching ...\n\n";
  145.  
  146.                 my $code = toma($url);
  147.  
  148.                 while ( $code =~
  149. /<a class=\"subject\" href=\"(.*?)\" name=(.*?)>(.*?)<\/a>/migs
  150.                   )
  151.                 {
  152.                     print "[+] ID : $2 [+] Name : $3\n";
  153.                 }
  154.  
  155.             }
  156.             else {
  157.                 $chau2 = 1;
  158.             }
  159.  
  160.         }
  161.  
  162.     }
  163.  
  164. }
  165.  
  166. #gets_list_mp();
  167. #gets_msg_mp();
  168. #gets_msg_now();
  169.  
  170. sub mps {
  171.  
  172.     my $url = shift;
  173.  
  174.     my $chau = "0";
  175.  
  176.     print "\n[+] Searching pages ..\n";
  177.  
  178.     my @founds = gets_list_mp($url);
  179.  
  180.     my $count = int(@founds);
  181.  
  182.     print "\n[+] Pages Found : $count\n";
  183.  
  184.     while ( $chau eq 0 ) {
  185.  
  186.         print "\n[+] 1 - Get List Messages\n";
  187.         print "[+] 2 - Read Message\n";
  188.         print "[+] 3 - Exit\n";
  189.  
  190.         print "\n[+] Option : ";
  191.         chomp( my $op = <stdin> );
  192.  
  193.         if ( $op eq "1" ) {
  194.  
  195.             print "\n[+] Number Page : ";
  196.             chomp( my $op = <stdin> );
  197.  
  198.             print "\n[+] Searching ..\n";
  199.  
  200.             gets_msg_mp( $founds[ $op - 1 ] );
  201.  
  202.         }
  203.         elsif ( $op eq "2" ) {
  204.  
  205.             print "\n[+] Number Page : ";
  206.             chomp( my $n = <stdin> );
  207.  
  208.             print "\n[+] ID : ";
  209.             chomp( my $id = <stdin> );
  210.  
  211.             print "\n[+] Reading ...\n";
  212.  
  213.             gets_msg_now( $founds[ $n - 1 ], $id );
  214.  
  215.         }
  216.         else {
  217.             $chau = 1;
  218.         }
  219.  
  220.     }
  221. }
  222.  
  223. sub gets_msg_now {
  224.  
  225.     my $url = toma( $_[0] );
  226.  
  227.     my $id = "msg_" . $_[1];
  228.  
  229.     if ( $url =~ /<div class=\"inner\" id=\"$id\">(.*?)<\/div>/mig ) {
  230.  
  231.         my $uno = HTML::Strip->new( emit_spaces => 1 );
  232.         my $final = $uno->parse($1);
  233.         $final =~ s/^[\t\f ]+|[\t\f ]+$//mg;
  234.  
  235.         print "\n[START]\n\n";
  236.         print $final;
  237.         print "\n\n[END]\n\n";
  238.  
  239.     }
  240.  
  241. }
  242.  
  243. sub gets_msg_mp {
  244.  
  245.     my $url = toma( $_[0] );
  246.  
  247.     my @ids;
  248.     my @asunto;
  249.     my @nombre;
  250.  
  251.     while ( $url =~ /<td><a href=\"#msg(.*?)\">(.*?)<\/a><\/td>/migs ) {
  252.  
  253.         #print "$1 $2\n";
  254.         push( @ids,    $1 );
  255.         push( @asunto, $2 );
  256.     }
  257.  
  258.     while ( $url =~ /Ver perfil de (.*?)">/migs ) {
  259.  
  260.         #print "$1\n\n";
  261.         push( @nombre, $1 );
  262.     }
  263.  
  264.     my $total = int(@ids) - 1;
  265.  
  266.     for my $num ( 0 .. $total ) {
  267.         print "[+] ID : "
  268.           . $ids[$num]
  269.           . " [+] Asunto : "
  270.           . $asunto[$num]
  271.           . " [+] De : "
  272.           . $nombre[$num] . "\n";
  273.     }
  274.  
  275. }
  276.  
  277. sub gets_list_mp {
  278.  
  279.     my $url = shift;
  280.  
  281.     my @paginas;
  282.     my $code = toma( $url . "/index.php?action=pm" );
  283.  
  284.     push( @paginas, $url . "/index.php?action=pm" );
  285.  
  286.     while ( $code =~ /<a class="navPages" href="(.*?)">(.*?)<\/a>/migs ) {
  287.         push( @paginas, $1 );
  288.     }
  289.  
  290.     my @paginas = repes(@paginas);
  291.  
  292.     return @paginas;
  293.  
  294. }
  295.  
  296. sub repes {
  297.     my @limpio;
  298.     foreach $test (@_) {
  299.         push @limpio, $test unless $repe{$test}++;
  300.     }
  301.     return @limpio;
  302. }
  303.  
  304. sub toma {
  305.     return $nave->get( $_[0] )->content;
  306. }
  307.  
  308. sub tomar {
  309.     my ( $web, $var ) = @_;
  310.     return $nave->post( $web, [ %{$var} ] )->content;
  311. }
  312.  
  313. #The End ?
  314.  
Coloreado en 0.008 segundos, usando GeSHi 1.0.8.4


AVISO : Solo está probado en el foro PortalHacker.
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Volver a Proyectos

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 2 invitados