Class: Snackhack2::WordPress
- Inherits:
-
Object
- Object
- Snackhack2::WordPress
- Defined in:
- lib/snackhack2/wordpress.rb
Instance Attribute Summary collapse
-
#save_file ⇒ Object
Returns the value of attribute save_file.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #all_in_one_seo ⇒ Object
- #file_site ⇒ Object
-
#initialize(save_file: true) ⇒ WordPress
constructor
A new instance of WordPress.
- #run ⇒ Object
- #users ⇒ Object
- #wp_content_uploads ⇒ Object
- #wp_log ⇒ Object
- #wp_login ⇒ Object
- #wp_plugin ⇒ Object
- #yoast_seo ⇒ Object
Constructor Details
#initialize(save_file: true) ⇒ WordPress
Returns a new instance of WordPress.
9 10 11 12 |
# File 'lib/snackhack2/wordpress.rb', line 9 def initialize(save_file: true) @site = site @save_file = save_file end |
Instance Attribute Details
#save_file ⇒ Object
Returns the value of attribute save_file.
7 8 9 |
# File 'lib/snackhack2/wordpress.rb', line 7 def save_file @save_file end |
#site ⇒ Object
Returns the value of attribute site.
7 8 9 |
# File 'lib/snackhack2/wordpress.rb', line 7 def site @site end |
Instance Method Details
#all_in_one_seo ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/snackhack2/wordpress.rb', line 88 def all_in_one_seo alios = Snackhack2::get(@site) if alios.code == 200 if alios.body.scan(/(All in One SEO Pro\s\d.\d.\d)/) puts "Site is using the plugin: #{alios.body.match(/(All in One SEO Pro\s\d.\d.\d)/)}" end end end |
#file_site ⇒ Object
23 24 25 |
# File 'lib/snackhack2/wordpress.rb', line 23 def file_site @site = @site.gsub('https://', '') end |
#run ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/snackhack2/wordpress.rb', line 14 def run wp_login yoast_seo users wp_content_uploads all_in_one_seo wp_log end |
#users ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/snackhack2/wordpress.rb', line 27 def users found_users = '' begin users = Snackhack2::get(File.join(@site, "wp-json", "wp", "v2", "users")).body json = JSON.parse(users) json.each do |k| found_users += "#{k['name']}\n" end rescue StandardError => e puts "[+] users not found\n\n\n" end if !found_users.empty? if @save_file Snackhack2::file_save(@site, "users", found_users) else puts found_users end end end |
#wp_content_uploads ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/snackhack2/wordpress.rb', line 48 def wp_content_uploads s = Snackhack2::get(File.join(@site, '/wp-content/uploads/')) if s.code == 200 if s.body.include?('Index of') puts "[+] #{File.join(@site, '/wp-content/uploads/')} is valid...\n\n\n" end end end |
#wp_log ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/snackhack2/wordpress.rb', line 97 def wp_log wplog_score = 0 wp = ['\wp-content\plugins', 'PHP Notice', 'wp-cron.php', '/var/www/html', 'Yoast\WP\SEO', 'wordpress-seo'] log = Snackhack2::get(File.join(@site, "/wp-content/debug.log")) if log.code == 200 puts "[+] #{File.join(@site, "/wp-content/debug.log")} is giving status 200. Now double checking...\n\n\n" wp.each do |e| if log.body.include?(e) wplog_score += 10 end end end puts "WordPress Log score: #{wplog_score}...\n\n\n" end |
#wp_login ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/snackhack2/wordpress.rb', line 57 def wp_login percent = 0 ## todo: maybe add Bayes Theorem to detect wp wp = ['wp-includes', 'wp-admin', 'Powered by WordPress', 'wp-login.php', 'yoast.com/wordpress/plugins/seo/', 'wordpress-login-url.jpg', 'wp-content/themes/', 'wp-json'] login = Snackhack2::get(File.join(@site, "wp-login.php")) if login.code == 200 wp.each do |path| percent += 10 if login.body.include?(path) end end login2 = Snackhack2::get(@site.to_s) wp.each do |path| percent += 10 if login2.body.include?(path) end puts "Wordpress Points: #{percent}" end |
#wp_plugin ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/snackhack2/wordpress.rb', line 112 def wp_plugin wp_plugin_score = 0 wp = ['Index of', 'Name', 'Last modified', 'Size', 'Parent Directory', '/wp-content/plugins'] plug = Snackhack2::get(File.join(@site, '/wp-content/plugins/')) if plug.code == 200 puts "[+] Looks like #{File.join(@site, '/wp-content/plugins/')} is giving status 200. Checking to make sure...\n\n\n" wp.each do |e| if plug.body.include?(e) wp_plugin_score += 10 end end end puts "[+] WordPress Plugin Score: #{wp_plugin_score}" end |
#yoast_seo ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/snackhack2/wordpress.rb', line 75 def yoast_seo ys = Snackhack2::get(@site) if ys.code == 200 yoast_version = ys.body.split("<!-- This site is optimized with the Yoast SEO Premium plugin")[1].split(" -->")[0] ["This site is optimized with the Yoast SEO plugin", "This site is optimized with the Yoast SEO Premium plugin"].each do |site| if !ys.body.scan(/#{site}/).shift.nil? puts "#{ys.body.scan(/#{site}/).shift.to_s} with version #{yoast_version}" end end end end |