shodanx 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8ad39eb54469dff1d133c73c328c9bea251fac93b72617bcf39e97dc227f135c
4
+ data.tar.gz: ca3d2ee2b0e6f13e9b7d010843685e7361a803cdc2426ecccf34332981ec2c0d
5
+ SHA512:
6
+ metadata.gz: e3b0767c08a4dfbecdbe07042f2c6849c76ea824e092af5b83785a2404a80f8d09beb1212aceae3d929260c60b8d126802057c1a497f91d372feba249de65bd8
7
+ data.tar.gz: c29ea5022540ee9f40707b345d616b871bfedf9514da0d9e3728d37c594a372ef34fceca2b2bba1e64b290bfb8b597dbd3baab99196f0fe68a203e7fca613aee
@@ -0,0 +1,52 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ Gemfile.lock
46
+ .ruby-version
47
+ .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in shodanx.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Manabu Niseki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,97 @@
1
+ # shodanx
2
+
3
+ [![Build Status](https://travis-ci.org/ninoseki/shodanx.svg?branch=master)](https://travis-ci.org/ninoseki/shodanx)
4
+ [![Coverage Status](https://coveralls.io/repos/github/ninoseki/shodanx/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/shodanx?branch=master)
5
+
6
+ Yet another Shodan API wrapper for Ruby.
7
+
8
+ **Note:** This is a fork version of [shodanz](https://github.com/picatz/shodanz).
9
+
10
+ ## Why I forked
11
+
12
+ I need a Shodan API wrapper which:
13
+
14
+ - works on Ruby 2.6.
15
+ - only needs minimum dependencies. (This gem needs no dependencies to run)
16
+ - is well tested.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ gem install shodanx
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```ruby
27
+ require "shodan"
28
+
29
+ # when given nothing, it tries to load your API key from ENV["SHODAN_API_KEY"]
30
+ api = Shodan::API.new
31
+ # or you can set it manually
32
+ api = Shodan::API.new(key: "YOUR_API_KEY")
33
+
34
+ api.host.get_by_ip("104.25.89.97")
35
+ api.host.count("nginx")
36
+ api.host.count("nginx", facets: { country: 10 })
37
+ api.host.search("nginx")
38
+ api.host.search("ftp", port: 21, facets: { country: 10 })
39
+ api.host.tokens("nginx")
40
+ ```
41
+
42
+ See `/spec` for more.
43
+
44
+ ## Supported API endpoints
45
+
46
+ ### [REST API](https://developer.shodan.io/api)
47
+
48
+ | Method | URI | API method |
49
+ |--------|-------------------------------------------------------|----------------------------------------------------------------------------|
50
+ | GET | /shodan/host/{ip} | `api.host.get_by_ip(ip, **params)` |
51
+ | GET | /shodan/host/count | `api.host.count(query = "", facets: {}, **params)` |
52
+ | GET | /shodan/host/search | `api.host.search(query = "", facets: {}, page: 1, minify: true, **params)` |
53
+ | GET | /shodan/host/search/tokens | `api.host.tokens(query = "", **params)` |
54
+ | GET | /shodan/ports | `api.ports` |
55
+ | GET | /shodan/protocols | `api.protocols` |
56
+ | POST | /shodan/scan | `api.scan.crawl(*ips)` |
57
+ | POST | /shodan/scan/internet | `api.scan.crawl_for(**params)` |
58
+ | GET | /shodan/scan/{id} | `api.scan.get_by_id(id)` |
59
+ | POST | /shodan/alert | `api.alert.create(name:, ip:)` |
60
+ | GET | /shodan/alert/{id}/info | `api.alert.get_by_id(id)` |
61
+ | DELETE | /shodan/alert/{id} | `api.alert.delete_by_id(id)` |
62
+ | GET | /shodan/alert/info | `api.alert.info` |
63
+ | GET | /shodan/alert/triggers | `api.alert.triggers` |
64
+ | PUT | /shodan/alert/{id}/trigger/{trigger} | N/A |
65
+ | DELETE | /shodan/alert/{id}/trigger/{trigger} | N/A |
66
+ | PUT | /shodan/alert/{id}/trigger/{trigger}/ignore/{service} | N/A |
67
+ | DELETE | /shodan/alert/{id}/trigger/{trigger}/ignore/{service} | N/A |
68
+ | GET | /shodan/query | `api.query.list(**params)` |
69
+ | GET | /shodan/query/search | `api.query.search(query, **params)` |
70
+ | GET | /shodan/query/tags | `api.query.tags(size = 10)` |
71
+ | GET | /shodan/data | N/A |
72
+ | GET | /shodan/data/{dataset} | N/A |
73
+ | GET | /org | N/A |
74
+ | PUT | /org/member/{user} | N/A |
75
+ | DELETE | /org/member/{user} | N/A |
76
+ | GET | /account/profile | `api.account.profile` |
77
+ | GET | /dns/resolve | `api.dns.resolve(**hostnames)` |
78
+ | GET | /dns/reverse | `api.dns.reverse(**ips)` |
79
+ | GET | /tools/httpheaders | `api.tools.http_headers` |
80
+ | GET | /tools/myip | `api.tools.my_ip` |
81
+ | GET | /api-info | `api.info` |
82
+ | GET | /labs/honeyscore/{ip} | `api.labs.honeyscore(ip)` |
83
+
84
+ ### [Exploits API](https://developer.shodan.io/api/exploits/rest)
85
+
86
+ | Method | URI | API method |
87
+ |--------|---------|------------------------------------------------------------------|
88
+ | GET | /search | `api.exploits.search(query = "", facets: {}, page: 1, **params)` |
89
+ | GET | /count | `api.exploits.count(query = "", facets: {}, page: 1, **params)` |
90
+
91
+ ### [Streaming API](https://developer.shodan.io/api/stream)
92
+
93
+ N/A
94
+
95
+ ## License
96
+
97
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "shodanx"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # original author: Kent 'picat' Gruber
4
+
5
+ require "shodan/version"
6
+ require "shodan/error"
7
+ require "shodan/api"
8
+
9
+ module Shodan
10
+ def self.api
11
+ API
12
+ end
13
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # original author: Kent 'picat' Gruber
4
+
5
+ require_relative "clients/base"
6
+
7
+ require_relative "clients/account"
8
+ require_relative "clients/alert"
9
+ require_relative "clients/dns"
10
+ require_relative "clients/host"
11
+ require_relative "clients/labs"
12
+ require_relative "clients/query"
13
+ require_relative "clients/scan"
14
+ require_relative "clients/tools"
15
+
16
+ require_relative "clients/rest"
17
+
18
+ require_relative "clients/exploits"
19
+
20
+ require "forwardable"
21
+
22
+ module Shodan
23
+ class API
24
+ extend Forwardable
25
+
26
+ # @return [Shodan::Clients::Host]
27
+ attr_reader :host
28
+
29
+ # @return [Shodan::Clients::Query]
30
+ attr_reader :query
31
+
32
+ # @return [Shodan::Clients::DNS]
33
+ attr_reader :dns
34
+
35
+ # @return [Shodan::Clients::Tools]
36
+ attr_reader :tools
37
+
38
+ # @return [Shodan::Clients::Labs]
39
+ attr_reader :labs
40
+
41
+ # @return [Shodan::Clients::Alert]
42
+ attr_reader :alert
43
+
44
+ # @return [Shodan::Clients::Scan]
45
+ attr_reader :scan
46
+
47
+ # @return [Shodan::Clients::Account]
48
+ attr_reader :account
49
+
50
+ # @return [Shodan::Clients::Exploits]
51
+ attr_reader :exploits
52
+
53
+ def initialize(key: ENV.fetch("SHODAN_API_KEY", nil))
54
+ raise ArgumentError, "No API key has been found or provided! (setup your SHODAN_API_KEY environment varialbe)" if key.nil?
55
+
56
+ @account = Clients::Account.new(key: key)
57
+ @alert = Clients::Alert.new(key: key)
58
+ @dns = Clients::DNS.new(key: key)
59
+ @host = Clients::Host.new(key: key)
60
+ @labs = Clients::Labs.new(key: key)
61
+ @query = Clients::Query.new(key: key)
62
+ @scan = Clients::Scan.new(key: key)
63
+ @tools = Clients::Tools.new(key: key)
64
+
65
+ @rest = Clients::REST.new(key: key)
66
+
67
+ @exploits = Clients::Exploits.new(key: key)
68
+ end
69
+
70
+ def_delegators :@rest, :ports, :protocols, :profile, :info
71
+ end
72
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shodan
4
+ module Clients
5
+ class Account < Base
6
+ # Returns information about the Shodan account linked to this API key.
7
+ def profile
8
+ get("/account/profile")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shodan
4
+ module Clients
5
+ class Alert < Base
6
+ def create(name:, ip:)
7
+ params = {
8
+ name: name,
9
+ filters: {
10
+ ip: ip
11
+ }
12
+ }
13
+ post("/shodan/alert", params)
14
+ end
15
+
16
+ def delete_by_id(id)
17
+ delete("/shodan/alert/#{id}")
18
+ end
19
+
20
+ def get_by_id(id)
21
+ get("/shodan/alert/#{id}/info")
22
+ end
23
+
24
+ def info
25
+ get("/shodan/alert/info")
26
+ end
27
+
28
+ def triggers
29
+ get("/shodan/alert/triggers")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "net/https"
5
+ require "uri"
6
+
7
+ module Shodan
8
+ module Clients
9
+ class Base
10
+ # The path to the REST API endpoint.
11
+ HOST = "api.shodan.io"
12
+ BASE_URL = "https://#{HOST}"
13
+
14
+ attr_reader :key
15
+
16
+ def initialize(key: ENV["SHODAN_API_KEY"])
17
+ @key = key
18
+ warn 'No key has been found or provided!' unless key?
19
+ end
20
+
21
+ def key?
22
+ !key.nil?
23
+ end
24
+
25
+ private
26
+
27
+ def _host
28
+ self.class::HOST
29
+ end
30
+
31
+ def base_url
32
+ self.class::BASE_URL
33
+ end
34
+
35
+ def request(req)
36
+ Net::HTTP.start(_host, 443, https_options) do |http|
37
+ response = http.request(req)
38
+
39
+ if response.code.to_i != 200
40
+ json = JSON.parse(response.body)
41
+ raise Error, json["error"] if json.key?("error")
42
+
43
+ raise Error, response.body
44
+ end
45
+ JSON.parse response.body
46
+ end
47
+ end
48
+
49
+ # Perform a direct GET HTTP request to the REST API.
50
+ def get(path, **params)
51
+ params[:key] = key
52
+
53
+ uri = URI("#{base_url}#{path}")
54
+ uri.query = URI.encode_www_form(params)
55
+ req = Net::HTTP::Get.new(uri)
56
+ request req
57
+ end
58
+
59
+ # Perform a direct POST HTTP request to the REST API.
60
+ def post(path, **params)
61
+ uri = URI("#{base_url}#{path}?key=#{key}")
62
+ req = Net::HTTP::Post.new(uri)
63
+ req.content_type = "application/json"
64
+ req.body = params.to_json
65
+
66
+ request req
67
+ end
68
+
69
+ # Perform a direct DELETE HTTP request to the REST API.
70
+ def delete(path, **params)
71
+ params[:key] = key
72
+
73
+ uri = URI("#{base_url}#{path}")
74
+ uri.query = URI.encode_www_form(params)
75
+ req = Net::HTTP::Delete.new(uri)
76
+ request req
77
+ end
78
+
79
+ def https_options
80
+ if proxy = ENV["HTTPS_PROXY"] || ENV["https_proxy"]
81
+ uri = URI(proxy)
82
+ {
83
+ proxy_address: uri.hostname,
84
+ proxy_port: uri.port,
85
+ proxy_from_env: false,
86
+ use_ssl: true
87
+ }
88
+ else
89
+ { use_ssl: true }
90
+ end
91
+ end
92
+
93
+ def turn_into_query(params)
94
+ query = params.dig(:query)
95
+ options = params.reject { |k, _| k == :query }.map { |k, v| "#{k}:#{v}" }
96
+ {
97
+ query: [query, options].flatten.compact.join(" ")
98
+ }
99
+ end
100
+
101
+ def turn_into_facets(facets)
102
+ {
103
+ facets: facets.map { |k, v| "#{k}:#{v}" }.join(",")
104
+ }
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shodan
4
+ module Clients
5
+ class DNS < Base
6
+ # Look up the IP address for the provided list of hostnames.
7
+ def resolve(*hostnames)
8
+ get("/dns/resolve", hostnames: hostnames.join(","))
9
+ end
10
+
11
+ # Look up the hostnames that have been defined for the
12
+ # given list of IP addresses.
13
+ def reverse(*ips)
14
+ get("/dns/reverse", ips: ips.join(","))
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # original author: Kent 'picat' Gruber
4
+
5
+ module Shodan
6
+ module Clients
7
+ # The Exploits API provides access to several exploit
8
+ # and vulnerability data sources. At the moment, it
9
+ # searches across the following:
10
+ # - Exploit DB
11
+ # - Metasploit
12
+ # - Common Vulnerabilities and Exposures (CVE)
13
+ class Exploits < Base
14
+ HOST = "exploits.shodan.io"
15
+ BASE_URL = "https://#{HOST}/api"
16
+
17
+ # Search across a variety of data sources for exploits and
18
+ # use facets to get summary information.
19
+ def search(query = "", facets: {}, page: 1, **params)
20
+ params[:query] = query
21
+ params = turn_into_query(params)
22
+ facets = turn_into_facets(facets)
23
+ params[:page] = page
24
+ get("/search", params.merge(facets))
25
+ end
26
+
27
+ # This method behaves identical to the "/search" method with
28
+ # the difference that it doesn't return any results.
29
+ def count(query = "", facets: {}, page: 1, **params)
30
+ params[:query] = query
31
+ params = turn_into_query(params)
32
+ facets = turn_into_facets(facets)
33
+ params[:page] = page
34
+ get("/count", params.merge(facets))
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # original author: Kent 'picat' Gruber
4
+
5
+ module Shodan
6
+ module Clients
7
+ class Host < Base
8
+ # Returns all services that have been found on the given host IP.
9
+ # @param ip [String]
10
+ # @option params [Hash]
11
+ # @return [Hash]
12
+ def get_by_ip(ip, **params)
13
+ get("/shodan/host/#{ip}", params)
14
+ end
15
+
16
+ # This method behaves identical to "/shodan/host/search" with the only
17
+ # difference that this method does not return any host results, it only
18
+ # returns the total number of results that matched the query and any
19
+ # facet information that was requested. As a result this method does
20
+ # not consume query credits.
21
+ def count(query = "", facets: {}, **params)
22
+ params[:query] = query
23
+ converted_params = turn_into_query(params)
24
+ facets = turn_into_facets(facets)
25
+ get("/shodan/host/count", converted_params.merge(facets))
26
+ end
27
+
28
+ # Search Shodan using the same query syntax as the website and use facets
29
+ # to get summary information for different properties.
30
+ def search(query = "", facets: {}, page: 1, minify: true, **params)
31
+ params[:query] = query
32
+ params = turn_into_query(params)
33
+ facets = turn_into_facets(facets)
34
+ params[:page] = page
35
+ params[:minify] = minify
36
+ get("/shodan/host/search", params.merge(facets))
37
+ end
38
+
39
+ # This method lets you determine which filters are being used by
40
+ # the query string and what parameters were provided to the filters.
41
+ def tokens(query = "", **params)
42
+ params[:query] = query
43
+ params = turn_into_query(params)
44
+ get("/shodan/host/search/tokens", params)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shodan
4
+ module Clients
5
+ class Labs < Base
6
+ # Calculates a honeypot probability score ranging
7
+ # from 0 (not a honeypot) to 1.0 (is a honeypot).
8
+ def honeyscore(ip)
9
+ get("/labs/honeyscore/#{ip}")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # original author: Kent 'picat' Gruber
4
+
5
+ module Shodan
6
+ module Clients
7
+ class Query < Base
8
+ # Use this method to obtain a list of search queries that users have saved in Shodan.
9
+ def list(**params)
10
+ get("/shodan/query", params)
11
+ end
12
+
13
+ # Use this method to search the directory of search queries that users have saved in Shodan.
14
+ def search(query, **params)
15
+ params[:query] = query
16
+ params = turn_into_query(params)
17
+ get("/shodan/query/search", params)
18
+ end
19
+
20
+ # Use this method to obtain a list of popular tags for the saved search queries in Shodan.
21
+ def tags(size = 10)
22
+ params = {}
23
+ params[:size] = size
24
+ get("/shodan/query/tags", params)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # original author: Kent 'picat' Gruber
4
+
5
+ module Shodan
6
+ module Clients
7
+ class REST < Base
8
+ # This method returns a list of port numbers that the crawlers are looking for.
9
+ def ports
10
+ get("/shodan/ports")
11
+ end
12
+
13
+ # List all protocols that can be used when performing on-demand Internet scans via Shodan.
14
+ def protocols
15
+ get("/shodan/protocols")
16
+ end
17
+
18
+ # Returns information about the API plan belonging to the given API key.
19
+ def info
20
+ get("/api-info")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # original author: Kent 'picat' Gruber
4
+
5
+ module Shodan
6
+ module Clients
7
+ class Scan < Base
8
+ # Use this method to request Shodan to crawl a network.
9
+ #
10
+ # This method uses API scan credits: 1 IP consumes 1 scan credit. You
11
+ # must have a paid API plan (either one-time payment or subscription)
12
+ # in order to use this method.
13
+ #
14
+ # IP, IPs or netblocks (in CIDR notation) that should get crawled.
15
+ def crawl(*ips)
16
+ post("/shodan/scan", ips: ips.join(","))
17
+ end
18
+
19
+ # Use this method to request Shodan to crawl the Internet for a specific port.
20
+ #
21
+ # This method is restricted to security researchers and companies with
22
+ # a Shodan Data license. To apply for access to this method as a researcher,
23
+ # please email jmath@shodan.io with information about your project.
24
+ # Access is restricted to prevent abuse.
25
+ def crawl_for(**params)
26
+ params[:query] = ""
27
+ params = turn_into_query(params)
28
+ post("/shodan/scan/internet", params)
29
+ end
30
+
31
+ # Check the progress of a previously submitted scan request.
32
+ def get_by_id(id)
33
+ get("/shodan/scan/#{id}")
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shodan
4
+ module Clients
5
+ class Tools < Base
6
+ # Shows the HTTP headers that your client sends when
7
+ # connecting to a webserver.
8
+ def http_headers
9
+ get("/tools/httpheaders")
10
+ end
11
+
12
+ # Get your current IP address as seen from the Internet.
13
+ def my_ip
14
+ get("/tools/myip")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shodan
4
+ class Error < StandardError; end
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shodan
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "shodan/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "shodanx"
9
+ spec.version = Shodan::VERSION
10
+ spec.authors = ["Manabu Niseki"]
11
+ spec.email = ["manabu.niseki@gmail.com"]
12
+
13
+ spec.summary = "Yet another Shodan API wrapper for Ruby"
14
+ spec.description = "Yet another Shodan API wrapper for Ruby"
15
+ spec.homepage = "https://github.com/ninoseki/shodanx"
16
+ spec.license = "MIT"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
+ spec.add_development_dependency "coveralls", "~> 0.8"
29
+ spec.add_development_dependency "rake", "~> 12.3"
30
+ spec.add_development_dependency "rspec", "~> 3.8"
31
+ spec.add_development_dependency "vcr", "~> 4.0"
32
+ spec.add_development_dependency "webmock", "~> 3.5"
33
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shodanx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Manabu Niseki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.5'
97
+ description: Yet another Shodan API wrapper for Ruby
98
+ email:
99
+ - manabu.niseki@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/shodan.rb
114
+ - lib/shodan/api.rb
115
+ - lib/shodan/clients/account.rb
116
+ - lib/shodan/clients/alert.rb
117
+ - lib/shodan/clients/base.rb
118
+ - lib/shodan/clients/dns.rb
119
+ - lib/shodan/clients/exploits.rb
120
+ - lib/shodan/clients/host.rb
121
+ - lib/shodan/clients/labs.rb
122
+ - lib/shodan/clients/query.rb
123
+ - lib/shodan/clients/rest.rb
124
+ - lib/shodan/clients/scan.rb
125
+ - lib/shodan/clients/tools.rb
126
+ - lib/shodan/error.rb
127
+ - lib/shodan/version.rb
128
+ - shodanx.gemspec
129
+ homepage: https://github.com/ninoseki/shodanx
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubygems_version: 3.0.2
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Yet another Shodan API wrapper for Ruby
152
+ test_files: []