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_DOWNLOAD_REPORT =
'https://api.deepviz.com/intel/report'- 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, domain, filters = nil) ⇒ Object
- #ip_info(api_key, ip, filters = nil) ⇒ Object
- #sample_info(api_key, md5, filters) ⇒ Object
- #sample_result(api_key, md5) ⇒ Object
- #search(api_key, search_string, options = {}) ⇒ Object
Instance Method Details
#advanced_search(api_key, options = {}) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 158 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 |
# File 'lib/deepviz/intel.rb', line 109 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, domain, filters = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/deepviz/intel.rb', line 43 def domain_info(api_key, domain, filters = nil) if api_key.nil? or api_key == '' return Result.new(status=INPUT_ERROR, msg='API key cannot be null or empty String') end if domain.nil? or domain == '' msg = 'Parameters missing or invalid. You must specify an domain.' return Result.new(status=INPUT_ERROR, msg=msg) 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 if filters != nil body = { :output_filters => filters, :api_key => api_key, :domain => domain, } else body = { :api_key => api_key, :domain => domain, } end return do_post(body, URL_INTEL_DOMAIN) end |
#ip_info(api_key, ip, filters = nil) ⇒ Object
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 |
# File 'lib/deepviz/intel.rb', line 11 def ip_info(api_key, ip, filters=nil) if api_key == nil or api_key == '' return Result.new(status=INPUT_ERROR, msg='API key cannot be null or empty String') end if ip.nil? or ip == '' msg = 'Parameters missing or invalid. You must specify an IP.' return Result.new(status=INPUT_ERROR, msg=msg) 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 if filters != nil body = { :output_filters => filters, :api_key => api_key, :ip => ip, } else body = { :api_key => api_key, :ip => ip, } end return do_post(body, URL_INTEL_IP) end |
#sample_info(api_key, md5, filters) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/deepviz/intel.rb', line 228 def sample_info(api_key, md5, filters) if api_key == nil or api_key == '' return Result.new(status=INPUT_ERROR, msg='API key cannot be null or empty String') end if md5 == nil or md5 == '' return Result.new(status=INPUT_ERROR, msg='MD5 cannot be null or empty String') end if filters != nil if 0 < filters.length > 10 return Result.new(status=INPUT_ERROR, msg='Parameter \'output_filters\' takes at least 1 value and at most 10 values (%s given)' % [filters.length]) end body = {:api_key => api_key, :md5 => md5, :output_filters => filters} else return Result.new(status=INPUT_ERROR, msg='Output filters cannot be null or empty') end return do_post(body, URL_INTEL_DOWNLOAD_REPORT) end |
#sample_result(api_key, md5) ⇒ Object
223 224 225 |
# File 'lib/deepviz/intel.rb', line 223 def sample_result(api_key, md5) return sample_info(api_key, md5, ['classification']) end |
#search(api_key, search_string, options = {}) ⇒ Object
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 |
# File 'lib/deepviz/intel.rb', line 75 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 |