2014-07-04 15:53:14 +00:00
|
|
|
require 'json'
|
|
|
|
|
|
|
|
module Sqlmap
|
|
|
|
class Manager
|
|
|
|
def initialize(session)
|
|
|
|
@session = session
|
|
|
|
end
|
|
|
|
|
|
|
|
def new_task
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.get('/task/new')
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def delete_task(task_id)
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.get('/task/' + task_id + '/delete')
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_option(task_id, key, value)
|
|
|
|
post = { key => value }
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.post('/option/' + task_id + '/set', nil, post.to_json, {'ctype' => 'application/json'})
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_options(task_id)
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.get('/option/' + task_id + '/list')
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_task(task_id, options = {})
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.post('/scan/' + task_id + '/start' , nil, options.to_json, {'ctype' => 'application/json'})
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2015-04-24 07:00:50 +00:00
|
|
|
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_task_status(task_id)
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.get('/scan/' + task_id + '/status')
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_task_log(task_id)
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.get('/scan/' + task_id + '/log')
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_task_data(task_id)
|
2014-07-21 23:04:36 +00:00
|
|
|
res = @session.get('/scan/' + task_id + '/data')
|
2015-04-24 10:40:35 +00:00
|
|
|
parse_response(res)
|
2015-04-24 07:00:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def parse_response(res)
|
2015-05-02 10:11:59 +00:00
|
|
|
json = {}
|
2015-04-24 10:40:35 +00:00
|
|
|
if res && res.body
|
|
|
|
begin
|
2015-05-02 10:11:59 +00:00
|
|
|
json = JSON.parse(res.body)
|
2015-04-24 10:40:35 +00:00
|
|
|
rescue JSON::ParserError
|
|
|
|
end
|
2015-04-24 07:00:50 +00:00
|
|
|
end
|
|
|
|
|
2015-05-02 10:11:59 +00:00
|
|
|
json
|
2014-07-04 15:53:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|