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
- #file_site ⇒ Object
- #find_plugins(print_version: true) ⇒ 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(print_version: false) ⇒ 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
#file_site ⇒ Object
23 24 25 |
# File 'lib/snackhack2/wordpress.rb', line 23 def file_site @site = @site.gsub('https://', '') end |
#find_plugins(print_version: true) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/snackhack2/wordpress.rb', line 96 def find_plugins(print_version: true) found_versions = {} alios = Snackhack2.get(@site) if alios.code.eql?(200) data = {"Yoast SEO plugin " => 'Yoast SEO plugin v\d\d\.\d', "MonsterInsights plugin" => 'MonsterInsights plugin v\d\d\.\d\.\d', "All in One SEO" => 'All in One SEO \d\.\d\.\d\.\d', "Site Kit by Google" => 'Site Kit by Google \d\.\d\d\d\.\d', "Google Analytics by ExactMetrics plugin" => 'Google Analytics by ExactMetrics plugin v\d\.\d\d\.\d', "HubSpot WordPress plugin" => 'HubSpot WordPress plugin v\d\d\.\d\.\d\d', "Simple Social Buttons" => 'Simple Social Buttons \d\.2\.0', "Powered by Slider Revolution" => 'Powered by Slider Revolution \d\.\d\.\d\d', "Generated By Events-Calendar - Version:" => 'Generated By Events-Calendar - Version: \d\.\d\.\d', "Open Graph and Twitter Card Tags" => 'Open Graph and Twitter Card Tags \d\.\d\.\d', "Google Analytics Tracking by Google Analyticator" => 'Google Analytics Tracking by Google Analyticator \d\.\d\.\d', "REVOLUTION SLIDER" => 'REVOLUTION SLIDER \d\.\d\.\d', "Generated By sidebarTabs" => 'Generated By sidebarTabs \d\.\d',\ "Yoast WordPress SEO plugin" => 'Yoast WordPress SEO plugin v\d\.\d\.\d', "Yoast SEO Premium plugin" => 'Yoast SEO Premium plugin v\d\d\.\d \(Yoast SEO v27\.1\.1\)', "Google Analytics by MonsterInsights plugin" => 'Google Analytics by MonsterInsights plugin v\d\d\.\d\.\d', "All in One SEO (AIOSEO\)" => 'All in One SEO \(AIOSEO\) \d\.\d\.\d', "EduBlock PRO" => 'EduBlock PRO \d\.\d\.\d', "WPZOOM Framework" => 'WPZOOM Framework \d\.0\.\d', "WPML" => 'WPML ver:\d\.\d\.\d', "Redux" => 'Redux \d\.\d\.\d', "WordPress Download Manager"=> 'WordPress Download Manager \d\.\d\.\d\d', "WP Rocket" => 'WP Rocket \d\.\d\d\.\d', "WooCommerce" => 'WooCommerce \d\d\.\d\.\d', "Yoast SEO plugin" => 'Yoast SEO plugin v\d\.\d', "Divi" => 'Divi v\.\d\.\d\d\.\d', "WordPress" => 'WordPress \d\.\d\.\d', "Newtek ChildTheme Base for Divi " => 'Newtek ChildTheme Base for Divi v\.\d\.\d', "Presence" => 'Presence \d\.\d\.\d\d', "WPZOOM Framework" => 'WPZOOM Framework \d\.\d\.\d'} data.each do |name, regex| version = alios.body.scan(/#{regex}/) unless version.empty? found_versions[name] = version.shift.gsub(name, "").strip end end end unless print_version return found_versions else found_versions.each do |name, version| puts "#{name}: #{version}" end end 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 puts "[+] users not found\n\n\n" end return if found_users.empty? if @save_file Snackhack2.file_save(@site, 'users', found_users) else puts found_users end end |
#wp_content_uploads ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/snackhack2/wordpress.rb', line 48 def wp_content_uploads s = Snackhack2.get(File.join(@site, '/wp-content/uploads/')) return unless s.code == 200 return unless s.body.include?('Index of') puts "[+] #{File.join(@site, '/wp-content/uploads/')} is valid...\n\n\n" end |
#wp_log ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/snackhack2/wordpress.rb', line 142 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| wplog_score += 10 if log.body.include?(e) end end puts "WordPress Log score: #{wplog_score}...\n\n\n" end |
#wp_login ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/snackhack2/wordpress.rb', line 56 def wp_login # detects if the site is using wordpress 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
155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/snackhack2/wordpress.rb', line 155 def wp_plugin wp_plugin_score = 0 # text in which it will search for 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| wp_plugin_score += 10 if plug.body.include?(e) end end puts "[+] WordPress Plugin Score: #{wp_plugin_score}" end |
#yoast_seo(print_version: false) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/snackhack2/wordpress.rb', line 75 def yoast_seo(print_version: false) # checks to see if the wordpress site # uses the yoast seo plugin ys = Snackhack2.get(@site) if ys.code.to_i.eql?(200) if ys.body.match?("Yoast") v = ys.body.scan(/This site is optimized with the Yoast SEO plugin\sv\d\d\.\d/).join(" ") # makes sure the word 'plugin' is in the 'v' string if v.include?("plugin") # gets the version version = v.split("plugin")[1].strip end end end unless print_version return version else puts "Yoast Seo is running version: #{version}" end end |