fofa 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/bin/fofacli +33 -27
- data/build.sh +3 -0
- data/lib/fofa.rb +10 -6
- data/lib/fofa/version.rb +3 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b606d3c74e7a72421fbed9e71bbfca25c6d6d04f
|
4
|
+
data.tar.gz: 43e5737e0f67c22e92521e7fd33f73b9d46328a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2760f21dd6300a39d30e58688c08651390542ceac468fff5b0cebf500f316c761880fc944f143229ad6b8843067c6123afb3444f7d7cf3491505d7aefb17ab85
|
7
|
+
data.tar.gz: 0b8fccd0f3fdd6a47c67714cc366489cfd1330c04c5112021f25deb2b3f32f337192339e39da75a5d1ffab76775b87c9f2146b45a23480eee83ecd4f090325e0
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Created by .ignore support plugin (hsz.mobi)
|
data/Gemfile.lock
CHANGED
data/bin/fofacli
CHANGED
@@ -6,14 +6,15 @@ require "optparse"
|
|
6
6
|
require "colorize"
|
7
7
|
|
8
8
|
options = {
|
9
|
-
email:
|
10
|
-
apikey:
|
9
|
+
email: ENV['FOFA_EMAIL'],
|
10
|
+
apikey: ENV['FOFA_KEY'],
|
11
11
|
page: 1,
|
12
12
|
verbose: false,
|
13
13
|
file: nil,
|
14
14
|
mode: :search,
|
15
15
|
split_size: 100,
|
16
|
-
limit: 100
|
16
|
+
limit: 100,
|
17
|
+
fields: 'host'
|
17
18
|
}
|
18
19
|
|
19
20
|
ARGV.options do |opts|
|
@@ -23,32 +24,36 @@ ARGV.options do |opts|
|
|
23
24
|
opts.separator "Specific Options:"
|
24
25
|
|
25
26
|
opts.on('-e', '--email=EMAIL', String, 'Email of fofa user') do |val|
|
26
|
-
|
27
|
-
|
27
|
+
options[:email] = val
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
opts.on('-a', '--apikey=APIKEY', String, 'APIKEY of fofa user') do |val|
|
31
|
+
options[:apikey] = val
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
opts.on('-p', '--page=PAGE', Integer, 'Page of query result') do |val|
|
35
|
+
options[:page] = val.to_i
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
opts.on('-m', '--mode=MODE', String, 'Mode, default to [search], -m should be specified when [import_service] ') do |val|
|
39
|
+
options[:mode] = val.to_sym
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
opts.on('-f', '--file=FILE', String, 'Used at [import_service] mode') do |val|
|
43
|
+
options[:file] = val
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
opts.on('-s', '--limit=SIZE', Integer, "Limit size to fetch, default to #{options[:limit]}") do |val|
|
47
|
+
options[:limit] = val.to_i
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on('-l', '--split_size=SIZE', Integer, "Used at [import_service] mode, default to #{options[:split_size]}") do |val|
|
51
|
+
options[:split_size] = val.to_i
|
52
|
+
end
|
48
53
|
|
49
|
-
|
50
|
-
|
51
|
-
|
54
|
+
opts.on('-d', '--fields=FIELDS', String, "Fields to return, split with ',', default to #{options[:fields]}") do |val|
|
55
|
+
options[:fields] = val
|
56
|
+
end
|
52
57
|
|
53
58
|
opts.separator "Common Options:"
|
54
59
|
|
@@ -65,8 +70,9 @@ ARGV.options do |opts|
|
|
65
70
|
opts.parse!
|
66
71
|
rescue OptionParser::InvalidOption => e
|
67
72
|
puts e
|
68
|
-
|
69
|
-
|
73
|
+
options.query += e.args
|
74
|
+
rescue => e
|
75
|
+
puts e
|
70
76
|
puts opts
|
71
77
|
exit
|
72
78
|
end
|
@@ -93,7 +99,7 @@ when :search
|
|
93
99
|
end
|
94
100
|
query = ARGV.join(' ')
|
95
101
|
puts "Query: '#{query}'"
|
96
|
-
puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]}).search(query, {page:options[:page], size:options[:limit]})
|
102
|
+
puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]}).search(query, {page:options[:page], size:options[:limit], fields:options[:fields]})
|
97
103
|
when :import_service
|
98
104
|
unless options[:file]
|
99
105
|
puts "File not specified.".red
|
@@ -101,6 +107,6 @@ when :import_service
|
|
101
107
|
exit -1
|
102
108
|
end
|
103
109
|
puts "Import server from '#{options[:file]}'"
|
104
|
-
puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]}).import_service(options[:file], {split_size:options[:split_size]})
|
110
|
+
puts Fofa::API.new(options[:email], options[:apikey], {debug:options[:verbose]}).import_service(options[:file], {split_size:options[:split_size], fields:options[:fields]})
|
105
111
|
end
|
106
112
|
|
data/build.sh
ADDED
data/lib/fofa.rb
CHANGED
@@ -8,22 +8,26 @@ module Fofa
|
|
8
8
|
def initialize(email, apikey, options={})
|
9
9
|
@options = {debug:false}.merge options
|
10
10
|
@api_server = ENV['FOFA_API_SERVER'] || 'https://fofa.so'
|
11
|
-
@email = email
|
12
|
-
@apikey = apikey
|
11
|
+
@email = email || ENV['FOFA_EMAIL']
|
12
|
+
@apikey = apikey || ENV['FOFA_KEY']
|
13
13
|
end
|
14
14
|
|
15
15
|
# Search page results from fofa
|
16
16
|
#
|
17
|
-
# Example:
|
17
|
+
# Example 1:
|
18
18
|
# >> Fofa::API.new(email,apikey).search("host==baidu.com")
|
19
|
-
# => {size:1, results:['1.1.1.1
|
19
|
+
# => {size:1, results:['1.1.1.1']}
|
20
|
+
#
|
21
|
+
# Example 2:
|
22
|
+
# >> Fofa::API.new(email,apikey).search("host==baidu.com", fields:'host,title,ip')
|
23
|
+
# => {size:1, results:[['1.1.1.1:81', 'title', '1.1.1.1']]}
|
20
24
|
#
|
21
25
|
# Arguments:
|
22
26
|
# query: (String) fofa query string
|
23
27
|
# options: (Hash) page(default 1, only fetch one page), size(defualt 100)
|
24
28
|
def search(query, options={})
|
25
|
-
options = {page:1,size:100}.merge(options)
|
26
|
-
url = "#{@api_server}/api/v1/search/all?key=#{@apikey}&email=#{@email}&q=#{URI.escape(query)}&page=#{options[:page]}&size=#{options[:size]}"
|
29
|
+
options = {page:1, size:100, fields:'host'}.merge(options)
|
30
|
+
url = "#{@api_server}/api/v1/search/all?key=#{@apikey}&email=#{@email}&q=#{URI.escape(query)}&page=#{options[:page]}&size=#{options[:size]}&fields=#{options[:fields]}"
|
27
31
|
puts url if @options[:debug]
|
28
32
|
uri = URI.parse(url)
|
29
33
|
http = Net::HTTP.new(uri.host, uri.port)
|
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.5
|
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-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ executables:
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".gitignore"
|
63
64
|
- CODE_OF_CONDUCT.md
|
64
65
|
- Gemfile
|
65
66
|
- Gemfile.lock
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- bin/console
|
70
71
|
- bin/fofacli
|
71
72
|
- bin/setup
|
73
|
+
- build.sh
|
72
74
|
- fofa.gemspec
|
73
75
|
- lib/fofa.rb
|
74
76
|
- lib/fofa/version.rb
|
@@ -92,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
94
|
version: '0'
|
93
95
|
requirements: []
|
94
96
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.5.1
|
96
98
|
signing_key:
|
97
99
|
specification_version: 4
|
98
100
|
summary: A Ruby library to interact with the FOFA API. https://fofa.so
|