mihari 5.6.2 → 5.7.1
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/lib/mihari/actor.rb +18 -2
- 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 +9 -16
- data/lib/mihari/commands/database.rb +3 -0
- data/lib/mihari/commands/rule.rb +10 -1
- data/lib/mihari/commands/search.rb +13 -29
- 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 +11 -9
- data/lib/mihari/enrichers/shodan.rb +4 -6
- data/lib/mihari/enrichers/whois.rb +12 -9
- data/lib/mihari/entities/tag.rb +1 -0
- 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 +31 -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 +26 -0
- data/lib/mihari/services/alert_builder.rb +85 -9
- data/lib/mihari/services/alert_runner.rb +8 -19
- data/lib/mihari/services/rule_builder.rb +13 -12
- data/lib/mihari/services/rule_runner.rb +7 -32
- data/lib/mihari/structs/binaryedge.rb +22 -28
- data/lib/mihari/structs/censys.rb +48 -141
- data/lib/mihari/structs/config.rb +19 -30
- data/lib/mihari/structs/filters.rb +38 -0
- data/lib/mihari/structs/fofa.rb +47 -0
- data/lib/mihari/structs/google_public_dns.rb +10 -32
- data/lib/mihari/structs/greynoise.rb +33 -90
- data/lib/mihari/structs/hunterhow.rb +24 -28
- data/lib/mihari/structs/ipinfo.rb +14 -37
- data/lib/mihari/structs/onyphe.rb +31 -80
- data/lib/mihari/structs/shodan.rb +47 -114
- data/lib/mihari/structs/urlscan.rb +24 -69
- data/lib/mihari/structs/virustotal_intelligence.rb +20 -64
- 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 +64 -56
- data/lib/mihari/web/endpoints/alerts.rb +127 -85
- data/lib/mihari/web/endpoints/artifacts.rb +91 -79
- data/lib/mihari/web/endpoints/configs.rb +18 -13
- data/lib/mihari/web/endpoints/ip_addresses.rb +35 -15
- data/lib/mihari/web/endpoints/rules.rb +236 -187
- data/lib/mihari/web/endpoints/tags.rb +42 -35
- 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-07fafab5.js} +31 -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 -6
- data/mihari.gemspec +9 -2
- data/mkdocs.yml +4 -2
- metadata +38 -133
- data/docs/alternatives.md +0 -5
- data/docs/analyzers/binaryedge.md +0 -26
- data/docs/analyzers/censys.md +0 -31
- data/docs/analyzers/circl.md +0 -37
- data/docs/analyzers/crtsh.md +0 -26
- data/docs/analyzers/dnstwister.md +0 -25
- data/docs/analyzers/feed.md +0 -73
- data/docs/analyzers/greynoise.md +0 -26
- data/docs/analyzers/hunterhow.md +0 -33
- data/docs/analyzers/index.md +0 -103
- data/docs/analyzers/onyphe.md +0 -26
- data/docs/analyzers/otx.md +0 -28
- data/docs/analyzers/passivetotal.md +0 -52
- data/docs/analyzers/pulsedive.md +0 -28
- data/docs/analyzers/securitytrails.md +0 -41
- data/docs/analyzers/shodan.md +0 -26
- data/docs/analyzers/urlscan.md +0 -28
- data/docs/analyzers/virustotal.md +0 -43
- data/docs/analyzers/virustotal_intelligence.md +0 -33
- data/docs/analyzers/zoomeye.md +0 -38
- data/docs/configuration.md +0 -35
- data/docs/emitters/database.md +0 -22
- data/docs/emitters/hive.md +0 -26
- data/docs/emitters/index.md +0 -36
- data/docs/emitters/misp.md +0 -21
- data/docs/emitters/slack.md +0 -21
- data/docs/emitters/webhook.md +0 -63
- data/docs/enrichers/google_public_dns.md +0 -19
- data/docs/enrichers/index.md +0 -35
- data/docs/enrichers/ipinfo.md +0 -26
- data/docs/enrichers/shodan.md +0 -22
- data/docs/enrichers/whois.md +0 -17
- data/docs/github_actions.md +0 -43
- data/docs/index.md +0 -11
- data/docs/installation.md +0 -31
- data/docs/requirements.md +0 -13
- data/docs/rule.md +0 -168
- data/docs/tags.md +0 -3
- data/docs/usage.md +0 -103
- data/frontend/.eslintrc.cjs +0 -22
- data/frontend/.gitignore +0 -31
- data/frontend/.prettierrc.json +0 -8
- data/frontend/README.md +0 -3
- data/frontend/env.d.ts +0 -5
- data/frontend/index.html +0 -21
- data/frontend/package-lock.json +0 -7219
- data/frontend/package.json +0 -67
- data/frontend/public/favicon.ico +0 -0
- data/frontend/scripts/swagger_doc_to_yaml.rb +0 -23
- data/frontend/src/App.vue +0 -27
- data/frontend/src/ace-config.ts +0 -6
- data/frontend/src/api-helper.ts +0 -111
- data/frontend/src/api.ts +0 -105
- data/frontend/src/components/ErrorMessage.vue +0 -31
- data/frontend/src/components/Loading.vue +0 -15
- data/frontend/src/components/Navbar.vue +0 -42
- data/frontend/src/components/Pagination.vue +0 -119
- data/frontend/src/components/alert/Alert.vue +0 -87
- data/frontend/src/components/alert/Alerts.vue +0 -63
- data/frontend/src/components/alert/AlertsWithPagination.vue +0 -90
- data/frontend/src/components/alert/AlertsWrapper.vue +0 -128
- data/frontend/src/components/alert/Form.vue +0 -182
- data/frontend/src/components/artifact/AS.vue +0 -29
- data/frontend/src/components/artifact/Artifact.vue +0 -287
- data/frontend/src/components/artifact/ArtifactTag.vue +0 -64
- data/frontend/src/components/artifact/ArtifactTags.vue +0 -29
- data/frontend/src/components/artifact/ArtifactWrapper.vue +0 -57
- data/frontend/src/components/artifact/CPEs.vue +0 -23
- data/frontend/src/components/artifact/DnsRecords.vue +0 -38
- data/frontend/src/components/artifact/Ports.vue +0 -23
- data/frontend/src/components/artifact/ReverseDnsNames.vue +0 -31
- data/frontend/src/components/artifact/Tags.vue +0 -29
- data/frontend/src/components/artifact/WhoisRecord.vue +0 -44
- data/frontend/src/components/config/Configs.vue +0 -65
- data/frontend/src/components/config/ConfigsWrapper.vue +0 -32
- data/frontend/src/components/link/Link.vue +0 -32
- data/frontend/src/components/link/Links.vue +0 -42
- data/frontend/src/components/rule/EditRule.vue +0 -72
- data/frontend/src/components/rule/EditRuleWrapper.vue +0 -48
- data/frontend/src/components/rule/Form.vue +0 -158
- data/frontend/src/components/rule/InputForm.vue +0 -45
- data/frontend/src/components/rule/NewRule.vue +0 -57
- data/frontend/src/components/rule/Rule.vue +0 -100
- data/frontend/src/components/rule/RuleWrapper.vue +0 -53
- data/frontend/src/components/rule/Rules.vue +0 -84
- data/frontend/src/components/rule/RulesWrapper.vue +0 -121
- data/frontend/src/components/rule/YAML.vue +0 -37
- data/frontend/src/components/tag/Tag.vue +0 -65
- data/frontend/src/components/tag/Tags.vue +0 -37
- data/frontend/src/countries.ts +0 -350
- data/frontend/src/index.ts +0 -20
- data/frontend/src/links/anyrun.ts +0 -19
- data/frontend/src/links/base.ts +0 -14
- data/frontend/src/links/censys.ts +0 -20
- data/frontend/src/links/crtsh.ts +0 -20
- data/frontend/src/links/dnslytics.ts +0 -38
- data/frontend/src/links/greynoise.ts +0 -20
- data/frontend/src/links/index.ts +0 -40
- data/frontend/src/links/intezer.ts +0 -20
- data/frontend/src/links/otx.ts +0 -33
- data/frontend/src/links/securitytrails.ts +0 -38
- data/frontend/src/links/shodan.ts +0 -20
- data/frontend/src/links/urlscan.ts +0 -50
- data/frontend/src/links/virustotal.ts +0 -72
- data/frontend/src/main.ts +0 -41
- data/frontend/src/router/index.ts +0 -57
- data/frontend/src/rule.ts +0 -14
- data/frontend/src/shims-vue.d.ts +0 -6
- data/frontend/src/swagger.yaml +0 -771
- data/frontend/src/types.ts +0 -188
- data/frontend/src/utils.ts +0 -54
- data/frontend/src/views/Alerts.vue +0 -20
- data/frontend/src/views/Artifact.vue +0 -39
- data/frontend/src/views/Configs.vue +0 -20
- data/frontend/src/views/EditRule.vue +0 -39
- data/frontend/src/views/NewRule.vue +0 -26
- data/frontend/src/views/Rule.vue +0 -39
- data/frontend/src/views/Rules.vue +0 -20
- data/frontend/tests/utils.spec.ts +0 -9
- data/frontend/tsconfig.app.json +0 -21
- data/frontend/tsconfig.json +0 -14
- data/frontend/tsconfig.node.json +0 -13
- data/frontend/tsconfig.vitest.json +0 -12
- data/frontend/vite.config.ts +0 -24
- data/frontend/vitest.config.ts +0 -21
- data/lib/mihari/services/alert_proxy.rb +0 -92
- data/lib/mihari/templates/rule.yml.erb +0 -5
- data/lib/mihari/web/public/assets/mode-yaml-a21faa53.js +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d27340b82929d2a9dba6cab93c9e429112eed2f254f18595b765bd65852cdfa
|
4
|
+
data.tar.gz: 137141dad2d1b3c4f5b33a2ed38824a9e19c965c7d13e99d20358c2d546dd24c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84825a14e57d1e740d7ee1e312ac23454017665b92dbdbe9fd2fe0cb55eb900addda0d9563049cf493094b67e9f1e5888d09fe37e7a102db5732f09837558fec
|
7
|
+
data.tar.gz: 393031f2550d7943271dd4b662c65b1da2df322661cdf1228808848e93f7bb7f65acaf8d1861599036bd951b464b5248f615e2abd738b171699eaf396b64f7c4
|
data/.rubocop.yml
CHANGED
@@ -3,12 +3,16 @@ Style/HashSyntax:
|
|
3
3
|
Style/StringLiterals:
|
4
4
|
EnforcedStyle: double_quotes
|
5
5
|
Metrics/BlockLength:
|
6
|
+
Max: 150
|
6
7
|
Exclude:
|
7
8
|
- "spec/**/*"
|
8
9
|
- "*.gemspec"
|
9
10
|
Metrics/ClassLength:
|
10
11
|
Enabled: false
|
11
12
|
Metrics/MethodLength:
|
12
|
-
Max:
|
13
|
+
Max: 50
|
14
|
+
Metrics/AbcSize:
|
15
|
+
Max: 50
|
13
16
|
require:
|
14
17
|
- rubocop-rspec
|
18
|
+
- rubocop-yard
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ Mihari supports the following services by default.
|
|
24
24
|
- [CIRCL passive DNS](https://www.circl.lu/services/passive-dns/) / [passive SSL](https://www.circl.lu/services/passive-ssl/)
|
25
25
|
- [crt.sh](https://crt.sh/)
|
26
26
|
- [dnstwister](https://dnstwister.report/)
|
27
|
+
- [Fofa](https://en.fofa.info/)
|
27
28
|
- [GreyNoise](https://www.greynoise.io/)
|
28
29
|
- [HunterHow](https://hunter.how/)
|
29
30
|
- [Onyphe](https://onyphe.io)
|
data/config.ru
CHANGED
data/lib/mihari/actor.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
#
|
5
|
-
#
|
5
|
+
# Yet another base service class for Analyzer, Emitter and Enricher
|
6
6
|
#
|
7
7
|
class Actor
|
8
8
|
include Dry::Monads[:result, :try]
|
@@ -16,7 +16,9 @@ module Mihari
|
|
16
16
|
#
|
17
17
|
# @param [Hash, nil] options
|
18
18
|
#
|
19
|
-
def initialize(
|
19
|
+
def initialize(options: nil)
|
20
|
+
super()
|
21
|
+
|
20
22
|
@options = options || {}
|
21
23
|
end
|
22
24
|
|
@@ -57,6 +59,20 @@ module Mihari
|
|
57
59
|
raise ConfigurationError, message
|
58
60
|
end
|
59
61
|
|
62
|
+
def call(*args, **kwargs)
|
63
|
+
raise NotImplementedError, "You must implement #{self.class}##{__method__}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def result(...)
|
67
|
+
Try[StandardError] do
|
68
|
+
retry_on_error(
|
69
|
+
times: retry_times,
|
70
|
+
interval: retry_interval,
|
71
|
+
exponential_backoff: retry_exponential_backoff
|
72
|
+
) { call(...) }
|
73
|
+
end.to_result
|
74
|
+
end
|
75
|
+
|
60
76
|
class << self
|
61
77
|
#
|
62
78
|
# @return [String]
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# Base class for analyzers
|
7
|
+
#
|
5
8
|
class Base < Actor
|
6
9
|
# @return [String]
|
7
10
|
attr_reader :query
|
@@ -53,22 +56,20 @@ module Mihari
|
|
53
56
|
# @return [Array<Mihari::Models::Artifact>]
|
54
57
|
#
|
55
58
|
def normalized_artifacts
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end.select(&:valid?).uniq(&:data)
|
64
|
-
end
|
59
|
+
artifacts.compact.sort.map do |artifact|
|
60
|
+
# No need to set data_type manually
|
61
|
+
# It is set automatically in #initialize
|
62
|
+
artifact = artifact.is_a?(Models::Artifact) ? artifact : Models::Artifact.new(data: artifact)
|
63
|
+
artifact.source = self.class.class_key
|
64
|
+
artifact
|
65
|
+
end.select(&:valid?).uniq(&:data)
|
65
66
|
end
|
66
67
|
|
67
68
|
#
|
68
|
-
# @return [
|
69
|
+
# @return [Array<Mihari::Models::Artifact>]
|
69
70
|
#
|
70
|
-
def
|
71
|
-
|
71
|
+
def call
|
72
|
+
normalized_artifacts
|
72
73
|
end
|
73
74
|
|
74
75
|
class << self
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# BinaryEdge analyzer
|
7
|
+
#
|
5
8
|
class BinaryEdge < Base
|
6
9
|
# @return [String, nil]
|
7
10
|
attr_reader :api_key
|
@@ -32,7 +35,7 @@ module Mihari
|
|
32
35
|
# @return [Mihari::Clients::BinaryEdge]
|
33
36
|
#
|
34
37
|
def client
|
35
|
-
|
38
|
+
Clients::BinaryEdge.new(
|
36
39
|
api_key: api_key,
|
37
40
|
pagination_interval: pagination_interval,
|
38
41
|
timeout: timeout
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# Censys analyzer
|
7
|
+
#
|
5
8
|
class Censys < Base
|
6
9
|
# @return [String, nil]
|
7
10
|
attr_reader :id
|
@@ -12,7 +15,6 @@ module Mihari
|
|
12
15
|
#
|
13
16
|
# @param [String] query
|
14
17
|
# @param [hash, nil] options
|
15
|
-
# @param [String, nil] api_key
|
16
18
|
# @param [String, nil] id
|
17
19
|
# @param [String, nil] secret
|
18
20
|
#
|
@@ -52,7 +54,7 @@ module Mihari
|
|
52
54
|
# @return [Mihari::Clients::Censys]
|
53
55
|
#
|
54
56
|
def client
|
55
|
-
|
57
|
+
Clients::Censys.new(
|
56
58
|
id: id,
|
57
59
|
secret: secret,
|
58
60
|
pagination_interval: pagination_interval,
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# CIRCL passive DNS/SSL analyzer
|
7
|
+
#
|
5
8
|
class CIRCL < Base
|
6
9
|
include Mixins::Refang
|
7
10
|
|
@@ -51,7 +54,7 @@ module Mihari
|
|
51
54
|
private
|
52
55
|
|
53
56
|
def client
|
54
|
-
|
57
|
+
Clients::CIRCL.new(username: username, password: password, timeout: timeout)
|
55
58
|
end
|
56
59
|
|
57
60
|
def username?
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# crt.sh analyzer
|
7
|
+
#
|
5
8
|
class Crtsh < Base
|
6
9
|
# @return [Boolean]
|
7
10
|
attr_reader :exclude_expired
|
@@ -28,7 +31,7 @@ module Mihari
|
|
28
31
|
# @return [Mihari::Clients::Crtsh]
|
29
32
|
#
|
30
33
|
def client
|
31
|
-
|
34
|
+
Mihari::Clients::Crtsh.new(timeout: timeout)
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# DNSTwister analyzer
|
7
|
+
#
|
5
8
|
class DNSTwister < Base
|
6
9
|
include Mixins::Refang
|
7
10
|
|
@@ -39,7 +42,7 @@ module Mihari
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def client
|
42
|
-
|
45
|
+
Clients::DNSTwister.new(timeout: timeout)
|
43
46
|
end
|
44
47
|
|
45
48
|
#
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mihari
|
4
|
+
module Analyzers
|
5
|
+
#
|
6
|
+
# Fofa analyzer
|
7
|
+
#
|
8
|
+
class Fofa < Base
|
9
|
+
# @return [String, nil]
|
10
|
+
attr_reader :api_key
|
11
|
+
|
12
|
+
# @return [String, nil]
|
13
|
+
attr_reader :email
|
14
|
+
|
15
|
+
#
|
16
|
+
# @param [String] query
|
17
|
+
# @param [Hash, nil] options
|
18
|
+
# @param [String, nil] api_key
|
19
|
+
# @param [String, nil] email
|
20
|
+
#
|
21
|
+
def initialize(query, options: nil, api_key: nil, email: nil)
|
22
|
+
super(query, options: options)
|
23
|
+
|
24
|
+
@api_key = api_key || Mihari.config.fofa_api_key
|
25
|
+
@email = email || Mihari.config.fofa_email
|
26
|
+
end
|
27
|
+
|
28
|
+
def artifacts
|
29
|
+
client.search_with_pagination(query, pagination_limit: pagination_limit).map do |res|
|
30
|
+
(res.results || []).map { |result| result[1] }
|
31
|
+
end.flatten.compact
|
32
|
+
end
|
33
|
+
|
34
|
+
def configuration_keys
|
35
|
+
%w[fofa_api_key fofa_email]
|
36
|
+
end
|
37
|
+
|
38
|
+
def configured?
|
39
|
+
api_key? && email?
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def api_key?
|
45
|
+
!api_key.nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
def email?
|
49
|
+
!email.nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# @return [Mihari::Clients::Fofa]
|
54
|
+
#
|
55
|
+
def client
|
56
|
+
Clients::Fofa.new(
|
57
|
+
api_key: api_key,
|
58
|
+
email: email,
|
59
|
+
pagination_interval: pagination_interval,
|
60
|
+
timeout: timeout
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# GreyNoise analyzer
|
7
|
+
#
|
5
8
|
class GreyNoise < Base
|
6
9
|
# @return [String, nil]
|
7
10
|
attr_reader :api_key
|
@@ -31,7 +34,7 @@ module Mihari
|
|
31
34
|
private
|
32
35
|
|
33
36
|
def client
|
34
|
-
|
37
|
+
Clients::GreyNoise.new(
|
35
38
|
api_key: api_key,
|
36
39
|
pagination_interval: pagination_interval,
|
37
40
|
timeout: timeout
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# hunter.how analyzer
|
7
|
+
#
|
5
8
|
class HunterHow < Base
|
6
9
|
# @return [String, nil]
|
7
10
|
attr_reader :api_key
|
@@ -14,6 +17,8 @@ module Mihari
|
|
14
17
|
|
15
18
|
#
|
16
19
|
# @param [String] query
|
20
|
+
# @param [Date] start_time
|
21
|
+
# @param [Date] end_time
|
17
22
|
# @param [Hash, nil] options
|
18
23
|
# @param [String, nil] api_key
|
19
24
|
#
|
@@ -46,7 +51,7 @@ module Mihari
|
|
46
51
|
private
|
47
52
|
|
48
53
|
def client
|
49
|
-
|
54
|
+
Clients::HunterHow.new(
|
50
55
|
api_key: api_key,
|
51
56
|
pagination_interval: pagination_interval,
|
52
57
|
timeout: timeout
|
@@ -4,6 +4,9 @@ require "normalize_country"
|
|
4
4
|
|
5
5
|
module Mihari
|
6
6
|
module Analyzers
|
7
|
+
#
|
8
|
+
# Onyphe analyzer
|
9
|
+
#
|
7
10
|
class Onyphe < Base
|
8
11
|
# @return [String, nil]
|
9
12
|
attr_reader :api_key
|
@@ -33,7 +36,7 @@ module Mihari
|
|
33
36
|
private
|
34
37
|
|
35
38
|
def client
|
36
|
-
|
39
|
+
Clients::Onyphe.new(
|
37
40
|
api_key: api_key,
|
38
41
|
pagination_interval: pagination_interval,
|
39
42
|
timeout: timeout
|
data/lib/mihari/analyzers/otx.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# OTX analyzer
|
7
|
+
#
|
5
8
|
class OTX < Base
|
6
9
|
include Mixins::Refang
|
7
10
|
|
@@ -42,7 +45,7 @@ module Mihari
|
|
42
45
|
private
|
43
46
|
|
44
47
|
def client
|
45
|
-
|
48
|
+
Mihari::Clients::OTX.new(api_key: api_key, timeout: timeout)
|
46
49
|
end
|
47
50
|
|
48
51
|
#
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# PassiveTotal analyzer
|
7
|
+
#
|
5
8
|
class PassiveTotal < Base
|
6
9
|
include Mixins::Refang
|
7
10
|
|
@@ -62,7 +65,7 @@ module Mihari
|
|
62
65
|
private
|
63
66
|
|
64
67
|
def client
|
65
|
-
|
68
|
+
Clients::PassiveTotal.new(username: username, api_key: api_key, timeout: timeout)
|
66
69
|
end
|
67
70
|
|
68
71
|
#
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# SecurityTrails
|
7
|
+
#
|
5
8
|
class SecurityTrails < Base
|
6
9
|
include Mixins::Refang
|
7
10
|
|
@@ -56,7 +59,7 @@ module Mihari
|
|
56
59
|
private
|
57
60
|
|
58
61
|
def client
|
59
|
-
|
62
|
+
Clients::SecurityTrails.new(api_key: api_key, timeout: timeout)
|
60
63
|
end
|
61
64
|
|
62
65
|
#
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# Shodan analyzer
|
7
|
+
#
|
5
8
|
class Shodan < Base
|
6
9
|
# @return [String, nil]
|
7
10
|
attr_reader :api_key
|
@@ -34,7 +37,7 @@ module Mihari
|
|
34
37
|
# @return [Clients::Shodan]
|
35
38
|
#
|
36
39
|
def client
|
37
|
-
|
40
|
+
Clients::Shodan.new(
|
38
41
|
api_key: api_key,
|
39
42
|
pagination_interval: pagination_interval,
|
40
43
|
timeout: timeout
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# urlscan.io analyzer
|
7
|
+
#
|
5
8
|
class Urlscan < Base
|
6
9
|
SUPPORTED_DATA_TYPES = %w[url domain ip].freeze
|
7
10
|
|
@@ -44,7 +47,7 @@ module Mihari
|
|
44
47
|
private
|
45
48
|
|
46
49
|
def client
|
47
|
-
|
50
|
+
Clients::Urlscan.new(
|
48
51
|
api_key: api_key,
|
49
52
|
pagination_interval: pagination_interval,
|
50
53
|
timeout: timeout
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# VirusTotal analyzer
|
7
|
+
#
|
5
8
|
class VirusTotal < Base
|
6
9
|
include Mixins::Refang
|
7
10
|
|
@@ -51,7 +54,7 @@ module Mihari
|
|
51
54
|
private
|
52
55
|
|
53
56
|
def client
|
54
|
-
|
57
|
+
Clients::VirusTotal.new(api_key: api_key)
|
55
58
|
end
|
56
59
|
|
57
60
|
#
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# VirusTotal Intelligence analyzer
|
7
|
+
#
|
5
8
|
class VirusTotalIntelligence < Base
|
6
9
|
# @return [String, nil]
|
7
10
|
attr_reader :api_key
|
@@ -49,7 +52,7 @@ module Mihari
|
|
49
52
|
# @return [::VirusTotal::API]
|
50
53
|
#
|
51
54
|
def client
|
52
|
-
|
55
|
+
Clients::VirusTotal.new(
|
53
56
|
api_key: api_key,
|
54
57
|
pagination_interval: pagination_interval,
|
55
58
|
timeout: timeout
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Analyzers
|
5
|
+
#
|
6
|
+
# ZoomEye analyzer
|
7
|
+
#
|
5
8
|
class ZoomEye < Base
|
6
9
|
# @return [String, nil]
|
7
10
|
attr_reader :api_key
|
@@ -53,7 +56,7 @@ module Mihari
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def client
|
56
|
-
|
59
|
+
Clients::ZoomEye.new(
|
57
60
|
api_key: api_key,
|
58
61
|
pagination_interval: pagination_interval,
|
59
62
|
timeout: timeout
|
@@ -63,7 +66,7 @@ module Mihari
|
|
63
66
|
#
|
64
67
|
# Convert responses into an array of String
|
65
68
|
#
|
66
|
-
# @param [Hash]
|
69
|
+
# @param [Hash] res
|
67
70
|
#
|
68
71
|
# @return [Array<Mihari::Models::Artifact>]
|
69
72
|
#
|
data/lib/mihari/cli/alert.rb
CHANGED
data/lib/mihari/cli/base.rb
CHANGED
data/lib/mihari/cli/database.rb
CHANGED
data/lib/mihari/cli/main.rb
CHANGED
data/lib/mihari/cli/rule.rb
CHANGED
data/lib/mihari/clients/base.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
module Clients
|
5
|
+
#
|
6
|
+
# BinaryEdge API client
|
7
|
+
#
|
5
8
|
class BinaryEdge < Base
|
6
9
|
#
|
7
10
|
# @param [String] base_url
|
@@ -27,7 +30,7 @@ module Mihari
|
|
27
30
|
# @param [Integer] page Default 1, Maximum: 500
|
28
31
|
# @param [Integer, nil] only_ips If selected, only output IP addresses, ports and protocols.
|
29
32
|
#
|
30
|
-
# @return [Structs::BinaryEdge::Response]
|
33
|
+
# @return [Mihari::Structs::BinaryEdge::Response]
|
31
34
|
#
|
32
35
|
def search(query, page: 1, only_ips: nil)
|
33
36
|
params = {
|
@@ -45,7 +48,7 @@ module Mihari
|
|
45
48
|
# @param [Integer, nil] only_ips
|
46
49
|
# @param [Integer] pagination_limit
|
47
50
|
#
|
48
|
-
# @return [Enumerable<Structs::BinaryEdge::Response
|
51
|
+
# @return [Enumerable<Mihari::Structs::BinaryEdge::Response>]
|
49
52
|
#
|
50
53
|
def search_with_pagination(query, only_ips: nil, pagination_limit: Mihari.config.pagination_limit)
|
51
54
|
Enumerator.new do |y|
|
@@ -4,6 +4,9 @@ require "base64"
|
|
4
4
|
|
5
5
|
module Mihari
|
6
6
|
module Clients
|
7
|
+
#
|
8
|
+
# Censys API client
|
9
|
+
#
|
7
10
|
class Censys < Base
|
8
11
|
#
|
9
12
|
# @param [String] base_url
|
@@ -36,10 +39,10 @@ module Mihari
|
|
36
39
|
# For more details, see our documentation: https://search.censys.io/api/v2/docs
|
37
40
|
#
|
38
41
|
# @param [String] query the query to be executed.
|
39
|
-
# @
|
40
|
-
# @
|
42
|
+
# @param [Integer, nil] per_page the number of results to be returned for each page.
|
43
|
+
# @param [Integer, nil] cursor the cursor of the desired result set.
|
41
44
|
#
|
42
|
-
# @return [Structs::Censys::Response]
|
45
|
+
# @return [Mihari::Structs::Censys::Response]
|
43
46
|
#
|
44
47
|
def search(query, per_page: nil, cursor: nil)
|
45
48
|
params = { q: query, per_page: per_page, cursor: cursor }.compact
|
@@ -52,7 +55,7 @@ module Mihari
|
|
52
55
|
# @param [Integer, nil] per_page
|
53
56
|
# @param [Integer] pagination_limit
|
54
57
|
#
|
55
|
-
# @return [Enumerable<Structs::Censys::Response>]
|
58
|
+
# @return [Enumerable<Mihari::Structs::Censys::Response>]
|
56
59
|
#
|
57
60
|
def search_with_pagination(query, per_page: nil, pagination_limit: Mihari.config.pagination_limit)
|
58
61
|
cursor = nil
|