fofa 0.3.17 → 0.3.18

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: c547727d9ed816e3d644f0416cc146bf6e856914
4
- data.tar.gz: 4b972ee2dc95eefadfe1233d4ab01cd912c790d1
3
+ metadata.gz: d1266f6e972edc71cf6f3c36c8dca778832d9340
4
+ data.tar.gz: 9e4c2976d711e4e43dfcd18878e6518434d5a7be
5
5
  SHA512:
6
- metadata.gz: e3650e6c08280779282fd7865c912d9e2ec152ca3b8aea318e43f7a6e70014ca32308b7a38de9a45edb2b9e27434dc74fba6c9d2811f05648aea9ba7acff7863
7
- data.tar.gz: 2e919a75409e0c1a6fc7ee1eba8f9c094f630c061eaabbfa2d84e56519efe98c9583040177503eb48a701f9bf18c913c0419c5d77908c4249a28a05cba5a79b3
6
+ metadata.gz: 077e078e08a70d059fed83f8f92cd425096172c160ab0eab71702eb9026a1328bb812a7b7cb7cbf03f1eb9e239a94258b138513bcb275f26351c088b32d8b36e
7
+ data.tar.gz: 892e27388b7cb3a1be9de0ec36d8b20c5c0223b1d481432218a61a6beeb86ebfcf9ddd6d464e4fb4e47fcc5994bed1ce9467981031d030ea23ce0874ec408fa9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fofa (0.3.16)
4
+ fofa (0.3.17)
5
5
  colorize
6
6
  concurrent-ruby
7
7
 
@@ -46,7 +46,7 @@ ARGV.options do |opts|
46
46
  options[:mode] = val.to_sym
47
47
  end
48
48
 
49
- opts.on('-f', '--file=FILE', String, 'Used at [import_service] mode') do |val|
49
+ opts.on('-f', '--file=FILE', String, 'Used at [import_service, check_app] mode') do |val|
50
50
  options[:file] = val
51
51
  end
52
52
 
@@ -110,6 +110,7 @@ ARGV.options do |opts|
110
110
  opts.separator "\t fofacli -e aaa@bbb.com -a xxx --query_file /tmp/fofaquery"
111
111
  opts.separator "\t fofacli -e aaa@bbb.com -a xxx -d ip,domain,title,port,protocol -m query_ip_list -f ip.txt"
112
112
  opts.separator %Q@\t cat vapps.txt | xargs -I{} -n 1 sh -c 'fofacli "app=$1" -d host,ip,port,country,province,city -s 1000 -o json -v > "$1.txt"' -- {}@
113
+ opts.separator "\t fofacli -m check_app --app \"Coremail\" mail.tsinghua.edu.cn"
113
114
 
114
115
  begin
115
116
  opts.parse!
@@ -248,16 +249,44 @@ case options[:mode]
248
249
  pool.wait_for_termination
249
250
  when :check_app
250
251
  query = options[:query] || ARGV.join(' ')
251
- res = Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
252
- .check_app(query, {
253
- category:options[:check_app_category],
254
- application:options[:check_app_application],
255
- all:options[:all],
256
- })
257
-
258
- res.each{|r|
259
- log_record(options, r)
260
- }
252
+ fofa = Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
253
+ if options[:file]
254
+ File.open(options[:file]){|f|
255
+ f.each_line{|line|
256
+ query = line.strip
257
+ res = fofa.check_app(query, {
258
+ category:options[:check_app_category],
259
+ application:options[:check_app_application],
260
+ all:options[:all],
261
+ })
262
+
263
+ if res && res.size>0
264
+ res.each{|r|
265
+ log_record(options, [query, r])
266
+ }
267
+ else
268
+ log_record(options, [query, nil])
269
+ end
270
+
271
+ }
272
+ }
273
+ else
274
+ res = fofa.check_app(query, {
275
+ category:options[:check_app_category],
276
+ application:options[:check_app_application],
277
+ all:options[:all],
278
+ })
279
+
280
+ if res && res.size>0
281
+ res.each{|r|
282
+ log_record(options, r)
283
+ }
284
+ else
285
+ $stderr.puts "[WARNING] No result!"
286
+ end
287
+
288
+ end
289
+
261
290
 
262
291
  end
263
292
 
@@ -153,30 +153,6 @@ module Fofa
153
153
  req = Net::HTTP::Get.new(uri.request_uri)
154
154
  resp = http.request(req)
155
155
  JSON.parse(resp.body)
156
-
157
- # File.open(file) do |f|
158
- # results = []
159
- # f.each_line.lazy.each_with_index do |line, i|
160
- #
161
- # line = line.strip
162
- # if m = /Discovered open port (?<port>.*?)\/tcp on (?<host>.*?)$/.match(line)
163
- # hostinfo = "#{m[:host]}:#{m[:port]}"
164
- # elsif line.include?(':')
165
- # hostinfo = line
166
- # else
167
- # hostinfo = "#{line}:#{options[:port]}"
168
- # end
169
- #
170
- # results << line
171
- # if i % split_size == 0
172
- # req = Net::HTTP::Post.new(uri.request_uri)
173
- # req.body = results.join("\n")
174
- # resp = http.request(req)
175
- # puts resp if @options[:debug]
176
- # results = []
177
- # end
178
- # end
179
- # end
180
156
  rescue => e
181
157
  {"error"=>"Error: #{e.to_s}"}
182
158
  end
@@ -1,3 +1,6 @@
1
+ # 0.3.18
2
+ # add feature: check applications from file
3
+ #
1
4
  # 0.3.17
2
5
  # add checkapp api call
3
6
  #
@@ -28,5 +31,5 @@
28
31
  # 0.3.6
29
32
  # add fields
30
33
  module Fofa
31
- VERSION = "0.3.17"
34
+ VERSION = "0.3.18"
32
35
  end
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.17
4
+ version: 0.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - fofa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2017-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler