update_wordpress_vulnerabilities.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env ruby
  2. # -*- coding: binary -*-
  3. #
  4. # Update modules/auxiliary/scanner/http/wordpress_scanner.rb to have the most
  5. # up to date list of vuln components based on exploits/scanners in the framework
  6. #
  7. # by h00die
  8. #
  9. require 'optparse'
  10. options = {}
  11. optparse = OptionParser.new do |opts|
  12. opts.banner = 'Usage: update_wordpress_vulnerabilities.rb [options]'
  13. opts.on('-h', '--help', 'Display this screen.') do
  14. puts opts
  15. exit
  16. end
  17. end
  18. optparse.parse!
  19. # colors and puts templates from msftidy.rb
  20. class String
  21. def red
  22. "\e[1;31;40m#{self}\e[0m"
  23. end
  24. def yellow
  25. "\e[1;33;40m#{self}\e[0m"
  26. end
  27. def green
  28. "\e[1;32;40m#{self}\e[0m"
  29. end
  30. def cyan
  31. "\e[1;36;40m#{self}\e[0m"
  32. end
  33. end
  34. #
  35. # Display an error message, given some text
  36. #
  37. def error(txt)
  38. puts "[#{'ERROR'.red}] #{cleanup_text(txt)}"
  39. end
  40. #
  41. # Display a warning message, given some text
  42. #
  43. def warning(txt)
  44. puts "[#{'WARNING'.yellow}] #{cleanup_text(txt)}"
  45. end
  46. #
  47. # Display a info message, given some text
  48. #
  49. def info(txt)
  50. puts "[#{'INFO'.cyan}] #{cleanup_text(txt)}"
  51. end
  52. def cleanup_text(txt)
  53. # remove line breaks
  54. txt = txt.gsub(/[\r\n]/, ' ')
  55. # replace multiple spaces by one space
  56. txt.gsub(/\s{2,}/, ' ')
  57. end
  58. plugins = []
  59. themes = []
  60. path = File.expand_path('../../', File.dirname(__FILE__))
  61. Dir.glob(path + '/modules/**/*.rb').each do |file|
  62. next unless file.include?('exploits') || file.include?('auxiliary')
  63. str = File.read(file)
  64. match = str.match(/check_plugin_version_from_readme\(['"]([^'"]+)['"]/)
  65. unless match.nil?
  66. plugins.append(match[1])
  67. info("#{file} contains plugin '#{match[1]}'")
  68. end
  69. match = str.match(/check_theme_version_from_readme\(['"]([^'"]+)['"]/)
  70. unless match.nil?
  71. themes.append(match[1])
  72. info("#{file} contains theme '#{match[1]}'")
  73. end
  74. end
  75. info('Updating wp-exploitable-themes.txt')
  76. wp_list = path + '/data/wordlists/wp-exploitable-themes.txt'
  77. File.open(wp_list, 'w+') do |f|
  78. f.puts(themes)
  79. end
  80. info('Updating wp-exploitable-plugins.txt')
  81. wp_list = path + '/data/wordlists/wp-exploitable-plugins.txt'
  82. File.open(wp_list, 'w+') do |f|
  83. f.puts(plugins)
  84. end