fofa 0.3.9 → 0.3.10
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 +2 -1
- data/Gemfile.lock +3 -1
- data/bin/fofacli +89 -36
- data/lib/fofa/version.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec762cac0cbe6e4e4ee3870f74c23bd428c57ceb
|
4
|
+
data.tar.gz: ea73a0e0ba7d6739966f10b4d67ab5a7a65a9017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f4dc47c12e9a2e667a72c7110199da7309174024c18fe794294527340205338e26f7bbf5a275c8a38387ff1af12ca10fb455b6e2518b89e700a8fa5f8232c80
|
7
|
+
data.tar.gz: 325524afc95a5713f61ace3cbd2b7f5d6837d82e36c39d538d7336a9e5a8797432deca8b4d9decf6a4c333ad3108f74ee8d790de4f6335fee1527887bca326f9
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fofa (0.3.
|
4
|
+
fofa (0.3.10)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
colorize (0.8.1)
|
10
|
+
concurrent-ruby (1.0.5)
|
10
11
|
diff-lcs (1.2.5)
|
11
12
|
rake (10.5.0)
|
12
13
|
rspec (3.5.0)
|
@@ -29,6 +30,7 @@ PLATFORMS
|
|
29
30
|
DEPENDENCIES
|
30
31
|
bundler (~> 1.12)
|
31
32
|
colorize
|
33
|
+
concurrent-ruby
|
32
34
|
fofa!
|
33
35
|
rake (~> 10.0)
|
34
36
|
rspec (~> 3.0)
|
data/bin/fofacli
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
|
4
|
+
require_relative "../lib/fofa"
|
5
5
|
require "optparse"
|
6
6
|
require "colorize"
|
7
7
|
|
@@ -38,7 +38,7 @@ ARGV.options do |opts|
|
|
38
38
|
options[:page] = val.to_i
|
39
39
|
end
|
40
40
|
|
41
|
-
opts.on('-m', '--mode=MODE', String, 'Mode, default to [search], -m should be specified when [import_service] ') do |val|
|
41
|
+
opts.on('-m', '--mode=MODE', String, 'Mode, default to [search], -m should be specified when [import_service, query_ip_list] ') do |val|
|
42
42
|
options[:mode] = val.to_sym
|
43
43
|
end
|
44
44
|
|
@@ -84,6 +84,7 @@ ARGV.options do |opts|
|
|
84
84
|
opts.separator "\t fofacli -e aaa@bbb.com -a xxx domain=\"baidu.com\""
|
85
85
|
opts.separator "\t fofacli -e aaa@bbb.com -a xxx -s 100 domain=\"baidu.com\""
|
86
86
|
opts.separator "\t fofacli -e aaa@bbb.com -a xxx --query_file /tmp/fofaquery"
|
87
|
+
opts.separator "\t fofacli -e aaa@bbb.com -a xxx -d ip,domain,title,port,protocol -m query_ip_list -f ip.txt"
|
87
88
|
|
88
89
|
begin
|
89
90
|
opts.parse!
|
@@ -110,39 +111,91 @@ unless options[:apikey]
|
|
110
111
|
end
|
111
112
|
|
112
113
|
case options[:mode]
|
113
|
-
when :search
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
when :import_service
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
114
|
+
when :search
|
115
|
+
if ARGV.empty? && !options[:query]
|
116
|
+
puts "Fofa query not specified.".red
|
117
|
+
puts ARGV.options
|
118
|
+
exit -1
|
119
|
+
end
|
120
|
+
query = options[:query] || ARGV.join(' ')
|
121
|
+
puts "Query: '#{query}'"
|
122
|
+
if options[:page] #search one page
|
123
|
+
puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
|
124
|
+
.search(query, {
|
125
|
+
page:options[:page],
|
126
|
+
size:options[:limit],
|
127
|
+
fields:options[:fields],
|
128
|
+
post:options[:post]
|
129
|
+
})
|
130
|
+
else
|
131
|
+
puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
|
132
|
+
.search_all(query, {
|
133
|
+
size:options[:limit],
|
134
|
+
page_size:options[:size_per_page],
|
135
|
+
fields:options[:fields],
|
136
|
+
post:options[:post]
|
137
|
+
})
|
138
|
+
end
|
139
|
+
|
140
|
+
when :import_service
|
141
|
+
unless options[:file]
|
142
|
+
puts "File not specified.".red
|
143
|
+
puts ARGV.options
|
144
|
+
exit -1
|
145
|
+
end
|
146
|
+
puts "Import service from '#{options[:file]}'"
|
147
|
+
puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]}).import_service(options[:file], {split_size:options[:split_size], fields:options[:fields]})
|
148
|
+
when :query_ip_list
|
149
|
+
unless options[:file]
|
150
|
+
puts "File not specified.".red
|
151
|
+
puts ARGV.options
|
152
|
+
exit -1
|
153
|
+
end
|
154
|
+
puts "Query information from '#{options[:file]}'"
|
155
|
+
fofa = Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]})
|
156
|
+
require 'concurrent'
|
157
|
+
semaphore = Concurrent::Semaphore.new(1)
|
158
|
+
pool = Concurrent::FixedThreadPool.new(10)
|
159
|
+
$stdout.sync = true
|
160
|
+
File.open(options[:file]){|f|
|
161
|
+
fields = options[:fields].split(',')
|
162
|
+
f.each_line{|line|
|
163
|
+
pool.post do
|
164
|
+
ip = line.strip
|
165
|
+
ip_hash = {'obj'=>ip, 'exists'=>false}
|
166
|
+
fields.each{|key|
|
167
|
+
ip_hash[key] = []
|
168
|
+
}
|
169
|
+
fofa.search_all(%Q|ip="#{ip}"|, {
|
170
|
+
size:options[:limit],
|
171
|
+
page_size:options[:size_per_page],
|
172
|
+
fields:options[:fields],
|
173
|
+
post:options[:post]
|
174
|
+
}).each{|a|
|
175
|
+
ip_hash['exists'] = true
|
176
|
+
a.each_with_index { |value, index|
|
177
|
+
if value && value.size>0
|
178
|
+
unless (fields[index] == 'domain' && value=~/\d*\.\d*\.\d*\.\d*/)
|
179
|
+
ip_hash[fields[index]] << value
|
180
|
+
ip_hash[fields[index]].uniq!
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
}
|
185
|
+
}
|
186
|
+
if ip_hash['exists']
|
187
|
+
ip_hash.delete('exists')
|
188
|
+
ip_hash.each{|k,v|
|
189
|
+
ip_hash.delete(k) if v.size==0
|
190
|
+
}
|
191
|
+
semaphore.acquire
|
192
|
+
puts ip_hash.to_json
|
193
|
+
semaphore.release
|
194
|
+
end
|
195
|
+
end
|
196
|
+
}
|
197
|
+
} #File
|
198
|
+
pool.shutdown
|
199
|
+
pool.wait_for_termination
|
147
200
|
end
|
148
201
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fofa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|