Module: Pentest
- Defined in:
- lib/pentest.rb,
lib/pentest/dsl.rb,
lib/pentest/logger.rb,
lib/pentest/runner.rb,
lib/pentest/payload.rb,
lib/pentest/version.rb,
lib/pentest/checkers.rb,
lib/pentest/endpoint.rb,
lib/pentest/ast_utils.rb,
lib/pentest/sql_proxy.rb,
lib/pentest/commandline.rb,
lib/pentest/ruby_parser.rb
Defined Under Namespace
Modules: AstUtils, DSL, Logger, RubyParser
Classes: BaseChecker, Checkers, Commandline, Endpoint, Error, Payload, Runner, SqlProxy, SqliChecker, XssChecker
Constant Summary
collapse
- VERSION =
"1.0.1"
- @@hooks =
{before_attacks: [], setups: []}
Class Method Summary
collapse
Class Method Details
.add_before_attack(*args, &block) ⇒ Object
77
78
79
|
# File 'lib/pentest.rb', line 77
def add_before_attack(*args, &block)
@@hooks[:before_attacks] << block
end
|
.add_setup(*args, &block) ⇒ Object
73
74
75
|
# File 'lib/pentest.rb', line 73
def add_setup(*args, &block)
@@hooks[:setups] << block
end
|
.get_project_name ⇒ Object
67
68
69
70
71
|
# File 'lib/pentest.rb', line 67
def get_project_name
if defined?(::Rails)
::Rails.application.class.parent_name
end
end
|
.is_project_loaded? ⇒ Boolean
63
64
65
|
# File 'lib/pentest.rb', line 63
def is_project_loaded?
defined?(::Rails)
end
|
.run(options) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/pentest.rb', line 22
def run options
Logger.debug "launched"
ENV['RAILS_ENV'] ||= 'test'
Logger.debug "Loading Rails project..."
@app_path = File.expand_path(options[:app_path])
unless File.directory?(@app_path)
Logger.error "#{options[:app_path]} is not valid directory."
return :error
end
environment_path = File.expand_path('config/environment.rb', @app_path)
unless File.file?(environment_path)
Logger.error "Your project does not contain config/environment.rb file, which must be exist on every valid Rails project. Check your configuration."
return :error
end
require environment_path
unless is_project_loaded?
Logger.error "Rails project not loaded. Check if your config/environment.rb file is valid."
return :error
end
Logger.debug "Loaded Rails project #{get_project_name.inspect} (Rails #{Rails::VERSION::STRING})"
pentestfile_path = options[:pentestfile] || 'Pentestfile'
Logger.debug "Loading #{pentestfile_path}..."
load_pentestfile(pentestfile_path)
Logger.debug "Initializing scanner..."
runner = Runner.new(@app_path, @@hooks)
runner.run
end
|