fofa 0.3.5 → 0.3.6
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 +2 -2
- data/lib/fofa.rb +14 -4
- data/lib/fofa/version.rb +2 -2
- 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: 3ce6f70d71b8ce5f95639e85ec14c4be632d37fa
|
4
|
+
data.tar.gz: 5aa510e4d45309d56ac7e1b3e53c604000c602b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a4ed37b9e7182f1d4efa45910174f53512c02b8166c02fef7d67830597428fbf357f3e29b74e6787378c99220130edbaea3221c2e5848343b4f30adc76f08b7
|
7
|
+
data.tar.gz: c1210f6b9c8a85e554caeeb6db49941a5c2a8995ef10d601574e1e883c9058d099ac87935ac7c193db17e0a539180f359876fa8dc59e5a921ea79af46639de5d
|
data/Gemfile.lock
CHANGED
data/lib/fofa.rb
CHANGED
@@ -15,11 +15,11 @@ module Fofa
|
|
15
15
|
# Search page results from fofa
|
16
16
|
#
|
17
17
|
# Example 1:
|
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']}
|
20
20
|
#
|
21
21
|
# Example 2:
|
22
|
-
# >> Fofa::API.new(email,apikey).search("host
|
22
|
+
# >> Fofa::API.new(email,apikey).search("host=baidu.com", fields:'host,title,ip')
|
23
23
|
# => {size:1, results:[['1.1.1.1:81', 'title', '1.1.1.1']]}
|
24
24
|
#
|
25
25
|
# Arguments:
|
@@ -47,17 +47,27 @@ module Fofa
|
|
47
47
|
# >> Fofa::API.new(email,apikey).search_all("domain==baidu.com") {|results, page| ... }
|
48
48
|
# => {size:1, results:['1.1.1.1:80']}
|
49
49
|
#
|
50
|
+
# Example:
|
51
|
+
# >> Fofa::API.new(email,apikey).search_all("domain==baidu.com", fields:'host,title,ip') {|results, page| ... }
|
52
|
+
# => {size:1, results:[['1.1.1.1:81', 'title', '1.1.1.1']]}
|
53
|
+
#
|
50
54
|
# Arguments:
|
51
55
|
# query: (String) fofa query string
|
52
|
-
def search_all(query)
|
56
|
+
def search_all(query, options={})
|
57
|
+
all_size = options.delete :size # do not pass to search
|
53
58
|
all_res = []
|
54
59
|
page = 0
|
55
60
|
loop do
|
56
61
|
page += 1
|
57
|
-
res = search(query, {page:page})
|
62
|
+
res = search(query, {page:page}.merge(options))
|
58
63
|
if !res['error'] && res['results'].size > 0
|
59
64
|
all_res += res['results']
|
60
65
|
yield(res['results'], page) if block_given?
|
66
|
+
|
67
|
+
if all_size && all_res.size > all_size.to_i
|
68
|
+
all_res = all_res[0..all_size-1]
|
69
|
+
break
|
70
|
+
end
|
61
71
|
else
|
62
72
|
break
|
63
73
|
end
|
data/lib/fofa/version.rb
CHANGED