您的当前位置:首页>全部文章>文章详情

破解gitlab-ee

发表于:2024-01-23 17:25:48浏览:60次TAG: #git #gitlab

安装依赖

  • ruby>=2.7.0
  • gitlab-license
sudo apt install ruby
sudo gem install gitlab-license

创建文件vi license.rb

require "openssl"
require "gitlab/license"

key_pair = OpenSSL::PKey::RSA.generate(2048)
File.open("license_key", "w") { |f| f.write(key_pair.to_pem) }

public_key = key_pair.public_key
File.open("license_key.pub", "w") { |f| f.write(public_key.to_pem) }

private_key = OpenSSL::PKey::RSA.new File.read("license_key")
Gitlab::License.encryption_key = private_key

license = Gitlab::License.new
license.licensee = {
"Name" => "bennie",
"Company" => "mynest",
"Email" => "ai@191201.me",
}
license.starts_at = Date.new(2024, 1, 1) # 开始时间
license.expires_at = Date.new(2099, 1, 1) # 结束时间
license.notify_admins_at = Date.new(2098, 12, 1)
license.notify_users_at = Date.new(2098, 12, 1)
license.block_changes_at = Date.new(2099, 1, 1)
license.restrictions = {
active_user_count: 100000,
}

puts "License:"
puts license

data = license.export
puts "Exported license:"
puts data
File.open("GitLabBV.gitlab-license", "w") { |f| f.write(data) }

public_key = OpenSSL::PKey::RSA.new File.read("license_key.pub")
Gitlab::License.encryption_key = public_key

data = File.read("GitLabBV.gitlab-license")
$license = Gitlab::License.import(data)

puts "Imported license:"
puts $license

unless $license
raise "The license is invalid."
end

if $license.restricted?(:active_user_count)
active_user_count = 100000
if active_user_count > $license.restrictions[:active_user_count]
    raise "The active user count exceeds the allowed amount!"
end
end

if $license.notify_admins?
puts "The license is due to expire on #{$license.expires_at}."
end

if $license.notify_users?
puts "The license is due to expire on #{$license.expires_at}."
end

module Gitlab
class GitAccess
    def check(cmd, changes = nil)
    if $license.block_changes?
        return build_status_object(false, "License expired")
    end
    end
end
end

puts "This instance of GitLab Enterprise Edition is licensed to:"
$license.licensee.each do |key, value|
puts "#{key}: #{value}"
end

if $license.expired?
puts "The license expired on #{$license.expires_at}"
elsif $license.will_expire?
puts "The license will expire on #{$license.expires_at}"
else
puts "The license will never expire."
end

生成证书

ruby license.rb

安装依赖到生成这一步可以在docker容器中进行也可以在宿主机上进行,在宿主机上进行的话需要将生成后的文件copy到容器中去。我这里演示是在容器中进行的。

替换默认公钥

cp -f license_key.pub /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub

升级到 ULTIMATE 版本

  • 修改文件 /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
  --- /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
  +++ /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
  @@ -367,7 +367,7 @@
  end

  def plan
  -    restricted_attr(:plan).presence || STARTER_PLAN
  +    restricted_attr(:plan).presence || ULTIMATE_PLAN
  end

  def edition

-表示删除,+表示添加

重启配置gitlab

gitlab-ctl reconfigure
gitlab-ctl restart

导入许可证

登录 gitlab 后台,管理中心 -> 通用 -> 许可证 (/admin/license),导入 GitLabBV.gitlab-license 可以选择 cat GitLabBV.gitlab-license 打印出文件内容后,把密钥复制后使用密钥文本,而不是上传文件