Added WordPress Duplicator <= 1.2.40 and documentation#10960
Conversation
bcoles
left a comment
There was a problem hiding this comment.
$ ./.git/hooks/post-merge
[*] Running msftidy.rb in ./.git/hooks/post-merge mode
--- Checking new and changed module syntax with tools/dev/msftidy.rb ---
modules/exploits/multi/php/wordpress_duplicator.rb - [WARNING] Please use 'WPVDB' for 'https://wpvulndb.com/vulnerabilities/9123'
modules/exploits/multi/php/wordpress_duplicator.rb - [WARNING] Invalid CVE format: 'CVE-2018-17207'
modules/exploits/multi/php/wordpress_duplicator.rb:17 - [WARNING] Spaces at EOL
modules/exploits/multi/php/wordpress_duplicator.rb:26 - [WARNING] Tabbed indent: "\t\t['CVE', 'CVE-2018-17207']\n"
------------------------------------------------------------------------
h00die
left a comment
There was a problem hiding this comment.
Lots of little changes here, don't be intimidated by how many there are. I bet you can knock out more than half in 5 minutes.
In general though, be careful about reading HTTP responses before you check that they aren't nil first.
|
Hi @hypn0s! I can address these changes if you're good with that. |
|
Hi @space-r7 ! Actually, I already made the changes on my side but the resulting code fails to establish a session. If I add a time.sleep before calling the wp-config.php file, it works, without it does not. Should I commit my code so you can validate the changes and help me figuring out what's wrong? |
Yes, please do! |
|
I pushed my changes with the sleep calls so you can see where I have the issue. |
|
Great! I'll take a look. |
|
I tested with both a restored backup and a backup that hasn't been restored yet (with the Restored: Without restore: In your case, you might need to add a timeout on the last |
|
Nevermind on the second output. I think that session was a result of the first run. This is what I get when I run without restoring Wordpress: |
|
I don't understand why the ZIP file detection fails. Do you have a line in the installer.php like this? $GLOBALS['FW_PACKAGE_NAME'] = '20180829_testduplicator_0db8a9891e406d3f9090180829154720_archive.zip' |
|
@hypn0s, here's mine: Adjusting the timeout in |
|
Thank's for the timeout tip! I just committed a patch with it, works very well. I have no idea why it does not find the ZIP file name, it works well on my side :( Can you share your installer.php? |
|
No problem! It could just be my test environment. Here's a link: https://gist.github.com/space-r7/83ff20274e74643ee6fe53c63beda342 Also, it looks like Travis may be failing due to this: |
|
Thank you for you installer.php. |
|
once the final outputs have been determined, I'd update the scenario in the docs. I believe that's all though |
I would like to see more defensive programming. This code strays far from the left margin. Given that nothing from step 1 is used in step 2, the entirety of the step 1 conditional could easily be abstracting into a I would also like to see changes to the The Given that the functionality within this method does not appear to require a session, nor require any data from other methods in the module, it's likely that this code could be moved to a |
| * `installer-log.txt` | ||
| * `installer.php` | ||
|
|
||
| WARNING: exploiting the vulnerability will overwrite the wp-config.php file, breaking the Wordpress instance. |
There was a problem hiding this comment.
| WARNING: exploiting the vulnerability will overwrite the wp-config.php file, breaking the Wordpress instance. | |
| WARNING: exploiting the vulnerability will overwrite the `wp-config.php` file, breaking the WordPress instance. |
|
Typically modules which target the WordPress code are given the prefix |
|
Well, it looks like the cleaning step does not work because the regex used in the step3 cannot match the MSF payload, I was sure it was working but I guess I was wrong. Thus, the only way to clean up is to actually have a session and edit or delete the wp-config.php file from session, but I guess it can only be performed manually right? |
I commited by changes with fixes and removed the cleanup step because it does not work at all. |
h00die is currently AWOL. All of hoodie's review comments were addressed, with the exception of Maybe remove installer.php to make the title a little shorter? - dismissing this review
I haven't played around with this bug, or this module, so I'm not exactly sure what the problem is here. If you can't perform cleanup with a HTTP request, you could cleanup with You can execute operating systems commands, and interact with the filesystem using the msf API, from within the |
|
I think we can run def on_new_session(session)
session.shell_command_token("rm wp-config.php")
endwithout worrying because if the session is established, it means the wp-config.php was overwritten so it is clean to delete it after the session is established. May I commit this function? |
Sounds reasonable, so long as:
You may also need to handle command shell session and meterpreter session like so: def on_new_session(client)
if client.type.eql? 'meterpreter'
client.core.use 'stdapi' unless client.ext.aliases.include? 'stdapi'
client.fs.file.rm 'wp-config.php'
else
client.shell_command_token 'rm wp-config.php'
end
end |
|
What if we recreate the wp-config.php after deleting it? def on_new_session(client)
if client.type.eql? 'meterpreter'
client.core.use 'stdapi' unless client.ext.aliases.include? 'stdapi'
client.fs.file.rm 'wp-config.php'
else
client.shell_command_token 'rm wp-config.php'
end
create_wp_config_file
end This way, the wp-config.php file will be clean. |
I think this should be fine. |
|
Hey @hypn0s, I can make the final change in the landing commit. Thank you! |
|
There your go, with my last commit. |
|
Renamed the module to Tested: |
Release NotesThe Snap Creek Duplicator WordPress Plugin module has been added to the framework. Code execution can be achieved by injecting commands in the |
Duplicator is a WordPress plugin that can be used to create a complete backup of a WordPress instance and restore it on a fresh server. The export method generates 2 files:
When the installer.php completes its process, the following files remain in the directory and has to be manually deleted:
Vulnerable application
Install a vulnerable version of WordPress Duplicator (<= 1.2.40) and create a backup.
Put the install.php and archive files on a clean web server.
Verification Steps
Confirm that check functionality works:
msfconsoleuse exploit/multi/php/wordpress_duplicator-RHOST.checkThe target is vulnerable.Confirm that command execution functionality works:
set PAYLOAD php/meterpreter/reverse_tcpLHOSTandLPORTrunOptions
TARGETURI
The path to the installer.php file to exploit By default, the path is
/installer.php.Scenarios
Meterpreter reverse tcp