fofa 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bf29364f1e2529bff9a522f6b9d0bea1b83ecc2
4
- data.tar.gz: 3a56e6bf2bd1cf675325250d40079bbf8f82ab3a
3
+ metadata.gz: d3fd620a7b7d85bd240669ffec7ebeaebdc19985
4
+ data.tar.gz: 03faad6a1352c771e81714ca41984a2c0b208445
5
5
  SHA512:
6
- metadata.gz: dbf1563ffd7138481a82f8c473bf9632641da7ebecabbaf13e123b2918e4668fea57eef04481288a2a173051c3f192ded62e65fd8ce5fb64d5bcc239dab136df
7
- data.tar.gz: 1c44cfbf1fabee47384ae686b57778d4a8d4e10ff625db37644beb70e29d6df08af659dceeefe4bcedf6260948c669698ded6164b5436191f3557a64d3c4b16e
6
+ metadata.gz: e1b428d99107084eb27a6809a80555c7051d0f32a8acb3e70b7f9d67732d516cc264492cf2d3b6ed59f43d1cc89a4464de8971424dbc501880eb7dbba082b5e0
7
+ data.tar.gz: 91b398f986f0933dd76a650f0b26a6d2ebbb9e9df1a4a02b9d6505cccea4d18f80396e95545f9e5cff226a41b52477c4ae5332674d48714bde257c224419c8ef
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fofa (0.2.0)
4
+ fofa (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -12,15 +12,15 @@ module Fofa
12
12
  @apikey = apikey
13
13
  end
14
14
 
15
- # Search from fofa
15
+ # Search page results from fofa
16
16
  #
17
17
  # Example:
18
- # >> Fofa::API.new(email,apikey).search("host=baidu.com")
18
+ # >> Fofa::API.new(email,apikey).search("host==baidu.com")
19
19
  # => {size:1, results:['1.1.1.1:80']}
20
20
  #
21
21
  # Arguments:
22
22
  # query: (String) fofa query string
23
- # options: (Hash) page
23
+ # options: (Hash) page(default 1, only fetch one page)
24
24
  def search(query, options={})
25
25
  options = {page:1}.merge(options)
26
26
  url = "#{@api_server}/api/v1/search/all?key=#{@apikey}&email=#{@email}&q=#{URI.escape(query)}&page=#{options[:page]}"
@@ -35,7 +35,31 @@ module Fofa
35
35
  JSON.parse(resp.body)
36
36
  rescue => e
37
37
  {"error"=>"Error: #{e.to_s}"}
38
- end
38
+ end
39
+
40
+ # Search all results from fofa
41
+ #
42
+ # Example:
43
+ # >> Fofa::API.new(email,apikey).search_all("domain==baidu.com") {|results, page| ... }
44
+ # => {size:1, results:['1.1.1.1:80']}
45
+ #
46
+ # Arguments:
47
+ # query: (String) fofa query string
48
+ def search_all(query)
49
+ all_res = []
50
+ page = 0
51
+ loop do
52
+ page += 1
53
+ res = search(query, {page:page})
54
+ if res['results'].size > 0
55
+ all_res += res['results']
56
+ yield(res['results'], page) if block_given?
57
+ else
58
+ break
59
+ end
60
+ end
61
+ all_res
62
+ end
39
63
 
40
64
  # Import asset into fofa
41
65
  #
@@ -1,3 +1,3 @@
1
1
  module Fofa
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fofa