Class: Intel
- Inherits:
-
Object
- Object
- Intel
- Defined in:
- lib/deepviz/intel.rb
Constant Summary collapse
- URL_INTEL_SEARCH =
'https://api.deepviz.com/intel/search'- URL_INTEL_IP =
'https://api.deepviz.com/intel/network/ip'- URL_INTEL_DOMAIN =
'https://api.deepviz.com/intel/network/domain'- URL_INTEL_SEARCH_ADVANCED =
'https://api.deepviz.com/intel/search/advanced'
Instance Method Summary collapse
- #advanced_search(api_key, options = {}) ⇒ Object
- #domain_info(api_key, options = {}) ⇒ Object
- #ip_info(api_key, options = {}) ⇒ Object
- #search(api_key, search_string, options = {}) ⇒ Object
Instance Method Details
#advanced_search(api_key, options = {}) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/deepviz/intel.rb', line 159 def advanced_search(api_key, ={}) if api_key == nil or api_key == '' return Result.new(status=INPUT_ERROR, msg='API key cannot be null or empty String') end defaults = { :classification => nil, :created_files => nil, :never_seen => false, :time_delta => nil, :result_set => nil, :sim_hash => nil, :imp_hash => nil, :ip_range => nil, :strings => nil, :country => nil, :domain => nil, :rules => nil, :asn => nil, :url => nil, :ip => nil, } = defaults.merge() body = { :api_key => api_key } if ['created_files'].kind_of?(Array) body[:created_files] = ['created_files'] end _never_seen = 'false' if [:never_seen] != nil and [:never_seen] _never_seen = 'true' end body[:never_seen] = _never_seen if ['result_set'].kind_of?(Array) body[:result_set] = ['result_set'] end if ['sim_hash'].kind_of?(Array) body[:sim_hash] = ['sim_hash'] end if ['imp_hash'].kind_of?(Array) body[:imp_hash] = ['imp_hash'] end if ['strings'].kind_of?(Array) body[:strings] = ['strings'] end if ['country'].kind_of?(Array) body[:country] = ['country'] end if ['classification'] != nil body[:classification] = ['classification'] end if ['domain'].kind_of?(Array) body[:domain] = ['domain'] end if ['rules'].kind_of?(Array) body[:rules] = ['rules'] end if ['time_delta'] != nil body[:time_delta] = ['time_delta'] end if ['asn'].kind_of?(Array) body[:asn] = ['asn'] end if ['url'].kind_of?(Array) body[:url] = ['url'] end if ['ip'].kind_of?(Array) body[:ip] = ['ip'] end if ['ip_range'] != nil body[:ip_range] = ['ip_range'] end return do_post(body, URL_INTEL_SEARCH_ADVANCED) end |
#domain_info(api_key, options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/deepviz/intel.rb', line 56 def domain_info(api_key, ={}) if api_key == nil or api_key == '' return Result.new(status=INPUT_ERROR, msg='API key cannot be null or empty String') end defaults = { :domain => nil, :filters => nil, :history => false, :time_delta => nil, } = defaults.merge() if (!['domain'].kind_of?(Array) and (['time_delta'] == nil or ['time_delta'] == '')) or (['domain'].kind_of?(Array) and ['time_delta'] != nil and ['time_delta'] != '') msg = 'Parameters missing or invalid. You must specify either a list of domains or time delta' return Result.new(status=INPUT_ERROR, msg=msg) end if ['history'] _history = 'true' else _history = 'false' end if ['filters'] != nil and !['filters'].kind_of?(Array) msg = 'You must provide one or more output filters in a list' return Result.new(status=INPUT_ERROR, msg=msg) end body = {} if ['domain'].kind_of?(Array) if ['filters'] != nil body = { :output_filters => ['filters'], :domain => ['domain'], :history => _history, :api_key => api_key, } else body = { :domain => ['domain'], :history => _history, :api_key => api_key, } end end if ['time_delta'] != nil and ['time_delta'] != '' if ['filters'] != nil body = { :time_delta => ['time_delta'], :output_filters => ['filters'], :history => _history, :api_key => api_key, } else body = { :time_delta => ['time_delta'], :history => _history, :api_key => api_key, } end end return do_post(body, URL_INTEL_DOMAIN) end |
#ip_info(api_key, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/deepviz/intel.rb', line 10 def ip_info(api_key, ={}) if api_key == nil or api_key == '' return Result.new(status=INPUT_ERROR, msg='API key cannot be null or empty String') end defaults = { :ip => nil, :history => false, :time_delta => nil, } = defaults.merge() if (!['ip'].kind_of?(Array) and (['time_delta'] == nil or ['time_delta'] == '')) or (['ip'].kind_of?(Array) and ['time_delta'] != nil and ['time_delta'] != '') msg = 'Parameters missing or invalid. You must specify either a list of IPs or time delta' return Result.new(status=INPUT_ERROR, msg=msg) end if ['history'] _history = 'true' else _history = 'false' end if ['ip'] != nil and !['ip'].kind_of?(Array) msg = 'You must provide one or more IPs in a list' return Result.new(status=INPUT_ERROR, msg=msg) else body = { :ip => ['ip'], :history => _history, :api_key => api_key, } end if ['time_delta'] != nil and ['time_delta'] != '' body = { :time_delta => ['time_delta'], :history => _history, :api_key => api_key, } end return do_post(body, URL_INTEL_IP) end |
#search(api_key, search_string, options = {}) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/deepviz/intel.rb', line 125 def search(api_key, search_string, ={}) if api_key == nil or api_key == '' return Result.new(status=INPUT_ERROR, msg='API key cannot be null or empty String') end if search_string == nil or search_string == '' return Result.new(status=INPUT_ERROR, msg='String to be searched cannot be null or empty') end defaults = { :start_offset => nil, :elements => nil, } = defaults.merge() if ['start_offset'] != nil and ['elements'] != nil and ['start_offset'].is_a? Integer and !['elements'].is_a? Integer result_set = ['start=%d' % ['start_offset'], 'rows=%d' % ['elements']] body = { :'result_set' => result_set, :'string' => search_string, :'api_key' => api_key, } else body = { :'string' => search_string, :'api_key' => api_key, } end return do_post(body, URL_INTEL_SEARCH) end |