intrigue_api_client 1.0.5 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/intrigue_api_client.rb +48 -54
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7584cd1b0f64137d233048a2417c114608108778
4
- data.tar.gz: 5120734394133b63b0d78993c124aadac04677ef
3
+ metadata.gz: 3147774f9cc7bca2a2645b1daeeabb4ec01ff203
4
+ data.tar.gz: af53daf2a1e68616a2527243e0bdb5b79ce7ec52
5
5
  SHA512:
6
- metadata.gz: 258cae10730ec552a67c32960bcf9bcd25eb783ec6d758e3fb66b448a50d895b5f96ef34d341376639841a4a7e45a9f04c1232620070a8f78cd261bb7a37169a
7
- data.tar.gz: c6914d3271b78359b6bb4ecb873e37dcbce30cf99a201fccffdba5e79592d1d31c8fe365af7f0d4c138c2a933a7acafd4c419601609a382579b1efe35e5e8be9
6
+ metadata.gz: e223ecfe1d3c04147f0aa31f0c6da6211f75f2de5cee64a205cccc11d79c1077e225572cbadc04cf87c8c90bb5f4ac6f999d715edc39c2ee09937134e3fef743
7
+ data.tar.gz: 1629e543d8203c531e65894092756437c5fe5c2d5bc5d4760a61ec83f56c39a4dcb6161208d9979ce1eba4cbf5254ba16d830c8302bac53bcf385acc75193c66
@@ -4,7 +4,7 @@ require 'rest_client'
4
4
 
5
5
  class IntrigueApi
6
6
 
7
- def initialize(uri,key="")
7
+ def initialize(uri="http://127.0.0.1:7777/v1",key="")
8
8
  @intrigue_basedir = File.dirname(__FILE__)
9
9
  @server_uri = uri
10
10
  end
@@ -16,50 +16,23 @@ class IntrigueApi
16
16
 
17
17
  # Show detailed about a task
18
18
  def info(task_name)
19
- _get_json_result "#{@server_uri}/tasks/#{task_name}.json"
19
+ _get_json_result "tasks/#{task_name}.json"
20
20
  end
21
21
 
22
- # start_and_background - start and background a task
23
- #
24
- # project_name - must exist as a valid project_name
25
- # task_name - must exist as a valid task name
26
- # entity_hash - symbol-based hash representing an entity: {
27
- # :type => "String"
28
- # :attributes => { :name => "intrigue.io"}
29
- # }
30
- # options_list - list of options: [
31
- # {:name => "resolver", :value => "8.8.8.8" }
32
- # ]
33
- def start_and_background(project_name,task_name,entity_hash,options_list=nil,handler_list=nil)
34
-
35
- payload = {
36
- "project_name" => project_name,
37
- "task" => task_name,
38
- "options" => options_list,
39
- "handlers" => handler_list,
40
- "entity" => entity_hash
41
- }
42
-
43
- ### Send to the server
44
- task_id = RestClient.post "#{@server_uri}/#{project_name}/task_results",
45
- payload.to_json, :content_type => "application/json"
46
-
47
- if task_id == "" # technically a nil is returned , but becomes an empty string
48
- #puts "[-] Task not started. Unknown Error. Exiting"
49
- return nil
50
- end
51
-
52
- task_id
22
+ # create a new project
23
+ def create_project(project_name)
24
+ RestClient.post "#{@server_uri}/project", { "project" => project_name }
53
25
  end
54
26
 
55
27
  # Start a task and wait for the result
56
- def start(project_name,task_name,entity_hash,options_list=nil,handler_list=nil)
28
+ def start(project_name,task_name,entity_hash,depth=1,options_list=nil,handler_list=nil, strategy_name="disovery")
57
29
 
58
30
  # Construct the request
59
- task_id = start_and_background(project_name,task_name,entity_hash,options_list,handler_list)
31
+ task_id = _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name)
60
32
 
61
33
  if task_id == "" # technically a nil is returned , but becomes an empty string
62
34
  #puts "[-] Task not started. Unknown Error. Exiting"
35
+ #raise "Problem getting result"
63
36
  return nil
64
37
  end
65
38
 
@@ -68,50 +41,70 @@ class IntrigueApi
68
41
  until complete
69
42
  sleep 1
