cloak 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "commander", ">= 1.0"
7
+ gem "bcrypt-ruby", ">= 3.0"
8
+ gem "crypt19", ">= 1.0"
9
+ gem "highline", ">= 1.0"
10
+
11
+ # Add dependencies to develop your gem here.
12
+ # Include everything needed to run rake, tests, features, etc.
13
+ group :development do
14
+ gem "rspec", ">= 2.3.0"
15
+ gem "bundler", "~> 1.0.0"
16
+ gem "jeweler", "~> 1.6.4"
17
+ gem "rcov", ">= 0"
18
+ end
@@ -0,0 +1,37 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ bcrypt-ruby (3.0.0)
5
+ commander (4.0.5)
6
+ highline (>= 1.5.0)
7
+ crypt19 (1.2.1)
8
+ diff-lcs (1.1.3)
9
+ git (1.2.5)
10
+ highline (1.6.2)
11
+ jeweler (1.6.4)
12
+ bundler (~> 1.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ rake (0.9.2)
16
+ rcov (0.9.10)
17
+ rspec (2.6.0)
18
+ rspec-core (~> 2.6.0)
19
+ rspec-expectations (~> 2.6.0)
20
+ rspec-mocks (~> 2.6.0)
21
+ rspec-core (2.6.4)
22
+ rspec-expectations (2.6.0)
23
+ diff-lcs (~> 1.1.2)
24
+ rspec-mocks (2.6.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bcrypt-ruby (>= 3.0)
31
+ bundler (~> 1.0.0)
32
+ commander (>= 1.0)
33
+ crypt19 (>= 1.0)
34
+ highline (>= 1.0)
35
+ jeweler (~> 1.6.4)
36
+ rcov
37
+ rspec (>= 2.3.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jason Lagaac
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ = Cloak
2
+
3
+ CLOAK is a simple encrypted password storage system.
4
+ It allows users to store passwords and don't have to
5
+ continually remember them. Just fire it up and it'll
6
+ tell you :)
7
+
8
+ == Installation
9
+
10
+ $ gem install cloak
11
+
12
+ == Getting Started
13
+
14
+ To start using CLOAK, you have to initialise it first.
15
+
16
+ $ cloak init
17
+
18
+ This will then prompt you for a password to secure access
19
+ to your cloak entries. This command also creates two files
20
+ .cloak_password (Your password hash) and .cloak
21
+
22
+ == Adding Entires
23
+
24
+ To add an entry, do the following:
25
+
26
+ $ cloak add "A Password That I NEED to Remember"
27
+
28
+ This will then prompt your for your cloak password and ask for the password to be secured.
29
+ Cloak will then encrypt the entry. Done.
30
+
31
+
32
+ == View Entries
33
+
34
+ To view your passwords:
35
+
36
+ $ cloak list
37
+
38
+ This will show you all your entries
39
+
40
+ == Remove an Entry
41
+
42
+ To remove an entry:
43
+
44
+ $ cloak remove <entry number in list>
45
+
46
+ Usually you'd list them first and see the ones that you want to delete.
47
+
48
+ == Clear all Entries
49
+
50
+ To clear / purge all stored entries
51
+
52
+ $ cloak clear
53
+
54
+
55
+
56
+ == Contributing to cloak
57
+
58
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
59
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
60
+ * Fork the project
61
+ * Start a feature/bugfix branch
62
+ * Commit and push until you are happy with your contribution
63
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
64
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
65
+
66
+ == Copyright
67
+
68
+ Copyright (c) 2011 Jason Lagaac. See LICENSE.txt for
69
+ further details.
70
+
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "cloak"
18
+ gem.version = "0.0.1"
19
+
20
+ gem.homepage = "http://github.com/safetyscissors/cloak"
21
+ gem.license = "GNU GPL 3.0"
22
+ gem.summary = %Q{Cloak is a simple encrypted password storage system}
23
+ gem.description = %Q{Cloak is a simple encrypted password storage system which uses crypt}
24
+ gem.email = "jason.lagaac@me.com"
25
+ gem.authors = ["Jason Lagaac"]
26
+
27
+ gem.executables << "cloak"
28
+
29
+ # dependencies defined in Gemfile
30
+
31
+ gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
32
+
33
+ end
34
+ Jeweler::RubygemsDotOrgTasks.new
35
+
36
+ require 'rspec/core'
37
+ require 'rspec/core/rake_task'
38
+ RSpec::Core::RakeTask.new(:spec) do |spec|
39
+ spec.pattern = FileList['spec/**/*_spec.rb']
40
+ end
41
+
42
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
43
+ spec.pattern = 'spec/**/*_spec.rb'
44
+ spec.rcov = true
45
+ end
46
+
47
+ task :default => :spec
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
+
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "cloak #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.dirname(__FILE__) + '/../lib'
4
+ require 'rubygems'
5
+ require 'commander/import'
6
+ require 'highline'
7
+ require 'bcrypt'
8
+ require 'cloak'
9
+
10
+
11
+ ##
12
+ #Setup Information
13
+ program :version, Cloak::VERSION
14
+ program :description, "
15
+ CLOAK is a simple password storage and reminder
16
+ system that stores all your credentials in an
17
+ encrypted format using the Blowfish cipher. So all
18
+ you need now is to remember a single password.
19
+
20
+ DISCLAIMER:
21
+ Even though Blowfish is not broken, I'd like to say
22
+ that I would not want to save really sensitive data
23
+ using Cloak. Maybe just some non-trivial stuff, like
24
+ twitter or logins that don't really matter.
25
+
26
+ !!! USE AT YOUR OWN RISK !!!
27
+ "
28
+
29
+ program :help, 'Getting Started', "
30
+ To get started with cloak, please execute the following:
31
+
32
+ cloak init
33
+
34
+ This will initialise your password and the necessary files.
35
+ "
36
+
37
+ program :help, 'Author', "Jason Lagaac <lagaac.j@gmail.com>"
38
+
39
+
40
+ default_command :help
41
+ list = Cloak::List.new
42
+
43
+ command :init do |c|
44
+ c.summary = 'Initialise cloak'
45
+ c.syntax = 'cloak init'
46
+ c.description = 'Initialise cloak'
47
+
48
+ c.action do |args, options|
49
+ begin
50
+ file_path = File.expand_path("~/.cloak_password")
51
+ if !File.exist?(file_path)
52
+ cloak_password = password "Please enter your cloak password: ", ""
53
+ cloak_password_confirm = password "Please confirm your cloak password: ", ""
54
+
55
+ if (cloak_password.eql?(cloak_password_confirm))
56
+ password = BCrypt::Password.create(cloak_password)
57
+ File.open(file_path, "w") do |file|
58
+ file.write(password)
59
+ end
60
+ Cloak::List.new
61
+ say "Cloak successfully configured"
62
+ else
63
+ raise "Error: Your passwords do not match"
64
+ end
65
+ else
66
+ raise "Error: Cloak is already configured"
67
+ end
68
+ rescue Exception => e
69
+ puts e.message
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ command :add do |c|
76
+ c.summary = 'Add a new entry'
77
+ c.syntax = 'cloak add \'<item description>\''
78
+ c.description = 'Add a new entry to the list'
79
+
80
+ c.action do |args, options|
81
+ begin
82
+ raise "Please enter a valid Description. Eg: cloak add \"Twitter Password\"" if (args.count == 0)
83
+
84
+ cloak_password = password "Please enter your cloak password: ", ""
85
+
86
+ if (Cloak.verify_password(cloak_password))
87
+ password_stored = password "Please enter the password to be stored: ", ""
88
+ password_stored_confirm = password "Please confirm the password to be stored: ", ""
89
+
90
+ if (password_stored.chomp.eql?(password_stored_confirm.chomp))
91
+ entry = Cloak::Entry.new(args.first)
92
+ entry.encrypt(password_stored, cloak_password)
93
+
94
+ list << entry
95
+ list.save
96
+ say "\"#{entry.description}\" - Added"
97
+ else
98
+ raise "The passwords to be stored do not match. Please try again."
99
+ end
100
+ end
101
+ rescue Exception => e
102
+ say e.message + "\n"
103
+ end
104
+ end
105
+
106
+ end
107
+
108
+ command :list do |c|
109
+ c.summary = 'List all entries'
110
+ c.syntax = "cloak list"
111
+ c.description = "List all entries stored"
112
+
113
+ c.action do |args, options|
114
+ begin
115
+
116
+ cloak_password = password "Please enter your cloak password: ", ""
117
+
118
+ if (Cloak.verify_password(cloak_password))
119
+ list.entries.each_with_index do | entry, i |
120
+ say '%2d. %-45s : %s' % [i, entry.description, entry.decrypt(cloak_password)]
121
+ end
122
+ end
123
+ rescue Exception
124
+ puts ""
125
+ end
126
+ end
127
+
128
+ end
129
+
130
+ command :remove do |c|
131
+ c.summary = 'Remove an entry'
132
+ c.syntax = 'cloak remove <item number>'
133
+ c.description = 'Remove an entry from the list'
134
+
135
+ c.action do |args, options|
136
+ begin
137
+ cloak_password = password "Please enter your cloak password: ", ""
138
+
139
+ raise "Invalid entry: " + args.first + " - Please try again." if !list.entries.at(args.first.to_i)
140
+
141
+ if (Cloak.verify_password(cloak_password))
142
+ entry = list.entries.delete_at(args.first.to_i)
143
+ list.save
144
+ say entry.description + " - removed"
145
+ end
146
+ rescue Exception => e
147
+ puts e
148
+ end
149
+ end
150
+
151
+ end
152
+
153
+ command :clear do |c|
154
+ c.summary = 'Remove all entries'
155
+ c.syntax = 'cloak clear'
156
+ c.description = 'Remove all entries'
157
+
158
+ c.action do |args, options|
159
+ begin
160
+ cloak_password = password "Please enter your cloak password: ", ""
161
+
162
+ if (Cloak.verify_password(cloak_password))
163
+ list.entries.clear
164
+ list.save
165
+ end
166
+ rescue Exception
167
+ puts ""
168
+ end
169
+ end
170
+
171
+ end
@@ -0,0 +1,23 @@
1
+ require 'yaml'
2
+ require 'crypt/blowfish'
3
+ require 'cloak/entry'
4
+ require 'cloak/list'
5
+ require 'cloak/version'
6
+
7
+
8
+ ##
9
+ # General Functions
10
+
11
+ module Cloak
12
+ extend self
13
+
14
+ def verify_password(password)
15
+ password_file = File.expand_path("~/.cloak_password")
16
+ cloak_password = File.new(password_file, "r")
17
+ password_hash = cloak_password.gets
18
+ hashed_password = BCrypt::Password.new(password_hash)
19
+
20
+ return hashed_password == password
21
+ end
22
+
23
+ end
@@ -0,0 +1,30 @@
1
+ module Cloak
2
+ class Entry
3
+
4
+ ##
5
+ # Password in clear
6
+ attr_accessor :password
7
+
8
+ ##
9
+ # Description
10
+ attr_accessor :description
11
+
12
+ ##
13
+ # Initialise with secret
14
+ def initialize(description = nil)
15
+ @password = nil
16
+ @description = description or raise 'Please enter a description of your entry'
17
+ end
18
+
19
+ def encrypt(password_data, key)
20
+ blowfish = Crypt::Blowfish.new(key)
21
+ @password = blowfish.encrypt_string(password_data)
22
+ @password.force_encoding("BINARY")
23
+ end
24
+
25
+ def decrypt(key)
26
+ blowfish = Crypt::Blowfish.new(key)
27
+ blowfish.decrypt_string(@password)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,51 @@
1
+ module Cloak
2
+ class List
3
+ ##
4
+ # List Path
5
+ attr_reader :path
6
+
7
+ ##
8
+ # Entries Array
9
+ attr_accessor :entries
10
+
11
+ def initialize
12
+ @path = File.expand_path('~/.cloak')
13
+ @entries = []
14
+ load rescue save
15
+ end
16
+
17
+ ##
18
+ # Append entries to the array
19
+ def add(entry)
20
+ @entries << entry
21
+ end
22
+ alias :<< :add
23
+
24
+ ##
25
+ # Save all entries to the specified path
26
+ def save
27
+ set_entry_encoding
28
+ File.open(path, "wb") do |file|
29
+ file.write YAML.dump(entries)
30
+ end
31
+ self
32
+ end
33
+
34
+ ##
35
+ # Load the all entries into the array
36
+ def load
37
+ @entries = YAML.load_file path
38
+ @entries = [] if !@entries
39
+ self
40
+ end
41
+
42
+ private
43
+
44
+ def set_entry_encoding
45
+ @entries.each do |e|
46
+ e.password.force_encoding("BINARY")
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Cloak
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloak
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Lagaac
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: commander
16
+ requirement: &70209517525680 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70209517525680
25
+ - !ruby/object:Gem::Dependency
26
+ name: bcrypt-ruby
27
+ requirement: &70209517525100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70209517525100
36
+ - !ruby/object:Gem::Dependency
37
+ name: crypt19
38
+ requirement: &70209517524460 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70209517524460
47
+ - !ruby/object:Gem::Dependency
48
+ name: highline
49
+ requirement: &70209517523880 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70209517523880
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70209517523280 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 2.3.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70209517523280
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: &70209517522800 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.0.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70209517522800
80
+ - !ruby/object:Gem::Dependency
81
+ name: jeweler
82
+ requirement: &70209517522240 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 1.6.4
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70209517522240
91
+ - !ruby/object:Gem::Dependency
92
+ name: rcov
93
+ requirement: &70209517521600 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70209517521600
102
+ description: Cloak is a simple encrypted password storage system which uses crypt
103
+ email: jason.lagaac@me.com
104
+ executables:
105
+ - cloak
106
+ extensions: []
107
+ extra_rdoc_files:
108
+ - LICENSE.txt
109
+ - README.rdoc
110
+ files:
111
+ - Gemfile
112
+ - Gemfile.lock
113
+ - LICENSE.txt
114
+ - README.rdoc
115
+ - Rakefile
116
+ - bin/cloak
117
+ - lib/cloak.rb
118
+ - lib/cloak/entry.rb
119
+ - lib/cloak/list.rb
120
+ - lib/cloak/version.rb
121
+ homepage: http://github.com/safetyscissors/cloak
122
+ licenses:
123
+ - GNU GPL 3.0
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ segments:
135
+ - 0
136
+ hash: -4214918684740020380
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 1.8.10
146
+ signing_key:
147
+ specification_version: 3
148
+ summary: Cloak is a simple encrypted password storage system
149
+ test_files: []