mycert 0.0.0.pre.dev

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a9796f84904954eda287d68d1e494c5eacc19a59e3c57c1291252025cb76b508
4
+ data.tar.gz: ad54351a74274524a005fac29fe417e134e63de6fa17c4eb7abf824d9b6ee4f4
5
+ SHA512:
6
+ metadata.gz: 2b4e28d8fd7c6ad47408ee054b7872f9b9bc5ca4e72054ba207ab550c75df2a729c8c476dfb35fb20950c6e08f41b31df285abce85fe8d09dfd901a1d4bd335d
7
+ data.tar.gz: 1898f0f036efa43f9b1fff9ab7510a706e6d322d99b0729f2673fb80e89c073fcc7c177e5a5c4ed74d737709e763d11b71571ff36ef82a619f8ad96f16477722
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in mycert.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', '~> 1.21'
13
+
14
+ gem 'thor'
15
+
16
+ gem 'openssl'
17
+
18
+ gem 'colorize'
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mycert (0.1.0)
5
+ thor (~> 1.2.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ colorize (0.8.1)
12
+ diff-lcs (1.5.0)
13
+ json (2.6.3)
14
+ openssl (3.1.0)
15
+ parallel (1.22.1)
16
+ parser (3.2.1.0)
17
+ ast (~> 2.4.1)
18
+ rainbow (3.1.1)
19
+ rake (13.0.6)
20
+ regexp_parser (2.7.0)
21
+ rexml (3.2.5)
22
+ rspec (3.12.0)
23
+ rspec-core (~> 3.12.0)
24
+ rspec-expectations (~> 3.12.0)
25
+ rspec-mocks (~> 3.12.0)
26
+ rspec-core (3.12.1)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-expectations (3.12.2)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-mocks (3.12.3)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-support (3.12.0)
35
+ rubocop (1.46.0)
36
+ json (~> 2.3)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.2.0.0)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml (>= 3.2.5, < 4.0)
42
+ rubocop-ast (>= 1.26.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 2.4.0, < 3.0)
45
+ rubocop-ast (1.26.0)
46
+ parser (>= 3.2.1.0)
47
+ ruby-progressbar (1.11.0)
48
+ thor (1.2.1)
49
+ unicode-display_width (2.4.2)
50
+
51
+ PLATFORMS
52
+ arm64-darwin-21
53
+
54
+ DEPENDENCIES
55
+ colorize
56
+ mycert!
57
+ openssl
58
+ rake (~> 13.0)
59
+ rspec (~> 3.0)
60
+ rubocop (~> 1.21)
61
+ thor
62
+
63
+ BUNDLED WITH
64
+ 2.4.5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 HAHWUL
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 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,
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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Mycert
2
+ RootCA Creation Tool for Pentest (ZAP/BurpSuite/Android/iOS/Etc..)
3
+
4
+ > https://www.hahwul.com/2020/07/03/one-custom-certificate-using-all-tools/
5
+
6
+ ## Installation
7
+ ```bash
8
+ gem install mycert
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ mycert -h
15
+ ```
16
+
17
+ ## Development
18
+
19
+ 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.
20
+
21
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
22
+
23
+ ## Contributing
24
+
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hahwul/mycert.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/mycert ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'mycert'
5
+
6
+ Mycert::CLI.start(ARGV)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+
5
+ def create_android(root_ca)
6
+ hash = root_ca.subject.hash.to_s(16)
7
+ File.open("#{hash}.0", 'wb') do |f|
8
+ f.write root_ca
9
+ end
10
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+
5
+ def make(name, day)
6
+ root_key = OpenSSL::PKey::RSA.new 2048
7
+ root_ca = OpenSSL::X509::Certificate.new
8
+ root_ca.version = 2
9
+ root_ca.serial = 1
10
+ root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=#{name}"
11
+ root_ca.issuer = root_ca.subject
12
+ root_ca.public_key = root_key.public_key
13
+ root_ca.not_before = Time.now
14
+ root_ca.not_after = root_ca.not_before + day * 24 * 60 * 60
15
+ ef = OpenSSL::X509::ExtensionFactory.new
16
+ ef.subject_certificate = root_ca
17
+ ef.issuer_certificate = root_ca
18
+ root_ca.add_extension(ef.create_extension('basicConstraints', 'CA:TRUE', true))
19
+ root_ca.add_extension(ef.create_extension('keyUsage', 'keyCertSign, cRLSign', true))
20
+ root_ca.add_extension(ef.create_extension('subjectKeyIdentifier', 'hash', false))
21
+ root_ca.add_extension(ef.create_extension('authorityKeyIdentifier', 'keyid:always', false))
22
+ root_ca.sign(root_key, OpenSSL::Digest.new('SHA256'))
23
+
24
+ root_ca
25
+ end
26
+
27
+ def make_file(root_ca, filename)
28
+ File.open(filename, 'wb') do |f|
29
+ f.write root_ca
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+
5
+ class Logger
6
+ def self.info(text)
7
+ puts '► '.colorize(:blue) + text.to_s.colorize(:light_blue)
8
+ end
9
+
10
+ def self.error(text)
11
+ puts '⚠︎ '.colorize(:red) + text.to_s
12
+ end
13
+
14
+ def self.data(text)
15
+ puts text.to_s.colorize(:light_green)
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+
5
+ def create_pkcs12(_name, password, filename)
6
+ p12 = OpenSSL::PKCS12.create(password, 'myapp', root_key, root_ca)
7
+ File.open(filename, 'wb') do |f|
8
+ f.write p12.to_der
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ def friendly_filename(filename)
4
+ filename.gsub(/[^\w\s_-]+/, '')
5
+ .gsub(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
6
+ .gsub(/\s+/, '_')
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mycert
4
+ VERSION = '0.0.0.pre.dev'
5
+ end
data/lib/mycert.rb ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'mycert/version'
4
+ require_relative 'mycert/general'
5
+ require_relative 'mycert/logger'
6
+ require_relative 'mycert/pkcs'
7
+ require_relative 'mycert/utils'
8
+ require_relative 'mycert/android'
9
+ require 'thor'
10
+
11
+ module Mycert
12
+ class Error < StandardError; end
13
+
14
+ class CLI < Thor
15
+ class_option :name, aliases: :n, default: 'mycert', type: :string, desc: 'RootCA Name'
16
+ class_optinon :expire, aliases: :e, default: 365, type: :numeric, desc: 'CA expire day'
17
+ class_option :pkcs12_password, default: '', type: :string, desc: 'Password for PKCS12'
18
+
19
+ desc 'all', ''
20
+ def all; end
21
+
22
+ desc 'android', ''
23
+ def android; end
24
+
25
+ desc 'pkcs12', ''
26
+ def pkcs12; end
27
+
28
+ desc 'version', 'Show version.'
29
+ def version
30
+ puts Mycert::VERSION.to_s
31
+ end
32
+
33
+ def self.exit_on_failure?
34
+ true
35
+ end
36
+ end
37
+ end
data/mycert.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/mycert/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'mycert'
7
+ spec.version = Mycert::VERSION
8
+ spec.authors = ['hahwul']
9
+ spec.email = ['hahwul@gmail.com']
10
+
11
+ spec.summary = 'Generate RootCA for Pentesting'
12
+ spec.description = 'Generate RootCA for ZAP/BurpSuite/Android/iOS/Etc..'
13
+ spec.homepage = 'https://github.com/hahwul/mycert'
14
+ spec.required_ruby_version = '>= 2.6.0'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/hahwul/mycert'
18
+ spec.license = 'MIT'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = 'mycert'
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_runtime_dependency 'thor', '~> 1.2.1'
32
+ end
data/sig/mycert.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Mycert
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mycert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0.pre.dev
5
+ platform: ruby
6
+ authors:
7
+ - hahwul
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.1
27
+ description: Generate RootCA for ZAP/BurpSuite/Android/iOS/Etc..
28
+ email:
29
+ - hahwul@gmail.com
30
+ executables:
31
+ - mycert
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - exe/mycert
41
+ - lib/mycert.rb
42
+ - lib/mycert/android.rb
43
+ - lib/mycert/general.rb
44
+ - lib/mycert/logger.rb
45
+ - lib/mycert/pkcs.rb
46
+ - lib/mycert/utils.rb
47
+ - lib/mycert/version.rb
48
+ - mycert.gemspec
49
+ - sig/mycert.rbs
50
+ homepage: https://github.com/hahwul/mycert
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ homepage_uri: https://github.com/hahwul/mycert
55
+ source_code_uri: https://github.com/hahwul/mycert
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.6.0
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">"
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.1
70
+ requirements: []
71
+ rubygems_version: 3.3.3
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Generate RootCA for Pentesting
75
+ test_files: []