Class: Mihari::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/mihari/cli.rb

Instance Method Summary collapse

Instance Method Details

#alertsObject



265
266
267
268
269
270
271
272
273
# File 'lib/mihari/cli.rb', line 265

def alerts
  with_error_handling do
    load_configuration

    viewer = AlertViewer.new
    alerts = viewer.list(limit: options["limit"], title: options["title"], source: options["source"], tag: options[:tag])
    puts JSON.pretty_generate(alerts)
  end
end

#binaryedge(query) ⇒ Object



141
142
143
144
145
# File 'lib/mihari/cli.rb', line 141

def binaryedge(query)
  with_error_handling do
    run_analyzer Analyzers::BinaryEdge, query: query, options: options
  end
end

#censys(query) ⇒ Object



15
16
17
18
19
# File 'lib/mihari/cli.rb', line 15

def censys(query)
  with_error_handling do
    run_analyzer Analyzers::Censys, query: query, options: options
  end
end

#circl(query) ⇒ Object



110
111
112
113
114
# File 'lib/mihari/cli.rb', line 110

def circl(query)
  with_error_handling do
    run_analyzer Analyzers::CIRCL, query: refang(query), options: options
  end
end

#crtsh(query) ⇒ Object



90
91
92
93
94
# File 'lib/mihari/cli.rb', line 90

def crtsh(query)
  with_error_handling do
    run_analyzer Analyzers::Crtsh, query: query, options: options
  end
end

#dnpedia(query) ⇒ Object



100
101
102
103
104
# File 'lib/mihari/cli.rb', line 100

def dnpedia(query)
  with_error_handling do
    run_analyzer Analyzers::DNPedia, query: query, options: options
  end
end

#dnstwister(domain) ⇒ Object



161
162
163
164
165
# File 'lib/mihari/cli.rb', line 161

def dnstwister(domain)
  with_error_handling do
    run_analyzer Analyzers::DNSTwister, query: refang(domain), options: options
  end
end

#free_text(text) ⇒ Object



225
226
227
228
229
# File 'lib/mihari/cli.rb', line 225

def free_text(text)
  with_error_handling do
    run_analyzer Analyzers::FreeText, query: text, options: options
  end
end

#http_hashObject



215
216
217
218
219
# File 'lib/mihari/cli.rb', line 215

def http_hash
  with_error_handling do
    run_analyzer Analyzers::HTTPHash, query: nil, options: options
  end
end

#import_from_json(input = nil) ⇒ Object



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/mihari/cli.rb', line 242

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")
    tags = json.dig("tags") || []

    basic = Analyzers::Basic.new(title: title, description: description, artifacts: artifacts, source: "json", tags: tags)
    basic.run
  end
end

#onyphe(query) ⇒ Object



35
36
37
38
39
# File 'lib/mihari/cli.rb', line 35

def onyphe(query)
  with_error_handling do
    run_analyzer Analyzers::Onyphe, query: query, options: options
  end
end

#otx(domain) ⇒ Object



171
172
173
174
175
# File 'lib/mihari/cli.rb', line 171

def otx(domain)
  with_error_handling do
    run_analyzer Analyzers::OTX, query: refang(domain), options: options
  end
end

#passive_dns(query) ⇒ Object



181
182
183
184
185
# File 'lib/mihari/cli.rb', line 181

def passive_dns(query)
  with_error_handling do
    run_analyzer Analyzers::PassiveDNS, query: refang(query), options: options
  end
end

#passive_ssl(query) ⇒ Object



191
192
193
194
195
# File 'lib/mihari/cli.rb', line 191

def passive_ssl(query)
  with_error_handling do
    run_analyzer Analyzers::PassiveSSL, query: query, options: options
  end
end

#passivetotal(indicator) ⇒ Object



120
121
122
123
124
# File 'lib/mihari/cli.rb', line 120

def passivetotal(indicator)
  with_error_handling do
    run_analyzer Analyzers::PassiveTotal, query: refang(indicator), options: options
  end
end

#pulsedive(indiactor) ⇒ Object



151
152
153
154
155
# File 'lib/mihari/cli.rb', line 151

def pulsedive(indiactor)
  with_error_handling do
    run_analyzer Analyzers::Pulsedive, query: refang(indiactor), options: options
  end
end

#reverse_whois(query) ⇒ Object



201
202
203
204
205
# File 'lib/mihari/cli.rb', line 201

def reverse_whois(query)
  with_error_handling do
    run_analyzer Analyzers::ReveseWhois, query: refang(query), options: options
  end
end

#securitytrails(indiactor) ⇒ Object



66
67
68
69
70
# File 'lib/mihari/cli.rb', line 66

def securitytrails(indiactor)
  with_error_handling do
    run_analyzer Analyzers::SecurityTrails, query: refang(indiactor), options: options
  end
end

#securitytrails_domain_feed(regexp) ⇒ Object



78
79
80
81
82
# File 'lib/mihari/cli.rb', line 78

def securitytrails_domain_feed(regexp)
  with_error_handling do
    run_analyzer Analyzers::SecurityTrailsDomainFeed, query: regexp, options: options
  end
end

#shodan(query) ⇒ Object



25
26
27
28
29
# File 'lib/mihari/cli.rb', line 25

def shodan(query)
  with_error_handling do
    run_analyzer Analyzers::Shodan, query: query, options: options
  end
end

#ssh_fingerprint(fingerprint) ⇒ Object



235
236
237
238
239
# File 'lib/mihari/cli.rb', line 235

def ssh_fingerprint(fingerprint)
  with_error_handling do
    run_analyzer Analyzers::SSHFingerprint, query: fingerprint, options: options
  end
end

#statusObject



276
277
278
279
280
281
282
# File 'lib/mihari/cli.rb', line 276

def status
  with_error_handling do
    load_configuration

    puts JSON.pretty_generate(Status.check)
  end
end

#urlscan(query) ⇒ Object



46
47
48
49
50
# File 'lib/mihari/cli.rb', line 46

def urlscan(query)
  with_error_handling do
    run_analyzer Analyzers::Urlscan, query: query, options: options
  end
end

#virustotal(indiactor) ⇒ Object



56
57
58
59
60
# File 'lib/mihari/cli.rb', line 56

def virustotal(indiactor)
  with_error_handling do
    run_analyzer Analyzers::VirusTotal, query: refang(indiactor), options: options
  end
end

#zoomeye(query) ⇒ Object



131
132
133
134
135
# File 'lib/mihari/cli.rb', line 131

def zoomeye(query)
  with_error_handling do
    run_analyzer Analyzers::ZoomEye, query: query, options: options
  end
end