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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fofa.rb +28 -4
- data/lib/fofa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3fd620a7b7d85bd240669ffec7ebeaebdc19985
|
4
|
+
data.tar.gz: 03faad6a1352c771e81714ca41984a2c0b208445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1b428d99107084eb27a6809a80555c7051d0f32a8acb3e70b7f9d67732d516cc264492cf2d3b6ed59f43d1cc89a4464de8971424dbc501880eb7dbba082b5e0
|
7
|
+
data.tar.gz: 91b398f986f0933dd76a650f0b26a6d2ebbb9e9df1a4a02b9d6505cccea4d18f80396e95545f9e5cff226a41b52477c4ae5332674d48714bde257c224419c8ef
|
data/Gemfile.lock
CHANGED
data/lib/fofa.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
#
|
data/lib/fofa/version.rb
CHANGED