dkimverify 0.0.2 → 0.0.3

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: ab8514ab9b191b18c0d9eab8d3f37b246555f4fd
4
- data.tar.gz: 0d6203cb46b3f520f63f8b301da4c586208076ac
3
+ metadata.gz: a8e478a5441b933c84c1880587bca90d3433f5d1
4
+ data.tar.gz: c6ff69ed30db9e8d03fb21f5fcec8277f9c51bc4
5
5
  SHA512:
6
- metadata.gz: b7eb314c2b983b38c2cdf98acb94c5197c3c122559e1eb0dc613dea75fec14ea3fa2da7aff2025ee20767a1e1962ba51dafb29935df0b2b8ae3fe51e1299a5b2
7
- data.tar.gz: 5c0c5ce840fa47bf365f6bb2822af363fe720a980f7e0203bef47b3675e7a98a463adae22d973bb8e7b58590b97607c03360d786775d36d32bc1d7f444701d3a
6
+ metadata.gz: 8d239d98049d9868040fed1e6267c6568a30499df36eb48663ca7968123f0de021be46bb0ca7fed8c67430f999e085cd9af23e43532943c41b6a465d148fe6e7
7
+ data.tar.gz: 8f38905a1d21db655e524469eb37fe6726383aeebe68375fb3257648cb85996ef599ba8c067dac878317ae7b5905e8c9033a7ae16f352206d732e3275eb0a5a6
data/README.md CHANGED
@@ -5,6 +5,8 @@ a gem for verifying DKIM signatures in Ruby
5
5
 
6
6
  this gem does not sign mail messages (but a PR to enable it would likely be accepted, I just have no use for it.)
7
7
 
8
+ **this gem doesn't work right yet!!!**
9
+
8
10
  how to use
9
11
  -----------
10
12
  ````Dkim::Verifier.new(eml_filepath).verify!````
@@ -24,7 +26,6 @@ with a debt of gratitude to:
24
26
  ----------------------------
25
27
 
