metasploit-framework/lib/sqlmap/sqlmap_manager.rb

65 lines
1.4 KiB
Ruby
Raw Normal View History

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')
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')
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'})
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')
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'})
parse_response(res)
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')
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')
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')
parse_response(res)
end
private
def parse_response(res)
json = {}
if res && res.body
begin
json = JSON.parse(res.body)
rescue JSON::ParserError
end
end
json
2014-07-04 15:53:14 +00:00
end
end
end