CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/sqlmap/sqlmap_manager.rb
Views: 1904
1
require 'json'
2
3
module Sqlmap
4
class Manager
5
def initialize(session)
6
@session = session
7
end
8
9
def new_task
10
res = @session.get('/task/new')
11
parse_response(res)
12
end
13
14
def delete_task(task_id)
15
res = @session.get('/task/' + task_id + '/delete')
16
parse_response(res)
17
end
18
19
def set_option(task_id, key, value)
20
post = { key => value }
21
res = @session.post('/option/' + task_id + '/set', nil, post.to_json, {'ctype' => 'application/json'})
22
parse_response(res)
23
end
24
25
def get_options(task_id)
26
res = @session.get('/option/' + task_id + '/list')
27
parse_response(res)
28
end
29
30
def start_task(task_id, options = {})
31
res = @session.post('/scan/' + task_id + '/start' , nil, options.to_json, {'ctype' => 'application/json'})
32
parse_response(res)
33
34
end
35
36
def get_task_status(task_id)
37
res = @session.get('/scan/' + task_id + '/status')
38
parse_response(res)
39
end
40
41
def get_task_log(task_id)
42
res = @session.get('/scan/' + task_id + '/log')
43
parse_response(res)
44
end
45
46
def get_task_data(task_id)
47
res = @session.get('/scan/' + task_id + '/data')
48
parse_response(res)
49
end
50
51
private
52
def parse_response(res)
53
json = {}
54
if res && res.body
55
begin
56
json = JSON.parse(res.body)
57
rescue JSON::ParserError
58
end
59
end
60
61
json
62
end
63
end
64
end
65
66