26
28
  - [pydkim](https://github.com/ghewgill/pydkim) by @ghewgill which I used as a reference implementation
27
- - [dkim-query](https://github.com/trailofbits/dkim-query) by @trailofbits (and included here in slightly-modified form)
28
29
  - [mail](https://github.com/mikel/mail) by @mikel
29
30
  - [carsonreinke's fork of the jhawthorne's dkim gem](https://github.com/carsonreinke/dkim/tree/feature_verification) which I wish I had found before I started this.
30
31
  - [rfc6376 authors](https://tools.ietf.org/html/rfc6376)
@@ -35,6 +36,7 @@ checking expiration dates (x=, t=)
35
36
  accounting for length limits (l= tag)
36
37
  tests (which I really ought to add)
37
38
  checking multiple dkim signature header lines (probably easy)
39
+ dealing with the "simple" canonicalization method (because I need to strip out the `mail` gem and instead write my own RFC822 parser that is better for maintaining the exact original string)
38
40
 
39
41
  by
40
42
  --
data/dkimverify.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "dkimverify"
5
- gem.version = '0.0.2'
5
+ gem.version = '0.0.3'
6
6
  gem.authors = ["Jeremy B. Merrill"]
7
7
  gem.license = "MIT"
8
8
  gem.email = ["jeremybmerrill@gmail.com"]
data/dkimverify.rb CHANGED
@@ -1,11 +1,10 @@
1
1
  require 'digest'
2
2
  require 'openssl'
3
3
  require 'base64'
4
- require_relative './dkim-query/lib/dkim/query'
5
-
4
+ require 'resolv'
6
5
 
7
6
  # TODO make this an option somehow
8
- $debuglog = nil # alternatively, set this to `STDERR` to log to stdout.
7
+ $debuglog = STDERR # nil # alternatively, set this to `STDERR` to log to stdout.
9
8
  require 'mail'
10
9
 
11
10
  module Mail
@@ -33,6 +32,17 @@ module Dkim
33
32
  class InvalidDkimSignature < DkimPermFail; end
34
33
  class DkimVerificationFailure < DkimPermFail; end
35
34
 
35
+ #TODO: what is this kind of key-value string even called?
36
+ def self.parse_header_kv(input_str)
37
+ parsed = {}
38
+ input_str.split(/\s*;\s*/).each do |key_val|
39
+ if m = key_val.match(/(\w+)\s*=\s*(.*)/)
40
+ parsed[m[1]] = m[2]
41
+ end
42
+ end
43
+ parsed
44
+ end
45
+
36
46
  class Verifier
37
47
  def initialize(email_filename)
38
48
  mail = Mail.read(email_filename) # TODO make this `mail` not `@mail`
@@ -45,12 +55,7 @@ module Dkim
45
55
  return false if @headers["DKIM-Signature"].nil?
46
56
 
47
57
  dkim_signature_str = @headers.first_field("DKIM-Signature").value.to_s
48
- @dkim_signature = {}
49
- dkim_signature_str.split(/\s*;\s*/).each do |key_val|
50
- if m = key_val.match(/(\w+)\s*=\s*(.*)/)
51
- @dkim_signature[m[1]] = m[2]
52
- end
53
- end
58
+ @dkim_signature = Dkim.parse_header_kv(dkim_signature_str)
54
59
  validate_signature! # just checking to make sure we have all the ingredients we need to actually verify the signature
55
60
 
56
61
  figure_out_canonicalization_methods!
@@ -121,10 +126,12 @@ module Dkim
121
126
  def public_key
122
127
  # here we're getting the website's actual public key from the DNS system
123
128
  # s = dnstxt(sig['s']+"._domainkey."+sig['d']+".")
124
- dkim_record_from_dns = DKIM::Query::Domain.query(@dkim_signature['d'], {:selectors => [@dkim_signature['s']]}).keys[@dkim_signature['s']]
125
- raise DkimTempFail.new("couldn't get public key from DNS system for #{@dkim_signature['s']}/#{@dkim_signature['d']}") if dkim_record_from_dns.nil? || dkim_record_from_dns.class == DKIM::Query::MalformedKey
126
- x = OpenSSL::ASN1.decode(Base64.decode64(dkim_record_from_dns.public_key.to_s))
127
- publickey = x.value[1].value
129
+ # dkim_record_from_dns = DKIM::Query::Domain.query(@dkim_signature['d'], {:selectors => [@dkim_signature['s']]}).keys[@dkim_signature['s']]
130
+ txt = Resolv::DNS.open{|dns| dns.getresources("#{@dkim_signature['s']}._domainkey.#{@dkim_signature['d']}", Resolv::DNS::Resource::IN::TXT).map(&:data) }
131
+ parsed_txt = Dkim.parse_header_kv(txt.first)
132
+ raise DkimTempFail.new("couldn't get public key from DNS system for #{@dkim_signature['s']}/#{@dkim_signature['d']}") if txt.first.nil? || !parsed_txt.keys.include?("p")
133
+ publickey_asn1 = OpenSSL::ASN1.decode(Base64.decode64(parsed_txt["p"]))
134
+ publickey = publickey_asn1.value[1].value
128
135
  end
129
136
 
130
137
  def headers_to_sign
@@ -134,13 +141,15 @@ module Dkim
134
141
  $debuglog.puts "header_fields_to_include: #{header_fields_to_include}" unless $debuglog.nil?
135
142
  canonicalized_headers = []
136
143
  header_fields_to_include_with_values = header_fields_to_include.map do |header_name|
137
- [header_name, @headers.first_field(header_name).instance_eval { unfold(split(@raw_value)[1]) } ]
144
+ puts @headers.first_field(header_name).inspect
145
+ [header_name, @headers.first_field(header_name).instance_variable_get("@raw_value").split(":")[1..-1].join(":") ]
138
146
  # .value and .instance_eval { unfold(split(@raw_value)[1]) } return subtly different values
139
147
  # if the value of the Date header is a date with a single-digit day.
140
148
  # see https://github.com/mikel/mail/issues/1075
141
149
  # incidentally, .instance_variable_get("@value") gives a third subtly different value in a way that I don't understand.
142
150
  end
143
151
  canonicalized_headers = Dkim.canonicalize_headers(header_fields_to_include_with_values, @how_to_canonicalize_headers)
152
+ puts @headers.first_field("DKIM-Signature").inspect
144
153
 
145
154
  canonicalized_headers += Dkim.canonicalize_headers([
146
155
  [
@@ -180,7 +189,6 @@ module Dkim
180
189
  ]),
181
190
  OpenSSL::ASN1::OctetString.new(headers_digest),
182
191
  ])
183
- $debuglog.puts "dinfo: #{ dinfo.to_der }" unless $debuglog.nil?
184
192
  headers_der = Base64.encode64(dinfo.to_der).gsub(/\s+/, '')
185
193
  $debuglog.puts "headers_hash: #{headers_der}" unless $debuglog.nil?
186
194
  headers_der
@@ -195,34 +203,34 @@ module Dkim
195
203
 
196
204
  def validate_signature!
197
205
  # version: only version 1 is defined
198
- raise InvalidDkimSignature("DKIM signature is missing required tag v=") unless @dkim_signature.include?('v')
199
- raise InvalidDkimSignature("DKIM signature v= value is invalid (got \"#{@dkim_signature['v']}\"; expected \"1\")") unless @dkim_signature['v'] == "1"
206
+ raise InvalidDkimSignature.new("DKIM signature is missing required tag v=") unless @dkim_signature.include?('v')
207
+ raise InvalidDkimSignature.new("DKIM signature v= value is invalid (got \"#{@dkim_signature['v']}\"; expected \"1\")") unless @dkim_signature['v'] == "1"
200
208
 
201
209
  # encryption algorithm
202
- raise InvalidDkimSignature("DKIM signature is missing required tag a=") unless @dkim_signature.include?('a')
210
+ raise InvalidDkimSignature.new("DKIM signature is missing required tag a=") unless @dkim_signature.include?('a')
203
211
 
204
212
  # header hash
205
- raise InvalidDkimSignature("DKIM signature is missing required tag b=") unless @dkim_signature.include?('b')
206
- raise InvalidDkimSignature("DKIM signature b= value is not valid base64") unless @dkim_signature['b'].match(/[\s0-9A-Za-z+\/]+=*$/)
207
- raise InvalidDkimSignature("DKIM signature is missing required tag h=") unless @dkim_signature.include?('h')
213
+ raise InvalidDkimSignature.new("DKIM signature is missing required tag b=") unless @dkim_signature.include?('b')
214
+ raise InvalidDkimSignature.new("DKIM signature b= value is not valid base64") unless @dkim_signature['b'].match(/[\s0-9A-Za-z+\/]+=*$/)
215
+ raise InvalidDkimSignature.new("DKIM signature is missing required tag h=") unless @dkim_signature.include?('h')
208
216
 
209
217
  # body hash (not directly encrypted)
210
- raise InvalidDkimSignature("DKIM signature is missing required tag bh=") unless @dkim_signature.include?('bh')
211
- raise InvalidDkimSignature("DKIM signature bh= value is not valid base64") unless @dkim_signature['bh'].match(/[\s0-9A-Za-z+\/]+=*$/)
218
+ raise InvalidDkimSignature.new("DKIM signature is missing required tag bh=") unless @dkim_signature.include?('bh')
219
+ raise InvalidDkimSignature.new("DKIM signature bh= value is not valid base64") unless @dkim_signature['bh'].match(/[\s0-9A-Za-z+\/]+=*$/)
212
220
 
213
221
  # domain selector
214
- raise InvalidDkimSignature("DKIM signature is missing required tag d=") unless @dkim_signature.include?('d')
215
- raise InvalidDkimSignature("DKIM signature is missing required tag s=") unless @dkim_signature.include?('s')
222
+ raise InvalidDkimSignature.new("DKIM signature is missing required tag d=") unless @dkim_signature.include?('d')
223
+ raise InvalidDkimSignature.new("DKIM signature is missing required tag s=") unless @dkim_signature.include?('s')
216
224
 
217
225
  # these are expiration dates, which are not checked above.
218
- raise InvalidDkimSignature("DKIM signature t= value is not a valid decimal integer") unless @dkim_signature['t'].nil? || @dkim_signature['t'].match(/\d+$/)
219
- raise InvalidDkimSignature("DKIM signature x= value is not a valid decimal integer") unless @dkim_signature['x'].nil? || @dkim_signature['x'].match(/\d+$/)
220
- raise InvalidDkimSignature("DKIM signature x= value is less than t= (and must be greater than or equal to t=). (x=#{@dkim_signature['x']}, t=#{@dkim_signature['t']}) ") unless @dkim_signature['x'].nil? || @dkim_signature['x'].to_i >= @dkim_signature['t'].to_i
226
+ raise InvalidDkimSignature.new("DKIM signature t= value is not a valid decimal integer") unless @dkim_signature['t'].nil? || @dkim_signature['t'].match(/\d+$/)
227
+ raise InvalidDkimSignature.new("DKIM signature x= value is not a valid decimal integer") unless @dkim_signature['x'].nil? || @dkim_signature['x'].match(/\d+$/)
228
+ raise InvalidDkimSignature.new("DKIM signature x= value is less than t= (and must be greater than or equal to t=). (x=#{@dkim_signature['x']}, t=#{@dkim_signature['t']}) ") unless @dkim_signature['x'].nil? || @dkim_signature['x'].to_i >= @dkim_signature['t'].to_i
221
229
 
222
230
  # other unimplemented stuff
223
- raise InvalidDkimSignature("DKIM signature i= domain is not a subdomain of d= (i=#{@dkim_signature[i]} d=#{@dkim_signature[d]})") if @dkim_signature['i'] && !(@dkim_signature['i'].end_with?(@dkim_signature['d']) || ["@", ".", "@."].include?(@dkim_signature['i'][-@dkim_signature['d'].size-1]))
224
- raise InvalidDkimSignature("DKIM signature l= value is invalid") if @dkim_signature['l'] && !@dkim_signature['l'].match(/\d{,76}$/)
225
- raise InvalidDkimSignature("DKIM signature q= value is invalid (got \"#{@dkim_signature['q']}\"; expected \"dns/txt\")") if @dkim_signature['q'] && @dkim_signature['q'] != "dns/txt"
231
+ raise InvalidDkimSignature.new("DKIM signature i= domain is not a subdomain of d= (i=#{@dkim_signature[i]} d=#{@dkim_signature[d]})") if @dkim_signature['i'] && !(@dkim_signature['i'].end_with?(@dkim_signature['d']) || ["@", ".", "@."].include?(@dkim_signature['i'][-@dkim_signature['d'].size-1]))
232
+ raise InvalidDkimSignature.new("DKIM signature l= value is invalid") if @dkim_signature['l'] && !@dkim_signature['l'].match(/\d{,76}$/)
233
+ raise InvalidDkimSignature.new("DKIM signature q= value is invalid (got \"#{@dkim_signature['q']}\"; expected \"dns/txt\")") if @dkim_signature['q'] && @dkim_signature['q'] != "dns/txt"
226
234
  end
227
235
  end
228
236
 
@@ -245,7 +253,7 @@ module Dkim
245
253
  if how == "simple"
246
254
  $debuglog.puts "canonicalizing body with 'simple'" unless $debuglog.nil?
247
255
  # Ignore all empty lines at the end of the message body.
248
- body.gsub(/(\r\n)*$/, "\r\n")
256
+ body.gsub(/(\r\n)+\Z/, "\r\n")
249
257
  elsif how == "relaxed"
250
258
  $debuglog.puts "canonicalizing body with 'relaxed'" unless $debuglog.nil?
251
259
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dkimverify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy B. Merrill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-30 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -49,32 +49,6 @@ files:
49
49
  - Gemfile
50
50
  - LICENSE.txt
51
51
  - README.md
52
- - dkim-query/.gitignore
53
- - dkim-query/.rspec
54
- - dkim-query/.travis.yml
55
- - dkim-query/.yardopts
56
- - dkim-query/ChangeLog.md
57
- - dkim-query/Gemfile
58
- - dkim-query/LICENSE.txt
59
- - dkim-query/README.md
60
- - dkim-query/Rakefile
61
- - dkim-query/bin/dkim-query
62
- - dkim-query/dkim-query.gemspec
63
- - dkim-query/lib/dkim/query.rb
64
- - dkim-query/lib/dkim/query/domain.rb
65
- - dkim-query/lib/dkim/query/exceptions.rb
66
- - dkim-query/lib/dkim/query/key.rb
67
- - dkim-query/lib/dkim/query/malformed_key.rb
68
- - dkim-query/lib/dkim/query/parser.rb
69
- - dkim-query/lib/dkim/query/query.rb
70
- - dkim-query/lib/dkim/query/version.rb
71
- - dkim-query/spec/domain_spec.rb
72
- - dkim-query/spec/key_spec.rb
73
- - dkim-query/spec/malformed_key.rb
74
- - dkim-query/spec/parser_spec.rb
75
- - dkim-query/spec/query_spec.rb
76
- - dkim-query/spec/spec_helper.rb
77
- - dkim-query/tasks/alexa.rb
78
52
  - dkimverify.gemspec
79
53
  - dkimverify.rb
80
54
  homepage: https://github.com/jeremybmerrill/dkimverify
@@ -1,51 +0,0 @@
1
- <<<<<<< HEAD
2
- /.bundle/
3
- /.yardoc
4
- /Gemfile.lock
5
- /_yardoc/
6
- /coverage/
7
- /doc/
8
- /pkg/
9
- /spec/reports/
10
- /tmp/
11
- *.bundle
12
- *.so
13
- *.o
14
- *.a
15
- mkmf.log
16
- =======
17
- *.gem
18
- *.rbc
19
- /.config
20
- /coverage/
21
- /InstalledFiles
22
- /pkg/
23
- /spec/reports/
24
- /test/tmp/
25
- /test/version_tmp/
26
- /tmp/
27
-
28
- ## Specific to RubyMotion:
29
- .dat*
30
- .repl_history
31
- build/
32
-
33
- ## Documentation cache and generated files:
34
- /.yardoc/
35
- /_yardoc/
36
- /doc/
37
- /rdoc/
38
-
39
- ## Environment normalisation:
40
- /.bundle/
41
- /lib/bundler/man/
42
-
43
- # for a library or gem, you might want to ignore these files since the code is
44
- # intended to run in multiple environments; otherwise, check them in:
45
- # Gemfile.lock
46
- # .ruby-version
47
- # .ruby-gemset
48
-
49
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
- .rvmrc
51
- >>>>>>> 62c17ee30b1a7d25ef12fab39fd6c2de0bcbadbc
data/dkim-query/.rspec DELETED
@@ -1 +0,0 @@
1
- --colour --format documentation
@@ -1,16 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.8
4
- - 2.2.4
5
- - 2.3.0
6
- - jruby
7
- - rbx-2
8
- matrix:
9
- allow_failures:
10
- - rvm: rbx-2
11
- addons:
12
- code_climate:
13
- repo_token: 151a667c2c51ff76ac825c07c33e8e63c1ae9956a73f4d0ec7a043d877d05c95
14
- notifications:
15
- slack:
16
- secure: Ykcz/gLRZcXhyOGedVgj1u3CDUbZS4y/nL1dREBE0Ar73Vrz+ulcMhri3VzfVBQGkWw06EjqHcIwsIomEInLJKxk3RTfpcYQAdYN+5iEDNOri9a5NK618WdrCuaCS3sKqYbJ/KB0slJDcJ1W+EXkr4GRqZTr5rPdmllUnoaqDCQ=
data/dkim-query/.yardopts DELETED
@@ -1 +0,0 @@
1
- --markup markdown --title "DKIM::Query Documentation" --protected
@@ -1,25 +0,0 @@
1
- ### 0.2.6 / 2016-08-3
2
-
3
- * Fixed a typo in the parser rules.
4
-
5
- ### 0.2.5 / 2016-06-17
6
-
7
- * Added `mandrill` and `google` to the list of default DKIM selectors.
8
-
9
- ### 0.2.4 / 2015-08-13
10
-
11
- * Fixed a bug where the queried host has no TLD (ex: `test`).
12
-
13
- ### 0.2.3 / 2015-07-22
14
-
15
- * Fixed a typo in the `dkim-query` util.
16
- * Convert all text into Strings.
17
- * Convert `t=y` or `t=s` values to Symbols.
18
-
19
- ### 0.2.2 / 2015-07-04
20
-
21
- * Fixed {DKIM::Query::MalformedKey#to_s}.
22
-
23
- ### 0.2.1 / 2015-07-01
24
-
25
- * Initial release.
data/dkim-query/Gemfile DELETED
@@ -1,19 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in dkim-query.gemspec
4
- gemspec
5
-
6
- group :development do
7
- gem 'rake'
8
- gem 'rubygems-tasks', '~> 0.2'
9
-
10
- gem 'rspec', '~> 3.0'
11
-
12
- gem 'kramdown'
13
- gem 'yard', '~> 0.8'
14
- end
15
-
16
- group :test do
17
- gem 'json'
18
- gem 'codeclimate-test-reporter', require: nil
19
- end
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014 Trail of Bits
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/dkim-query/README.md DELETED
@@ -1,105 +0,0 @@
1
- # dkim-query
2
-
3
- [![Code Climate](https://codeclimate.com/github/trailofbits/dkim-query/badges/gpa.svg)](https://codeclimate.com/github/trailofbits/dkim-query)
4
- [![Test Coverage](https://codeclimate.com/github/trailofbits/dkim-query/badges/coverage.svg)](https://codeclimate.com/github/trailofbits/dkim-query)
5
- [![Build Status](https://travis-ci.org/trailofbits/dkim-query.svg)](https://travis-ci.org/trailofbits/dkim-query)
6
-
7
- The `dkim-query` library searches the [DKIM] records for a host. We assume the
8
- host uses standard dkim 'selectors', and also check if they use their own
9
- 'selector'.
10
-
11
- ## Examples
12
-
13
- Parse a DKIM record:
14
-
15
- require 'dkim/query'
16
-
17
- key = DKIM::Query::Key.parse("k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrEee0Ri4Juz+QfiWYui/E9UGSXau/2P8LjnTD8V4Unn+2FAZVGE3kL23bzeoULYv4PeleB3gfmJiDJOKU3Ns5L4KJAUUHjFwDebt0NP+sBK0VKeTATL2Yr/S3bT/xhy+1xtj4RkdV7fVxTn56Lb4udUnwuxK4V5b5PdOKj/+XcwIDAQAB; n=A 1024 bit key")
18
-
19
- key.v
20
- # => nil
21
-
22
- key.g
23
- # => nil
24
-
25
- key.h
26
- # => nil
27
-
28
- key.k
29
- # => :rsa
30
-
31
- key.n
32
- # => "A 1024 bit key"
33
-
34
- key.p
35
- # => "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrEee0Ri4Juz+QfiWYui/E9UGSXau/2P8LjnTD8V4Unn+2FAZVGE3kL23bzeoULYv4PeleB3gfmJiDJOKU3Ns5L4KJAUUHjFwDebt0NP+sBK0VKeTATL2Yr/S3bT/xhy+1xtj4RkdV7fVxTn56Lb4udUnwuxK4V5b5PdOKj/+XcwIDAQAB"
36
-
37
- key.s
38
- # => nil
39
-
40
- key.t
41
- # => nil
42
-
43
- Query all keys for a domain:
44
-
45
- domain = DKIM::Query::Domain.query('yahoo.com')
46
- # => #<DKIM::Query::Domain:0x0000000315c950 @name="yahoo.com", @keys={"s1024"=>#<DKIM::Query::Key:0x0000000315c9f0 @v=nil, @g=nil, @h=nil, @k=:rsa, @n="A 1024 bit key;", @p="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrEee0Ri4Juz+QfiWYui/E9UGSXau/2P8LjnTD8V4Unn+2FAZVGE3kL23bzeoULYv4PeleB3gfmJiDJOKU3Ns5L4KJAUUHjFwDebt0NP+sBK0VKeTATL2Yr/S3bT/xhy+1xtj4RkdV7fVxTn56Lb4udUnwuxK4V5b5PdOKj/+XcwIDAQAB", @s=nil, @t=nil>}>
47
-
48
- domain['s1024']
49
- # => #<DKIM::Query::Key:0x0000000315c9f0 @v=nil, @g=nil, @h=nil, @k=:rsa, @n="A 1024 bit key;", @p="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrEee0Ri4Juz+QfiWYui/E9UGSXau/2P8LjnTD8V4Unn+2FAZVGE3kL23bzeoULYv4PeleB3gfmJiDJOKU3Ns5L4KJAUUHjFwDebt0NP+sBK0VKeTATL2Yr/S3bT/xhy+1xtj4RkdV7fVxTn56Lb4udUnwuxK4V5b5PdOKj/+XcwIDAQAB", @s=nil, @t=nil>
50
-
51
- domain.each do |key|
52
- # ...
53
- end
54
-
55
- ## Synopsis
56
-
57
- Query a domain:
58
-
59
- dkim-query google.com
60
- ____________________________
61
- DKIM record search for google.com
62
- - using selectors: ["default", "dkim", "google"]
63
- - no DKIM record found for google.com
64
- ____________________________
65
-
66
-
67
- Query multiple domains:
68
-
69
- dkim-query trailofbits.com facebook.com yahoo.com
70
- ____________________________
71
- DKIM record search for trailofbits.com
72
- - using selectors: ["default", "dkim", "google", "trailofbits"]
73
- - found DKIM record for trailofbits.com at trailofbits._domainkey.trailofbits.com:
74
- v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwe04g1hSR55ACcRiLAg0MoEiY5BBviJHJHq/d9r6o+F50fa1TrNNulwKXaST+WCEcW6D2KZ+dt9JvgB9ApIEAFCzHRXhawga0GsfDkOllvpXgT95IPcnYrSkM+rJSbaqHh+YI5sV9sKnvzZDVmB7l5gU3yD74aDmjs9wSg8RC5wIDAQAB
75
- ____________________________
76
-
77
- ____________________________
78
- DKIM record search for facebook.com
79
- - using selectors: ["default", "dkim", "google", "facebook"]
80
- - found DKIM record for facebook.com at default._domainkey.facebook.com:
81
- t=y; k=rsa; p=MHwwDQYJKoZIhvcNAQEBBQADawAwaAJhALkZ4wTn2SQ3EW0vVBExi8izmZZnjZH8JIY5Y964jzDORZku43o6ooFq6HLMjBxmcDYOrJFRdcsKDWtI0Be/uLfc/rClXuyEbcENXfadg77HHv35BI85RNy4TKeai3hxoQIDAQAB;
82
- ____________________________
83
-
84
- ____________________________
85
- DKIM record search for yahoo.com
86
- - using selectors: ["default", "dkim", "google", "yahoo"]
87
- - no DKIM record found for yahoo.com
88
- ____________________________
89
-
90
- ## Requirements
91
-
92
- * [ruby] >= 1.9.1
93
- * [parslet] ~> 1.6
94
-
95
- ## Install
96
-
97
- $ gem install dkim-query
98
-
99
- ## License
100
-
101
- See the {file:LICENSE.txt} file.
102
-
103
- [DKIM]: https://tools.ietf.org/html/rfc6376
104
- [ruby]: https://www.ruby-lang.org/
105
- [parslet]: http://kschiess.github.io/parslet/
data/dkim-query/Rakefile DELETED
@@ -1,24 +0,0 @@
1
- # encoding: utf-8
2
- require 'rubygems'
3
-
4
- begin
5
- require 'bundler/setup'
6
- rescue LoadError => e
7
- warn e.message
8
- warn "Run `gem install bundler` to install Bundler."
9
- exit -1
10
- end
11
-
12
- require 'rake'
13
- require 'rubygems/tasks'
14
- Gem::Tasks.new
15
-
16
- require 'rspec/core/rake_task'
17
- RSpec::Core::RakeTask.new
18
-
19
- task :test => :spec
20
- task :default => :spec
21
-
22
- require 'yard'
23
- YARD::Rake::YardocTask.new
24
- task :doc => :yard
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- lib_dir = File.expand_path('../../lib',__FILE__)
4
- $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
5
-
6
- require 'dkim/query'
7
-
8
- unless ARGV[0]
9
- warn "Please supply at least one host name"
10
- exit
11
- end
12
-
13
- ARGV.each do |arg|
14
- puts "____________________________\n"
15
- puts "DKIM record search for #{arg}"
16
-
17
- domain = DKIM::Query::Domain.query(arg)
18
-
19
- unless domain.keys.empty?
20
- puts "- found DKIM record for #{arg}"
21
-
22
- domain.keys.each do |selector,key|
23
- puts " #{selector}:"
24
-
25
- [:v, :g, :h, :k, :n, :p, :s, :t].each do |field|
26
- value = key.send(field)
27
- puts " #{field}: #{value}" if value
28
- end
29
- end
30
- else
31
- puts "- no DKIM record found for #{arg}"
32
- end
33
- puts "____________________________\n\n"
34
- end
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'dkim/query/version'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.name = "dkim-query"
8
- gem.version = DKIM::Query::VERSION
9
- gem.authors = ["nicktitle"]
10
- gem.email = ["nick.esposito@trailofbits.com"]
11
- gem.summary = %q{DKIM Retriever and Parser}
12
- gem.description = %q{Search and retrieve DKIM records for any number of hosts}
13
- gem.homepage = "https://github.com/trailofbits/dkim-query#readme"
14
- gem.license = "MIT"
15
-
16
- gem.files = `git ls-files -z`.split("\x0")
17
- gem.executables = ['dkim-query']
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ["lib"]
20
- gem.required_ruby_version = '>= 1.9.1'
21
-
22
- gem.add_dependency "parslet", "~> 1.6"
23
-
24
- gem.add_development_dependency "bundler", "~> 1.6"
25
- gem.add_development_dependency "rake", "~> 10.0"
26
- end