mihari 5.3.2 → 5.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/frontend/package-lock.json +298 -235
- data/frontend/package.json +7 -7
- data/lib/mihari/analyzers/base.rb +10 -3
- data/lib/mihari/analyzers/binaryedge.rb +5 -5
- data/lib/mihari/analyzers/censys.rb +3 -3
- data/lib/mihari/analyzers/circl.rb +2 -2
- data/lib/mihari/analyzers/greynoise.rb +2 -2
- data/lib/mihari/analyzers/hunterhow.rb +68 -0
- data/lib/mihari/analyzers/onyphe.rb +5 -5
- data/lib/mihari/analyzers/otx.rb +2 -2
- data/lib/mihari/analyzers/passivetotal.rb +2 -2
- data/lib/mihari/analyzers/pulsedive.rb +2 -2
- data/lib/mihari/analyzers/rule.rb +14 -12
- data/lib/mihari/analyzers/securitytrails.rb +2 -2
- data/lib/mihari/analyzers/shodan.rb +5 -5
- data/lib/mihari/analyzers/urlscan.rb +3 -3
- data/lib/mihari/analyzers/virustotal.rb +2 -2
- data/lib/mihari/analyzers/virustotal_intelligence.rb +3 -3
- data/lib/mihari/analyzers/zoomeye.rb +6 -6
- data/lib/mihari/clients/hunterhow.rb +47 -0
- data/lib/mihari/config.rb +45 -26
- data/lib/mihari/constants.rb +0 -3
- data/lib/mihari/schemas/analyzer.rb +12 -2
- data/lib/mihari/schemas/rule.rb +1 -1
- data/lib/mihari/structs/hunterhow.rb +104 -0
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/public/assets/{index-116033d0.js → index-61dc587c.js} +34 -33
- data/lib/mihari/web/public/index.html +1 -1
- data/lib/mihari.rb +3 -0
- data/mihari.gemspec +1 -1
- metadata +8 -5
data/lib/mihari/config.rb
CHANGED
@@ -1,86 +1,98 @@
|
|
1
1
|
module Mihari
|
2
2
|
class Config
|
3
3
|
# @return [String, nil]
|
4
|
-
|
4
|
+
attr_reader :binaryedge_api_key
|
5
5
|
|
6
6
|
# @return [String, nil]
|
7
|
-
|
7
|
+
attr_reader :censys_id
|
8
8
|
|
9
9
|
# @return [String, nil]
|
10
|
-
|
10
|
+
attr_reader :censys_secret
|
11
11
|
|
12
12
|
# @return [String, nil]
|
13
|
-
|
13
|
+
attr_reader :circl_passive_password
|
14
14
|
|
15
15
|
# @return [String, nil]
|
16
|
-
|
16
|
+
attr_reader :circl_passive_username
|
17
17
|
|
18
18
|
# @return [URI]
|
19
|
-
|
19
|
+
attr_reader :database_url
|
20
20
|
|
21
21
|
# @return [String, nil]
|
22
|
-
|
22
|
+
attr_reader :greynoise_api_key
|
23
23
|
|
24
24
|
# @return [String, nil]
|
25
|
-
|
25
|
+
attr_reader :hunterhow_api_key
|
26
26
|
|
27
27
|
# @return [String, nil]
|
28
|
-
|
28
|
+
attr_reader :ipinfo_api_key
|
29
29
|
|
30
30
|
# @return [String, nil]
|
31
|
-
|
31
|
+
attr_reader :misp_url
|
32
32
|
|
33
33
|
# @return [String, nil]
|
34
|
-
|
34
|
+
attr_reader :misp_api_key
|
35
35
|
|
36
36
|
# @return [String, nil]
|
37
|
-
|
37
|
+
attr_reader :onyphe_api_key
|
38
38
|
|
39
39
|
# @return [String, nil]
|
40
|
-
|
40
|
+
attr_reader :otx_api_key
|
41
41
|
|
42
42
|
# @return [String, nil]
|
43
|
-
|
43
|
+
attr_reader :passivetotal_api_key
|
44
44
|
|
45
45
|
# @return [String, nil]
|
46
|
-
|
46
|
+
attr_reader :passivetotal_username
|
47
47
|
|
48
48
|
# @return [String, nil]
|
49
|
-
|
49
|
+
attr_reader :pulsedive_api_key
|
50
50
|
|
51
51
|
# @return [String, nil]
|
52
|
-
|
52
|
+
attr_reader :securitytrails_api_key
|
53
53
|
|
54
54
|
# @return [String, nil]
|
55
|
-
|
55
|
+
attr_reader :shodan_api_key
|
56
56
|
|
57
57
|
# @return [String, nil]
|
58
|
-
|
58
|
+
attr_reader :slack_channel
|
59
59
|
|
60
60
|
# @return [String, nil]
|
61
|
-
|
61
|
+
attr_reader :slack_webhook_url
|
62
62
|
|
63
63
|
# @return [String, nil]
|
64
|
-
|
64
|
+
attr_reader :thehive_url
|
65
65
|
|
66
66
|
# @return [String, nil]
|
67
|
-
|
67
|
+
attr_reader :thehive_api_key
|
68
68
|
|
69
69
|
# @return [String, nil]
|
70
|
-
|
70
|
+
attr_reader :thehive_api_version
|
71
71
|
|
72
72
|
# @return [String, nil]
|
73
|
-
|
73
|
+
attr_reader :urlscan_api_key
|
74
74
|
|
75
75
|
# @return [String, nil]
|
76
|
-
|
76
|
+
attr_reader :virustotal_api_key
|
77
77
|
|
78
78
|
# @return [String, nil]
|
79
|
-
|
79
|
+
attr_reader :zoomeye_api_key
|
80
80
|
|
81
81
|
# @return [String, nil]
|
82
|
+
attr_reader :sentry_dsn
|
83
|
+
|
84
|
+
# @return [Boolean]
|
82
85
|
attr_accessor :hide_config_values
|
83
86
|
|
87
|
+
# @return [Integer]
|
88
|
+
attr_reader :retry_interval
|
89
|
+
|
90
|
+
# @return [Integer]
|
91
|
+
attr_reader :retry_times
|
92
|
+
|
93
|
+
# @return [Integer]
|
94
|
+
attr_reader :pagination_limit
|
95
|
+
|
84
96
|
def initialize
|
85
97
|
@binaryedge_api_key = ENV.fetch("BINARYEDGE_API_KEY", nil)
|
86
98
|
|
@@ -96,6 +108,8 @@ module Mihari
|
|
96
108
|
|
97
109
|
@ipinfo_api_key = ENV.fetch("IPINFO_API_KEY", nil)
|
98
110
|
|
111
|
+
@hunterhow_api_key = ENV.fetch("HUNTERHOW_API_KEY", nil)
|
112
|
+
|
99
113
|
@misp_url = ENV.fetch("MISP_URL", nil)
|
100
114
|
@misp_api_key = ENV.fetch("MISP_API_KEY", nil)
|
101
115
|
|
@@ -128,6 +142,11 @@ module Mihari
|
|
128
142
|
@sentry_dsn = ENV.fetch("SENTRY_DSN", nil)
|
129
143
|
|
130
144
|
@hide_config_values = ENV.fetch("HIDE_CONFIG_VALUES", false)
|
145
|
+
|
146
|
+
@retry_times = ENV.fetch("RETRY_TIMES", 3).to_i
|
147
|
+
@retry_interval = ENV.fetch("RETRY_INTERVAL", 5).to_i
|
148
|
+
|
149
|
+
@pagination_limit = ENV.fetch("PAGINATION_LIMIT", 1000).to_i
|
131
150
|
end
|
132
151
|
end
|
133
152
|
end
|
data/lib/mihari/constants.rb
CHANGED
@@ -4,8 +4,9 @@ module Mihari
|
|
4
4
|
module Schemas
|
5
5
|
AnalyzerOptions = Dry::Schema.Params do
|
6
6
|
optional(:interval).value(:integer)
|
7
|
-
optional(:
|
8
|
-
optional(:
|
7
|
+
optional(:pagination_limit).value(:integer).default(Mihari.config.pagination_limit)
|
8
|
+
optional(:retry_times).value(:integer).default(Mihari.config.retry_times)
|
9
|
+
optional(:retry_interval).value(:integer).default(Mihari.config.retry_interval)
|
9
10
|
end
|
10
11
|
|
11
12
|
AnalyzerWithoutAPIKey = Dry::Schema.Params do
|
@@ -75,6 +76,15 @@ module Mihari
|
|
75
76
|
optional(:options).hash(AnalyzerOptions)
|
76
77
|
end
|
77
78
|
|
79
|
+
HunterHow = Dry::Schema.Params do
|
80
|
+
required(:analyzer).value(Types::String.enum("hunterhow"))
|
81
|
+
required(:query).value(:string)
|
82
|
+
required(:start_time).value(:date)
|
83
|
+
required(:end_time).value(:date)
|
84
|
+
optional(:api_key).value(:string)
|
85
|
+
optional(:options).hash(AnalyzerOptions)
|
86
|
+
end
|
87
|
+
|
78
88
|
Feed = Dry::Schema.Params do
|
79
89
|
required(:analyzer).value(Types::String.enum("feed"))
|
80
90
|
required(:query).value(:string)
|
data/lib/mihari/schemas/rule.rb
CHANGED
@@ -22,7 +22,7 @@ module Mihari
|
|
22
22
|
optional(:updated_on).value(:date)
|
23
23
|
|
24
24
|
required(:queries).value(:array).each do
|
25
|
-
AnalyzerWithoutAPIKey | AnalyzerWithAPIKey | Censys | CIRCL | PassiveTotal | ZoomEye | Crtsh | Feed
|
25
|
+
AnalyzerWithoutAPIKey | AnalyzerWithAPIKey | Censys | CIRCL | PassiveTotal | ZoomEye | Crtsh | Feed | HunterHow
|
26
26
|
end
|
27
27
|
|
28
28
|
optional(:emitters).value(:array).each { Database | MISP | TheHive | Slack | Webhook }.default(DEFAULT_EMITTERS)
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Mihari
|
2
|
+
module Structs
|
3
|
+
module HunterHow
|
4
|
+
class ListItem < Dry::Struct
|
5
|
+
attribute :domain, Types::String
|
6
|
+
attribute :ip, Types::String
|
7
|
+
attribute :port, Types::Integer
|
8
|
+
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
def ip
|
13
|
+
attributes[:ip]
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# @return [Mihari::Artifact]
|
18
|
+
#
|
19
|
+
def artifact
|
20
|
+
Artifact.new(data: ip)
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
#
|
25
|
+
# @param [Hash] d
|
26
|
+
#
|
27
|
+
# @return [ListItem]
|
28
|
+
#
|
29
|
+
def from_dynamic!(d)
|
30
|
+
d = Types::Hash[d]
|
31
|
+
new(
|
32
|
+
domain: d.fetch("domain"),
|
33
|
+
ip: d.fetch("ip"),
|
34
|
+
port: d.fetch("port")
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class DataClass < Dry::Struct
|
41
|
+
attribute :list, Types.Array(ListItem)
|
42
|
+
attribute :total, Types::Integer
|
43
|
+
|
44
|
+
#
|
45
|
+
# @return [Array<ListItem>]
|
46
|
+
#
|
47
|
+
def list
|
48
|
+
attributes[:list]
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# @return [Array<Mihari::Artifact>]
|
53
|
+
#
|
54
|
+
def artifacts
|
55
|
+
list.map(&:artifact)
|
56
|
+
end
|
57
|
+
|
58
|
+
class << self
|
59
|
+
#
|
60
|
+
# @param [Hash] d
|
61
|
+
#
|
62
|
+
# @return [DataClass]
|
63
|
+
#
|
64
|
+
def from_dynamic!(d)
|
65
|
+
d = Types::Hash[d]
|
66
|
+
new(
|
67
|
+
list: d.fetch("list").map { |x| ListItem.from_dynamic!(x) },
|
68
|
+
total: d.fetch("total")
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Response < Dry::Struct
|
75
|
+
attribute :code, Types::Integer
|
76
|
+
attribute :data, DataClass
|
77
|
+
attribute :message, Types::String
|
78
|
+
|
79
|
+
#
|
80
|
+
# @return [DataClass]
|
81
|
+
#
|
82
|
+
def data
|
83
|
+
attributes[:data]
|
84
|
+
end
|
85
|
+
|
86
|
+
class << self
|
87
|
+
#
|
88
|
+
# @param [Hash] d
|
89
|
+
#
|
90
|
+
# @return [Response]
|
91
|
+
#
|
92
|
+
def from_dynamic!(d)
|
93
|
+
d = Types::Hash[d]
|
94
|
+
new(
|
95
|
+
code: d.fetch("code"),
|
96
|
+
data: DataClass.from_dynamic!(d.fetch("data")),
|
97
|
+
message: d.fetch("message")
|
98
|
+
)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/lib/mihari/version.rb
CHANGED