remmina 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07c051fd9ca21ed990b810036697c3203a2b895b
4
+ data.tar.gz: 2cd95740d2015667e4f6b66273df932327fd5bfe
5
+ SHA512:
6
+ metadata.gz: 18ba3977741be3ef5bd28b0766a078673d5d625677952a0e56667f533e96c0e1832338694b629c8691b497107d911978a516cae9bb5482fe57cc51939d7db613
7
+ data.tar.gz: b480d4a88d7cfea86162135a3465d8eeec298ca1f94defefb5be51ed5437d84cf3519965e537bea4c23a96f34eb0bf5f1be80ab339153737436faf24cea800ca
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at kost@linux.hr. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in remmina.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Vlatko Kosturjak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,82 @@
1
+ # Remmina
2
+
3
+ Ruby support classes for Remmina. You can encrypt and decrypt password, dump passwords and
4
+ read config files.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'remmina'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install remmina
21
+
22
+ ## Usage command line
23
+
24
+ If you just need to dumo the password after gem installation, just type:
25
+ ```
26
+ remmina-dump
27
+ ```
28
+
29
+ ## Usage in Ruby
30
+
31
+
32
+ Basic decryption example:
33
+
34
+ ```ruby
35
+ require "remmina"
36
+
37
+ secretstr='FeIQ1I6+cs5dpS2yvHruae3KKiE8YXKMBs2yFiN0Yjg='
38
+ pass=Remmina::Password.new('secret'=>secretstr)
39
+ enchash=pass.encrypt_password('test')
40
+ puts enchash
41
+ ```
42
+
43
+ Basic encryption example:
44
+
45
+ ```ruby
46
+ require "remmina"
47
+
48
+ secretstr='FeIQ1I6+cs5dpS2yvHruae3KKiE8YXKMBs2yFiN0Yjg='
49
+ pass=Remmina::Password.new('secret'=>secretstr)
50
+ plain=pass.decrypt_password('kl7zf+xc7g4=')
51
+ puts plain
52
+ ```
53
+
54
+ Basic decryption example (reading secret from default configuration location):
55
+
56
+ ```ruby
57
+ require "remmina"
58
+
59
+ config=Remmina::Config.new
60
+ secretstr=config.readsecret(config.deflocation)
61
+
62
+ pass=Remmina::Password.new('secret'=>secretstr)
63
+ encrypted="kl7zf+xc7g4="
64
+ plain = pass.decrypt_password(encrypted)
65
+ puts plain
66
+ ```
67
+
68
+ ## Development
69
+
70
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
71
+
72
+ 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).
73
+
74
+ ## Contributing
75
+
76
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/remmina. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
77
+
78
+
79
+ ## License
80
+
81
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
82
+
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "remmina"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/pry ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "remmina"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
11
+
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'remmina'
5
+ require 'optparse'
6
+
7
+ config=Remmina::Config.new
8
+
9
+ $PRGNAME='remmina-dump'
10
+ $options={}
11
+ $options['preferences']=config.deflocation
12
+
13
+ OptionParser.new do |opts|
14
+ opts.banner = "Usage: #{$PRGNAME} [options]"
15
+
16
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
17
+ $options['verbose'] = v
18
+ end
19
+
20
+ opts.on("-d", "--[no-]debug", "Run in debug mode") do |v|
21
+ $options['debug'] = v
22
+ end
23
+
24
+ opts.on("-c", "--config DIR", "specify config DIR location of Remmina") do |optarg|
25
+ $options['config'] = optarg
26
+ end
27
+
28
+ opts.on("-r", "--pref FILE", "use different preferences FILE") do |optarg|
29
+ $options['preferences'] = optarg
30
+ end
31
+
32
+ opts.on("-f", "--file FILE", "decrypt from following file") do |optarg|
33
+ $options['file'] = optarg
34
+ end
35
+
36
+ opts.on("-s", "--secret SECRET", "use SECRET as global secret") do |optarg|
37
+ $options['secret'] = optarg
38
+ end
39
+
40
+ opts.on("-p", "--password ENCPASS", "use ENCPASS as encrypted password") do |optarg|
41
+ $options['password'] = optarg
42
+ end
43
+
44
+ opts.on("-h", "--help", "Prints this help") do
45
+ puts opts
46
+ exit
47
+ end
48
+
49
+ opts.separator ""
50
+ opts.separator "Example #1: #{$PRGNAME}"
51
+ opts.separator "Example #2: #{$PRGNAME} -s FeIQ1I6+cs5dpS2yvHruae3KKiE8YXKMBs2yFiN0Yjg= -p kl7zf+xc7g4="
52
+ end.parse!
53
+
54
+
55
+ unless $options['config'] then
56
+ $options['config'] = config.confdir
57
+ end
58
+
59
+ unless $options['preferences'] then
60
+ $options['preferences']=$options['config'] + "/" + config.preffile
61
+ end
62
+
63
+ unless $options['secret'] then
64
+ $options['secret']=config.readsecret($options['preferences'])
65
+ end
66
+
67
+ pass=Remmina::Password.new('secret'=>$options['secret'])
68
+
69
+ def decrypt(config,pass,file)
70
+ conn=config.loadini(file)
71
+ password=''
72
+ encrypted=conn['remmina']['password']
73
+ unless encrypted == '' then
74
+ password = pass.decrypt_password(encrypted)
75
+ end
76
+ printf "%-16s %-15s %-20s %s\n",conn['remmina']['server'],conn['remmina']['domain'],conn['remmina']['username'],password
77
+
78
+ end
79
+
80
+ if $options['password'] then
81
+ password = pass.decrypt_password($options['password'])
82
+ puts password
83
+ exit 0
84
+ end
85
+
86
+ if $options['file'] then
87
+ decrypt(config,pass,$options['file'])
88
+ exit 0
89
+ end
90
+
91
+
92
+ Dir.glob($options['config']+'/[0-9]*.remmina') do |file|
93
+ # puts file
94
+ decrypt(config,pass,file)
95
+ end
96
+
@@ -0,0 +1,7 @@
1
+ require "remmina/version"
2
+ require "remmina/config"
3
+ require "remmina/password"
4
+
5
+ module Remmina
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module Remmina
4
+
5
+ class Config
6
+
7
+ def confdir
8
+ confdir=ENV['HOME']+"/"+'.remmina/'
9
+ return confdir
10
+ end
11
+
12
+ def preffile
13
+ return 'remmina.pref'
14
+ end
15
+
16
+ def deflocation
17
+ conffile=confdir+preffile
18
+ return conffile
19
+ end
20
+
21
+
22
+ def loadini(file)
23
+ ini = Hash.new
24
+ cur_section = nil
25
+
26
+ File.open(file).each do |line|
27
+
28
+ if line.strip.split(';').first =~ /^\[(.*)\]$/
29
+ cur_section = $1
30
+ ini[cur_section] = Hash.new
31
+ next
32
+ end
33
+
34
+ if line.strip.split(';').first =~ /\=/
35
+ key = line.strip.split(';').first.split('=')
36
+ ini[cur_section].merge!( key[0] => key[1].nil? ? '' : key[1] )
37
+ end
38
+ end
39
+ return ini
40
+ end
41
+
42
+ def readsecret(conffile)
43
+ secret=nil
44
+ input= File.new(conffile, "r")
45
+
46
+ input.each do |line|
47
+ if (line =~ /^secret=/) then
48
+ secini=line.split("=",2)
49
+ secret=secini[1]
50
+ break
51
+ end
52
+ end
53
+
54
+ input.close
55
+
56
+ return secret
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'base64'
4
+ require 'openssl'
5
+
6
+ module Remmina
7
+
8
+ class Password
9
+ attr_accessor :key, :iv
10
+
11
+ def initialize(params={})
12
+ secret=params.fetch('secret',nil)
13
+ unless secret.nil?
14
+ secret64=Base64.decode64(secret)
15
+ @key=secret64[0..23]
16
+ @iv=secret64[24..48]
17
+ end
18
+ end
19
+
20
+ def decrypt_password (encstr)
21
+ cipher = OpenSSL::Cipher::Cipher.new('DES3')
22
+ cipher.decrypt
23
+ cipher.iv=@iv
24
+ cipher.key=@key
25
+ cipher.padding=0
26
+ str=Base64.decode64(encstr)
27
+ dec=cipher.update(str)+cipher.final
28
+ dec.delete!("\000")
29
+ return dec
30
+ end
31
+
32
+ def encrypt_password (password)
33
+ cipher = OpenSSL::Cipher::Cipher.new('DES3')
34
+ cipher.encrypt
35
+ cipher.iv=@iv
36
+ cipher.key=@key
37
+ cipher.padding=0
38
+ strpad=password+"\0"*(8-password.length%8)
39
+ str=strpad.encode("ascii")
40
+ enc=cipher.update(str)+cipher.final
41
+ b64=Base64.encode64(enc)
42
+ return b64.chomp
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,3 @@
1
+ module Remmina
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'remmina/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "remmina"
8
+ spec.version = Remmina::VERSION
9
+ spec.authors = ["Vlatko Kosturjak"]
10
+ spec.email = ["vlatko.kosturjak@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby support for Remmina.}
13
+ spec.description = %q{Ruby support classes for Remmina}
14
+ spec.homepage = "https://github.com/kost/remmina-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "pry", "> 0"
26
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remmina
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vlatko Kosturjak
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruby support classes for Remmina
70
+ email:
71
+ - vlatko.kosturjak@gmail.com
72
+ executables:
73
+ - remmina-dump
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/pry
87
+ - bin/setup
88
+ - exe/remmina-dump
89
+ - lib/remmina.rb
90
+ - lib/remmina/config.rb
91
+ - lib/remmina/password.rb
92
+ - lib/remmina/version.rb
93
+ - remmina.gemspec
94
+ homepage: https://github.com/kost/remmina-ruby
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.5.2.1
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Ruby support for Remmina.
118
+ test_files: []