Path: blob/master/app/finders/users/login_error_messages.rb
1479 views
# frozen_string_literal: true12module WPScan3module Finders4module Users5# Login Error Messages6#7# Existing username:8# WP < 3.1 - Incorrect password.9# WP >= 3.1 - The password you entered for the username admin is incorrect.10# Non existent username: Invalid username.11#12class LoginErrorMessages < CMSScanner::Finders::Finder13# @param [ Hash ] opts14# @option opts [ String ] :list15#16# @return [ Array<User> ]17def aggressive(opts = {})18found = []1920usernames(opts).each do |username|21res = target.do_login(username, SecureRandom.hex[0, 8])22error = res.html.css('div#login_error').text.strip2324return found if error.empty? # Protection plugin / error disabled2526next unless /The password you entered for the username|Incorrect Password/i.match?(error)2728found << Model::User.new(username, found_by: found_by, confidence: 100)29end3031found32end3334# @return [ Array<String> ] List of usernames to check35def usernames(opts = {})36# usernames from the potential Users found37unames = opts[:found].map(&:username)3839Array(opts[:list]).each { |uname| unames << uname.chomp }4041unames.uniq42end43end44end45end46end474849