shh 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -20
- data/README.rdoc +7 -7
- data/bin/shh +4 -4
- data/lib/shh/cli.rb +92 -92
- data/lib/shh/clipboard.rb +13 -9
- data/lib/shh/crypt.rb +24 -24
- data/lib/shh/darwin10_clipboard.rb +5 -0
- data/lib/shh/win32_clipboard.rb +7 -15
- metadata +2 -1
data/MIT-LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2009 Mark Ryall
|
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.
|
1
|
+
Copyright (c) 2009 Mark Ryall
|
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.
|
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
= SHH
|
2
|
-
|
3
|
-
Secret Squirrel
|
4
|
-
|
5
|
-
This is a command line utility for managing secure information such as accounts, passwords as individual files so that they can be easily managed in a version control repository.
|
6
|
-
|
7
|
-
You won't be hiding anything from the NSA with this level of encryption so it isn't recommended that you make your repository publicly accessible.
|
1
|
+
= SHH
|
2
|
+
|
3
|
+
Secret Squirrel
|
4
|
+
|
5
|
+
This is a command line utility for managing secure information such as accounts, passwords as individual files so that they can be easily managed in a version control repository.
|
6
|
+
|
7
|
+
You won't be hiding anything from the NSA with this level of encryption so it isn't recommended that you make your repository publicly accessible.
|
data/bin/shh
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift File.dirname(__FILE__)+'/../lib'
|
4
|
-
require 'shh'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.dirname(__FILE__)+'/../lib'
|
4
|
+
require 'shh'
|
5
5
|
Shh::Cli.new.execute(*ARGV)
|
data/lib/shh/cli.rb
CHANGED
@@ -1,92 +1,92 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'pathname2'
|
3
|
-
require 'highline/import'
|
4
|
-
require 'uuidtools'
|
5
|
-
require 'yaml'
|
6
|
-
require 'shh/crypt'
|
7
|
-
require 'shh/clipboard'
|
8
|
-
|
9
|
-
module Shh
|
10
|
-
class Cli
|
11
|
-
def execute *args
|
12
|
-
passphrase = ask('Enter your passphrase') { |q| q.echo = false }
|
13
|
-
|
14
|
-
@folder = Pathname.new('secret')
|
15
|
-
@folder.mkdir_p
|
16
|
-
@crypt = Crypt.new(passphrase)
|
17
|
-
@clipboard = Shh.clipboard
|
18
|
-
|
19
|
-
loop do
|
20
|
-
choose do |menu|
|
21
|
-
menu.layout = :menu_only
|
22
|
-
menu.shell = true
|
23
|
-
menu.choice('list entries') { list }
|
24
|
-
menu.choice('edit entry') { |command, details| edit details }
|
25
|
-
menu.choice('view entry') { |command, details| view details }
|
26
|
-
menu.choice('quit') { exit }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def list
|
32
|
-
each_entry {|entry| say "#{entry['name']} (#{entry['id']})" }
|
33
|
-
end
|
34
|
-
|
35
|
-
def edit name=''
|
36
|
-
entry = find_entry(check_name(name))
|
37
|
-
entry ||= {'name' => check_name(name), 'id' => UUIDTools::UUID.random_create.to_s}
|
38
|
-
persist_entry prompt_loop(entry)
|
39
|
-
end
|
40
|
-
|
41
|
-
def view name=''
|
42
|
-
prompt_loop find_entry(check_name(name)), true
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def each_entry
|
48
|
-
@folder.children.each do |child|
|
49
|
-
yield load_entry(child)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def check_name name
|
54
|
-
name = ask('Enter the entry name') unless name.size > 0
|
55
|
-
name
|
56
|
-
end
|
57
|
-
|
58
|
-
def find_entry name
|
59
|
-
each_entry {|e| return e if e['name'] == name}
|
60
|
-
nil
|
61
|
-
end
|
62
|
-
|
63
|
-
def load_entry path
|
64
|
-
entry = path.open('rb') {|io| @crypt.decrypt(io) }
|
65
|
-
YAML::load(entry)
|
66
|
-
end
|
67
|
-
|
68
|
-
def persist_entry entry
|
69
|
-
(@folder + entry['id']).open('wb') {|io| @crypt.encrypt(entry.to_yaml, io) }
|
70
|
-
end
|
71
|
-
|
72
|
-
def prompt_loop hash, read_only=false
|
73
|
-
loop do
|
74
|
-
choose do |menu|
|
75
|
-
menu.layout = :menu_only
|
76
|
-
menu.shell = true
|
77
|
-
menu.choice('edit key') { |command, name| hash[name] = new_value(name) } unless read_only
|
78
|
-
menu.choice('list keys') { say(hash.keys.sort.join(',')) }
|
79
|
-
menu.choice('show key') { |command, name| say(hash[name]) if hash[name] }
|
80
|
-
menu.choice('delete key') { |command, name| hash[name] = nil } unless read_only
|
81
|
-
menu.choice('copy key') { |command, name| @clipboard.content = hash[name] } if @clipboard
|
82
|
-
menu.choice('quit') { return hash }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def new_value name
|
88
|
-
echo = (name =~ /pass/) ? false : true
|
89
|
-
ask("Enter new value for #{name}") {|q| q.echo = echo }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'pathname2'
|
3
|
+
require 'highline/import'
|
4
|
+
require 'uuidtools'
|
5
|
+
require 'yaml'
|
6
|
+
require 'shh/crypt'
|
7
|
+
require 'shh/clipboard'
|
8
|
+
|
9
|
+
module Shh
|
10
|
+
class Cli
|
11
|
+
def execute *args
|
12
|
+
passphrase = ask('Enter your passphrase') { |q| q.echo = false }
|
13
|
+
|
14
|
+
@folder = Pathname.new('secret')
|
15
|
+
@folder.mkdir_p
|
16
|
+
@crypt = Crypt.new(passphrase)
|
17
|
+
@clipboard = Shh.clipboard
|
18
|
+
|
19
|
+
loop do
|
20
|
+
choose do |menu|
|
21
|
+
menu.layout = :menu_only
|
22
|
+
menu.shell = true
|
23
|
+
menu.choice('list entries') { list }
|
24
|
+
menu.choice('edit entry') { |command, details| edit details }
|
25
|
+
menu.choice('view entry') { |command, details| view details }
|
26
|
+
menu.choice('quit') { exit }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def list
|
32
|
+
each_entry {|entry| say "#{entry['name']} (#{entry['id']})" }
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit name=''
|
36
|
+
entry = find_entry(check_name(name))
|
37
|
+
entry ||= {'name' => check_name(name), 'id' => UUIDTools::UUID.random_create.to_s}
|
38
|
+
persist_entry prompt_loop(entry)
|
39
|
+
end
|
40
|
+
|
41
|
+
def view name=''
|
42
|
+
prompt_loop find_entry(check_name(name)), true
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def each_entry
|
48
|
+
@folder.children.each do |child|
|
49
|
+
yield load_entry(child)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def check_name name
|
54
|
+
name = ask('Enter the entry name') unless name.size > 0
|
55
|
+
name
|
56
|
+
end
|
57
|
+
|
58
|
+
def find_entry name
|
59
|
+
each_entry {|e| return e if e['name'] == name}
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_entry path
|
64
|
+
entry = path.open('rb') {|io| @crypt.decrypt(io) }
|
65
|
+
YAML::load(entry)
|
66
|
+
end
|
67
|
+
|
68
|
+
def persist_entry entry
|
69
|
+
(@folder + entry['id']).open('wb') {|io| @crypt.encrypt(entry.to_yaml, io) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def prompt_loop hash, read_only=false
|
73
|
+
loop do
|
74
|
+
choose do |menu|
|
75
|
+
menu.layout = :menu_only
|
76
|
+
menu.shell = true
|
77
|
+
menu.choice('edit key') { |command, name| hash[name] = new_value(name) } unless read_only
|
78
|
+
menu.choice('list keys') { say(hash.keys.sort.join(',')) }
|
79
|
+
menu.choice('show key') { |command, name| say(hash[name]) if hash[name] }
|
80
|
+
menu.choice('delete key') { |command, name| hash[name] = nil } unless read_only
|
81
|
+
menu.choice('copy key') { |command, name| @clipboard.content = hash[name] } if @clipboard
|
82
|
+
menu.choice('quit') { return hash }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def new_value name
|
88
|
+
echo = (name =~ /pass/) ? false : true
|
89
|
+
ask("Enter new value for #{name}") {|q| q.echo = echo }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/shh/clipboard.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
module Shh
|
2
|
-
def self.clipboard
|
3
|
-
if RUBY_PLATFORM =~ /mswin32/
|
4
|
-
require 'shh/win32_clipboard'
|
5
|
-
return Win32Clipboard.new
|
6
|
-
end
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
module Shh
|
2
|
+
def self.clipboard
|
3
|
+
if RUBY_PLATFORM =~ /mswin32/
|
4
|
+
require 'shh/win32_clipboard'
|
5
|
+
return Win32Clipboard.new
|
6
|
+
end
|
7
|
+
if RUBY_PLATFORM =~ /darwin10/
|
8
|
+
require 'shh/darwin10_clipboard'
|
9
|
+
return Darwin10Clipboard.new
|
10
|
+
end
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
end
|
data/lib/shh/crypt.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
require 'crypt/blowfish'
|
2
|
-
|
3
|
-
module Shh
|
4
|
-
class Crypt
|
5
|
-
def initialize passphrase
|
6
|
-
@blowfish = ::Crypt::Blowfish.new(passphrase)
|
7
|
-
end
|
8
|
-
|
9
|
-
def encrypt text, out_io
|
10
|
-
in_io = StringIO.new(text)
|
11
|
-
while l = in_io.read(8) do
|
12
|
-
while l.size < 8 do l += "\0" end
|
13
|
-
out_io.print @blowfish.encrypt_block(l)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def decrypt in_io
|
18
|
-
out_io = StringIO.new
|
19
|
-
while l = in_io.read(8) do
|
20
|
-
out_io.print @blowfish.decrypt_block(l)
|
21
|
-
end
|
22
|
-
out_io.string.gsub("\0",'')
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require 'crypt/blowfish'
|
2
|
+
|
3
|
+
module Shh
|
4
|
+
class Crypt
|
5
|
+
def initialize passphrase
|
6
|
+
@blowfish = ::Crypt::Blowfish.new(passphrase)
|
7
|
+
end
|
8
|
+
|
9
|
+
def encrypt text, out_io
|
10
|
+
in_io = StringIO.new(text)
|
11
|
+
while l = in_io.read(8) do
|
12
|
+
while l.size < 8 do l += "\0" end
|
13
|
+
out_io.print @blowfish.encrypt_block(l)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def decrypt in_io
|
18
|
+
out_io = StringIO.new
|
19
|
+
while l = in_io.read(8) do
|
20
|
+
out_io.print @blowfish.decrypt_block(l)
|
21
|
+
end
|
22
|
+
out_io.string.gsub("\0",'')
|
23
|
+
end
|
24
|
+
end
|
25
25
|
end
|
data/lib/shh/win32_clipboard.rb
CHANGED
@@ -1,15 +1,7 @@
|
|
1
|
-
require 'win32/clipboard'
|
2
|
-
|
3
|
-
class Win32Clipboard
|
4
|
-
def content
|
5
|
-
Win32::Clipboard.
|
6
|
-
end
|
7
|
-
|
8
|
-
def content= text
|
9
|
-
Win32::Clipboard.set_data(text)
|
10
|
-
end
|
11
|
-
|
12
|
-
def clear
|
13
|
-
Win32::Clipboard.empty
|
14
|
-
end
|
15
|
-
end
|
1
|
+
require 'win32/clipboard'
|
2
|
+
|
3
|
+
class Win32Clipboard
|
4
|
+
def content= text
|
5
|
+
Win32::Clipboard.set_data(text)
|
6
|
+
end
|
7
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Ryall
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/shh/cli.rb
|
67
67
|
- lib/shh/clipboard.rb
|
68
68
|
- lib/shh/crypt.rb
|
69
|
+
- lib/shh/darwin10_clipboard.rb
|
69
70
|
- lib/shh/win32_clipboard.rb
|
70
71
|
- lib/shh.rb
|
71
72
|
- bin/shh
|