shodan 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -0
- data/lib/shodan/api.rb +38 -1
- data/lib/shodan/version.rb +1 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
Visit the official Shodan API documentation at:
|
2
|
+
|
3
|
+
[http://docs.shodanhq.com](http://docs.shodanhq.com)
|
4
|
+
|
1
5
|
## Installation
|
2
6
|
|
3
7
|
To install the library use rubygems:
|
@@ -37,3 +41,7 @@ To properly handle potential errors, you should wrap all requests in a try/excep
|
|
37
41
|
else
|
38
42
|
puts "Unknown error"
|
39
43
|
end
|
44
|
+
|
45
|
+
## Articles
|
46
|
+
|
47
|
+
* [Perl, Python and Ruby API libraries](http://www.surtri.com/2010/10/20/perl-python-ruby-api/)
|
data/lib/shodan/api.rb
CHANGED
@@ -17,11 +17,13 @@ module Shodan
|
|
17
17
|
attr_accessor :api_key
|
18
18
|
attr_accessor :base_url
|
19
19
|
attr_accessor :exploitdb
|
20
|
+
attr_accessor :msf
|
20
21
|
|
21
22
|
def initialize(api_key)
|
22
23
|
@api_key = api_key
|
23
24
|
@base_url = "http://www.shodanhq.com/api/"
|
24
25
|
@exploitdb = ExploitDB.new(self)
|
26
|
+
@msf = Msf.new(self)
|
25
27
|
end
|
26
28
|
|
27
29
|
# Internal method that sends out the HTTP request.
|
@@ -68,7 +70,7 @@ module Shodan
|
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
|
-
# The ExploitDB class
|
73
|
+
# The ExploitDB class shouldn't be used independently,
|
72
74
|
# as it depends on the WebAPI class.
|
73
75
|
#
|
74
76
|
# Author:: achillean (mailto:jmath at surtri.com)
|
@@ -124,4 +126,39 @@ module Shodan
|
|
124
126
|
|
125
127
|
end
|
126
128
|
|
129
|
+
# The Msf class shouldn't be used independently,
|
130
|
+
# as it depends on the WebAPI class.
|
131
|
+
#
|
132
|
+
# Author:: achillean (mailto:jmath at surtri.com)
|
133
|
+
#
|
134
|
+
# :title:Shodan::Msf
|
135
|
+
class Msf
|
136
|
+
attr_accessor :api
|
137
|
+
|
138
|
+
def initialize(api)
|
139
|
+
@api = api
|
140
|
+
end
|
141
|
+
|
142
|
+
# Download a metasploit module given the fullname (id) of it.
|
143
|
+
#
|
144
|
+
# Arguments:
|
145
|
+
# id -- fullname of the module (ex. auxiliary/admin/backupexec/dump)
|
146
|
+
#
|
147
|
+
# Returns:
|
148
|
+
# A dictionary with the following fields:
|
149
|
+
# # filename -- Name of the file
|
150
|
+
# content-type -- Mimetype
|
151
|
+
# data -- File content
|
152
|
+
def download(id)
|
153
|
+
return @api.request('msf/download', {:id => "#{id}"})
|
154
|
+
end
|
155
|
+
|
156
|
+
# Search for a metasploit module
|
157
|
+
def search(query, params={})
|
158
|
+
params[:q] = query
|
159
|
+
return @api.request('msf/search', params)
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
127
164
|
end
|
data/lib/shodan/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shodan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Matherly
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-09 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|