70
43
  begin
71
- response = RestClient.get "#{@server_uri}/#{project_name}/task_results/#{task_id}/complete"
44
+ check_uri = "#{@server_uri}/#{project_name}/results/#{task_id}/complete"
45
+ response = RestClient.get check_uri
72
46
  complete = true if response == "true"
47
+
48
+ return nil if response == ""
49
+
73
50
  rescue URI::InvalidURIError => e
74
- puts "[-] Invalid URI: #{uri}"
75
- return
51
+ puts "[-] Invalid URI: #{check_uri}"
52
+ return nil
76
53
  end
77
54
  end
78
55
 
79
56
  ### Get the response
80
- response = _get_json_result "#{project_name}/task_results/#{task_id}.json"
57
+ response = _get_json_result "#{project_name}/results/#{task_id}.json"
58
+ #puts response
81
59
 
82
60
  response
83
61
  end
84
62
 
85
- # start_scan_and_background - start and background a scan
86
- def start_scan_and_background(project_name,scan_type,entity_hash,options_list=nil,handler_list=nil)
63
+
64
+ private
65
+ # start_and_background - start and background a task
66
+ #
67
+ # project_name - must exist as a valid project_name
68
+ # task_name - must exist as a valid task name
69
+ # entity_hash - symbol-based hash representing an entity: {
70
+ # :type => "String"
71
+ # :attributes => { :name => "intrigue.io"}
72
+ # }
73
+ # options_list - list of options: [
74
+ # {:name => "resolver", :value => "8.8.8.8" }
75
+ # ]
76
+ def _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name)
87
77
 
88
78
  payload = {
89
79
  "project_name" => project_name,
90
- "scan_type" => scan_type,
80
+ "task" => task_name,
91
81
  "options" => options_list,
82
+ "handlers" => handler_list,
92
83
  "entity" => entity_hash,
93
- "handlers" => handler_list
84
+ "depth" => depth,
85
+ "strategy_name" => strategy_name
94
86
  }
95
87
 
96
88
  ### Send to the server
97
- scan_id = RestClient.post "#{@server_uri}/#{project_name}/scan_results",
89
+ task_id = RestClient.post "#{@server_uri}/#{project_name}/results",
98
90
  payload.to_json, :content_type => "application/json"
99
91
 
100
-
101
- if scan_id == "" # technically a nil is returned , but becomes an empty string
92
+ if task_id == "" # technically a nil is returned , but becomes an empty string
93
+ #puts "[-] Task not started. Unknown Error. Exiting"
94
+ #raise "Problem getting result"
102
95
  return nil
103
96
  end
104
97
 
105
- scan_id
98
+ task_id
106
99
  end
107
100
 
108
- def get_log(task_id)
109
- log = _get_json_result "#{project_name}/task_results/#{task_id}/log"
101
+ def _get_log(task_id)
102
+ log = _get_json_result "#{project_name}/results/#{task_id}/log"
110
103
  end
111
104
 
112
- def get_result(task_id)
105
+ def _get_result(task_id)
113
106
  begin
114
- result = _get_json_result "#{project_name}/task_results/#{task_id}.json"
107
+ result = _get_json_result "#{project_name}/results/#{task_id}.json"
115
108
  rescue JSON::ParserError => e
116
109
  response = nil
117
110
  end
@@ -120,12 +113,13 @@ class IntrigueApi
120
113
 
121
114
  def _get_json_result(path)
122
115
  begin
123
- JSON.parse(RestClient.get "#{@server_uri}/#{path}")
116
+ result = JSON.parse(RestClient.get "#{@server_uri}/#{path}")
124
117
  rescue JSON::ParserError => e
125
118
  puts "Error: #{e}"
126
119
  rescue RestClient::InternalServerError => e
127
120
  puts "Error: #{e}"
128
121
  end
122
+ result
129
123
  end
130
124
 
131
125
 
@@ -158,7 +152,7 @@ x = Intrigue.new
158
152
 
159
153
  x.start "example", entity_hash, options_list
160
154
  id = x.start "search_bing", entity_hash, options_list
161
- puts x.get_log id
162
- puts x.get_result id
155
+ puts x._get_log id
156
+ puts x._get_result id
163
157
 
164
158
  =end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intrigue_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jcran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2017-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client