Underc0de - Hacking y seguridad informática

Programación Scripting => Perl => Mensaje iniciado por: BigBear en Julio 03, 2011, 10:03:54 pm

Título: [Perl] Mysql Manager
Publicado por: BigBear en Julio 03, 2011, 10:03:54 pm
Un simple mysql manager , un triste intento de imitacion al comando mysql pero bueno....

Código: Perl
  1. #!usr/bin/perl
  2. #Mysql Manager (C) Doddy Hackman 2011
  3. #ppm install http://www.bribes.org/perl/ppm/DBI.ppd
  4.  
  5. use DBI;
  6.  
  7. sub head {
  8. print "\n\n -- == Mysql Manager == --\n\n";
  9. }
  10.  
  11. sub copyright {
  12. print "\n\n-- == (C) Doddy Hackman 2011 == --\n\n";
  13. exit(1);
  14. }
  15.  
  16. sub sintax {
  17. print "\n[+] Sintax : $0 <host> <user> <pass>\n";
  18. }
  19.  
  20. head();
  21. unless (@ARGV > 2) {
  22. sintax();
  23. } else {
  24. enter($ARGV[0],$ARGV[1],$ARGV[2]);
  25. }
  26. copyright();
  27.  
  28. sub enter {
  29.  
  30. print "\n[+] Connecting to the server\n";
  31.  
  32. $info = "dbi:mysql::".$_[0].":3306";
  33. if (my $enter = DBI->connect($info,$_[1],$_[2],{PrintError=>0})) {
  34.  
  35. print "\n[+] Enter in the database";
  36.  
  37. while(1) {
  38. print "\n\n\n[+] Query : ";
  39. chomp(my $ac = <stdin>);
  40.  
  41. if ($ac eq "exit") {
  42. $enter->disconnect;
  43. print "\n\n[+] Closing connection\n\n";
  44. copyright();
  45. }
  46.  
  47. $re = $enter->prepare($ac);
  48. $re->execute();
  49. my $total = $re->rows();
  50.  
  51. my @columnas = @{$re->{NAME}};
  52.  
  53. if ($total eq "-1") {
  54. print "\n\n[-] Query Error\n";
  55. next;
  56. } else {
  57. print "\n\n[+] Result of the query\n";
  58. if ($total eq 0) {
  59. print "\n\n[+] Not rows returned\n\n";
  60. } else {
  61. print "\n\n[+] Rows returned : ".$total."\n\n\n";
  62. for(@columnas) {
  63. print $_."\t\t";
  64. }
  65. print "\n\n";
  66. while (@row = $re->fetchrow_array) {
  67. for(@row) {
  68. print $_."\t\t";
  69. }
  70. print "\n";
  71. }}}}
  72. } else {
  73. print "\n[-] Error connecting\n";
  74. }}
  75.  
  76. # ¿ The End ?
  77.  

Un ejemplo de uso

Código: [Seleccionar]

C:\Documents and Settings\Administrador\Escritorio\Todo\Warfactory II\proyectos\
mysqlman>manager.PL localhost root ""


 -- == Mysql Manager == --


[+] Connecting to the server

[+] Enter in the database


[+] Query : show databases


[+] Result of the query


[+] Rows returned : 6


Database

information_schema
cdcol
hackman
mysql
phpmyadmin
test



[+] Query : exit


[+] Closing connection



-- == (C) Doddy Hackman 2011 == --