Class: Mihari::CLI
- Inherits:
-
Thor
- Object
- Thor
- Mihari::CLI
- Defined in:
- lib/mihari/cli.rb
Instance Method Summary collapse
- #alerts ⇒ Object
- #censys(query) ⇒ Object
- #crtsh(query) ⇒ Object
- #import_from_json(input = nil) ⇒ Object
- #onyphe(query) ⇒ Object
- #securitytrails(indiactor) ⇒ Object
- #securitytrails_domain_feed(regexp) ⇒ Object
- #shodan(query) ⇒ Object
- #status ⇒ Object
- #urlscan(query) ⇒ Object
- #virustotal(indiactor) ⇒ Object
Instance Method Details
#alerts ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/mihari/cli.rb', line 113 def alerts with_error_handling do viewer = AlertViewer.new(limit: ["limit"]) alerts = viewer.list puts JSON.pretty_generate(alerts) end end |
#censys(query) ⇒ Object
12 13 14 15 16 |
# File 'lib/mihari/cli.rb', line 12 def censys(query) with_error_handling do run_analyzer Analyzers::Censys, query: query, options: end end |
#crtsh(query) ⇒ Object
86 87 88 89 90 |
# File 'lib/mihari/cli.rb', line 86 def crtsh(query) with_error_handling do run_analyzer Analyzers::Crtsh, query: query, options: end end |
#import_from_json(input = nil) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/mihari/cli.rb', line 93 def import_from_json(input = nil) with_error_handling do json = input || STDIN.gets.chomp raise ArgumentError, "Input not found: please give an input in a JSON format" unless json json = parse_as_json(json) raise ArgumentError, "Invalid input format: an input JSON data should have title, description and artifacts key" unless valid_json?(json) title = json.dig("title") description = json.dig("description") artifacts = json.dig("artifacts") = json.dig("tags") || [] basic = Analyzers::Basic.new(title: title, description: description, artifacts: artifacts, tags: ) basic.run end end |
#onyphe(query) ⇒ Object
32 33 34 35 36 |
# File 'lib/mihari/cli.rb', line 32 def onyphe(query) with_error_handling do run_analyzer Analyzers::Onyphe, query: query, options: end end |
#securitytrails(indiactor) ⇒ Object
63 64 65 66 67 |
# File 'lib/mihari/cli.rb', line 63 def securitytrails(indiactor) with_error_handling do run_analyzer Analyzers::SecurityTrails, query: indiactor, options: end end |
#securitytrails_domain_feed(regexp) ⇒ Object
75 76 77 78 79 |
# File 'lib/mihari/cli.rb', line 75 def securitytrails_domain_feed(regexp) with_error_handling do run_analyzer Analyzers::SecurityTrailsDomainFeed, query: regexp, options: end end |
#shodan(query) ⇒ Object
22 23 24 25 26 |
# File 'lib/mihari/cli.rb', line 22 def shodan(query) with_error_handling do run_analyzer Analyzers::Shodan, query: query, options: end end |
#status ⇒ Object
122 123 124 125 126 |
# File 'lib/mihari/cli.rb', line 122 def status with_error_handling do puts JSON.pretty_generate(Status.check) end end |
#urlscan(query) ⇒ Object
43 44 45 46 47 |
# File 'lib/mihari/cli.rb', line 43 def urlscan(query) with_error_handling do run_analyzer Analyzers::Urlscan, query: query, options: end end |
#virustotal(indiactor) ⇒ Object
53 54 55 56 57 |
# File 'lib/mihari/cli.rb', line 53 def virustotal(indiactor) with_error_handling do run_analyzer Analyzers::VirusTotal, query: indiactor, options: end end |