CoderPirata

E-DUMP: Extracts email addresses from a MySQL database

Jul 20th, 2015
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.20 KB | None | 0 0
  1. <?php
  2. /*
  3.  
  4. From http://pastebin.com/UDf1UV64
  5.  
  6. -------------------------------------------------------------------------------
  7. [ E-DUMP ]---------------------------------------------------------------------
  8. - Extracts email addresses from a MySQL database.
  9.  
  10. -------------------------------------------------------------------------------
  11. [ TO RUN THE SCRIPT ]----------------------------------------------------------
  12. PHP Version       5.6.8
  13.  php5-cli         Lib
  14. MySQL support     Enabled
  15. MySQL version     5.0.11
  16. Permission        Writing
  17.  
  18. -------------------------------------------------------------------------------
  19. [ ABOUT DEVELOPER ]------------------------------------------------------------
  20. NAME              CoderPirata
  21. Blog              http://coderpirata.blogspot.com.br/
  22. Twitter           https://twitter.com/coderpirata
  23. Google+           https://plus.google.com/103146866540699363823
  24. Pastebin          http://pastebin.com/u/CoderPirata
  25. Github            https://github.com/coderpirata/
  26.  
  27. */
  28.  
  29. ini_set('error_log',NULL);
  30. ini_set('log_errors',FALSE);
  31. ini_set('display_errors', FALSE);
  32. ini_set('max_execution_time', FALSE);
  33.  
  34. $oo = getopt('h::', ['help::', 'host:', 'user:', 'pass:', 'dbname:', 'save:', 'no-info']);
  35.  
  36. function cores($nome){
  37. $cores = array("r" => "\033[1;31m", "g" => "\033[0;32m", "b" => "\033[1;34m", "g2" => "\033[1;30m", "g1" => "\033[0;37m");
  38. if(substr(strtolower(PHP_OS), 0, 3) != "win"){ return $cores[strtolower($nome)]; }
  39. }
  40.  
  41. echo cores("g1")."
  42. ooooooooooo       ooooooooo  ooooo  oooo oooo     oooo oooooooooo
  43.  888    88         888    88o 888    88   8888o   888   888    888
  44.  888ooo8    oooooo 888    888 888    88   88 888o8 88   888oooo88
  45.  888    oo         888    888 888    88   88  888  88   888
  46. o888ooo8888       o888ooo88    888oo88   o88o  8  o88o o888o\n
  47. \t       ".cores("g2")."[  ".cores("g1")."DUMP EMAILS FROM ".cores("b")."MYSQL".cores("g1")." DATABASE! ".cores("g2")."]
  48. -----------------------------------------------------------------\n\n";
  49.  
  50. if(isset($oo['h']) or isset($oo['help'])){
  51. die(cores("g1")."\t  ooooo ooooo ooooooooooo ooooo       oooooooooo
  52. \t   888   888   888    88   888         888    888
  53. \t   888ooo888   888ooo8     888         888oooo88
  54. \t   888   888   888    oo   888      o  888
  55. \t  o888o o888o o888ooo8888 o888ooooo88 o888o\n
  56. ".cores("g2")."-----------------------------------------------------------------\n".cores("g1")."
  57. COMMAND:: ".cores("b")."--host ".cores("g1")."~ Sets the Host.
  58.       Example: {$_SERVER["SCRIPT_NAME"]} ".cores("b")."--host ".cores("g1")."localhost
  59. \n
  60. COMMAND:: ".cores("b")."--user ".cores("g1")."~ Sets the User.
  61.       Example: {$_SERVER["SCRIPT_NAME"]} ".cores("b")."--user ".cores("g1")."root
  62. \n
  63. COMMAND:: ".cores("b")."--pass ".cores("g1")."~ Sets the Password.
  64.       Example: {$_SERVER["SCRIPT_NAME"]} ".cores("b")."--pass ".cores("g1")."admin123
  65. \n
  66. COMMAND:: ".cores("b")."--dbname ".cores("g1")."~ Command to set the db that will be scanned. By default, all dbs will be scanned.
  67.       Example: {$_SERVER["SCRIPT_NAME"]} ".cores("b")."--dbname ".cores("g1")."mydatabase
  68. \n
  69. COMMAND:: ".cores("b")."--save ".cores("g1")."~ Saves the emails found on a list.
  70.       Example: {$_SERVER["SCRIPT_NAME"]} ".cores("b")."--save ".cores("g1")."email_list.txt
  71.                {$_SERVER["SCRIPT_NAME"]} ".cores("b")."--save ".cores("g1")."\"\"
  72.  
  73. COMMAND:: ".cores("b")."--no-info ".cores("g1")."~ It does not display the \"databases\" and the tables.
  74.       Example: {$_SERVER["SCRIPT_NAME"]} ".cores("b")."--no-info
  75. \n");
  76. }
  77.  
  78.  
  79. if(empty($oo['host']) or empty($oo['user']) or !isset($oo['pass'])){ die(); }              
  80. $db_blacklist = array('information_schema', 'performance_schema');
  81.  
  82. if(isset($oo["save"])){
  83. $save = cores("g")."YES";
  84. if(!empty($oo["save"])){$save .= cores("g2")."\n| ".cores("g1")."FILE NAME:: ".cores("b").$oo["save"].cores("g2"); }
  85. }else{ $save = cores("r")."NOT"; }
  86. if(isset($oo["dbname"])){ $dbnme = cores("g").$oo["dbname"]; }else{ $dbnme = cores("r")."NOT DEFINED"; }
  87. echo cores("g2").".-[ ".cores("g1")."INFOS".cores("g2")." ] ------------------------------------------------------
  88. | ".cores("g1")."HOST:: ".cores("b").$oo["host"].cores("g2")."
  89. | ".cores("g1")."USER:: ".cores("b").$oo["user"].cores("g2")."
  90. | ".cores("g1")."PASS:: ".cores("b").$oo["pass"].cores("g2")."
  91. | ".cores("g1")."DBNAME:: ".cores("b").$dbnme.cores("g2")."
  92. | ".cores("g1")."SAVE:: {$save}".cores("g2")."
  93. '-----------------------------------------------------------------\n";
  94.  
  95. $conect = mysql_connect($oo["host"],$oo["user"],$oo["pass"]) or die(cores("r")."\n\nERROR:: ".mysql_error()."\n\n");
  96. if(empty($oo["dbname"])){
  97. $resultado = mysql_query("SHOW DATABASES;", $conect) or die(cores("r")."\n\nERROR:: ".mysql_error()."\n\n");
  98. while($data = mysql_fetch_row($resultado)){ $resultado_query .= implode('|-|-|-|-|-|',$data)."\n"; }
  99. $lim = explode("|-|-|-|-|-|", $resultado_query);
  100. foreach($lim as $lin){ if(!empty($lin)){ $dbnames = $lin; } }
  101. $dbname = explode("\n", $dbnames);
  102. foreach($dbname as $n => $d){
  103.  foreach($db_blacklist as $blocked){ if(empty($d) or $d == $blocked){ unset($dbname[$n]); } }
  104. }
  105. }else{ $dbname[] = $oo["dbname"]; }
  106.  
  107. if(!isset($oo["no-info"])){ echo cores("g1")."\n SEARCHIN IN:: "; }
  108. foreach($dbname as $dbnam3){
  109. if(!isset($oo["no-info"])){ echo cores("g2")."\n -----------------------------------\n  ".cores("g2")."[ ".cores("g1")."DBNAME".cores("g2")." ]::".cores("b")."$dbnam3\n".cores("g2")."  [ ".cores("g1")."TABLES ".cores("g2")."]::"; }
  110. mysql_select_db($dbnam3) or die(cores("r")."\n\nERROR:: ".mysql_error()."\n\n");
  111. $res = mysql_list_tables($dbnam3) or die(cores("r")."\n\nERROR:: ".mysql_error()."\n\n");
  112. while ($row = mysql_fetch_row($res)){
  113.  $table = $row[0];
  114.  $res2 = mysql_query("SHOW CREATE TABLE $table");
  115.  if(!isset($oo["no-info"])){ echo cores("g2")." - ".cores("b")."{$table}"; }
  116.  while ($lin = mysql_fetch_row($res2)){
  117.   $res3 = mysql_query("SELECT * FROM $table");
  118.    while($r=mysql_fetch_row($res3)){
  119.    $sql="INSERT INTO $table VALUES (";
  120.  
  121.    for($j=0; $j<mysql_num_fields($res3);$j++){
  122.     if($r[$j] != ""){ $dados .= " - ".$r[$j]." - "; }
  123.    }
  124.    }
  125.   }
  126. $table = NULL;
  127. }
  128. }
  129. mysql_close($coneccao);
  130.  
  131. if(!isset($oo["no-info"])){ echo cores("g2")."\n\n -----------------------------------------------------------------\n"; }
  132. preg_match_all("/([\w\d\.\-\_]+)@([\w\d\.\_\-]+)/mi", $dados, $possiveis);
  133. $email = array_unique(array_unique($possiveis[0]));
  134. if(empty($email)){ echo cores("r")."\n EMAIL(s) NOT FOUND\n"; goto sai; }else{ echo cores("g")."\n  ".count($email)." EMAIL(s) FOUND".cores("g1")."\n\n"; }
  135. foreach ($email as $emails){ if(eregi(".", $emails)){ echo cores("g1")."\n EMAIL:: ".cores("g")."{$emails}"; } }
  136. echo "\n\n";
  137.  
  138. if(!empty($email) and isset($oo["save"])){
  139. if(isset($oo["save"]) and empty($oo["save"])){ $name = "e-dump_emails.txt"; }else{ $name = $oo["save"]; }
  140. if(!file_exists($name)){ file_put_contents($name, "EMAIL's LEAKED FROM {$oo["host"]} WITH E-DUMP! ".PHP_EOL.PHP_EOL.PHP_EOL); }
  141. foreach ($email as $emails){ file_put_contents($name, "EMAIL: ".$emails.PHP_EOL, FILE_APPEND); }
  142. echo "  ".cores("g1")."EMAILS SAVED IN: ".cores("b")."{$name}\n";
  143. }
  144.  
  145. sai:
  146. echo cores("g2")." -----------------------------------------------------------------\n";
  147.  
  148. #END
Advertisement
Add Comment
Please, Sign In to add comment