mihari 7.3.1 → 7.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/.rubocop.yml +0 -2
- data/.shadowenv.d/.gitignore +2 -0
- data/.shadowenv.d/000_unset_all.lisp +39 -0
- data/README.md +2 -8
- data/lib/mihari/analyzers/base.rb +2 -2
- data/lib/mihari/analyzers/binaryedge.rb +5 -5
- data/lib/mihari/analyzers/censys.rb +6 -6
- data/lib/mihari/analyzers/circl.rb +2 -2
- data/lib/mihari/analyzers/crtsh.rb +3 -3
- data/lib/mihari/analyzers/dnstwister.rb +2 -2
- data/lib/mihari/analyzers/feed.rb +12 -18
- data/lib/mihari/analyzers/fofa.rb +6 -6
- data/lib/mihari/analyzers/greynoise.rb +5 -5
- data/lib/mihari/analyzers/hunterhow.rb +4 -4
- data/lib/mihari/analyzers/onyphe.rb +5 -5
- data/lib/mihari/analyzers/otx.rb +2 -2
- data/lib/mihari/analyzers/passivetotal.rb +3 -3
- data/lib/mihari/analyzers/pulsedive.rb +3 -3
- data/lib/mihari/analyzers/securitytrails.rb +4 -4
- data/lib/mihari/analyzers/shodan.rb +5 -5
- data/lib/mihari/analyzers/urlscan.rb +5 -5
- data/lib/mihari/analyzers/virustotal.rb +4 -4
- data/lib/mihari/analyzers/virustotal_intelligence.rb +5 -5
- data/lib/mihari/analyzers/zoomeye.rb +5 -5
- data/lib/mihari/cli/application.rb +1 -1
- data/lib/mihari/clients/base.rb +5 -5
- data/lib/mihari/clients/binaryedge.rb +6 -6
- data/lib/mihari/clients/censys.rb +4 -4
- data/lib/mihari/clients/circl.rb +2 -2
- data/lib/mihari/clients/crtsh.rb +2 -2
- data/lib/mihari/clients/dnstwister.rb +1 -1
- data/lib/mihari/clients/fofa.rb +4 -4
- data/lib/mihari/clients/google_public_dns.rb +2 -2
- data/lib/mihari/clients/greynoise.rb +4 -4
- data/lib/mihari/clients/hunterhow.rb +10 -10
- data/lib/mihari/clients/misp.rb +1 -1
- data/lib/mihari/clients/mmdb.rb +1 -1
- data/lib/mihari/clients/onyphe.rb +4 -4
- data/lib/mihari/clients/otx.rb +1 -1
- data/lib/mihari/clients/passivetotal.rb +5 -5
- data/lib/mihari/clients/publsedive.rb +3 -3
- data/lib/mihari/clients/securitytrails.rb +6 -6
- data/lib/mihari/clients/shodan.rb +6 -6
- data/lib/mihari/clients/shodan_internet_db.rb +1 -1
- data/lib/mihari/clients/the_hive.rb +2 -2
- data/lib/mihari/clients/urlscan.rb +4 -4
- data/lib/mihari/clients/virustotal.rb +4 -4
- data/lib/mihari/clients/zoomeye.rb +12 -12
- data/lib/mihari/commands/alert.rb +1 -1
- data/lib/mihari/commands/artifact.rb +1 -1
- data/lib/mihari/commands/rule.rb +1 -1
- data/lib/mihari/commands/tag.rb +1 -1
- data/lib/mihari/concerns/autonomous_system_normalizable.rb +1 -4
- data/lib/mihari/concerns/configurable.rb +1 -1
- data/lib/mihari/concerns/database_connectable.rb +2 -2
- data/lib/mihari/concerns/retriable.rb +1 -1
- data/lib/mihari/config.rb +6 -2
- data/lib/mihari/constants.rb +2 -2
- data/lib/mihari/emitters/base.rb +2 -2
- data/lib/mihari/emitters/database.rb +1 -1
- data/lib/mihari/emitters/misp.rb +12 -4
- data/lib/mihari/emitters/slack.rb +9 -9
- data/lib/mihari/emitters/the_hive.rb +9 -4
- data/lib/mihari/emitters/webhook.rb +4 -4
- data/lib/mihari/enrichers/base.rb +1 -1
- data/lib/mihari/enrichers/google_public_dns.rb +1 -1
- data/lib/mihari/enrichers/mmdb.rb +1 -1
- data/lib/mihari/enrichers/shodan.rb +10 -12
- data/lib/mihari/enrichers/whois.rb +2 -2
- data/lib/mihari/entities/alert.rb +6 -6
- data/lib/mihari/entities/artifact.rb +17 -17
- data/lib/mihari/entities/autonomous_system.rb +1 -1
- data/lib/mihari/entities/config.rb +8 -4
- data/lib/mihari/entities/cpe.rb +2 -2
- data/lib/mihari/entities/dns.rb +3 -3
- data/lib/mihari/entities/geolocation.rb +3 -3
- data/lib/mihari/entities/ip_address.rb +3 -3
- data/lib/mihari/entities/messages.rb +3 -3
- data/lib/mihari/entities/pagination.rb +3 -3
- data/lib/mihari/entities/port.rb +2 -2
- data/lib/mihari/entities/reverse_dns.rb +2 -2
- data/lib/mihari/entities/rule.rb +8 -8
- data/lib/mihari/entities/tag.rb +3 -3
- data/lib/mihari/entities/vulnerability.rb +2 -2
- data/lib/mihari/entities/whois.rb +7 -7
- data/lib/mihari/errors.rb +1 -1
- data/lib/mihari/models/artifact.rb +2 -2
- data/lib/mihari/models/port.rb +1 -1
- data/lib/mihari/models/tag.rb +3 -0
- data/lib/mihari/rule.rb +10 -14
- data/lib/mihari/schemas/emitter.rb +2 -0
- data/lib/mihari/services/feed.rb +3 -3
- data/lib/mihari/services/getters.rb +1 -1
- data/lib/mihari/services/proxies.rb +1 -1
- data/lib/mihari/services/renderer.rb +2 -0
- data/lib/mihari/services/searchers.rb +1 -1
- data/lib/mihari/sidekiq/application.rb +2 -2
- data/lib/mihari/structs/censys.rb +4 -4
- data/lib/mihari/structs/google_public_dns.rb +3 -3
- data/lib/mihari/structs/greynoise.rb +2 -2
- data/lib/mihari/structs/onyphe.rb +3 -3
- data/lib/mihari/structs/shodan.rb +10 -10
- data/lib/mihari/structs/urlscan.rb +1 -1
- data/lib/mihari/structs/virustotal_intelligence.rb +2 -2
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/api.rb +1 -1
- data/lib/mihari/web/application.rb +1 -1
- data/lib/mihari/web/endpoints/alerts.rb +12 -12
- data/lib/mihari/web/endpoints/artifacts.rb +11 -11
- data/lib/mihari/web/endpoints/configs.rb +7 -2
- data/lib/mihari/web/endpoints/ip_addresses.rb +5 -5
- data/lib/mihari/web/endpoints/rules.rb +26 -26
- data/lib/mihari/web/endpoints/tags.rb +4 -4
- data/lib/mihari/web/public/assets/index-DsMIBgVm.js +1787 -0
- data/lib/mihari/web/public/assets/{index-ReF8ffd-.css → index-qLffdzXi.css} +1 -1
- data/lib/mihari/web/public/index.html +2 -2
- data/lib/mihari/web/public/redoc-static.html +2 -2
- data/lib/mihari.rb +1 -1
- data/mihari.gemspec +16 -16
- data/renovate.json +1 -3
- data/requirements.txt +1 -1
- metadata +37 -36
- data/.standard.yml +0 -4
- data/lib/mihari/web/public/assets/index-JHS0L8KZ.js +0 -1786
- /data/lib/mihari/web/public/assets/{mode-yaml-BC4MIiYj.js → mode-yaml-ELgwiJiP.js} +0 -0
data/lib/mihari/clients/base.rb
CHANGED
@@ -41,7 +41,7 @@ module Mihari
|
|
41
41
|
# @return [::HTTP::Client]
|
42
42
|
#
|
43
43
|
def http
|
44
|
-
@http ||= HTTP::Factory.build(headers
|
44
|
+
@http ||= HTTP::Factory.build(headers:, timeout:)
|
45
45
|
end
|
46
46
|
|
47
47
|
#
|
@@ -60,7 +60,7 @@ module Mihari
|
|
60
60
|
# @return [::HTTP::Response]
|
61
61
|
#
|
62
62
|
def get(path, params: nil)
|
63
|
-
http.get(url_for(path), params:
|
63
|
+
http.get(url_for(path), params:)
|
64
64
|
end
|
65
65
|
|
66
66
|
#
|
@@ -70,7 +70,7 @@ module Mihari
|
|
70
70
|
# @return [Hash]
|
71
71
|
#
|
72
72
|
def get_json(path, params: nil)
|
73
|
-
res = get(path, params:
|
73
|
+
res = get(path, params:)
|
74
74
|
JSON.parse res.body.to_s
|
75
75
|
end
|
76
76
|
|
@@ -81,7 +81,7 @@ module Mihari
|
|
81
81
|
# @return [::HTTP::Response]
|
82
82
|
#
|
83
83
|
def post(path, json: {})
|
84
|
-
http.post(url_for(path), json:
|
84
|
+
http.post(url_for(path), json:)
|
85
85
|
end
|
86
86
|
|
87
87
|
#
|
@@ -91,7 +91,7 @@ module Mihari
|
|
91
91
|
# @return [Hash]
|
92
92
|
#
|
93
93
|
def post_json(path, json: {})
|
94
|
-
res = http.post(url_for(path), json:
|
94
|
+
res = http.post(url_for(path), json:)
|
95
95
|
JSON.parse res.body.to_s
|
96
96
|
end
|
97
97
|
end
|
@@ -22,7 +22,7 @@ module Mihari
|
|
22
22
|
)
|
23
23
|
headers["x-key"] = api_key
|
24
24
|
|
25
|
-
super(base_url, headers
|
25
|
+
super(base_url, headers:, timeout:, pagination_interval:)
|
26
26
|
end
|
27
27
|
|
28
28
|
#
|
@@ -34,11 +34,11 @@ module Mihari
|
|
34
34
|
#
|
35
35
|
def search(query, page: 1, only_ips: nil)
|
36
36
|
params = {
|
37
|
-
query
|
38
|
-
page
|
39
|
-
only_ips:
|
37
|
+
query:,
|
38
|
+
page:,
|
39
|
+
only_ips:
|
40
40
|
}.compact
|
41
|
-
Structs::BinaryEdge::Response.from_dynamic! get_json("/v2/query/search", params:
|
41
|
+
Structs::BinaryEdge::Response.from_dynamic! get_json("/v2/query/search", params:)
|
42
42
|
end
|
43
43
|
|
44
44
|
#
|
@@ -51,7 +51,7 @@ module Mihari
|
|
51
51
|
def search_with_pagination(query, only_ips: nil, pagination_limit: Mihari.config.pagination_limit)
|
52
52
|
Enumerator.new do |y|
|
53
53
|
(1..pagination_limit).each do |page|
|
54
|
-
res = search(query, page
|
54
|
+
res = search(query, page:, only_ips:)
|
55
55
|
|
56
56
|
y.yield res
|
57
57
|
|
@@ -29,7 +29,7 @@ module Mihari
|
|
29
29
|
|
30
30
|
headers["authorization"] = "Basic #{Base64.strict_encode64("#{id}:#{secret}")}"
|
31
31
|
|
32
|
-
super(base_url, headers
|
32
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
33
33
|
end
|
34
34
|
|
35
35
|
#
|
@@ -45,8 +45,8 @@ module Mihari
|
|
45
45
|
# @return [Mihari::Structs::Censys::Response]
|
46
46
|
#
|
47
47
|
def search(query, per_page: nil, cursor: nil)
|
48
|
-
params = {
|
49
|
-
Structs::Censys::Response.from_dynamic! get_json("/api/v2/hosts/search", params:
|
48
|
+
params = {q: query, per_page:, cursor:}.compact
|
49
|
+
Structs::Censys::Response.from_dynamic! get_json("/api/v2/hosts/search", params:)
|
50
50
|
end
|
51
51
|
|
52
52
|
#
|
@@ -61,7 +61,7 @@ module Mihari
|
|
61
61
|
|
62
62
|
Enumerator.new do |y|
|
63
63
|
pagination_limit.times do
|
64
|
-
res = search(query, per_page
|
64
|
+
res = search(query, per_page:, cursor:)
|
65
65
|
|
66
66
|
y.yield res
|
67
67
|
|
data/lib/mihari/clients/circl.rb
CHANGED
@@ -21,7 +21,7 @@ module Mihari
|
|
21
21
|
|
22
22
|
headers["authorization"] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
23
23
|
|
24
|
-
super(base_url, headers
|
24
|
+
super(base_url, headers:, timeout:)
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
@@ -77,7 +77,7 @@ module Mihari
|
|
77
77
|
# @param [Hash] params
|
78
78
|
#
|
79
79
|
def _get(path, params: {})
|
80
|
-
res = get(path, params:
|
80
|
+
res = get(path, params:)
|
81
81
|
body = res.body.to_s
|
82
82
|
content_type = res["Content-Type"].to_s
|
83
83
|
|
data/lib/mihari/clients/crtsh.rb
CHANGED
@@ -12,7 +12,7 @@ module Mihari
|
|
12
12
|
# @param [Integer, nil] timeout
|
13
13
|
#
|
14
14
|
def initialize(base_url = "https://crt.sh", headers: {}, timeout: nil)
|
15
|
-
super(base_url, headers
|
15
|
+
super(base_url, headers:, timeout:)
|
16
16
|
end
|
17
17
|
|
18
18
|
#
|
@@ -25,7 +25,7 @@ module Mihari
|
|
25
25
|
# @return [Array<Hash>]
|
26
26
|
#
|
27
27
|
def search(identity, match: nil, exclude: nil)
|
28
|
-
get_json("/", params: {
|
28
|
+
get_json("/", params: {identity:, match:, exclude:, output: "json"}.compact)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/mihari/clients/fofa.rb
CHANGED
@@ -39,7 +39,7 @@ module Mihari
|
|
39
39
|
@api_key = api_key
|
40
40
|
@email = email
|
41
41
|
|
42
|
-
super(base_url, headers
|
42
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
43
43
|
end
|
44
44
|
|
45
45
|
#
|
@@ -51,8 +51,8 @@ module Mihari
|
|
51
51
|
#
|
52
52
|
def search(query, page:, size: PAGE_SIZE)
|
53
53
|
qbase64 = Base64.urlsafe_encode64(query)
|
54
|
-
params = {
|
55
|
-
res = Structs::Fofa::Response.from_dynamic!(get_json("/api/v1/search/all", params:
|
54
|
+
params = {qbase64:, size:, page:, email:, key: api_key}.compact
|
55
|
+
res = Structs::Fofa::Response.from_dynamic!(get_json("/api/v1/search/all", params:))
|
56
56
|
raise ResponseError, res.errmsg if res.error
|
57
57
|
|
58
58
|
res
|
@@ -68,7 +68,7 @@ module Mihari
|
|
68
68
|
def search_with_pagination(query, size: PAGE_SIZE, pagination_limit: Mihari.config.pagination_limit)
|
69
69
|
Enumerator.new do |y|
|
70
70
|
(1..pagination_limit).each do |page|
|
71
|
-
res = search(query, page
|
71
|
+
res = search(query, page:, size:)
|
72
72
|
|
73
73
|
y.yield res
|
74
74
|
|
@@ -12,7 +12,7 @@ module Mihari
|
|
12
12
|
# @param [Integer, nil] timeout
|
13
13
|
#
|
14
14
|
def initialize(base_url = "https://dns.google", headers: {}, timeout: nil)
|
15
|
-
super(base_url, headers
|
15
|
+
super(base_url, headers:, timeout:)
|
16
16
|
end
|
17
17
|
|
18
18
|
#
|
@@ -24,7 +24,7 @@ module Mihari
|
|
24
24
|
#
|
25
25
|
def query_all(name)
|
26
26
|
Structs::GooglePublicDNS::Response.from_dynamic! get_json("/resolve",
|
27
|
-
params: {
|
27
|
+
params: {name:, type: "ALL"})
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -25,7 +25,7 @@ module Mihari
|
|
25
25
|
raise(ArgumentError, "api_key is required") unless api_key
|
26
26
|
|
27
27
|
headers["key"] = api_key
|
28
|
-
super(base_url, headers
|
28
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
29
29
|
end
|
30
30
|
|
31
31
|
#
|
@@ -38,8 +38,8 @@ module Mihari
|
|
38
38
|
# @return [Mihari::Structs::GreyNoise::Response]
|
39
39
|
#
|
40
40
|
def gnql_search(query, size: PAGE_SIZE, scroll: nil)
|
41
|
-
params = {
|
42
|
-
Structs::GreyNoise::Response.from_dynamic! get_json("/v2/experimental/gnql", params:
|
41
|
+
params = {query:, size:, scroll:}.compact
|
42
|
+
Structs::GreyNoise::Response.from_dynamic! get_json("/v2/experimental/gnql", params:)
|
43
43
|
end
|
44
44
|
|
45
45
|
#
|
@@ -54,7 +54,7 @@ module Mihari
|
|
54
54
|
|
55
55
|
Enumerator.new do |y|
|
56
56
|
pagination_limit.times do
|
57
|
-
res = gnql_search(query, size
|
57
|
+
res = gnql_search(query, size:, scroll:)
|
58
58
|
|
59
59
|
y.yield res
|
60
60
|
|
@@ -29,7 +29,7 @@ module Mihari
|
|
29
29
|
)
|
30
30
|
raise(ArgumentError, "api_key is required") unless api_key
|
31
31
|
|
32
|
-
super(base_url, headers
|
32
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
33
33
|
|
34
34
|
@api_key = api_key
|
35
35
|
end
|
@@ -46,13 +46,13 @@ module Mihari
|
|
46
46
|
def search(query, start_time:, end_time:, page: 1, page_size: PAGE_SIZE)
|
47
47
|
params = {
|
48
48
|
query: Base64.urlsafe_encode64(query),
|
49
|
-
page
|
50
|
-
page_size
|
51
|
-
start_time
|
52
|
-
end_time
|
49
|
+
page:,
|
50
|
+
page_size:,
|
51
|
+
start_time:,
|
52
|
+
end_time:,
|
53
53
|
"api-key": api_key
|
54
54
|
}.compact
|
55
|
-
Structs::HunterHow::Response.from_dynamic! get_json("/search", params:
|
55
|
+
Structs::HunterHow::Response.from_dynamic! get_json("/search", params:)
|
56
56
|
end
|
57
57
|
|
58
58
|
#
|
@@ -75,10 +75,10 @@ module Mihari
|
|
75
75
|
(1..pagination_limit).each do |page|
|
76
76
|
res = search(
|
77
77
|
query,
|
78
|
-
start_time
|
79
|
-
end_time
|
80
|
-
page
|
81
|
-
page_size:
|
78
|
+
start_time:,
|
79
|
+
end_time:,
|
80
|
+
page:,
|
81
|
+
page_size:
|
82
82
|
)
|
83
83
|
|
84
84
|
y.yield res
|
data/lib/mihari/clients/misp.rb
CHANGED
data/lib/mihari/clients/mmdb.rb
CHANGED
@@ -27,7 +27,7 @@ module Mihari
|
|
27
27
|
)
|
28
28
|
raise(ArgumentError, "api_key is required") if api_key.nil?
|
29
29
|
|
30
|
-
super(base_url, headers
|
30
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
31
31
|
|
32
32
|
@api_key = api_key
|
33
33
|
end
|
@@ -39,8 +39,8 @@ module Mihari
|
|
39
39
|
# @return [Mihari::Structs::Onyphe::Response]
|
40
40
|
#
|
41
41
|
def datascan(query, page: 1)
|
42
|
-
params = {
|
43
|
-
Structs::Onyphe::Response.from_dynamic! get_json("/api/v2/simple/datascan/#{query}", params:
|
42
|
+
params = {page:, apikey: api_key}
|
43
|
+
Structs::Onyphe::Response.from_dynamic! get_json("/api/v2/simple/datascan/#{query}", params:)
|
44
44
|
end
|
45
45
|
|
46
46
|
#
|
@@ -52,7 +52,7 @@ module Mihari
|
|
52
52
|
def datascan_with_pagination(query, pagination_limit: Mihari.config.pagination_limit)
|
53
53
|
Enumerator.new do |y|
|
54
54
|
(1..pagination_limit).each do |page|
|
55
|
-
res = datascan(query, page:
|
55
|
+
res = datascan(query, page:)
|
56
56
|
|
57
57
|
y.yield res
|
58
58
|
|
data/lib/mihari/clients/otx.rb
CHANGED
@@ -21,7 +21,7 @@ module Mihari
|
|
21
21
|
|
22
22
|
headers["authorization"] = "Basic #{Base64.strict_encode64("#{username}:#{api_key}")}"
|
23
23
|
|
24
|
-
super(base_url, headers
|
24
|
+
super(base_url, headers:, timeout:)
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
@@ -32,8 +32,8 @@ module Mihari
|
|
32
32
|
# @return [Hash]
|
33
33
|
#
|
34
34
|
def passive_dns_search(query)
|
35
|
-
params = {
|
36
|
-
get_json("/v2/dns/passive/unique", params:
|
35
|
+
params = {query:}
|
36
|
+
get_json("/v2/dns/passive/unique", params:)
|
37
37
|
end
|
38
38
|
|
39
39
|
#
|
@@ -45,7 +45,7 @@ module Mihari
|
|
45
45
|
#
|
46
46
|
def reverse_whois_search(query)
|
47
47
|
get_json("/v2/whois/search", params: {
|
48
|
-
query
|
48
|
+
query:,
|
49
49
|
field: "email"
|
50
50
|
}.compact)
|
51
51
|
end
|
@@ -58,7 +58,7 @@ module Mihari
|
|
58
58
|
# @return [Hash]
|
59
59
|
#
|
60
60
|
def ssl_search(query)
|
61
|
-
get_json("/v2/ssl-certificate/history", params: {
|
61
|
+
get_json("/v2/ssl-certificate/history", params: {query:})
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -20,7 +20,7 @@ module Mihari
|
|
20
20
|
|
21
21
|
@api_key = api_key
|
22
22
|
|
23
|
-
super(base_url, headers
|
23
|
+
super(base_url, headers:, timeout:)
|
24
24
|
end
|
25
25
|
|
26
26
|
#
|
@@ -29,7 +29,7 @@ module Mihari
|
|
29
29
|
# @return [Hash]
|
30
30
|
#
|
31
31
|
def get_indicator(ip_or_domain)
|
32
|
-
get_json "/api/info.php", params: {
|
32
|
+
get_json "/api/info.php", params: {indicator: ip_or_domain, key: api_key}
|
33
33
|
end
|
34
34
|
|
35
35
|
#
|
@@ -38,7 +38,7 @@ module Mihari
|
|
38
38
|
# @return [Hash]
|
39
39
|
#
|
40
40
|
def get_properties(indicator_id)
|
41
|
-
get_json "/api/info.php", params: {
|
41
|
+
get_json "/api/info.php", params: {iid: indicator_id, get: "properties", key: api_key}
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -17,7 +17,7 @@ module Mihari
|
|
17
17
|
|
18
18
|
headers["apikey"] = api_key
|
19
19
|
|
20
|
-
super(base_url, headers
|
20
|
+
super(base_url, headers:, timeout:)
|
21
21
|
end
|
22
22
|
|
23
23
|
#
|
@@ -48,7 +48,7 @@ module Mihari
|
|
48
48
|
# @return [Hash]
|
49
49
|
#
|
50
50
|
def search_by_mail(mail)
|
51
|
-
post_json "/v1/domains/list", json: {
|
51
|
+
post_json "/v1/domains/list", json: {filter: {whois_email: mail}}
|
52
52
|
end
|
53
53
|
|
54
54
|
#
|
@@ -57,7 +57,7 @@ module Mihari
|
|
57
57
|
# @return [Hash]
|
58
58
|
#
|
59
59
|
def search_by_ip(ip)
|
60
|
-
post_json "/v1/domains/list", json: {
|
60
|
+
post_json "/v1/domains/list", json: {filter: {ipv4: ip}}
|
61
61
|
end
|
62
62
|
|
63
63
|
#
|
@@ -69,13 +69,13 @@ module Mihari
|
|
69
69
|
#
|
70
70
|
def get_all_dns_history(domain, type:, page: 1)
|
71
71
|
Enumerator.new do |y|
|
72
|
-
res = get_dns_history(domain, type
|
72
|
+
res = get_dns_history(domain, type:, page:)
|
73
73
|
y.yield res
|
74
74
|
|
75
75
|
pages = res["pages"].to_i
|
76
76
|
|
77
77
|
(page + 1..pages).each do |page|
|
78
|
-
y.yield get_dns_history(domain, type
|
78
|
+
y.yield get_dns_history(domain, type:, page:)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -90,7 +90,7 @@ module Mihari
|
|
90
90
|
# @return [Hash]
|
91
91
|
#
|
92
92
|
def get_dns_history(domain, type:, page:)
|
93
|
-
get_json "/v1/history/#{domain}/dns/#{type}", params: {
|
93
|
+
get_json "/v1/history/#{domain}/dns/#{type}", params: {page:}
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
@@ -27,7 +27,7 @@ module Mihari
|
|
27
27
|
)
|
28
28
|
raise(ArgumentError, "api_key is required") unless api_key
|
29
29
|
|
30
|
-
super(base_url, headers
|
30
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
31
31
|
|
32
32
|
@api_key = api_key
|
33
33
|
end
|
@@ -41,12 +41,12 @@ module Mihari
|
|
41
41
|
#
|
42
42
|
def search(query, page: 1, minify: true)
|
43
43
|
params = {
|
44
|
-
query
|
45
|
-
page
|
46
|
-
minify
|
44
|
+
query:,
|
45
|
+
page:,
|
46
|
+
minify:,
|
47
47
|
key: api_key
|
48
48
|
}
|
49
|
-
Structs::Shodan::Response.from_dynamic! get_json("/shodan/host/search", params:
|
49
|
+
Structs::Shodan::Response.from_dynamic! get_json("/shodan/host/search", params:)
|
50
50
|
end
|
51
51
|
|
52
52
|
#
|
@@ -59,7 +59,7 @@ module Mihari
|
|
59
59
|
def search_with_pagination(query, minify: true, pagination_limit: Mihari.config.pagination_limit)
|
60
60
|
Enumerator.new do |y|
|
61
61
|
(1..pagination_limit).each do |page|
|
62
|
-
res = search(query, page
|
62
|
+
res = search(query, page:, minify:)
|
63
63
|
|
64
64
|
y.yield res
|
65
65
|
|
@@ -19,7 +19,7 @@ module Mihari
|
|
19
19
|
raise(ArgumentError, "api_key is required") unless api_key
|
20
20
|
|
21
21
|
headers["authorization"] = "Bearer #{api_key}"
|
22
|
-
super(base_url, headers
|
22
|
+
super(base_url, headers:, timeout:)
|
23
23
|
|
24
24
|
@api_version = api_version
|
25
25
|
end
|
@@ -31,7 +31,7 @@ module Mihari
|
|
31
31
|
#
|
32
32
|
def alert(json)
|
33
33
|
json = json.to_camelback_keys.compact
|
34
|
-
post_json("/api/#{api_version}/alert", json:
|
34
|
+
post_json("/api/#{api_version}/alert", json:)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -24,7 +24,7 @@ module Mihari
|
|
24
24
|
|
25
25
|
headers["api-key"] = api_key
|
26
26
|
|
27
|
-
super(base_url, headers
|
27
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
28
28
|
end
|
29
29
|
|
30
30
|
#
|
@@ -35,8 +35,8 @@ module Mihari
|
|
35
35
|
# @return [Mihari::Structs::Urlscan::Response]
|
36
36
|
#
|
37
37
|
def search(q, size: nil, search_after: nil)
|
38
|
-
params = {
|
39
|
-
Structs::Urlscan::Response.from_dynamic! get_json("/api/v1/search/", params:
|
38
|
+
params = {q:, size:, search_after:}.compact
|
39
|
+
Structs::Urlscan::Response.from_dynamic! get_json("/api/v1/search/", params:)
|
40
40
|
end
|
41
41
|
|
42
42
|
#
|
@@ -51,7 +51,7 @@ module Mihari
|
|
51
51
|
|
52
52
|
Enumerator.new do |y|
|
53
53
|
pagination_limit.times do
|
54
|
-
res = search(q, size
|
54
|
+
res = search(q, size:, search_after:)
|
55
55
|
|
56
56
|
y.yield res
|
57
57
|
|
@@ -24,7 +24,7 @@ module Mihari
|
|
24
24
|
|
25
25
|
headers["x-apikey"] = api_key
|
26
26
|
|
27
|
-
super(base_url, headers
|
27
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
28
28
|
end
|
29
29
|
|
30
30
|
#
|
@@ -52,8 +52,8 @@ module Mihari
|
|
52
52
|
# @return [Mihari::Structs::VirusTotalIntelligence::Response]
|
53
53
|
#
|
54
54
|
def intel_search(query, cursor: nil)
|
55
|
-
params = {
|
56
|
-
Structs::VirusTotalIntelligence::Response.from_dynamic! get_json("/api/v3/intelligence/search", params:
|
55
|
+
params = {query:, cursor:}.compact
|
56
|
+
Structs::VirusTotalIntelligence::Response.from_dynamic! get_json("/api/v3/intelligence/search", params:)
|
57
57
|
end
|
58
58
|
|
59
59
|
#
|
@@ -67,7 +67,7 @@ module Mihari
|
|
67
67
|
|
68
68
|
Enumerator.new do |y|
|
69
69
|
pagination_limit.times do
|
70
|
-
res = intel_search(query, cursor:
|
70
|
+
res = intel_search(query, cursor:)
|
71
71
|
|
72
72
|
y.yield res
|
73
73
|
|
@@ -27,14 +27,14 @@ module Mihari
|
|
27
27
|
raise(ArgumentError, "api_key is required") unless api_key
|
28
28
|
|
29
29
|
headers["api-key"] = api_key
|
30
|
-
super(base_url, headers
|
30
|
+
super(base_url, headers:, pagination_interval:, timeout:)
|
31
31
|
end
|
32
32
|
|
33
33
|
#
|
34
34
|
# @return [::HTTP::Client]
|
35
35
|
#
|
36
36
|
def http
|
37
|
-
@http ||= HTTP::Factory.build(headers
|
37
|
+
@http ||= HTTP::Factory.build(headers:, timeout:, raise_exception: false)
|
38
38
|
end
|
39
39
|
|
40
40
|
#
|
@@ -48,11 +48,11 @@ module Mihari
|
|
48
48
|
#
|
49
49
|
def host_search(query, page: nil, facets: nil)
|
50
50
|
params = {
|
51
|
-
query
|
52
|
-
page
|
53
|
-
facets:
|
51
|
+
query:,
|
52
|
+
page:,
|
53
|
+
facets:
|
54
54
|
}.compact
|
55
|
-
get_json "/host/search", params:
|
55
|
+
get_json "/host/search", params:
|
56
56
|
end
|
57
57
|
|
58
58
|
#
|
@@ -65,7 +65,7 @@ module Mihari
|
|
65
65
|
def host_search_with_pagination(query, facets: nil, pagination_limit: Mihari.config.pagination_limit)
|
66
66
|
Enumerator.new do |y|
|
67
67
|
(1..pagination_limit).each do |page|
|
68
|
-
res = host_search(query, facets
|
68
|
+
res = host_search(query, facets:, page:)
|
69
69
|
|
70
70
|
break if res.nil?
|
71
71
|
|
@@ -90,11 +90,11 @@ module Mihari
|
|
90
90
|
#
|
91
91
|
def web_search(query, page: nil, facets: nil)
|
92
92
|
params = {
|
93
|
-
query
|
94
|
-
page
|
95
|
-
facets:
|
93
|
+
query:,
|
94
|
+
page:,
|
95
|
+
facets:
|
96
96
|
}.compact
|
97
|
-
get_json "/web/search", params:
|
97
|
+
get_json "/web/search", params:
|
98
98
|
end
|
99
99
|
|
100
100
|
#
|
@@ -107,7 +107,7 @@ module Mihari
|
|
107
107
|
def web_search_with_pagination(query, facets: nil, pagination_limit: Mihari.config.pagination_limit)
|
108
108
|
Enumerator.new do |y|
|
109
109
|
(1..pagination_limit).each do |page|
|
110
|
-
res = web_search(query, facets
|
110
|
+
res = web_search(query, facets:, page:)
|
111
111
|
|
112
112
|
break if res.nil?
|
113
113
|
|
@@ -21,7 +21,7 @@ module Mihari
|
|
21
21
|
# @return [Mihari::Services::ResultValue]
|
22
22
|
#
|
23
23
|
def _search(q, page: 1, limit: 10)
|
24
|
-
filter = Structs::Filters::Search.new(q
|
24
|
+
filter = Structs::Filters::Search.new(q:, page:, limit:)
|
25
25
|
Services::AlertSearcher.result(filter).value!
|
26
26
|
end
|
27
27
|
end
|