mihari 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bd4fc32291966114c9c687f44c930d1974348cc61a36cf682f33efcc617118f
4
- data.tar.gz: a7ed78b49a8b3fe3e9ea398d1e41d13c3ed9f3dd6c23ac2de4e1d8cd8328e59e
3
+ metadata.gz: 6d6b5d42dc4fbe937cc101f7dbdfa1491104f2b6f70fdf690b2ad51db02304c5
4
+ data.tar.gz: 32b5df5f6970d6aaf6f9d5c57ca9bc86d8e43f0298f22c6c9e811cf60a6d1089
5
5
  SHA512:
6
- metadata.gz: f752ce54d8cccc4b6f8c81a87939dabf707629ca1ce5c3244f7ae7a595e808b0a326dc068eac58f705b48b65c7d378aa22f7ee062bcce3d967a6e3518ea29974
7
- data.tar.gz: 00110a28edd487a1f4f200f3f0fd93f28b8fd358de936651453b2caa75420a90b330f1605f3a8c2a3e36b362fc269a178b693f1752249768591dbb413dcaf555
6
+ metadata.gz: 16cdfd458c0d464eb618fc5aae8386c1cb37fd554fd6aba275323cb539a08916f3cd855e4e5683085e03f206debe879af6f2e3c7a42b1cd0b2a6395d86e3f55a
7
+ data.tar.gz: 93f9e9e2165e79ef6602d1628b5689e0993ae4d88605db4f6aa4ff79dc6a21d25437997a1402f76ce3a5e2e9155ad68a441a8cc8351b54c5f4d1c3a72eb82df4
data/README.md CHANGED
@@ -71,6 +71,7 @@ Mihari supports the following services by default.
71
71
  - [PassiveTotal](https://community.riskiq.com/)
72
72
  - [SecurityTrails](https://securitytrails.com/)
73
73
  - [Shodan](https://shodan.io)
74
+ - [Spyse](https://spyse.com)
74
75
  - [urlscan.io](https://urlscan.io)
75
76
  - [VirusTotal](http://virustotal.com)
76
77
  - [ZoomEye](https://zoomeye.org)
@@ -99,6 +100,7 @@ Commands:
99
100
  mihari securitytrails [IP|DOMAIN|EMAIL] # SecurityTrails lookup by an ip, domain or email
100
101
  mihari securitytrails_domain_feed [REGEXP] # SecurityTrails new domain feed search by a regexp
101
102
  mihari shodan [QUERY] # Shodan host search by a query
103
+ mihari spyse [QUERY] # Spyse search by a query
102
104
  mihari ssh_fingerprint [FINGERPRINT] # Cross search with search engines by an SSH fingerprint (e.g. dc:14:de:8e:d7:c1:15:43:23:82:25:81:d2:59:e8:c0)
103
105
  mihari status # Show the current configuration status
104
106
  mihari urlscan [QUERY] # urlscan search by a given query
@@ -221,6 +223,7 @@ Configuration can be done via environment variables or a YAML file.
221
223
  | SHODAN_API_KEY | Shodan API key | |
222
224
  | SLACK_CHANNEL | Slack channel name | `#general` |
223
225
  | SLACK_WEBHOOK_URL | Slack Webhook URL | |
226
+ | SPYSE_API_KEY | Spyse API key | |
224
227
  | THEHIVE_API_ENDPOINT | TheHive URL | |
225
228
  | THEHIVE_API_KEY | TheHive API key | |
226
229
  | VIRUSTOTAL_API_KEY | VirusTotal API key | |
@@ -56,6 +56,7 @@ require "mihari/analyzers/pulsedive"
56
56
  require "mihari/analyzers/securitytrails_domain_feed"
57
57
  require "mihari/analyzers/securitytrails"
58
58
  require "mihari/analyzers/shodan"
59
+ require "mihari/analyzers/spyse"
59
60
  require "mihari/analyzers/urlscan"
60
61
  require "mihari/analyzers/virustotal"
61
62
  require "mihari/analyzers/zoomeye"
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spyse"
4
+ require "json"
5
+
6
+ module Mihari
7
+ module Analyzers
8
+ class Spyse < Base
9
+ attr_reader :query
10
+ attr_reader :type
11
+
12
+ attr_reader :title
13
+ attr_reader :description
14
+ attr_reader :tags
15
+
16
+ def initialize(query, title: nil, description: nil, tags: [], type: "domain")
17
+ super()
18
+
19
+ @query = query
20
+
21
+ @title = title || "Spyse lookup"
22
+ @description = description || "query = #{query}"
23
+ @tags = tags
24
+ @type = type
25
+ end
26
+
27
+ def artifacts
28
+ lookup || []
29
+ end
30
+
31
+ private
32
+
33
+ def search_params
34
+ @search_params ||= JSON.parse(query)
35
+ end
36
+
37
+ def config_keys
38
+ %w(spyse_api_key)
39
+ end
40
+
41
+ def api
42
+ @api ||= ::Spyse::API.new(Mihari.config.spyse_api_key)
43
+ end
44
+
45
+ def valid_type?
46
+ %w(ip domain cert).include? type
47
+ end
48
+
49
+ def domain_lookup
50
+ res = api.domain.search(search_params, limit: 100)
51
+ items = res.dig("data", "items") || []
52
+ items.map do |item|
53
+ item.dig("name")
54
+ end.uniq.compact
55
+ end
56
+
57
+ def ip_lookup
58
+ res = api.ip.search(search_params, limit: 100)
59
+ items = res.dig("data", "items") || []
60
+ items.map do |item|
61
+ item.dig("ip")
62
+ end.uniq.compact
63
+ end
64
+
65
+ def lookup
66
+ case type
67
+ when "domain"
68
+ domain_lookup
69
+ when "ip"
70
+ ip_lookup
71
+ else
72
+ raise InvalidInputError, "#{query}(type: #{type || 'unknown'}) is not supported." unless valid_type?
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -174,6 +174,17 @@ module Mihari
174
174
  end
175
175
  end
176
176
 
177
+ desc "spyse [QUERY]", "Spyse search by a query"
178
+ method_option :title, type: :string, desc: "title"
179
+ method_option :description, type: :string, desc: "description"
180
+ method_option :tags, type: :array, desc: "tags"
181
+ method_option :type, type: :string, desc: "type to search (ip or domain)", default: "doamin"
182
+ def spyse(query)
183
+ with_error_handling do
184
+ run_analyzer Analyzers::Spyse, query: query, options: options
185
+ end
186
+ end
187
+
177
188
  desc "passive_dns [IP|DOMAIN]", "Cross search with passive DNS services by an ip or domain"
178
189
  method_option :title, type: :string, desc: "title"
179
190
  method_option :description, type: :string, desc: "description"
@@ -20,6 +20,7 @@ module Mihari
20
20
  attr_accessor :shodan_api_key
21
21
  attr_accessor :slack_channel
22
22
  attr_accessor :slack_webhook_url
23
+ attr_accessor :spyse_api_key
23
24
  attr_accessor :thehive_api_endpoint
24
25
  attr_accessor :thehive_api_key
25
26
  attr_accessor :virustotal_api_key
@@ -49,6 +50,7 @@ module Mihari
49
50
  @shodan_api_key = ENV["SHODAN_API_KEY"]
50
51
  @slack_channel = ENV["SLACK_CHANNEL"]
51
52
  @slack_webhook_url = ENV["SLACK_WEBHOOK_URL"]
53
+ @spyse_api_key = ENV["SPYSE_API_KEY"]
52
54
  @thehive_api_endpoint = ENV["THEHIVE_API_ENDPOINT"]
53
55
  @thehive_api_key = ENV["THEHIVE_API_KEY"]
54
56
  @virustotal_api_key = ENV["VIRUSTOTAL_API_KEY"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "1.2.1"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -62,6 +62,7 @@ Gem::Specification.new do |spec|
62
62
  spec.add_dependency "securitytrails", "~> 1.0"
63
63
  spec.add_dependency "shodanx", "~> 0.2"
64
64
  spec.add_dependency "slack-notifier", "~> 2.3"
65
+ spec.add_dependency "spysex", "~> 0.1"
65
66
  spec.add_dependency "sqlite3", "~> 1.4"
66
67
  spec.add_dependency "thor", "~> 1.0"
67
68
  spec.add_dependency "urlscan", "~> 0.5"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mihari
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-10 00:00:00.000000000 Z
11
+ date: 2020-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -528,6 +528,20 @@ dependencies:
528
528
  - - "~>"
529
529
  - !ruby/object:Gem::Version
530
530
  version: '2.3'
531
+ - !ruby/object:Gem::Dependency
532
+ name: spysex
533
+ requirement: !ruby/object:Gem::Requirement
534
+ requirements:
535
+ - - "~>"
536
+ - !ruby/object:Gem::Version
537
+ version: '0.1'
538
+ type: :runtime
539
+ prerelease: false
540
+ version_requirements: !ruby/object:Gem::Requirement
541
+ requirements:
542
+ - - "~>"
543
+ - !ruby/object:Gem::Version
544
+ version: '0.1'
531
545
  - !ruby/object:Gem::Dependency
532
546
  name: sqlite3
533
547
  requirement: !ruby/object:Gem::Requirement
@@ -642,6 +656,7 @@ files:
642
656
  - lib/mihari/analyzers/securitytrails.rb
643
657
  - lib/mihari/analyzers/securitytrails_domain_feed.rb
644
658
  - lib/mihari/analyzers/shodan.rb
659
+ - lib/mihari/analyzers/spyse.rb
645
660
  - lib/mihari/analyzers/ssh_fingerprint.rb
646
661
  - lib/mihari/analyzers/urlscan.rb
647
662
  - lib/mihari/analyzers/virustotal.rb