ooxml_decrypt 0.1.0 → 1.0.0

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
- SHA256:
3
- metadata.gz: 84f71ccf2d737f1b14169099dfaae2d12bbc2ab527a97c44b84670d682b598be
4
- data.tar.gz: 5ed8efac3dffe9e9b2863443c5cf8a2fdb0a58c27f3e1f0156eeab9305bb3f42
2
+ SHA1:
3
+ metadata.gz: 6d07cc929ff8df49738470666db236138fd7f0ea
4
+ data.tar.gz: 5f64c2484844484959f5bfa03b868262d9096f2e
5
5
  SHA512:
6
- metadata.gz: 30fe6f7b9acbbaf6237cc34dd4d54730c88a695834f08196a8bcc0f15217c018a5efee7cf596efe2071dc0cd06957dc9262b32e0560e0fe1151800648aeb34d5
7
- data.tar.gz: a9a54b23a57528592bd41cdcdee322787cf0d45b0a4fbcf46fd8986cc9adda371f3688d8fbc8b52715fb662af695c02d28b806b9efc3c1b357fe960b5d138ff1
6
+ metadata.gz: 2d5849be67cc23e5b3ade74a84a2f388b7eb97f1e71c0537a834a777fd80cca1dd147bf82aaef159537909e2f51001deb2ff150750b4aeaf0f103025d9d68d57
7
+ data.tar.gz: b4a8c4af8c921499294808a81b5e3f9a4c723df9f939ccc5a8a7b8d9acc7650cbe61665e786c74d8f63c34750c7ff44378a13473141ba13073ce6d71002cf3a3
data/.gitignore CHANGED
@@ -33,3 +33,6 @@ Gemfile.lock
33
33
 
34
34
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
35
  .rvmrc
36
+
37
+ # rspec failure tracking
38
+ .rspec_status
@@ -0,0 +1,9 @@
1
+ ## [Unreleased]
2
+ *no unreleased changes*
3
+
4
+ ## 1.0.0 / 2019-05-08
5
+ ### Added
6
+ * Added Installation and Usage instructions to the README
7
+
8
+ ### Changed
9
+ * Moved the executable, removing the .rb file extention and added a shebang
data/README.md CHANGED
@@ -1,9 +1,59 @@
1
- # ooxml_decrypt [![Build Status](https://travis-ci.org/woodbusy/ooxml_decrypt.svg?branch=master)](https://travis-ci.org/woodbusy/ooxml_decrypt)
1
+ # OoxmlDecrypt [![Build Status](https://travis-ci.org/woodbusy/ooxml_decrypt.svg?branch=master)](https://travis-ci.org/woodbusy/ooxml_decrypt)
2
2
 
3
3
  A Ruby library and script for decrypting password-protected Microsoft Office XML files (.docx, .xlsx, etc.), which use the OOXML format. There are many tools available for working with OOXML files without Office, but a password-protected document typically requires an Office installation to decrypt. This pure-Ruby, standalone library and script can decrypt Office files without an Office installation.
4
4
 
5
5
  At present, this only supports documents encrypted (i.e. password-protected) by Office 2010 or later. Office 2007 also uses XML, but the encryption settings are a bit different.
6
6
 
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ooxml_decrypt'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ooxml_decrypt
22
+
23
+ ## Usage
24
+
25
+ ### Command Line Tool
26
+
27
+ If you installed the gem using Bundler, execute:
28
+
29
+ $ bundle exec ooxml_decrypt --source <path> --destination <path> --password <password>
30
+
31
+ otherwise use:
32
+
33
+ $ ooxml_decrypt --source <path> --destination <path> --password <password>
34
+
35
+ ### Within your code
36
+
37
+ To decrypt a file programatically:
38
+
39
+ ```ruby
40
+ require 'ooxml_decrypt'
41
+
42
+ encrypted_path = ...
43
+ decrypted_path = ...
44
+ # Ensure password is a binary representation of a UTF-16LE string
45
+ binary_password = password.encode("utf-16le")
46
+ .bytes.pack("c*")
47
+ .encode("binary")
48
+
49
+ OoxmlDecrypt::EncryptedFile.decrypt_to_file(encrypted_path, binary_password, decrypted_path)
50
+ ```
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
7
57
 
8
58
  ## Contributing
9
59
 
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
2
4
 
