mihari 3.6.0 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/README.md +2 -0
  4. data/Steepfile +32 -0
  5. data/lib/mihari/analyzers/base.rb +5 -5
  6. data/lib/mihari/analyzers/binaryedge.rb +13 -0
  7. data/lib/mihari/analyzers/censys.rb +5 -0
  8. data/lib/mihari/analyzers/circl.rb +15 -0
  9. data/lib/mihari/analyzers/crtsh.rb +5 -0
  10. data/lib/mihari/analyzers/dnpedia.rb +5 -0
  11. data/lib/mihari/analyzers/dnstwister.rb +17 -0
  12. data/lib/mihari/analyzers/onyphe.rb +20 -4
  13. data/lib/mihari/analyzers/otx.rb +20 -0
  14. data/lib/mihari/analyzers/passivetotal.rb +25 -0
  15. data/lib/mihari/analyzers/pulsedive.rb +10 -0
  16. data/lib/mihari/analyzers/rule.rb +18 -0
  17. data/lib/mihari/analyzers/securitytrails.rb +25 -0
  18. data/lib/mihari/analyzers/shodan.rb +13 -0
  19. data/lib/mihari/analyzers/spyse.rb +20 -0
  20. data/lib/mihari/analyzers/urlscan.rb +10 -0
  21. data/lib/mihari/analyzers/virustotal.rb +20 -0
  22. data/lib/mihari/analyzers/zoomeye.rb +38 -0
  23. data/lib/mihari/emitters/base.rb +1 -1
  24. data/lib/mihari/emitters/misp.rb +38 -5
  25. data/lib/mihari/emitters/slack.rb +20 -2
  26. data/lib/mihari/emitters/the_hive.rb +16 -3
  27. data/lib/mihari/emitters/webhook.rb +18 -3
  28. data/lib/mihari/mixins/disallowed_data_value.rb +1 -1
  29. data/lib/mihari/structs/onyphe.rb +2 -2
  30. data/lib/mihari/type_checker.rb +9 -9
  31. data/lib/mihari/version.rb +1 -1
  32. data/mihari.gemspec +1 -0
  33. data/sig/lib/mihari/analyzers/base.rbs +99 -0
  34. data/sig/lib/mihari/analyzers/basic.rbs +17 -0
  35. data/sig/lib/mihari/analyzers/binaryedge.rbs +25 -0
  36. data/sig/lib/mihari/analyzers/censys.rbs +38 -0
  37. data/sig/lib/mihari/analyzers/circl.rbs +29 -0
  38. data/sig/lib/mihari/analyzers/crtsh.rbs +19 -0
  39. data/sig/lib/mihari/analyzers/dnpedia.rbs +18 -0
  40. data/sig/lib/mihari/analyzers/dnstwister.rbs +27 -0
  41. data/sig/lib/mihari/analyzers/onyphe.rbs +33 -0
  42. data/sig/lib/mihari/analyzers/otx.rbs +33 -0
  43. data/sig/lib/mihari/analyzers/passivetotal.rbs +33 -0
  44. data/sig/lib/mihari/analyzers/pulsedive.rbs +27 -0
  45. data/sig/lib/mihari/analyzers/rule.rbs +68 -0
  46. data/sig/lib/mihari/analyzers/securitytrails.rbs +33 -0
  47. data/sig/lib/mihari/analyzers/shodan.rbs +33 -0
  48. data/sig/lib/mihari/analyzers/spyse.rbs +29 -0
  49. data/sig/lib/mihari/analyzers/urlscan.rbs +28 -0
  50. data/sig/lib/mihari/analyzers/virustotal.rbs +31 -0
  51. data/sig/lib/mihari/analyzers/zoomeye.rbs +33 -0
  52. data/sig/lib/mihari/cli/analyzer.rbs +39 -0
  53. data/sig/lib/mihari/cli/base.rbs +11 -0
  54. data/sig/lib/mihari/cli/init.rbs +7 -0
  55. data/sig/lib/mihari/cli/main.rbs +9 -0
  56. data/sig/lib/mihari/cli/mixins/utils.rbs +50 -0
  57. data/sig/lib/mihari/cli/validator.rbs +7 -0
  58. data/sig/lib/mihari/commands/binaryedge.rbs +7 -0
  59. data/sig/lib/mihari/commands/censys.rbs +7 -0
  60. data/sig/lib/mihari/commands/circl.rbs +7 -0
  61. data/sig/lib/mihari/commands/crtsh.rbs +7 -0
  62. data/sig/lib/mihari/commands/dnpedia.rbs +7 -0
  63. data/sig/lib/mihari/commands/dnstwister.rbs +7 -0
  64. data/sig/lib/mihari/commands/init.rbs +11 -0
  65. data/sig/lib/mihari/commands/json.rbs +7 -0
  66. data/sig/lib/mihari/commands/onyphe.rbs +7 -0
  67. data/sig/lib/mihari/commands/otx.rbs +7 -0
  68. data/sig/lib/mihari/commands/passivetotal.rbs +7 -0
  69. data/sig/lib/mihari/commands/pulsedive.rbs +7 -0
  70. data/sig/lib/mihari/commands/search.rbs +35 -0
  71. data/sig/lib/mihari/commands/securitytrails.rbs +7 -0
  72. data/sig/lib/mihari/commands/shodan.rbs +7 -0
  73. data/sig/lib/mihari/commands/spyse.rbs +7 -0
  74. data/sig/lib/mihari/commands/urlscan.rbs +7 -0
  75. data/sig/lib/mihari/commands/validator.rbs +11 -0
  76. data/sig/lib/mihari/commands/virustotal.rbs +7 -0
  77. data/sig/lib/mihari/commands/web.rbs +7 -0
  78. data/sig/lib/mihari/commands/zoomeye.rbs +7 -0
  79. data/sig/lib/mihari/constants.rbs +3 -0
  80. data/sig/lib/mihari/database.rbs +25 -0
  81. data/sig/lib/mihari/emitters/base.rbs +18 -0
  82. data/sig/lib/mihari/emitters/database.rbs +9 -0
  83. data/sig/lib/mihari/emitters/misp.rbs +28 -0
  84. data/sig/lib/mihari/emitters/slack.rbs +58 -0
  85. data/sig/lib/mihari/emitters/stdout.rbs +9 -0
  86. data/sig/lib/mihari/emitters/the_hive.rbs +24 -0
  87. data/sig/lib/mihari/emitters/webhook.rbs +20 -0
  88. data/sig/lib/mihari/errors.rbs +10 -0
  89. data/sig/lib/mihari/mixins/configurable.rbs +26 -0
  90. data/sig/lib/mihari/mixins/configuration.rbs +45 -0
  91. data/sig/lib/mihari/mixins/disallowed_data_value.rbs +25 -0
  92. data/sig/lib/mihari/mixins/hash.rbs +14 -0
  93. data/sig/lib/mihari/mixins/refang.rbs +14 -0
  94. data/sig/lib/mihari/mixins/retriable.rbs +15 -0
  95. data/sig/lib/mihari/mixins/rule.rbs +41 -0
  96. data/sig/lib/mihari/models/alert.rbs +46 -0
  97. data/sig/lib/mihari/models/artifact.rbs +54 -0
  98. data/sig/lib/mihari/models/autonomous_system.rbs +5 -0
  99. data/sig/lib/mihari/models/dns.rbs +19 -0
  100. data/sig/lib/mihari/models/geolocation.rbs +6 -0
  101. data/sig/lib/mihari/models/reverse_dns.rbs +14 -0
  102. data/sig/lib/mihari/models/tag.rbs +5 -0
  103. data/sig/lib/mihari/models/tagging.rbs +4 -0
  104. data/sig/lib/mihari/models/whois.rbs +66 -0
  105. data/sig/lib/mihari/notifiers/base.rbs +18 -0
  106. data/sig/lib/mihari/notifiers/exception_notifier.rbs +75 -0
  107. data/sig/lib/mihari/notifiers/slack.rbs +50 -0
  108. data/sig/lib/mihari/status.rbs +25 -0
  109. data/sig/lib/mihari/structs/censys.rbs +50 -0
  110. data/sig/lib/mihari/structs/onyphe.rbs +25 -0
  111. data/sig/lib/mihari/structs/shodan.rbs +28 -0
  112. data/sig/lib/mihari/type_checker.rbs +48 -0
  113. data/sig/lib/mihari/types.rbs +17 -0
  114. data/sig/lib/mihari/version.rbs +3 -0
  115. data/sig/lib/mihari/web/app.rbs +5 -0
  116. data/sig/lib/mihari.rbs +57 -0
  117. metadata +102 -2
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module CLI
3
+ class Validator < Base
4
+ include Mihari::Commands::Validator
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module BinaryEdge
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Censys
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module CIRCL
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Crtsh
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module DNPedia
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module DNSTwister
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Mihari
2
+ module Commands
3
+ module Initialization
4
+ include Mixins::Configuration
5
+
6
+ include Mixins::Rule
7
+
8
+ def self.included: (untyped thor) -> untyped
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module JSON
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Onyphe
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module OTX
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module PassiveTotal
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Pulsedive
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,35 @@
1
+ module Mihari
2
+ module Commands
3
+ module Search
4
+ include Mixins::Rule
5
+
6
+ def self.included: (untyped thor) -> untyped
7
+
8
+ private
9
+
10
+ #
11
+ # Build a rule analyzer
12
+ #
13
+ # @param [String] title
14
+ # @param [String] description
15
+ # @param [Array<Hash>] queries
16
+ # @param [Array<String>, nil] tags
17
+ # @param [Array<String>, nil] allowed_data_types
18
+ # @param [Array<String>, nil] disallowed_data_values
19
+ # @param [String, nil] source
20
+ #
21
+ # @return [Mihari::Analyzers::Rule]
22
+ #
23
+ def build_rule_analyzer: (title: String title, description: String description, queries: Array[Hash[(String | Symbol), untyped]] queries, ?tags: Array[String]? tags, ?allowed_data_types: Array[String]? allowed_data_types, ?disallowed_data_values: Array[String]? disallowed_data_values, ?source: String? source, ?id: String? id) -> Mihari::Analyzers::Rule
24
+
25
+ #
26
+ # Run rule analyzer
27
+ #
28
+ # @param [Mihari::Analyzer::Rule] analyzer
29
+ #
30
+ # @return [nil]
31
+ #
32
+ def run_rule_analyzer: (Mihari::Analyzers::Rule analyzer, ?ignore_old_artifacts: bool ignore_old_artifacts, ?ignore_threshold: ::Integer ignore_threshold) -> untyped
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module SecurityTrails
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Shodan
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Spyse
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Urlscan
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Mihari
2
+ module Commands
3
+ module Validator
4
+ include Mixins::Rule
5
+
6
+ include Mixins::Configuration
7
+
8
+ def self.included: (untyped thor) -> untyped
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module VirusTotal
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module Web
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Mihari
2
+ module Commands
3
+ module ZoomEye
4
+ def self.included: (untyped thor) -> untyped
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Mihari
2
+ ALLOWED_DATA_TYPES: Array[String]
3
+ end
@@ -0,0 +1,25 @@
1
+ class InitialSchema
2
+ def change: () -> void
3
+ end
4
+
5
+ class AddeSourceToArtifactSchema
6
+ def change: () -> void
7
+ end
8
+
9
+ class EnrichmentsSchema
10
+ def change: () -> void
11
+ end
12
+
13
+ module Mihari
14
+ class Database
15
+ def self.connect: () -> void
16
+
17
+ def self.close: () -> void
18
+
19
+ def self.destroy!: () -> void
20
+ end
21
+ end
22
+
23
+ class Object
24
+ def adapter: () -> ("postgresql" | "mysql2" | "sqlite3")
25
+ end
@@ -0,0 +1,18 @@
1
+ module Mihari
2
+ module Emitters
3
+ class Base
4
+ include Mixins::Configurable
5
+
6
+ include Mixins::Retriable
7
+
8
+ def self.inherited: (untyped child) -> untyped
9
+
10
+ # @return [true, false]
11
+ def valid?: () -> bool
12
+
13
+ def run: (**untyped params) -> void
14
+
15
+ def emit: () -> void
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module Mihari
2
+ module Emitters
3
+ class Database < Base
4
+ def valid?: () -> bool
5
+
6
+ def emit: (title: String title, description: String description, artifacts: Array[Mihari::Artifact] artifacts, source: String source, ?tags: Array[String] tags) -> void
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ module Mihari
2
+ module Emitters
3
+ class MISP < Base
4
+ def initialize: () -> void
5
+
6
+ # @return [true, false]
7
+ def valid?: () -> bool
8
+
9
+ def emit: (title: String title, artifacts: Array[Mihari::Artifact] artifacts, ?tags: Array[String] tags, **untyped _options) -> void
10
+
11
+ private
12
+
13
+ def configuration_keys: () -> ::Array["misp_api_endpoint" | "misp_api_key"]
14
+
15
+ def build_attribute: (Mihari::Artifact artifact) -> untyped
16
+
17
+ def hash_type: (String value) -> String?
18
+
19
+ def to_misp_type: (type: String `type`, value: String value) -> String?
20
+
21
+ def api_endpoint?: () -> bool
22
+
23
+ def api_key?: () -> bool
24
+
25
+ def ping?: () -> bool
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,58 @@
1
+ module Mihari
2
+ module Emitters
3
+ class Attachment
4
+ attr_reader data: String
5
+ attr_reader data_type: String
6
+ # include Mem
7
+
8
+ # extend Dry::Initializer
9
+
10
+ def actions: () -> Array[Hash[(String | Symbol), untyped]]
11
+
12
+ def vt_link: () -> (nil | { :type => "button", text: "VirusTotal", url: String })
13
+
14
+ def urlscan_link: () -> (nil | { :type => "button", text: "urlscan.io", url: String })
15
+
16
+ def censys_link: () -> (nil | { :type => "button", text: "Censys", url: String })
17
+
18
+ def shodan_link: () -> (nil | { :type => "button", text: "Shodan", url: String })
19
+
20
+ # @return [Array]
21
+ def to_a: () -> ::Array[{ text: String, fallback: "VT & urlscan.io links", actions: Array[Hash[(String | Symbol), untyped]] }]
22
+
23
+ private
24
+
25
+ # @return [String]
26
+ def _urlscan_link: () -> String?
27
+
28
+ # @return [String]
29
+ def _vt_link: () -> String?
30
+
31
+ def _censys_link: () -> String?
32
+
33
+ def _shodan_link: () -> String?
34
+
35
+ # @return [String]
36
+ def sha256: () -> String
37
+
38
+ # @return [String]
39
+ def defanged_data: () -> String
40
+ end
41
+
42
+ class Slack < Base
43
+ def notifier: () -> Mihari::Notifiers::Slack
44
+
45
+ def valid?: () -> bool
46
+
47
+ def to_attachments: (Array[Mihari::Artifact] artifacts) -> Array[Mihari::Emitters::Attachment]
48
+
49
+ def to_text: (title: String title, description: String description, ?tags: Array[String] tags) -> String
50
+
51
+ def emit: (title: String title, description: String description, artifacts: Array[Mihari::Artifact] artifacts, ?tags: Array[String] tags, **untyped _options) -> void
52
+
53
+ private
54
+
55
+ def configuration_keys: () -> ::Array["slack_webhook_url"]
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,9 @@
1
+ module Mihari
2
+ module Emitters
3
+ class StandardOutput < Base
4
+ def valid?: () -> ::TrueClass
5
+
6
+ def emit: (title: String title, description: String description, artifacts: Array[Mihari::Artifact] artifacts, source: String source, tags: Array[String] tags) -> void
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ module Mihari
2
+ module Emitters
3
+ class TheHive < Base
4
+ # @return [true, false]
5
+ def valid?: () -> bool
6
+
7
+ def emit: (title: untyped title, description: untyped description, artifacts: untyped artifacts, ?tags: untyped tags, **untyped _options) -> (nil | untyped)
8
+
9
+ private
10
+
11
+ def configuration_keys: () -> ::Array["thehive_api_endpoint" | "thehive_api_key"]
12
+
13
+ def api: () -> untyped
14
+
15
+ # @return [true, false]
16
+ def api_endpont?: () -> bool
17
+
18
+ # @return [true, false]
19
+ def api_key?: () -> bool
20
+
21
+ def ping?: () -> bool
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ module Mihari
2
+ module Emitters
3
+ class Webhook < Base
4
+ # @return [true, false]
5
+ def valid?: () -> bool
6
+
7
+ def emit: (title: String title, description: String description, artifacts: Array[Mihari::Artifact] artifacts, source: String source, tags: Array[String] tags) -> void
8
+
9
+ private
10
+
11
+ def configuration_keys: () -> ::Array["webhook_url"]
12
+
13
+ def webhook_url: () -> String?
14
+
15
+ def webhook_url?: () -> bool
16
+
17
+ def use_json_body?: () -> bool?
18
+ end
19
+ end
20
+ end