Bienvenido a Tecnohackers

Tecnohackers » Programacion » Area de Programacion » Scripting. VBS, Batch, Bash, JavaSript.
 » 

[Perl] Mysql Manager 0.5



Autor Tema: [Perl] Mysql Manager 0.5  (Leído 829 veces)

Desconectado Doddy

  • Veterano
  • ***
  • Mensajes: 249
  • Slow Mind
[Perl] Mysql Manager 0.5
« en: Abril 14, 2012, 07:47:01 pm »
Nueva version de un mysql manager que hice hace un largo tiempo.

Código: You are not allowed to view links. Register or Login
#!usr/bin/perl
#Mysql Manager 0.5
#Coded By Doddy H
#Modules
#ppm install http://www.bribes.org/perl/ppm/Scalar-List-Utils.ppd
#ppm install http://www.bribes.org/perl/ppm/Storable.ppd
#ppm install http://www.bribes.org/perl/ppm/DBI.ppd
#ppm install http://theoryx5.uwinnipeg.ca/ppms/DBD-mysql.ppd

use DBI;

sub head {
    print "\n\n -- == Mysql Manager 0.5 == --\n\n";
}

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

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

head();
unless ( @ARGV > 2 ) {
    sintax();
}
else {
    enter( $ARGV[0], $ARGV[1], $ARGV[2] );
}
copyright();

sub enter {

    print "\n[+] Connecting to the server\n";

    $info = "dbi:mysql::" . $_[0] . ":3306";
    if ( my $enter = DBI->connect( $info, $_[1], $_[2], { PrintError => 0 } ) )
    {

        print "\n[+] Enter in the database";

        while (1) {
            print "\n\n\n[+] Query : ";
            chomp( my $ac = <stdin> );

            if ( $ac eq "exit" ) {
                $enter->disconnect;
                print "\n\n[+] Closing connection\n\n";
                copyright();
            }

            $re = $enter->prepare($ac);
            $re->execute();
            my $total = $re->rows();

            my @columnas = @{ $re->{NAME} };

            if ( $total eq "-1" ) {
                print "\n\n[-] Query Error\n";
                next;
            }
            else {
                print "\n\n[+] Result of the query\n";
                if ( $total eq 0 ) {
                    print "\n\n[+] Not rows returned\n\n";
                }
                else {
                    print "\n\n[+] Rows returned : " . $total . "\n\n\n";
                    for (@columnas) {
                        print $_. "\t\t";
                    }
                    print "\n\n";
                    while ( @row = $re->fetchrow_array ) {
                        for (@row) {
                            print $_. "\t\t";
                        }
                        print "\n";
                    }
                }
            }
        }
    }
    else {
        print "\n[-] Error connecting\n";
    }
}

# ¿ The End ?

« Última modificación: Abril 14, 2012, 07:49:26 pm por Doddy »
You are not allowed to view links. Register or Login

Tags:
Tags:

 


SMF 2.0.19 | SMF © 2016, Simple Machines
Paginas Afiliadas
Twitter - FaceBook - Daraxblog
Designed by Smf Personal