Class: Codesake::Core::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/codesake/core/target.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Target

Returns a new instance of Target.



31
32
33
34
35
36
37
38
39
# File 'lib/codesake/core/target.rb', line 31

def initialize(options={})
  $logger = Codesake::Commons::Logging.instance
  @agent  = Mechanize.new
  @page   = nil

  @url      ||= options[:url]
  @username ||= options[:username]
  @password ||= options[:password]
end

Instance Attribute Details

#cmsObject (readonly)

Returns the value of attribute cms.



17
18
19
# File 'lib/codesake/core/target.rb', line 17

def cms
  @cms
end

#cookiesObject (readonly)

Returns the value of attribute cookies.



26
27
28
# File 'lib/codesake/core/target.rb', line 26

def cookies
  @cookies
end

#languageObject (readonly)

Returns the value of attribute language.



16
17
18
# File 'lib/codesake/core/target.rb', line 16

def language
  @language
end

#pageObject (readonly)

Returns the value of attribute page.



11
12
13
# File 'lib/codesake/core/target.rb', line 11

def page
  @page
end

#passwordObject (readonly)

Returns the value of attribute password.



9
10
11
# File 'lib/codesake/core/target.rb', line 9

def password
  @password
end

#scoreObject (readonly)

Returns the value of attribute score.



28
29
30
# File 'lib/codesake/core/target.rb', line 28

def score
  @score
end

#site_treeObject (readonly)

This is the website tree. Fed by codesake-links. Each tree element is an hash like :code, :kind, :dynamic :dynamic is true or false if the page has some dynamic content that needs to be exploited (url parameters, forms, …)



24
25
26
# File 'lib/codesake/core/target.rb', line 24

def site_tree
  @site_tree
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/codesake/core/target.rb', line 7

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username.



8
9
10
# File 'lib/codesake/core/target.rb', line 8

def username
  @username
end

#vulnsObject (readonly)

Returns the value of attribute vulns.



29
30
31
# File 'lib/codesake/core/target.rb', line 29

def vulns
  @vulns
end

#webserverObject (readonly)

This will be fed by codesake-gengiscan



15
16
17
# File 'lib/codesake/core/target.rb', line 15

def webserver
  @webserver
end

Instance Method Details

#get_page(url = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/codesake/core/target.rb', line 45

def get_page(url = nil)
  url = @url if url.nil?

  begin
    @page = @agent.get(url)
    @cookies = @agent.cookies
  rescue => e
    $logger.err "get_page(): #{e.message}"
    @page = nil
  end

  @page
end

#has_page?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/codesake/core/target.rb', line 41

def has_page?
  ! @page.nil?
end

#is_alive?Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
68
69
# File 'lib/codesake/core/target.rb', line 59

def is_alive?
  return false unless url
  return false unless @agent

  begin
    @agent.get('/')
    return true
  rescue Net::HTTP::Persistent::Error=>e
    return false
  end
end