wpscanteam / wpscan

WPScan WordPress security scanner. Written for security professionals and blog maintainers to test the security of their WordPress websites. Contact us via contact@wpscan.com
https://wpscan.com/wordpress-cli-scanner
Other
8.51k stars 1.25k forks source link

Enumerate Themes #26

Closed firefart closed 11 years ago

firefart commented 12 years ago

Implement a feature similar to the enumerate plugins to enumerate currently installed themes.

SVN Repo of Wordpress Themes: http://themes.svn.wordpress.org/

erwanlr commented 12 years ago

Nice idea :) (the most difficult will be to find the letter for enumeration as 't' is for timthumbs :p, maybe 'h' xD)

firefart commented 12 years ago

Jeah I will have a look at this today ;)

firefart commented 12 years ago

Almost finished with rewriting the plugin / theme fetching I will commit it tomorrow

ethicalhack3r commented 12 years ago

Nice!

firefart commented 12 years ago

This will be a really big pull request. Anyone interesting in testing a new "beta"? ;)

firefart commented 12 years ago

would be great if you can have a pre-look at it for bugs: https://github.com/FireFart/wpscan/tree/themes

git clone -b themes git://github.com/FireFart/wpscan.git wpscan-firefart

Next thing to do is fix the rspec tests and add a documentation

firefart commented 12 years ago

differences: https://github.com/FireFart/wpscan/compare/master...themes

ethicalhack3r commented 12 years ago

Awesome! I'll have a look through soon.

ethicalhack3r commented 12 years ago

It seems to be checking the wrong theme directory (or at least outputting the wrong directory):

"| Name: 4colourslover | Location: http://www.xxx.com/blog/wp-content/4colourslover/ | Directory listing enabled? No. " Location should be http://www.xxx.com/blog/wp-content/themes/4colourslover/. I think the bug is in the "get_url_without_filename" method. But it seems to work fine for plugins so might not be.

There seems to be a problem with theme version fingerprinting but not sure if this was introduced before.

"[!] The WordPress theme in use is storque v1.0 v1.0"

firefart commented 12 years ago

hmpf it's the function when passive plugin detection returns urls without filename. will fix that thx ;)

firefart commented 12 years ago

both should be fixed now

ethicalhack3r commented 12 years ago

Awesome! Can confirm both fixed for the blog I was scanning. Thanks! :)

@erwanlr, @gbrindisi, you both OK with merging these changes?

firefart commented 12 years ago

great ;) rspec tests still failing need to fix them first ;)

erwanlr commented 12 years ago

A lot of specs fail because the create_location_url_from_name and create_url_from_raw methods do no longer exist in plugin.rb

These methods were used to create the plugin location url from his name or a raw data : https://github.com/wpscanteam/wpscan/blob/master/lib/wpscan/wp_plugin.rb

Furthermore, i would rather do a WpItem class instead of a module :

class WpItem < Vulnerable
class WpPlugin < WpItem
class WpTheme < WpItem
gbrindisi commented 12 years ago

Love this feature! :+1:

firefart commented 12 years ago

thx for the feedback WpItem is now a class

firefart commented 12 years ago

rspec tests are now fixed. time for some final testing guys ;)

PS: i will add tests for the new methods later

erwanlr commented 12 years ago

If the blog uses a custom wp-plugins directory, the plugin enumeration does not work because it try to get them from wp-content/plugins (wp-content can be a custom dir)

A solution could be to pass the wp_plugins_dir directory to the class WpItem like the wp_content_dir one.

Furthermore, for the same reason, the timthumbs enumeration does not work when the file is located in a plugin directory

Custom content & plugins directories are explained there : http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content

firefart commented 12 years ago

just pushed an update on the wp-content dir detection. When i switch my wp-content directory to a custom location, many themes and plugins render incorrect maybe this is the problem? example: http://10.211.55.8/wordpress/wp-custom/plugins/usr/share/wordpress/wp-content/plugins/add-link-to-facebook/add-link-to-facebook.css?ver=3.3.1

