Class: WpUser

Inherits:
WpItem show all
Includes:
BruteForcable, Existable
Defined in:
lib/common/models/wp_user.rb,
lib/common/models/wp_user/existable.rb,
lib/common/models/wp_user/brute_forcable.rb

Defined Under Namespace

Modules: BruteForcable, Existable

Instance Attribute Summary collapse

Attributes inherited from WpItem

#found_from, #name, #path, #version, #wp_content_dir, #wp_plugins_dir

Attributes included from WpItem::Vulnerable

#identifier, #vulns_file

Instance Method Summary collapse

Methods included from BruteForcable

#brute_force, #login_request, #progress_bar, #valid_password?

Methods included from Existable

display_name_from_body, #exists_from_response?, login_from_author_pattern, login_from_body

Methods inherited from WpItem

#forge_uri, #initialize, #url

Methods included from WpItem::Output

#output

Methods included from WpItem::Infos

#changelog_url, #error_log_url, #has_changelog?, #has_directory_listing?, #has_error_log?, #has_readme?, #readme_url, #url_is_200?

Methods included from WpItem::Existable

#exists?

Methods included from WpItem::Vulnerable

#vulnerabilities, #vulnerable?, #vulnerable_to?

Methods included from WpItem::Versionable

#version

Constructor Details

This class inherits a constructor from WpItem

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name


10
11
12
# File 'lib/common/models/wp_user.rb', line 10

def display_name
  @display_name
end

#idObject

Returns the value of attribute id


10
11
12
# File 'lib/common/models/wp_user.rb', line 10

def id
  @id
end

#loginObject

Returns the value of attribute login


10
11
12
# File 'lib/common/models/wp_user.rb', line 10

def 
  @login
end

#passwordObject

Returns the value of attribute password


10
11
12
# File 'lib/common/models/wp_user.rb', line 10

def password
  @password
end

Instance Method Details

#<=>(other) ⇒ Object

Parameters:


63
64
65
# File 'lib/common/models/wp_user.rb', line 63

def <=>(other)
  id <=> other.id
end

#==(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)

70
71
72
# File 'lib/common/models/wp_user.rb', line 70

def ==(other)
  self === other
end

#===(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)

77
78
79
# File 'lib/common/models/wp_user.rb', line 77

def ===(other)
  id === other.id &&  === other.
end

#allowed_optionsArray<Symbol>

Returns:


13
# File 'lib/common/models/wp_user.rb', line 13

def allowed_options; [:id, :login, :display_name, :password] end

#login_urlString

Returns:

  • (String)

25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/common/models/wp_user.rb', line 25

def 
  unless @login_url
    @login_url = @uri.merge('wp-login.php').to_s

    # Let's check if the login url is redirected (to https url for example)
    if redirection = redirection(@login_url)
      @login_url = redirection
    end
  end

  @login_url
end

#redirection(url) ⇒ Object


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/common/models/wp_user.rb', line 38

def redirection(url)
  redirection = nil
  response = Browser.get(url)

  if response.code == 301 || response.code == 302
    redirection = response.headers_hash['location']

    # Let's check if there is a redirection in the redirection
    if other_redirection = redirection(redirection)
      redirection = other_redirection
    end
  end

  redirection
end

#to_sString

Returns:

  • (String)

55
56
57
58
59
60
# File 'lib/common/models/wp_user.rb', line 55

def to_s
  s  = "#{id}"
  s << " | #{}" if 
  s << " | #{display_name}" if display_name
  s
end

#uriURI

Returns The uri to the author page

Returns:

  • (URI)

    The uri to the author page


16
17
18
19
20
21
22
# File 'lib/common/models/wp_user.rb', line 16

def uri
  if id
    return @uri.merge("?author=#{id}")
  else
    raise 'The id is nil'
  end
end