3
5
  require "ooxml_decrypt"
@@ -1,3 +1,4 @@
1
1
  require "ooxml_decrypt/key_data"
2
2
  require "ooxml_decrypt/encrypted_key"
3
3
  require "ooxml_decrypt/encrypted_file"
4
+ require "ooxml_decrypt/version"
@@ -0,0 +1,4 @@
1
+ # This stores the current version of the OoxmlDecrypt gem
2
+ module OoxmlDecrypt
3
+ VERSION = '1.0.0'.freeze
4
+ end
@@ -1,20 +1,30 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "ooxml_decrypt/version"
4
+
1
5
  Gem::Specification.new do |spec|
2
6
  spec.name = 'ooxml_decrypt'
3
- spec.version = '0.1.0'
7
+ spec.version = OoxmlDecrypt::VERSION
4
8
  spec.authors = %w[woodbusy phish]
5
9
  spec.summary = 'Ruby library and script for decrypting password-protected ' \
6
10
  'Microsoft Office XML files (.docx, .xlsx, etc.)'
7
11
  spec.homepage = 'https://github.com/woodbusy/ooxml_decrypt'
8
12
  spec.license = 'Apache-2.0'
9
13
 
10
- spec.files = `git ls-files -z`.split("\x0").reject { |s| s =~ %r{^pkg/} }
14
+ # Specify which files should be added to the gem when it is released.
15
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|spec)/}) }
18
+ end
11
19
  spec.files -= %w[.travis.yml] # Not needed in the gem
12
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
13
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
14
22
  spec.require_paths = ['lib']
15
23
 
16
- spec.add_dependency 'nokogiri'
17
- spec.add_dependency 'ruby-ole'
24
+ spec.add_dependency 'nokogiri', '~> 1.10'
25
+ spec.add_dependency 'ruby-ole', '~> 1.2'
18
26
 
27
+ spec.add_development_dependency 'bundler', '~> 2.0'
28
+ spec.add_development_dependency 'rake', '~> 12.3'
19
29
  spec.add_development_dependency 'rspec', '>= 2.11.0', '< 4.0'
20
30
  end
metadata CHANGED
@@ -1,44 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ooxml_decrypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - woodbusy
8
8
  - phish
9
9
  autorequire:
10
- bindir: bin
10
+ bindir: exe
11
11
  cert_chain: []
12
- date: 2019-05-07 00:00:00.000000000 Z
12
+ date: 2019-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: '1.10'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: '1.10'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: ruby-ole
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '1.2'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.2'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '12.3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
40
68
  - !ruby/object:Gem::Version
41
- version: '0'
69
+ version: '12.3'
42
70
  - !ruby/object:Gem::Dependency
43
71
  name: rspec
44
72
  requirement: !ruby/object:Gem::Requirement
@@ -62,30 +90,25 @@ dependencies:
62
90
  description:
63
91
  email:
64
92
  executables:
65
- - decrypt_ooxml.rb
93
+ - decrypt_ooxml
66
94
  extensions: []
67
95
  extra_rdoc_files: []
68
96
  files:
69
97
  - ".gitignore"
98
+ - CHANGELOG.md
70
99
  - Gemfile
71
100
  - LICENSE
72
101
  - README.md
73
- - bin/decrypt_ooxml.rb
102
+ - Rakefile
103
+ - exe/decrypt_ooxml
74
104
  - lib/ooxml_decrypt.rb
75
105
  - lib/ooxml_decrypt/encrypted_file.rb
76
106
  - lib/ooxml_decrypt/encrypted_key.rb
77
107
  - lib/ooxml_decrypt/key_data.rb
78
108
  - lib/ooxml_decrypt/key_info_base.rb
79
109
  - lib/ooxml_decrypt/string_helpers.rb
110
+ - lib/ooxml_decrypt/version.rb
80
111
  - ooxml_decrypt.gemspec
81
- - spec/crypto_spec.rb
82
- - spec/encrypted_file_spec.rb
83
- - spec/examples/1qaz2wsx.xlsx
84
- - spec/examples/password.encrypted_package
85
- - spec/examples/password.encryption_info
86
- - spec/examples/password.xlsx
87
- - spec/examples/password.xlsx_decrypted
88
- - spec/spec_helper.rb
89
112
  homepage: https://github.com/woodbusy/ooxml_decrypt
