Skip to content

Commit

Permalink
support for additional strategies via the api
Browse files Browse the repository at this point in the history
  • Loading branch information
jcran committed Feb 18, 2017
1 parent 2f05bf4 commit d203b10
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gem 'rake'
gem 'rspec' # Testing
gem 'rack-test' # Testing
gem 'rack-protection' # https://github.com/sinatra/rack-protection
gem 'intrigue_api_client', :git => 'https://github.com/intrigueio/intrigue_api_client.git'
gem 'intrigue_api_client', :path => "api_client"
gem 'nokogiri' # Client::Search::*Scraper

# Database
Expand Down
15 changes: 7 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ GIT
nokogiri
typhoeus

GIT
remote: https://github.com/intrigueio/intrigue_api_client.git
revision: 456e55146f9d3f7a85f974eb9525d72898aaf220
specs:
intrigue_api_client (1.1.0)
json (~> 1.8)
rest-client (~> 1.8)

GIT
remote: https://github.com/intrigueio/screencap.git
revision: e3af2819f083b021babff97a9a61278ccf99cc22
Expand Down Expand Up @@ -50,6 +42,13 @@ GIT
specs:
whoisology (0.1.0)

PATH
remote: api_client
specs:
intrigue_api_client (1.2.0)
json (~> 1.8)
rest-client (~> 1.8)

GEM
remote: https://rubygems.org/
specs:
Expand Down
3 changes: 1 addition & 2 deletions app/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Helper
###
### Helper method for starting a task run
###
def start_task(queue, project, existing_scan_result, task_name, entity, depth, options=[], handlers=[])
def start_task(queue, project, existing_scan_result, task_name, entity, depth, options=[], handlers=[], strategy_name="discovery")

# Create the task result, and associate our entity and options
task_result = Intrigue::Model::TaskResult.create({
Expand All @@ -29,7 +29,6 @@ def start_task(queue, project, existing_scan_result, task_name, entity, depth, o
# If the depth is greater than 1, AND we don't have a prexisting scan id, start a new scan
if !existing_scan_result && depth > 1

strategy_name = "discovery"
scan_result = Intrigue::Model::ScanResult.create({
:name => "#{strategy_name} to depth #{depth} on #{entity.name}",
:project => project,
Expand Down
5 changes: 3 additions & 2 deletions app/routes/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IntrigueApp < Sinatra::Base
Thread.new { `sleep 10 && service intrigue restart` }
end
end
result
result
end

### ###
Expand Down Expand Up @@ -183,6 +183,7 @@ class IntrigueApp < Sinatra::Base
task_name = payload["task"]
options = payload["options"]
handlers = payload["handlers"]
strategy_name = payload["strategy_name"]

# Try to find our project and create it if it doesn't exist
project = Intrigue::Model::Project.first(:name => project_name)
Expand All @@ -199,7 +200,7 @@ class IntrigueApp < Sinatra::Base
end

# Start the task_run
task_result = start_task("task", project, nil, task_name, entity, depth, options, handlers)
task_result = start_task("task", project, nil, task_name, entity, depth, options, handlers, strategy_name)
status 200 if task_result

# must be a string otherwise it can be interpreted as a status code
Expand Down
12 changes: 6 additions & 6 deletions core-cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def info(task_name)
end
end

desc "start [Project Name] [Task] [Type#Entity] [Depth] [Option1=Value1#...#...] [Handlers]", "Start a single task within a project."
def start(project_name,task_name,entity_string,depth=1,option_string=nil,handler_string=nil)
desc "start [Project Name] [Task] [Type#Entity] [Depth] [Option1=Value1#...#...] [Handlers] [Strategy Name]", "Start a single task within a project."
def start(project_name,task_name,entity_string,depth=1,option_string=nil,handler_string=nil, strategy_name="discovery")

# Do the setup
entity_hash = _parse_entity entity_string
Expand All @@ -81,7 +81,7 @@ def start(project_name,task_name,entity_string,depth=1,option_string=nil,handler
# Get the response from the API
#puts "[+] Starting Task."

response = @api.start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list)
response = @api.start(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name)
#puts "[D] Got response: #{response}" if @debug
#unless response
# puts "Error retrieving response. Failing."
Expand Down Expand Up @@ -151,8 +151,8 @@ def local_handle_task_results(project,handler_type)

end

desc "local_load [Task] [File] [Depth] [Option1=Value1#...#...] [Handlers]", "Load entities from a file and runs a task on each in a new project."
def load(task_name,filename,depth=1,options_string=nil,handler_string=nil)
desc "local_load [Task] [File] [Depth] [Option1=Value1#...#...] [Handlers] [Strategy]", "Load entities from a file and runs a task on each in a new project."
def load(task_name,filename,depth=1,options_string=nil,handler_string=nil, strategy_name="discovery")

# Load in the main core file for direct access to TaskFactory and the Tasks
# This makes this super speedy.
Expand Down Expand Up @@ -195,7 +195,7 @@ def load(task_name,filename,depth=1,options_string=nil,handler_string=nil)
})
end

task_result = start_task("task", p, nil, task_name, e, depth, options, handlers)
task_result = start_task("task", p, nil, task_name, e, depth, options, handlers, strategy_name)

puts "Created task #{task_result.inspect} for entity #{e}"
end
Expand Down
2 changes: 2 additions & 0 deletions lib/entity_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def self.create_or_merge_entity_recursive(task_result,type_string,name,details,
unless prohibited_entity? entity
if scan_result.strategy == "discovery"
Intrigue::Strategy::Discovery.recurse(entity, task_result)
elsif scan_result.strategy == "web_discovery"
Intrigue::Strategy::WebDiscovery.recurse(entity, task_result)
end
end
end
Expand Down

0 comments on commit d203b10

Please sign in to comment.