Class: Mihari::Analyzers::Censys
- Defined in:
- lib/mihari/analyzers/censys.rb
Constant Summary collapse
- CENSYS_ID_KEY =
"CENSYS_ID"- CENSYS_SECRET_KEY =
"CENSYS_SECRET"
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Attributes inherited from Base
Instance Method Summary collapse
- #artifacts ⇒ Object
- #censys_id? ⇒ true, false
- #censys_secret? ⇒ true, false
-
#initialize(query, title: nil, description: nil, tags: []) ⇒ Censys
constructor
A new instance of Censys.
- #valid? ⇒ true, false
Methods inherited from Base
Constructor Details
#initialize(query, title: nil, description: nil, tags: []) ⇒ Censys
Returns a new instance of Censys.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mihari/analyzers/censys.rb', line 17 def initialize(query, title: nil, description: nil, tags: []) super() raise ArgumentError, "#{CENSYS_ID_KEY} and #{CENSYS_SECRET_KEY} are required" unless valid? @api = ::Censys::API.new @query = query @title = title || "Censys lookup" @description = description || "query = #{query}" = end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
8 9 10 |
# File 'lib/mihari/analyzers/censys.rb', line 8 def api @api end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/mihari/analyzers/censys.rb', line 10 def description @description end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
11 12 13 |
# File 'lib/mihari/analyzers/censys.rb', line 11 def query @query end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
12 13 14 |
# File 'lib/mihari/analyzers/censys.rb', line 12 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/mihari/analyzers/censys.rb', line 9 def title @title end |
Instance Method Details
#artifacts ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/mihari/analyzers/censys.rb', line 29 def artifacts ipv4s = [] res = api.ipv4.search(query: query) res.each_page do |page| page.each { |result| ipv4s << result.ip } end ipv4s end |
#censys_id? ⇒ true, false
40 41 42 |
# File 'lib/mihari/analyzers/censys.rb', line 40 def censys_id? ENV.key? CENSYS_ID_KEY end |
#censys_secret? ⇒ true, false
45 46 47 |
# File 'lib/mihari/analyzers/censys.rb', line 45 def censys_secret? ENV.key? CENSYS_SECRET_KEY end |
#valid? ⇒ true, false
50 51 52 |
# File 'lib/mihari/analyzers/censys.rb', line 50 def valid? censys_id? && censys_secret? end |