Class: Mihari::CLI

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

Instance Method Summary collapse

Instance Method Details

#alertsObject



205
206
207
208
209
210
211
# File 'lib/mihari/cli.rb', line 205

def alerts
  with_error_handling do
    viewer = AlertViewer.new(limit: options["limit"])
    alerts = viewer.list
    puts JSON.pretty_generate(alerts)
  end
end

#binaryedge(query) ⇒ Object



138
139
140
141
142
# File 'lib/mihari/cli.rb', line 138

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

#censys(query) ⇒ Object



13
14
15
16
17
# File 'lib/mihari/cli.rb', line 13

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

#circl(query) ⇒ Object



107
108
109
110
111
# File 'lib/mihari/cli.rb', line 107

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

#crtsh(query) ⇒ Object



87
88
89
90
91
# File 'lib/mihari/cli.rb', line 87

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

#dnpedia(query) ⇒ Object



97
98
99
100
101
# File 'lib/mihari/cli.rb', line 97

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

#import_from_json(input = nil) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/mihari/cli.rb', line 185

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, tags: tags)
    basic.run
  end
end

#onyphe(query) ⇒ Object



33
34
35
36
37
# File 'lib/mihari/cli.rb', line 33

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

#passive_dns(query) ⇒ Object



148
149
150
151
152
# File 'lib/mihari/cli.rb', line 148

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

#passive_ssl(query) ⇒ Object



158
159
160
161
162
# File 'lib/mihari/cli.rb', line 158

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

#passivetotal(indicator) ⇒ Object



117
118
119
120
121
# File 'lib/mihari/cli.rb', line 117

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

#reverse_whois(query) ⇒ Object



168
169
170
171
172
# File 'lib/mihari/cli.rb', line 168

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

#securitytrails(indiactor) ⇒ Object



64
65
66
67
68
# File 'lib/mihari/cli.rb', line 64

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

#securitytrails_domain_feed(regexp) ⇒ Object



76
77
78
79
80
# File 'lib/mihari/cli.rb', line 76

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

#sha256(query) ⇒ Object



178
179
180
181
182
# File 'lib/mihari/cli.rb', line 178

def sha256(query)
  with_error_handling do
    run_analyzer Analyzers::SHA256, query: query, options: options
  end
end

#shodan(query) ⇒ Object



23
24
25
26
27
# File 'lib/mihari/cli.rb', line 23

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

#statusObject



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

def status
  with_error_handling do
    puts JSON.pretty_generate(Status.check)
  end
end

#urlscan(query) ⇒ Object



44
45
46
47
48
# File 'lib/mihari/cli.rb', line 44

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

#virustotal(indiactor) ⇒ Object



54
55
56
57
58
# File 'lib/mihari/cli.rb', line 54

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

#zoomeye(query) ⇒ Object



128
129
130
131
132
# File 'lib/mihari/cli.rb', line 128

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