WPSTools updated to respect ruby standards according to rubocop
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# encoding: UTF-8
|
||||
#--
|
||||
# WPScan - WordPress Security Scanner
|
||||
# Copyright (C) 2012-2013
|
||||
@@ -26,14 +25,14 @@ class GenerateList
|
||||
# type = themes | plugins
|
||||
def initialize(type, verbose)
|
||||
if type =~ /plugins/i
|
||||
@type = "plugin"
|
||||
@svn_url = "http://plugins.svn.wordpress.org/"
|
||||
@popular_url = "http://wordpress.org/extend/plugins/browse/popular/"
|
||||
@type = 'plugin'
|
||||
@svn_url = 'http://plugins.svn.wordpress.org/'
|
||||
@popular_url = 'http://wordpress.org/extend/plugins/browse/popular/'
|
||||
@popular_regex = %r{<h3><a href="http://wordpress.org/extend/plugins/(.+)/">.+</a></h3>}i
|
||||
elsif type =~ /themes/i
|
||||
@type = "theme"
|
||||
@svn_url = "http://themes.svn.wordpress.org/"
|
||||
@popular_url = "http://wordpress.org/extend/themes/browse/popular/"
|
||||
@type = 'theme'
|
||||
@svn_url = 'http://themes.svn.wordpress.org/'
|
||||
@popular_url = 'http://wordpress.org/extend/themes/browse/popular/'
|
||||
@popular_regex = %r{<h3><a href="http://wordpress.org/extend/themes/(.+)">.+</a></h3>}i
|
||||
else
|
||||
raise "Type #{type} not defined"
|
||||
@@ -45,24 +44,24 @@ class GenerateList
|
||||
|
||||
def set_file_name(type)
|
||||
case @type
|
||||
when "plugin"
|
||||
case type
|
||||
when :full
|
||||
@file_name = PLUGINS_FULL_FILE
|
||||
when :popular
|
||||
@file_name = PLUGINS_FILE
|
||||
else
|
||||
raise "Unknown type"
|
||||
end
|
||||
when "theme"
|
||||
case type
|
||||
when :full
|
||||
@file_name = THEMES_FULL_FILE
|
||||
when :popular
|
||||
@file_name = THEMES_FILE
|
||||
else
|
||||
raise "Unknown type"
|
||||
end
|
||||
when 'plugin'
|
||||
case type
|
||||
when :full
|
||||
@file_name = PLUGINS_FULL_FILE
|
||||
when :popular
|
||||
@file_name = PLUGINS_FILE
|
||||
else
|
||||
raise 'Unknown type'
|
||||
end
|
||||
when 'theme'
|
||||
case type
|
||||
when :full
|
||||
@file_name = THEMES_FULL_FILE
|
||||
when :popular
|
||||
@file_name = THEMES_FILE
|
||||
else
|
||||
raise 'Unknown type'
|
||||
end
|
||||
else
|
||||
raise "Unknown type #@type"
|
||||
end
|
||||
@@ -87,7 +86,7 @@ class GenerateList
|
||||
page_count = 1
|
||||
queue_count = 0
|
||||
|
||||
(1...(pages.to_i+1)).each do |page|
|
||||
(1...(pages.to_i + 1)).each do |page|
|
||||
# First page has another URL
|
||||
url = (page == 1) ? @popular_url : @popular_url + 'page/' + page.to_s + '/'
|
||||
request = @browser.forge_request(url)
|
||||
@@ -95,7 +94,7 @@ class GenerateList
|
||||
queue_count += 1
|
||||
|
||||
request.on_complete do |response|
|
||||
puts "[+] Parsing page " + page_count.to_s if @verbose
|
||||
puts "[+] Parsing page #{page_count}" if @verbose
|
||||
page_count += 1
|
||||
response.body.scan(@popular_regex).each do |item|
|
||||
puts "[+] Found popular #@type: #{item}" if @verbose
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# encoding: UTF-8
|
||||
#
|
||||
# WPScan - WordPress Security Scanner
|
||||
# Copyright (C) 2012-2013
|
||||
#
|
||||
@@ -18,18 +20,16 @@
|
||||
class ListGeneratorPlugin < Plugin
|
||||
|
||||
def initialize
|
||||
super(
|
||||
:author => "WPScanTeam - @FireFart"
|
||||
)
|
||||
super(author: 'WPScanTeam - @FireFart')
|
||||
|
||||
register_options(
|
||||
["--generate-plugin-list [NUMBER_OF_PAGES]", "--gpl", Integer, "Generate a new data/plugins.txt file. (supply number of *pages* to parse, default : 150)"],
|
||||
["--generate-full-plugin-list", "--gfpl", "Generate a new full data/plugins.txt file"],
|
||||
['--generate-plugin-list [NUMBER_OF_PAGES]', '--gpl', Integer, 'Generate a new data/plugins.txt file. (supply number of *pages* to parse, default : 150)'],
|
||||
['--generate-full-plugin-list', '--gfpl', 'Generate a new full data/plugins.txt file'],
|
||||
|
||||
["--generate-theme-list [NUMBER_OF_PAGES]", "--gtl", Integer, "Generate a new data/themes.txt file. (supply number of *pages* to parse, default : 150)"],
|
||||
["--generate-full-theme-list", "--gftl", "Generate a new full data/themes.txt file"],
|
||||
['--generate-theme-list [NUMBER_OF_PAGES]', '--gtl', Integer, 'Generate a new data/themes.txt file. (supply number of *pages* to parse, default : 150)'],
|
||||
['--generate-full-theme-list', '--gftl', 'Generate a new full data/themes.txt file'],
|
||||
|
||||
["--generate-all", "--ga", "Generate a new full plugins, full themes, popular plugins and popular themes list"],
|
||||
['--generate-all', '--ga', 'Generate a new full plugins, full themes, popular plugins and popular themes list']
|
||||
)
|
||||
end
|
||||
|
||||
@@ -40,13 +40,13 @@ class ListGeneratorPlugin < Plugin
|
||||
if options.has_key?(:generate_plugin_list) || generate_all
|
||||
number_of_pages = options[:generate_plugin_list] || 150
|
||||
|
||||
puts "[+] Generating new most popular plugin list"
|
||||
puts '[+] Generating new most popular plugin list'
|
||||
puts
|
||||
GenerateList.new('plugins', verbose).generate_popular_list(number_of_pages)
|
||||
end
|
||||
|
||||
if options[:generate_full_plugin_list] || generate_all
|
||||
puts "[+] Generating new full plugin list"
|
||||
puts '[+] Generating new full plugin list'
|
||||
puts
|
||||
GenerateList.new('plugins', verbose).generate_full_list
|
||||
end
|
||||
@@ -54,13 +54,13 @@ class ListGeneratorPlugin < Plugin
|
||||
if options.has_key?(:generate_theme_list) || generate_all
|
||||
number_of_pages = options[:generate_theme_list] || 150
|
||||
|
||||
puts "[+] Generating new most popular theme list"
|
||||
puts '[+] Generating new most popular theme list'
|
||||
puts
|
||||
GenerateList.new('themes', verbose).generate_popular_list(number_of_pages)
|
||||
end
|
||||
|
||||
if options[:generate_full_theme_list] || generate_all
|
||||
puts "[+] Generating new full theme list"
|
||||
puts '[+] Generating new full theme list'
|
||||
puts
|
||||
GenerateList.new('themes', verbose).generate_full_list
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# encoding: UTF-8
|
||||
#--
|
||||
# WPScan - WordPress Security Scanner
|
||||
# Copyright (C) 2012-2013
|
||||
@@ -24,12 +23,12 @@ class SvnParser
|
||||
attr_accessor :verbose, :svn_root, :keep_empty_dirs
|
||||
|
||||
def initialize(svn_root)
|
||||
@svn_root = svn_root
|
||||
@svn_browser = Browser.instance
|
||||
@svn_hydra = @svn_browser.hydra
|
||||
@svn_root = svn_root
|
||||
@svn_browser = Browser.instance
|
||||
@svn_hydra = @svn_browser.hydra
|
||||
end
|
||||
|
||||
def parse()
|
||||
def parse
|
||||
get_root_directories
|
||||
end
|
||||
|
||||
@@ -38,11 +37,13 @@ class SvnParser
|
||||
|
||||
# Gets all directories in the SVN root
|
||||
def get_root_directories
|
||||
dirs = []
|
||||
dirs = []
|
||||
rootindex = @svn_browser.get(@svn_root).body
|
||||
|
||||
rootindex.scan(%r{<li><a href=".+">(.+)/</a></li>}i).each do |dir|
|
||||
dirs << dir[0]
|
||||
end
|
||||
|
||||
dirs.sort!
|
||||
dirs.uniq
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user