mihari 5.6.2 → 5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/README.md +1 -0
- data/config.ru +1 -1
- data/docs/analyzers/fofa.md +31 -0
- data/docs/analyzers/index.md +1 -0
- data/frontend/package-lock.json +73 -73
- data/frontend/package.json +5 -5
- data/frontend/src/components/alert/Form.vue +1 -14
- data/frontend/src/components/artifact/AS.vue +2 -8
- data/frontend/src/components/artifact/DnsRecords.vue +2 -8
- data/frontend/src/components/artifact/ReverseDnsNames.vue +2 -10
- data/frontend/src/components/artifact/WhoisRecord.vue +1 -1
- data/lib/mihari/actor.rb +14 -4
- data/lib/mihari/analyzers/base.rb +13 -12
- data/lib/mihari/analyzers/binaryedge.rb +4 -1
- data/lib/mihari/analyzers/censys.rb +4 -2
- data/lib/mihari/analyzers/circl.rb +4 -1
- data/lib/mihari/analyzers/crtsh.rb +4 -1
- data/lib/mihari/analyzers/dnstwister.rb +4 -1
- data/lib/mihari/analyzers/feed.rb +3 -0
- data/lib/mihari/analyzers/fofa.rb +65 -0
- data/lib/mihari/analyzers/greynoise.rb +4 -1
- data/lib/mihari/analyzers/hunterhow.rb +6 -1
- data/lib/mihari/analyzers/onyphe.rb +4 -1
- data/lib/mihari/analyzers/otx.rb +4 -1
- data/lib/mihari/analyzers/passivetotal.rb +4 -1
- data/lib/mihari/analyzers/pulsedive.rb +3 -0
- data/lib/mihari/analyzers/securitytrails.rb +4 -1
- data/lib/mihari/analyzers/shodan.rb +4 -1
- data/lib/mihari/analyzers/urlscan.rb +4 -1
- data/lib/mihari/analyzers/virustotal.rb +4 -1
- data/lib/mihari/analyzers/virustotal_intelligence.rb +4 -1
- data/lib/mihari/analyzers/zoomeye.rb +5 -2
- data/lib/mihari/cli/alert.rb +3 -0
- data/lib/mihari/cli/base.rb +3 -0
- data/lib/mihari/cli/database.rb +3 -0
- data/lib/mihari/cli/main.rb +3 -0
- data/lib/mihari/cli/rule.rb +3 -0
- data/lib/mihari/clients/base.rb +3 -0
- data/lib/mihari/clients/binaryedge.rb +5 -2
- data/lib/mihari/clients/censys.rb +7 -4
- data/lib/mihari/clients/circl.rb +3 -0
- data/lib/mihari/clients/crtsh.rb +3 -0
- data/lib/mihari/clients/dnstwister.rb +3 -0
- data/lib/mihari/clients/fofa.rb +83 -0
- data/lib/mihari/clients/greynoise.rb +5 -2
- data/lib/mihari/clients/hunterhow.rb +5 -2
- data/lib/mihari/clients/misp.rb +3 -0
- data/lib/mihari/clients/onyphe.rb +5 -2
- data/lib/mihari/clients/otx.rb +3 -0
- data/lib/mihari/clients/passivetotal.rb +3 -0
- data/lib/mihari/clients/publsedive.rb +4 -1
- data/lib/mihari/clients/securitytrails.rb +3 -0
- data/lib/mihari/clients/shodan.rb +5 -2
- data/lib/mihari/clients/the_hive.rb +3 -0
- data/lib/mihari/clients/urlscan.rb +7 -4
- data/lib/mihari/clients/virustotal.rb +5 -2
- data/lib/mihari/clients/zoomeye.rb +3 -0
- data/lib/mihari/commands/alert.rb +5 -14
- data/lib/mihari/commands/database.rb +3 -0
- data/lib/mihari/commands/rule.rb +10 -1
- data/lib/mihari/commands/search.rb +9 -6
- data/lib/mihari/commands/version.rb +3 -0
- data/lib/mihari/commands/web.rb +4 -1
- data/lib/mihari/config.rb +139 -150
- data/lib/mihari/constants.rb +1 -1
- data/lib/mihari/database.rb +6 -0
- data/lib/mihari/emitters/base.rb +13 -11
- data/lib/mihari/emitters/database.rb +4 -1
- data/lib/mihari/emitters/misp.rb +7 -4
- data/lib/mihari/emitters/slack.rb +3 -3
- data/lib/mihari/emitters/the_hive.rb +3 -3
- data/lib/mihari/emitters/webhook.rb +4 -3
- data/lib/mihari/enrichers/base.rb +15 -9
- data/lib/mihari/enrichers/google_public_dns.rb +6 -5
- data/lib/mihari/enrichers/ipinfo.rb +10 -8
- data/lib/mihari/enrichers/shodan.rb +4 -6
- data/lib/mihari/enrichers/whois.rb +12 -9
- data/lib/mihari/errors.rb +6 -0
- data/lib/mihari/feed/parser.rb +3 -0
- data/lib/mihari/feed/reader.rb +3 -0
- data/lib/mihari/http.rb +6 -0
- data/lib/mihari/mixins/autonomous_system.rb +3 -0
- data/lib/mihari/mixins/configurable.rb +3 -0
- data/lib/mihari/mixins/error_notification.rb +3 -0
- data/lib/mihari/mixins/falsepositive.rb +3 -0
- data/lib/mihari/mixins/refang.rb +3 -0
- data/lib/mihari/mixins/retriable.rb +6 -2
- data/lib/mihari/models/alert.rb +7 -4
- data/lib/mihari/models/artifact.rb +6 -0
- data/lib/mihari/models/autonomous_system.rb +4 -1
- data/lib/mihari/models/cpe.rb +4 -1
- data/lib/mihari/models/dns.rb +4 -1
- data/lib/mihari/models/geolocation.rb +4 -1
- data/lib/mihari/models/port.rb +4 -1
- data/lib/mihari/models/reverse_dns.rb +4 -1
- data/lib/mihari/models/rule.rb +6 -3
- data/lib/mihari/models/tag.rb +3 -0
- data/lib/mihari/models/tagging.rb +3 -0
- data/lib/mihari/models/whois.rb +4 -3
- data/lib/mihari/rule.rb +17 -12
- data/lib/mihari/schemas/alert.rb +3 -0
- data/lib/mihari/schemas/analyzer.rb +11 -0
- data/lib/mihari/schemas/emitter.rb +3 -0
- data/lib/mihari/schemas/enricher.rb +3 -0
- data/lib/mihari/schemas/macros.rb +4 -0
- data/lib/mihari/schemas/mixins.rb +5 -0
- data/lib/mihari/schemas/rule.rb +3 -0
- data/lib/mihari/service.rb +16 -0
- data/lib/mihari/services/alert_builder.rb +8 -5
- data/lib/mihari/services/alert_proxy.rb +6 -1
- data/lib/mihari/services/alert_runner.rb +8 -12
- data/lib/mihari/services/rule_builder.rb +8 -5
- data/lib/mihari/services/rule_runner.rb +8 -10
- data/lib/mihari/structs/binaryedge.rb +13 -28
- data/lib/mihari/structs/censys.rb +48 -127
- data/lib/mihari/structs/config.rb +19 -30
- data/lib/mihari/structs/filters.rb +38 -0
- data/lib/mihari/structs/fofa.rb +44 -0
- data/lib/mihari/structs/google_public_dns.rb +10 -28
- data/lib/mihari/structs/greynoise.rb +33 -84
- data/lib/mihari/structs/hunterhow.rb +24 -22
- data/lib/mihari/structs/ipinfo.rb +14 -35
- data/lib/mihari/structs/onyphe.rb +31 -76
- data/lib/mihari/structs/shodan.rb +47 -112
- data/lib/mihari/structs/urlscan.rb +24 -63
- data/lib/mihari/structs/virustotal_intelligence.rb +20 -56
- data/lib/mihari/type_checker.rb +4 -0
- data/lib/mihari/types.rb +3 -0
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/api.rb +15 -10
- data/lib/mihari/web/app.rb +59 -54
- data/lib/mihari/web/endpoints/alerts.rb +94 -89
- data/lib/mihari/web/endpoints/artifacts.rb +115 -110
- data/lib/mihari/web/endpoints/configs.rb +18 -13
- data/lib/mihari/web/endpoints/ip_addresses.rb +21 -16
- data/lib/mihari/web/endpoints/rules.rb +203 -198
- data/lib/mihari/web/endpoints/tags.rb +41 -36
- data/lib/mihari/web/middleware/connection_adapter.rb +16 -9
- data/lib/mihari/web/middleware/error_notification_adapter.rb +17 -10
- data/lib/mihari/web/public/assets/{index-28d4c79d.js → index-821134e2.js} +30 -30
- data/lib/mihari/web/public/assets/mode-yaml-24faa242.js +8 -0
- data/lib/mihari/web/public/index.html +1 -1
- data/lib/mihari.rb +24 -5
- data/mihari.gemspec +8 -1
- data/mkdocs.yml +3 -2
- metadata +39 -7
- data/lib/mihari/templates/rule.yml.erb +0 -5
- data/lib/mihari/web/public/assets/mode-yaml-a21faa53.js +0 -8
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Clients
|
5
|
+
#
|
6
|
+
# Onyphe API client
|
7
|
+
#
|
5
8
|
class Onyphe < Base
|
6
9
|
PAGE_SIZE = 10
|
7
10
|
|
@@ -33,7 +36,7 @@ module Mihari
|
|
33
36
|
# @param [String] query
|
34
37
|
# @param [Integer] page
|
35
38
|
#
|
36
|
-
# @return [Structs::Onyphe::Response]
|
39
|
+
# @return [Mihari::Structs::Onyphe::Response]
|
37
40
|
#
|
38
41
|
def datascan(query, page: 1)
|
39
42
|
params = { page: page, apikey: api_key }
|
@@ -45,7 +48,7 @@ module Mihari
|
|
45
48
|
# @param [String] query
|
46
49
|
# @param [Integer] pagination_limit
|
47
50
|
#
|
48
|
-
# @return [Enumerable<Structs::Onyphe::Response>]
|
51
|
+
# @return [Enumerable<Mihari::Structs::Onyphe::Response>]
|
49
52
|
#
|
50
53
|
def datascan_with_pagination(query, pagination_limit: Mihari.config.pagination_limit)
|
51
54
|
Enumerator.new do |y|
|
data/lib/mihari/clients/otx.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Clients
|
5
|
+
#
|
6
|
+
# PulseDive API client
|
7
|
+
#
|
5
8
|
class PulseDive < Base
|
6
9
|
# @return [String]
|
7
10
|
attr_reader :api_key
|
@@ -21,7 +24,7 @@ module Mihari
|
|
21
24
|
end
|
22
25
|
|
23
26
|
#
|
24
|
-
# @param [String]
|
27
|
+
# @param [String] ip_or_domain
|
25
28
|
#
|
26
29
|
# @return [Hash]
|
27
30
|
#
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Clients
|
5
|
+
#
|
6
|
+
# Shodan API client
|
7
|
+
#
|
5
8
|
class Shodan < Base
|
6
9
|
PAGE_SIZE = 100
|
7
10
|
|
@@ -34,7 +37,7 @@ module Mihari
|
|
34
37
|
# @param [Integer] page
|
35
38
|
# @param [Boolean] minify
|
36
39
|
#
|
37
|
-
# @return [Structs::Shodan::Result]
|
40
|
+
# @return [Mihari::Structs::Shodan::Result]
|
38
41
|
#
|
39
42
|
def search(query, page: 1, minify: true)
|
40
43
|
params = {
|
@@ -52,7 +55,7 @@ module Mihari
|
|
52
55
|
# @param [Boolean] minify
|
53
56
|
# @param [Integer] pagination_limit
|
54
57
|
#
|
55
|
-
# @return [Enumerable<Structs::Shodan::Response>]
|
58
|
+
# @return [Enumerable<Mihari::Structs::Shodan::Response>]
|
56
59
|
#
|
57
60
|
def search_with_pagination(query, minify: true, pagination_limit: Mihari.config.pagination_limit)
|
58
61
|
Enumerator.new do |y|
|
@@ -2,12 +2,15 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Clients
|
5
|
-
|
5
|
+
#
|
6
|
+
# urlscan.io API client
|
7
|
+
#
|
8
|
+
class Urlscan < Base
|
6
9
|
#
|
7
10
|
# @param [String] base_url
|
8
11
|
# @param [String, nil] api_key
|
9
12
|
# @param [Hash] headers
|
10
|
-
# @param [Integer, nil]
|
13
|
+
# @param [Integer, nil] pagination_interval
|
11
14
|
# @param [Integer, nil] timeout
|
12
15
|
#
|
13
16
|
def initialize(
|
@@ -29,7 +32,7 @@ module Mihari
|
|
29
32
|
# @param [Integer, nil] size
|
30
33
|
# @param [String, nil] search_after
|
31
34
|
#
|
32
|
-
# @return [Structs::Urlscan::Response]
|
35
|
+
# @return [Mihari::Structs::Urlscan::Response]
|
33
36
|
#
|
34
37
|
def search(q, size: nil, search_after: nil)
|
35
38
|
params = { q: q, size: size, search_after: search_after }.compact
|
@@ -42,7 +45,7 @@ module Mihari
|
|
42
45
|
# @param [Integer, nil] size
|
43
46
|
# @param [Integer] pagination_limit
|
44
47
|
#
|
45
|
-
# @return [Enumerable<Structs::Urlscan::Response>]
|
48
|
+
# @return [Enumerable<Mihari::Structs::Urlscan::Response>]
|
46
49
|
#
|
47
50
|
def search_with_pagination(q, size: nil, pagination_limit: Mihari.config.pagination_limit)
|
48
51
|
search_after = nil
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Clients
|
5
|
+
#
|
6
|
+
# VirusTotal API client
|
7
|
+
#
|
5
8
|
class VirusTotal < Base
|
6
9
|
#
|
7
10
|
# @param [String] base_url
|
@@ -46,7 +49,7 @@ module Mihari
|
|
46
49
|
# @param [String] query
|
47
50
|
# @param [String, nil] cursor
|
48
51
|
#
|
49
|
-
# @return [Structs::VirusTotalIntelligence::Response]
|
52
|
+
# @return [Mihari::Structs::VirusTotalIntelligence::Response]
|
50
53
|
#
|
51
54
|
def intel_search(query, cursor: nil)
|
52
55
|
params = { query: query, cursor: cursor }.compact
|
@@ -58,7 +61,7 @@ module Mihari
|
|
58
61
|
# @param [String] query
|
59
62
|
# @param [Integer] pagination_limit
|
60
63
|
#
|
61
|
-
# @return [Enumerable<Structs::VirusTotalIntelligence::Response>]
|
64
|
+
# @return [Enumerable<Mihari::Structs::VirusTotalIntelligence::Response>]
|
62
65
|
#
|
63
66
|
def intel_search_with_pagination(query, pagination_limit: Mihari.config.pagination_limit)
|
64
67
|
cursor = nil
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Commands
|
5
|
+
#
|
6
|
+
# Alert sub-commands
|
7
|
+
#
|
5
8
|
module Alert
|
6
9
|
class << self
|
7
10
|
def included(thor)
|
@@ -16,26 +19,14 @@ module Mihari
|
|
16
19
|
Mihari::Database.with_db_connection do
|
17
20
|
builder = Services::AlertBuilder.new(path)
|
18
21
|
|
19
|
-
|
20
|
-
result = builder.result.bind(
|
22
|
+
runner_result_l = ->(proxy) { Services::AlertRunner.new(proxy).result }
|
23
|
+
result = builder.result.bind(runner_result_l)
|
21
24
|
|
22
25
|
alert = result.value!
|
23
26
|
data = Entities::Alert.represent(alert)
|
24
27
|
puts JSON.pretty_generate(data.as_json)
|
25
28
|
end
|
26
29
|
end
|
27
|
-
|
28
|
-
no_commands do
|
29
|
-
#
|
30
|
-
# @param [Mihari::Services::AlertProxy] proxy
|
31
|
-
#
|
32
|
-
def run_proxy(proxy)
|
33
|
-
Dry::Monads::Try[StandardError] do
|
34
|
-
runner = Services::AlertRunner.new(proxy)
|
35
|
-
runner.run
|
36
|
-
end.to_result
|
37
|
-
end
|
38
|
-
end
|
39
30
|
end
|
40
31
|
end
|
41
32
|
end
|
data/lib/mihari/commands/rule.rb
CHANGED
@@ -4,6 +4,9 @@ require "pathname"
|
|
4
4
|
|
5
5
|
module Mihari
|
6
6
|
module Commands
|
7
|
+
#
|
8
|
+
# Rule sub-commands
|
9
|
+
#
|
7
10
|
module Rule
|
8
11
|
class << self
|
9
12
|
def included(thor)
|
@@ -48,7 +51,13 @@ module Mihari
|
|
48
51
|
# @return [nil]
|
49
52
|
#
|
50
53
|
def initialize_rule(path, files = Dry::Files.new)
|
51
|
-
rule = Mihari::Rule.
|
54
|
+
rule = Mihari::Rule.new(
|
55
|
+
id: SecureRandom.uuid,
|
56
|
+
title: "Title goes here",
|
57
|
+
description: "Description goes here",
|
58
|
+
created_on: Date.today,
|
59
|
+
queries: []
|
60
|
+
)
|
52
61
|
files.write(path, rule.yaml)
|
53
62
|
end
|
54
63
|
end
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Commands
|
5
|
+
#
|
6
|
+
# Search sub-commands
|
7
|
+
#
|
5
8
|
module Search
|
6
9
|
class << self
|
7
10
|
def included(thor)
|
@@ -20,9 +23,9 @@ module Mihari
|
|
20
23
|
builder = Services::RuleBuilder.new(path_or_id)
|
21
24
|
|
22
25
|
check_diff_l = ->(rule) { check_diff rule }
|
23
|
-
|
26
|
+
update_and_call_l = ->(runner) { update_and_call runner }
|
24
27
|
|
25
|
-
result = builder.result.bind(check_diff_l).bind(
|
28
|
+
result = builder.result.bind(check_diff_l).bind(update_and_call_l)
|
26
29
|
|
27
30
|
alert = result.value!
|
28
31
|
data = Entities::Alert.represent(alert)
|
@@ -32,7 +35,7 @@ module Mihari
|
|
32
35
|
|
33
36
|
no_commands do
|
34
37
|
#
|
35
|
-
# @param [Mihari::
|
38
|
+
# @param [Mihari::RuleRunner] rule
|
36
39
|
#
|
37
40
|
def check_diff(rule)
|
38
41
|
force_overwrite = options["force_overwrite"] || false
|
@@ -45,12 +48,12 @@ module Mihari
|
|
45
48
|
end
|
46
49
|
|
47
50
|
#
|
48
|
-
# @param [Mihari::
|
51
|
+
# @param [Mihari::RuleRunner] runner
|
49
52
|
#
|
50
|
-
def
|
53
|
+
def update_and_call(runner)
|
51
54
|
Dry::Monads::Try[StandardError] do
|
52
55
|
runner.update_or_create
|
53
|
-
runner.
|
56
|
+
runner.call
|
54
57
|
end.to_result
|
55
58
|
end
|
56
59
|
end
|
data/lib/mihari/commands/web.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Commands
|
5
|
+
#
|
6
|
+
# Web sub-commands
|
7
|
+
#
|
5
8
|
module Web
|
6
9
|
class << self
|
7
10
|
def included(thor)
|
@@ -20,7 +23,7 @@ module Mihari
|
|
20
23
|
Mihari.config.hide_config_values = options["hide_config_values"]
|
21
24
|
# set rack env as production
|
22
25
|
ENV["RACK_ENV"] ||= options["rack_env"]
|
23
|
-
Mihari::App.run!(
|
26
|
+
Mihari::Web::App.run!(
|
24
27
|
port: options["port"],
|
25
28
|
host: options["host"],
|
26
29
|
threads: options["threads"],
|
data/lib/mihari/config.rb
CHANGED
@@ -1,178 +1,167 @@
|
|
1
|
-
|
2
|
-
class Config
|
3
|
-
# @return [String, nil]
|
4
|
-
attr_reader :binaryedge_api_key
|
5
|
-
|
6
|
-
# @return [String, nil]
|
7
|
-
attr_reader :censys_id
|
8
|
-
|
9
|
-
# @return [String, nil]
|
10
|
-
attr_reader :censys_secret
|
11
|
-
|
12
|
-
# @return [String, nil]
|
13
|
-
attr_reader :circl_passive_password
|
14
|
-
|
15
|
-
# @return [String, nil]
|
16
|
-
attr_reader :circl_passive_username
|
17
|
-
|
18
|
-
# @return [URI]
|
19
|
-
attr_reader :database_url
|
20
|
-
|
21
|
-
# @return [String, nil]
|
22
|
-
attr_reader :greynoise_api_key
|
23
|
-
|
24
|
-
# @return [String, nil]
|
25
|
-
attr_reader :hunterhow_api_key
|
26
|
-
|
27
|
-
# @return [String, nil]
|
28
|
-
attr_reader :ipinfo_api_key
|
29
|
-
|
30
|
-
# @return [String, nil]
|
31
|
-
attr_reader :misp_url
|
32
|
-
|
33
|
-
# @return [String, nil]
|
34
|
-
attr_reader :misp_api_key
|
35
|
-
|
36
|
-
# @return [String, nil]
|
37
|
-
attr_reader :onyphe_api_key
|
38
|
-
|
39
|
-
# @return [String, nil]
|
40
|
-
attr_reader :otx_api_key
|
41
|
-
|
42
|
-
# @return [String, nil]
|
43
|
-
attr_reader :passivetotal_api_key
|
44
|
-
|
45
|
-
# @return [String, nil]
|
46
|
-
attr_reader :passivetotal_username
|
47
|
-
|
48
|
-
# @return [String, nil]
|
49
|
-
attr_reader :pulsedive_api_key
|
50
|
-
|
51
|
-
# @return [String, nil]
|
52
|
-
attr_reader :securitytrails_api_key
|
53
|
-
|
54
|
-
# @return [String, nil]
|
55
|
-
attr_reader :shodan_api_key
|
56
|
-
|
57
|
-
# @return [String, nil]
|
58
|
-
attr_reader :slack_channel
|
59
|
-
|
60
|
-
# @return [String, nil]
|
61
|
-
attr_reader :slack_webhook_url
|
62
|
-
|
63
|
-
# @return [String, nil]
|
64
|
-
attr_reader :thehive_url
|
1
|
+
# frozen_string_literal: true
|
65
2
|
|
66
|
-
|
67
|
-
attr_reader :thehive_api_key
|
3
|
+
require "anyway_config"
|
68
4
|
|
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
|
-
@greynoise_api_key = ENV.fetch("GREYNOISE_API_KEY", nil)
|
121
|
-
|
122
|
-
@ipinfo_api_key = ENV.fetch("IPINFO_API_KEY", nil)
|
123
|
-
|
124
|
-
@hunterhow_api_key = ENV.fetch("HUNTERHOW_API_KEY", nil)
|
5
|
+
module Mihari
|
6
|
+
class Config < Anyway::Config
|
7
|
+
config_name :mihari
|
8
|
+
env_prefix ""
|
9
|
+
|
10
|
+
attr_config(
|
11
|
+
# analyzers, emitters & enrichers
|
12
|
+
binaryedge_api_key: nil,
|
13
|
+
censys_id: nil,
|
14
|
+
censys_secret: nil,
|
15
|
+
circl_passive_password: nil,
|
16
|
+
circl_passive_username: nil,
|
17
|
+
database_url: URI("sqlite3:///mihari.db"),
|
18
|
+
fofa_api_key: nil,
|
19
|
+
fofa_email: nil,
|
20
|
+
greynoise_api_key: nil,
|
21
|
+
hunterhow_api_key: nil,
|
22
|
+
ipinfo_api_key: nil,
|
23
|
+
misp_api_key: nil,
|
24
|
+
misp_url: nil,
|
25
|
+
onyphe_api_key: nil,
|
26
|
+
otx_api_key: nil,
|
27
|
+
passivetotal_api_key: nil,
|
28
|
+
passivetotal_username: nil,
|
29
|
+
pulsedive_api_key: nil,
|
30
|
+
securitytrails_api_key: nil,
|
31
|
+
shodan_api_key: nil,
|
32
|
+
slack_channel: nil,
|
33
|
+
slack_webhook_url: nil,
|
34
|
+
thehive_api_key: nil,
|
35
|
+
thehive_api_version: nil,
|
36
|
+
thehive_url: nil,
|
37
|
+
urlscan_api_key: nil,
|
38
|
+
virustotal_api_key: nil,
|
39
|
+
zoomeye_api_key: nil,
|
40
|
+
# others
|
41
|
+
hide_config_values: true,
|
42
|
+
ignore_error: false,
|
43
|
+
pagination_interval: 0,
|
44
|
+
pagination_limit: 100,
|
45
|
+
retry_exponential_backoff: true,
|
46
|
+
retry_interval: 5,
|
47
|
+
retry_times: 3,
|
48
|
+
sentry_dsn: nil
|
49
|
+
)
|
50
|
+
|
51
|
+
# @!attribute [r] binaryedge_api_key
|
52
|
+
# @return [String, nil]
|
53
|
+
|
54
|
+
# @!attribute [r] censys_id
|
55
|
+
# @return [String, nil]
|
125
56
|
|
126
|
-
|
127
|
-
|
57
|
+
# @!attribute [r] circl_passive_password
|
58
|
+
# @return [String, nil]
|
59
|
+
|
60
|
+
# @!attribute [r] circl_passive_username
|
61
|
+
# @return [String, nil]
|
62
|
+
|
63
|
+
# @!attribute [r] database_url
|
64
|
+
# @return [String, nil]
|
65
|
+
|
66
|
+
# @!attribute [r] fofa_api_key
|
67
|
+
# @return [String, nil]
|
68
|
+
|
69
|
+
# @!attribute [r] fofa_email
|
70
|
+
# @return [String, nil]
|
71
|
+
|
72
|
+
# @!attribute [r] greynoise_api_key
|
73
|
+
# @return [String, nil]
|
74
|
+
|
75
|
+
# @!attribute [r] hunterhow_api_key
|
76
|
+
# @return [String, nil]
|
77
|
+
|
78
|
+
# @!attribute [r] ipinfo_api_key
|
79
|
+
# @return [String, nil]
|
80
|
+
|
81
|
+
# @!attribute [r] misp_url
|
82
|
+
# @return [String, nil]
|
83
|
+
|
84
|
+
# @!attribute [r] misp_api_key
|
85
|
+
# @return [String, nil]
|
86
|
+
|
87
|
+
# @!attribute [r] onyphe_api_key
|
88
|
+
# @return [String, nil]
|
89
|
+
|
90
|
+
# @!attribute [r] otx_api_key
|
91
|
+
# @return [String, nil]
|
92
|
+
|
93
|
+
# @!attribute [r] passivetotal_api_key
|
94
|
+
# @return [String, nil]
|
95
|
+
|
96
|
+
# @!attribute [r] passivetotal_username
|
97
|
+
# @return [String, nil]
|
98
|
+
|
99
|
+
# @!attribute [r] pulsedive_api_key
|
100
|
+
# @return [String, nil]
|
101
|
+
|
102
|
+
# @!attribute [r] securitytrails_api_key
|
103
|
+
# @return [String, nil]
|
104
|
+
|
105
|
+
# @!attribute [r] shodan_api_key
|
106
|
+
# @return [String, nil]
|
128
107
|
|
129
|
-
|
108
|
+
# @!attribute [r] slack_channel
|
109
|
+
# @return [String, nil]
|
110
|
+
|
111
|
+
# @!attribute [r] slack_webhook_url
|
112
|
+
# @return [String, nil]
|
130
113
|
|
131
|
-
|
114
|
+
# @!attribute [r] thehive_url
|
115
|
+
# @return [String, nil]
|
132
116
|
|
133
|
-
|
134
|
-
|
117
|
+
# @!attribute [r] thehive_api_key
|
118
|
+
# @return [String, nil]
|
135
119
|
|
136
|
-
|
120
|
+
# @!attribute [r] thehive_api_version
|
121
|
+
# @return [String, nil]
|
137
122
|
|
138
|
-
|
123
|
+
# @!attribute [r] urlscan_api_key
|
124
|
+
# @return [String, nil]
|
139
125
|
|
140
|
-
|
126
|
+
# @!attribute [r] virustotal_api_key
|
127
|
+
# @return [String, nil]
|
141
128
|
|
142
|
-
|
143
|
-
|
129
|
+
# @!attribute [r] zoomeye_api_key
|
130
|
+
# @return [String, nil]
|
144
131
|
|
145
|
-
|
146
|
-
|
147
|
-
@thehive_api_version = ENV.fetch("THEHIVE_API_VERSION", nil)
|
132
|
+
# @!attribute [r] sentry_dsn
|
133
|
+
# @return [String, nil]
|
148
134
|
|
149
|
-
|
135
|
+
# @!attribute [r] retry_interval
|
136
|
+
# @return [Integer]
|
150
137
|
|
151
|
-
|
138
|
+
# @!attribute [r] retry_times
|
139
|
+
# @return [Integer]
|
152
140
|
|
153
|
-
|
141
|
+
# @!attribute [r] retry_exponential_backoff
|
142
|
+
# @return [Boolean]
|
154
143
|
|
155
|
-
|
144
|
+
# @!attribute [r] pagination_interval
|
145
|
+
# @return [Integer]
|
156
146
|
|
157
|
-
|
147
|
+
# @!attribute [r] pagination_limit
|
148
|
+
# @return [Integer]
|
158
149
|
|
159
|
-
|
160
|
-
|
161
|
-
@retry_exponential_backoff = ENV.fetch("RETRY_EXPONENTIAL_BACKOFF", true).to_s.downcase == "true"
|
150
|
+
# @!attribute [r] ignore_error
|
151
|
+
# @return [Boolean]
|
162
152
|
|
163
|
-
|
164
|
-
|
153
|
+
# @!attribute [rw] hide_config_values
|
154
|
+
# @return [Boolean]
|
165
155
|
|
166
|
-
|
156
|
+
def database_url=(val)
|
157
|
+
super URI(val.to_s)
|
167
158
|
end
|
168
159
|
|
169
160
|
#
|
170
161
|
# @return [Array<String>]
|
171
162
|
#
|
172
163
|
def keys
|
173
|
-
|
174
|
-
key[1..].to_s.upcase
|
175
|
-
end
|
164
|
+
to_h.keys.map(&:to_s).map(&:upcase)
|
176
165
|
end
|
177
166
|
end
|
178
167
|
end
|
data/lib/mihari/constants.rb
CHANGED
@@ -5,7 +5,7 @@ module Mihari
|
|
5
5
|
DEFAULT_DATA_TYPES = Types::DataTypes.values.freeze
|
6
6
|
|
7
7
|
# @return [Array<Hash>]
|
8
|
-
DEFAULT_EMITTERS =
|
8
|
+
DEFAULT_EMITTERS = Emitters::Database.class_keys.map { |name| { emitter: name } }.freeze
|
9
9
|
|
10
10
|
# @return [Array<Hash>]
|
11
11
|
DEFAULT_ENRICHERS = Mihari.enricher_to_class.keys.map { |name| { enricher: name.downcase } }.freeze
|