fofa 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/fofacli +30 -6
- data/lib/fofa/version.rb +4 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87d0a961aecc981843e098178b7c3fc2c70c14f7
|
4
|
+
data.tar.gz: 10df9f621ee857e19eb9a31ea5c488fe71895135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c2eaf481b20f662ecac532f950c866ca7fc11d966e4a8b067ad67faca035e08d305923c6ad3a5c85025f3da7d3afc247b91461d4cbb2590cc126f26f28034b2
|
7
|
+
data.tar.gz: f639fd08740c4df9bcece0443a4b802d9d8df01de17c5136abe4c9fdf4b1a5b6bb09e7c6f04c3c4bd9ddd6127df39ff5aa67e98de72d550f7cf4aefc81193028
|
data/bin/fofacli
CHANGED
@@ -17,7 +17,8 @@ options = {
|
|
17
17
|
limit: 1000,
|
18
18
|
fields: 'host',
|
19
19
|
post: false,
|
20
|
-
query: nil
|
20
|
+
query: nil,
|
21
|
+
format: 'csv'
|
21
22
|
}
|
22
23
|
|
23
24
|
ARGV.options do |opts|
|
@@ -52,6 +53,10 @@ ARGV.options do |opts|
|
|
52
53
|
|
53
54
|
opts.on(nil, '--size_per_page=SIZE', Integer, "API fetch size per page, default to #{options[:size_per_page]}") do |val|
|
54
55
|
options[:size_per_page] = val.to_i
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on('-o', '--output-format=FORMAT', String, "Format of output, default to #{options[:format]}, can be csv or json") do |val|
|
59
|
+
options[:format] = val
|
55
60
|
end
|
56
61
|
|
57
62
|
opts.on('-d', '--fields=FIELDS', String, "Fields to return, split with ',', default to #{options[:fields]}") do |val|
|
@@ -110,6 +115,21 @@ unless options[:apikey]
|
|
110
115
|
exit -1
|
111
116
|
end
|
112
117
|
|
118
|
+
def log_record(options, r)
|
119
|
+
case options[:format]
|
120
|
+
when 'json'
|
121
|
+
if r.kind_of?(Array)
|
122
|
+
puts Hash[options[:fields].split(',').zip r].to_json
|
123
|
+
elsif r.kind_of?(Hash)
|
124
|
+
puts r.to_json
|
125
|
+
else
|
126
|
+
puts %Q|{"id":"#{r}"}|
|
127
|
+
end
|
128
|
+
when 'csv'
|
129
|
+
puts r.map{|v| v}.join("\t")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
113
133
|
case options[:mode]
|
114
134
|
when :search
|
115
135
|
if ARGV.empty? && !options[:query]
|
@@ -120,21 +140,25 @@ case options[:mode]
|
|
120
140
|
query = options[:query] || ARGV.join(' ')
|
121
141
|
puts "Query: '#{query}'"
|
122
142
|
if options[:page] #search one page
|
123
|
-
|
143
|
+
Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
|
124
144
|
.search(query, {
|
125
145
|
page:options[:page],
|
126
146
|
size:options[:limit],
|
127
147
|
fields:options[:fields],
|
128
148
|
post:options[:post]
|
129
|
-
})
|
149
|
+
}).each{|r|
|
150
|
+
log_record(options, r)
|
151
|
+
}
|
130
152
|
else
|
131
|
-
|
153
|
+
Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
|
132
154
|
.search_all(query, {
|
133
155
|
size:options[:limit],
|
134
156
|
page_size:options[:size_per_page],
|
135
157
|
fields:options[:fields],
|
136
158
|
post:options[:post]
|
137
|
-
})
|
159
|
+
}).each{|r|
|
160
|
+
log_record(options, r)
|
161
|
+
}
|
138
162
|
end
|
139
163
|
|
140
164
|
when :import_service
|
@@ -189,7 +213,7 @@ case options[:mode]
|
|
189
213
|
ip_hash.delete(k) if v.size==0
|
190
214
|
}
|
191
215
|
semaphore.acquire
|
192
|
-
|
216
|
+
log_record(options, ip_hash)
|
193
217
|
semaphore.release
|
194
218
|
end
|
195
219
|
end
|
data/lib/fofa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fofa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fofa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.6.3
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: A Ruby library to interact with the FOFA API. https://fofa.so
|