apullo 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f1f9e5d90ef5abdc9a8caf4084a6afa69d36938aefe6ea5b22d97df003dee16
4
- data.tar.gz: 5b25da846587a8a2a96b649a7cb2cd2fec853070a09a13ac57e7e176f20f8199
3
+ metadata.gz: b0827cde956b63c66bd88b8c6a37597626f355cd677a701e6590ab5996011c21
4
+ data.tar.gz: bb53dfba7e8297f85b3992a54efa8546e2d815247443430134bfbd1b15963acd
5
5
  SHA512:
6
- metadata.gz: afe5791fb852dbf7b162dea37380a057f1491f4878a59186831610e0e9221c7c17c4766e9b169c0e0be68b10f0440482afd355b2b468e127d17f9b1d3a6cfc05
7
- data.tar.gz: aa23fc08523091e1f9444fe3261131cda5dd65f8655af513be3c2f7cfd34ebcbbf36aae3aa6724122afb2fdbaad1997caf888e5436479848f17e1c30a514363b
6
+ metadata.gz: 53469022402714f62e9561da863f35e0bf5032b29d7ec2754224d04b5dc44e40615d4f3fee980d23c8e60a3a27b84388561f3f00e7b14ab816e79aec63ec7acb
7
+ data.tar.gz: c67723532f368589ee043c700fa4fb3cc5a6dd500bdbbe29244f5a3f2c992a64181c08d7531c2ef2315c0b4854fa109052485ab81b64c9de09e845f369945f88
@@ -36,7 +36,6 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "mem", "~> 0.1"
37
37
  spec.add_dependency "murmurhash3", "~> 0.1"
38
38
  spec.add_dependency "oga", "~> 2.15"
39
- spec.add_dependency "parallel", "~> 1.18"
40
39
  spec.add_dependency "public_suffix", "~> 4.0"
41
40
  spec.add_dependency "ssh_scan", "~> 0.0"
42
41
  spec.add_dependency "thor", "~> 0.20"
@@ -1,16 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
- require "parallel"
5
4
  require "thor"
6
5
 
7
6
  module Apullo
8
7
  class CLI < Thor
9
8
  desc "check [Target]", "Take fingerprints from a target(IP, domain or URL)"
9
+ method_option :headers, type: :hash, default: {}
10
10
  def check(target)
11
11
  target = Target.new(target)
12
+ headers = options["headers"]
12
13
 
13
- results = build_results(target)
14
+ results = build_results(target, headers: headers)
14
15
  meta = { target: target.id }
15
16
  results = results.merge(meta: meta)
16
17
 
@@ -18,15 +19,17 @@ module Apullo
18
19
  end
19
20
 
20
21
  no_commands do
21
- def build_results(target)
22
+ def build_results(target, headers: {})
22
23
  unless target.valid?
23
24
  return {
24
25
  error: "Invalid target is given. Target should be an IP, domain or URL."
25
26
  }
26
27
  end
27
28
 
28
- Parallel.map(Apullo.fingerprints) do |klass|
29
+ Apullo.fingerprints.map do |klass|
29
30
  fingerprint = klass.new(target)
31
+ fingerprint.headers = headers if fingerprint.respond_to?(:headers=)
32
+
30
33
  [fingerprint.name, fingerprint.results]
31
34
  end.to_h
32
35
  end
@@ -48,7 +48,7 @@ module Apullo
48
48
  response = http.request(request)
49
49
 
50
50
  response.code.to_i == 200 ? response.body : nil
51
- rescue Errno::ECONNREFUSED, Net::HTTPError, OpenSSL::OpenSSLError => _e
51
+ rescue Errno::ECONNREFUSED, Net::HTTPError, OpenSSL::OpenSSLError, Timeout::Error => _e
52
52
  nil
53
53
  end
54
54
 
@@ -7,6 +7,13 @@ require "openssl"
7
7
  module Apullo
8
8
  module Fingerprint
9
9
  class HTTP < Base
10
+ attr_writer :headers
11
+
12
+ def initialize(target)
13
+ @target = target
14
+ @headers = {}
15
+ end
16
+
10
17
  def results
11
18
  @results ||= [].tap do |out|
12
19
  get(target.uri.path)
@@ -14,7 +21,10 @@ module Apullo
14
21
  out << {
15
22
  body: body,
16
23
  cert: cert,
17
- favicon: favicon
24
+ favicon: favicon,
25
+ meta: {
26
+ url: target.url
27
+ }
18
28
  }
19
29
  end.first
20
30
  end
@@ -53,6 +63,10 @@ module Apullo
53
63
 
54
64
  private
55
65
 
66
+ def headers
67
+ @headers.compact
68
+ end
69
+
56
70
  def default_favicon_url
57
71
  "#{target.uri.scheme}://#{target.uri.host}:#{target.uri.port}/favicon.ico"
58
72
  end
@@ -73,18 +87,23 @@ module Apullo
73
87
  def get(path, limit: 3)
74
88
  http = build_http
75
89
  path = path.empty? ? "/" : path
76
- request = Net::HTTP::Get.new(path)
90
+ request = Net::HTTP::Get.new(path, headers)
77
91
  response = http.request request
78
92
 
79
93
  location = response["Location"]
80
94
  if location && limit.positive?
81
- get(location, limit: limit - 1)
95
+ if location.start_with?("http://", "https://")
96
+ rebuild_target location
97
+ get(target.uri.path)
98
+ else
99
+ get(location, limit: limit - 1)
100
+ end
82
101
  else
83
102
  @peer_cert = http.peer_cert
84
103
  @body = response.body
85
104
  @path = path
86
105
  end
87
- rescue Errno::ECONNREFUSED, Net::HTTPError, OpenSSL::OpenSSLError => _e
106
+ rescue Errno::ECONNREFUSED, Net::HTTPError, OpenSSL::OpenSSLError, Timeout::Error => _e
88
107
  nil
89
108
  end
90
109
 
@@ -95,6 +114,10 @@ module Apullo
95
114
  Net::HTTP.start(target.uri.host, target.uri.port, use_ssl: true)
96
115
  end
97
116
  end
117
+
118
+ def rebuild_target(url)
119
+ @target = Target.new(url)
120
+ end
98
121
  end
99
122
  end
100
123
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Apullo
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apullo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-04 00:00:00.000000000 Z
11
+ date: 2019-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -164,20 +164,6 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '2.15'
167
- - !ruby/object:Gem::Dependency
168
- name: parallel
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.18'
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '1.18'
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: public_suffix
183
169
  requirement: !ruby/object:Gem::Requirement