Class: Shodan::API

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/shodan/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: ENV.fetch("SHODAN_API_KEY", nil)) ⇒ API

Returns a new instance of API.

Raises:

  • (ArgumentError)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/shodan/api.rb', line 53

def initialize(key: ENV.fetch("SHODAN_API_KEY", nil))
  raise ArgumentError, "No API key has been found or provided! (setup your SHODAN_API_KEY environment varialbe)" if key.nil?

  @account = Clients::Account.new(key: key)
  @alert = Clients::Alert.new(key: key)
  @dns = Clients::DNS.new(key: key)
  @host = Clients::Host.new(key: key)
  @labs = Clients::Labs.new(key: key)
  @query = Clients::Query.new(key: key)
  @scan = Clients::Scan.new(key: key)
  @tools = Clients::Tools.new(key: key)

  @rest = Clients::REST.new(key: key)

  @exploits = Clients::Exploits.new(key: key)
end

Instance Attribute Details

#accountShodan::Clients::Account (readonly)



48
49
50
# File 'lib/shodan/api.rb', line 48

def 
  @account
end

#alertShodan::Clients::Alert (readonly)



42
43
44
# File 'lib/shodan/api.rb', line 42

def alert
  @alert
end

#dnsShodan::Clients::DNS (readonly)



33
34
35
# File 'lib/shodan/api.rb', line 33

def dns
  @dns
end

#exploitsShodan::Clients::Exploits (readonly)



51
52
53
# File 'lib/shodan/api.rb', line 51

def exploits
  @exploits
end

#hostShodan::Clients::Host (readonly)



27
28
29
# File 'lib/shodan/api.rb', line 27

def host
  @host
end

#labsShodan::Clients::Labs (readonly)



39
40
41
# File 'lib/shodan/api.rb', line 39

def labs
  @labs
end

#queryShodan::Clients::Query (readonly)



30
31
32
# File 'lib/shodan/api.rb', line 30

def query
  @query
end

#scanShodan::Clients::Scan (readonly)



45
46
47
# File 'lib/shodan/api.rb', line 45

def scan
  @scan
end

#toolsShodan::Clients::Tools (readonly)



36
37
38
# File 'lib/shodan/api.rb', line 36

def tools
  @tools
end