Class: Gophish::Page

Inherits:
Base
  • Object
show all
Defined in:
lib/gophish/page.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, configuration, delete, #destroy, find, get, #initialize, #new_record?, #persisted?, post, put, resource_name, resource_path, #save, #update_attributes

Constructor Details

This class inherits a constructor from Gophish::Base

Class Method Details

.build_import_options(url, include_resources) ⇒ Object



37
38
39
40
41
42
# File 'lib/gophish/page.rb', line 37

def self.build_import_options(url, include_resources)
  {
    body: { url:, include_resources: }.to_json,
    headers: { 'Content-Type' => 'application/json' }
  }
end

.import_site(url, include_resources: false) ⇒ Object

Raises:



29
30
31
32
33
34
35
# File 'lib/gophish/page.rb', line 29

def self.import_site(url, include_resources: false)
  options = build_import_options url, include_resources
  response = post '/import/site', options
  raise StandardError, 'Failed to import site' unless response.success?

  response.parsed_response
end

Instance Method Details

#body_for_createObject



19
20
21
22
23
24
25
26
27
# File 'lib/gophish/page.rb', line 19

def body_for_create
  {
    name:,
    html:,
    capture_credentials:,
    capture_passwords:,
    redirect_url:
  }
end

#captures_credentials?Boolean

Returns:



44
45
46
# File 'lib/gophish/page.rb', line 44

def captures_credentials?
  capture_credentials == true
end

#captures_passwords?Boolean

Returns:



48
49
50
# File 'lib/gophish/page.rb', line 48

def captures_passwords?
  capture_passwords == true
end

#has_redirect?Boolean

Returns:



52
53
54
# File 'lib/gophish/page.rb', line 52

def has_redirect?
  !redirect_url.blank?
end