90
113
  licenses:
91
114
  - Apache-2.0
@@ -105,17 +128,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
128
  - !ruby/object:Gem::Version
106
129
  version: '0'
107
130
  requirements: []
108
- rubygems_version: 3.0.3
131
+ rubyforge_project:
132
+ rubygems_version: 2.5.2.3
109
133
  signing_key:
110
134
  specification_version: 4
111
135
  summary: Ruby library and script for decrypting password-protected Microsoft Office
112
136
  XML files (.docx, .xlsx, etc.)
113
- test_files:
114
- - spec/crypto_spec.rb
115
- - spec/encrypted_file_spec.rb
116
- - spec/examples/1qaz2wsx.xlsx
117
- - spec/examples/password.encrypted_package
118
- - spec/examples/password.encryption_info
119
- - spec/examples/password.xlsx
120
- - spec/examples/password.xlsx_decrypted
121
- - spec/spec_helper.rb
137
+ test_files: []
@@ -1,46 +0,0 @@
1
- require "spec_helper"
2
-
3
- module OoxmlDecrypt
4
- describe "When testing decryption" do
5
- let(:encrypted_key) do
6
- EncryptedKey.new( :spin_count => 100_000,
7
- :block_size => 16,
8
- :key_bits => 128,
9
- :cipher_algorithm => "AES",
10
- :cipher_chaining => "ChainingModeCBC",
11
- :hash_algorithm => "SHA1",
12
- :salt => "oksWUymFqdISO4t7krYTMQ==".base64_decode,
13
- :encrypted_key => "7fHCMYen4j6VmJtYiuoKdA==".base64_decode,
14
- )
15
- end
16
- let(:key_data) do
17
- KeyData.new( :block_size => 16,
18
- :key_bits => 128,
19
- :cipher_algorithm => "AES",
20
- :cipher_chaining => "ChainingModeCBC",
21
- :hash_algorithm => "SHA1",
22
- :salt => "O/HT8XgDoXnw+k9ts0Esxw==".base64_decode,
23
- )
24
- end
25
- let(:password) { "p\0a\0s\0s\0w\0o\0r\0d\0" }
26
-
27
- # it "should generate a key-decryption key" do
28
- # key_encryption_key = encrypted_key.key_encryption_key(password)
29
- # expect( key_encryption_key.hexify ).to eql("1a1f6755f5a4f216023707fa3c986502")
30
- # end
31
-
32
- it "should decrypt a symmetric key" do
33
- expect( encrypted_key.key(password).hexify ).to eql("c965e405bc4183399e038d3784d26f93")
34
- end
35
-
36
- it "should decrypt an entire encrypted package stream" do
37
- encrypted_package = File.read("spec/examples/password.encrypted_package", :encoding => 'binary')
38
- plaintext = key_data.decrypt_encrypted_package_stream( encrypted_package, encrypted_key.key(password) )
39
- expect(plaintext[0,16].hexify).to eql("504b0304140006000800000021009745")
40
- expect(plaintext[-16,16].hexify).to eql("0000090009003e020000731b00000000")
41
-
42
- expected_plaintext = File.read("spec/examples/password.xlsx_decrypted", :encoding => "binary")
43
- expect(plaintext.hexify).to eql(expected_plaintext.hexify)
44
- end
45
- end
46
- end
@@ -1,17 +0,0 @@
1
- require "spec_helper"
2
-
3
- module OoxmlDecrypt
4
- describe EncryptedFile do
5
- it "should decrypt an encrypted XLSX" do
6
- password = "p\0a\0s\0s\0w\0o\0r\0d\0"
7
- filename = "spec/examples/password.xlsx"
8
- plaintext = EncryptedFile.decrypt(filename, password)
9
-
10
- expect(plaintext[0,16].hexify).to eql("504b0304140006000800000021009745")
11
- expect(plaintext[-16,16].hexify).to eql("0000090009003e020000731b00000000")
12
-
13
- expected_plaintext = File.read("spec/examples/password.xlsx_decrypted", :encoding => "binary")
14
- expect(plaintext.hexify).to eql(expected_plaintext.hexify)
15
- end
16
- end
17
- end
Binary file
Binary file
@@ -1,2 +0,0 @@
1
- require "ooxml_decrypt"
2
- require "ooxml_decrypt/string_helpers"