Module: Shodan
- Defined in:
- lib/shodan/host.rb,
lib/shodan/page.rb,
lib/shodan/query.rb,
lib/shodan/shodan.rb,
lib/shodan/version.rb,
lib/shodan/countries.rb,
lib/shodan/has_pages.rb
Overview
shodan-ruby - A Ruby interface to SHODAN, a computer search engine.
Copyright © 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Defined Under Namespace
Modules: Countries, HasPages Classes: Host, Page, Query
Constant Summary collapse
- COMMON_PROXY_PORT =
Common proxy port.
8080
- VERSION =
shodanrb version
'0.1.1'
Class Method Summary collapse
-
.proxy ⇒ Hash
The proxy information used by Query.
-
.proxy_uri(proxy_info = Shodan.proxy) ⇒ Object
Creates a HTTP URI based from the given proxy information.
-
.query(options = {}) {|query| ... } ⇒ Query
Creates a new Query object.
-
.user_agent ⇒ String
The default Shodan User-Agent.
-
.user_agent=(agent) ⇒ String
Sets the default Shodan User-Agent.
-
.user_agent_alias=(name) ⇒ String
Sets the default Shodan User-Agent alias.
-
.user_agent_aliases ⇒ Hash{String => String}
The supported Shodan User-Agent Aliases.
-
.web_agent(options = {}, &block) ⇒ Object
Creates a new WWW::Mechanize agent.
Class Method Details
.proxy ⇒ Hash
The proxy information used by Query.
35 36 37 |
# File 'lib/shodan/shodan.rb', line 35 def Shodan.proxy @@shodan_proxy ||= {:host => nil, :port => COMMON_PROXY_PORT, :user => nil, :password => nil} end |
.proxy_uri(proxy_info = Shodan.proxy) ⇒ Object
Creates a HTTP URI based from the given proxy information.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/shodan/shodan.rb', line 57 def Shodan.proxy_uri(proxy_info=Shodan.proxy) if Shodan.proxy[:host] return URI::HTTP.build( :host => Shodan.proxy[:host], :port => Shodan.proxy[:port], :userinfo => "#{Shodan.proxy[:user]}:#{Shodan.proxy[:password]}", :path => '/' ) end end |
.query(options = {}) {|query| ... } ⇒ Query
Creates a new Query object.
213 214 215 |
# File 'lib/shodan/shodan.rb', line 213 def Shodan.query(={},&block) Query.new(,&block) end |
.user_agent ⇒ String
The default Shodan User-Agent
84 85 86 |
# File 'lib/shodan/shodan.rb', line 84 def Shodan.user_agent @@shodan_user_agent ||= Shodan.user_agent_aliases['Windows IE 6'] end |
.user_agent=(agent) ⇒ String
Sets the default Shodan User-Agent.
97 98 99 |
# File 'lib/shodan/shodan.rb', line 97 def Shodan.user_agent=(agent) @@shodan_user_agent = agent end |
.user_agent_alias=(name) ⇒ String
Sets the default Shodan User-Agent alias.
110 111 112 |
# File 'lib/shodan/shodan.rb', line 110 def Shodan.user_agent_alias=(name) @@shodan_user_agent = Shodan.user_agent_aliases[name.to_s] end |
.user_agent_aliases ⇒ Hash{String => String}
The supported Shodan User-Agent Aliases.
74 75 76 |
# File 'lib/shodan/shodan.rb', line 74 def Shodan.user_agent_aliases WWW::Mechanize::AGENT_ALIASES end |
.web_agent(options = {}, &block) ⇒ Object
Creates a new WWW::Mechanize agent.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/shodan/shodan.rb', line 150 def Shodan.web_agent(={},&block) agent = WWW::Mechanize.new if [:user_agent_alias] agent.user_agent_alias = [:user_agent_alias] elsif [:user_agent] agent.user_agent = [:user_agent] elsif Shodan.user_agent agent.user_agent = Shodan.user_agent end proxy = ([:proxy] || Shodan.proxy) if proxy[:host] agent.set_proxy(proxy[:host],proxy[:port],proxy[:user],proxy[:password]) end block.call(agent) if block return agent end |