Module: Ronin::Script::Deployable

Includes:
Testable, UI::Output::Helpers
Defined in:
lib/ronin/script/deployable.rb

Overview

Adds deployment methods to an Ronin::Script.

Since:

  • 1.1.0

Instance Method Summary collapse

Methods included from Testable

#flunk, #test, #test!, #test?, #test_equal, #test_in, #test_match, #test_no_match, #test_not_equal, #test_not_in, #test_set

Instance Method Details

#deploy { ... } ⇒ Script (protected)

Registers a given block to be called when the script is being deployed.

Yields:

  • [] The given block will be called when the script is being deployed.

Returns:

Since:

  • 1.1.0


177
178
179
180
# File 'lib/ronin/script/deployable.rb', line 177

def deploy(&block)
  @deploy_blocks << block
  return self
end

#deploy! { ... } ⇒ Script

Tests and then deploys the exploit. If a payload has been set, the payload will also be deployed.

Yields:

  • [] If a block is given, it will be passed the deployed script after a successful deploy.

Returns:

  • (Script)

    The deployed script.

See Also:

Since:

  • 1.1.0


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ronin/script/deployable.rb', line 86

def deploy!
  test!

  print_info "Deploying #{script_type} #{self} ..."

  @deployed = false
  @deploy_blocks.each { |block| block.call() }
  @deployed = true
  @evacuated = false

  print_info "#{script_type} #{self} deployed!"

  yield if block_given?
  return self
end

#deploy_failed!(message) ⇒ Object (protected)

Indicates the deployment of the exploit has failed.

Raises:

Since:

  • 1.1.0


158
159
160
# File 'lib/ronin/script/deployable.rb', line 158

def deploy_failed!(message)
  raise(DeployFailed,message)
end

#deployed?Boolean

Determines whether the script was deployed.

Returns:

  • (Boolean)

    Specifies whether the script was previously deployed.

Since:

  • 1.1.0


65
66
67
# File 'lib/ronin/script/deployable.rb', line 65

def deployed?
  @deployed == true
end

#evacuate { ... } ⇒ Script (protected)

Registers a given block to be called when the script is being evacuated.

Yields:

  • [] The given block will be called when the script is being evacuated.

Returns:

Since:

  • 1.1.0


197
198
199
200
# File 'lib/ronin/script/deployable.rb', line 197

def evacuate(&block)
  @evacuate_blocks.unshift(block)
  return self
end

#evacuate! { ... } ⇒ Script

Evacuates the deployed script.

Yields:

  • [] If a block is given, it will be called before the script is evacuated.

Returns:

  • (Script)

    The evacuated script.

See Also:

Since:

  • 1.1.0


132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/ronin/script/deployable.rb', line 132

def evacuate!
  yield if block_given?

  print_info "Evauating #{script_type} #{self} ..."

  @evacuated = false
  @evacuate_blocks.each { |block| block.call() }
  @evacuated = true
  @deployed = false

  print_info "#{script_type} #{self} evacuated."
  return self
end

#evacuated?Boolean

Determines whether the script was evacuated.

Returns:

  • (Boolean)

    Specifies whether the script has been evacuated.

Since:

  • 1.1.0


112
113
114
# File 'lib/ronin/script/deployable.rb', line 112

def evacuated?
  @evacuated == true
end

#initialize(attributes = {}) ⇒ Object

Initializes the deployable script.

Parameters:

  • attributes (Hash) (defaults to: {})

    Additional attributes for the script.

Since:

  • 1.1.0


45
46
47
48
49
50
51
52
53
# File 'lib/ronin/script/deployable.rb', line 45

def initialize(attributes={})
  super(attributes)

  @deploy_blocks = []
  @deployed = false

  @evacuate_blocks = []
  @evacuated = false
end