Current version should detect only the "real" wp-content dir, but in this case wpscan detects a usr plugin, because the full path is rendered by the plugin/theme

erwanlr commented 11 years ago

The brute force does no longer work because of this :

# Start the brute forcer
bruteforce = false

and because the usernames variable is no more an array of usernames but an array of hashes.

Btw, do we really need to know other thing than the username and maybe the id ?

If you still plan to use all these information, it could be easier to create a wp_user class instead of an array of hashes for each user ;)

ethicalhack3r commented 11 years ago

Opened a new issue for it: https://github.com/wpscanteam/wpscan/issues/31 (I'll have a look at it)

firefart commented 11 years ago

should i open a pull request so you can merge it in a seperate branch of the "main" wpscan project?

erwanlr commented 11 years ago

What do you want to merge ? the themes branch ?

firefart commented 11 years ago

noooo i thought @ethicalhack3r wants to fix the #31 issue so it would be a possibility to create a themes branch on this project. but the issue was kind of false/positive because it was on my branch ;)

erwanlr commented 11 years ago

kk xD

firefart commented 11 years ago

anybody knows a reliable way to determine a custom plugins directory? or is the sli option the only way to determine it? If so, what do you think of a check if "WP_CONTENT_DIR" + "/plugins" exists on the front page and if not, put a message that either no plugins are installed or a custom plugin dir must be supplied?

firefart commented 11 years ago

@erwanlr custom plugin directory is now working. combination of custom wp-content and custom wp-plugin dir is also working. plugin dir needs to be speficied via cli, wp-content is automatically detected (no need for cli options here)

any open tasks for this left?

erwanlr commented 11 years ago

You are assuming that the plugins directory is a sub folder of wp-content, but it's not necessarily the case for a custom wp_plugins_dir :

# spec/lib/wpscan/wp_item_spec.rb

it "should return the correct url (custom wp_plugins_dir)" do
  @instance.wp_plugin_dir = "wp-custom/c-plugins"
  @instance.type = "plugins"
  @instance.get_url.to_s.should === "http://sub.example.com/path/to/wordpress/wp-custom/plugins/test/asdf.php"
end

Furthermore, a 's' is missing to the wp_plugin_dir attribute of WpItem => wp_plugins_dir

Then, the WpItem#url and WpItem#get_url are tricky xD, i would say that they return the same thing according to their name but no ^^ (i know why you have done that but it could be better to find another name for the attribute url ;))

firefart commented 11 years ago

a ok i thought the plugins die must always be in wp-content. will fix that and the naming issues

firefart commented 11 years ago

new changes are in:

would be great if you can test it ;)

erwanlr commented 11 years ago

I will ASAP, but from what i saw on your commits it looks great :)

Just one thing : in string sometimes you use #{variable} and another time #@attribute like :

ret = URI.parse("#{url}#@wp_plugins_dir/#{path}")

Is there a particular reason or it's just to save 2 chars ? :p

firefart commented 11 years ago

its because the {} are not needed on @ variables and my ide suggests this. so it's just some "code styling" ^^

erwanlr commented 11 years ago

kk :D

erwanlr commented 11 years ago

The wp-content and multisite detection does not work for this site : http://buddypress.org/

For the multisite it's because their redirection is http://buddypress.org/register/

edit : "[+] Userregistration is enabled" a space is missing ;)

firefart commented 11 years ago

wp-content detection works for me on buddypress.org (wp-content).

Multisite detection is a bit tricky on this site. Do you have a good solution for this? I think a 100% accurate multisite detection on customized Wordpress instances is impossible. Or is /register/ a valid wordpress link?

erwanlr commented 11 years ago

wp-content detection works for me on buddypress.org (wp-content).

Ok, it was a rubygems issue (i was with an old one on BT5r3)

I do not think /register/ is a valid wp link, like you said it's a custom one

erwanlr commented 11 years ago

Great :)