Loading...

Loading...

This page has no en version yet, showing default language content

由于需要一些镜像等 gitlab 高级功能,所有破解gitlab ee版本。你能信么? 这些破解方法来自官方自己的文档!个人研究使用,企业请付费购买正版授权。

  • 已经在最新 gitlab ee 18.5 上验证可行

使用 ruby 生成许可证

安装ruby

安装完gitlab ee之后

安装ruby:yum install ruby

ruby版本需要2.3或以上。

生成许可证

gem install gitlab-license

创建一个rb文件

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" => "none",
  "Company" => "none",
  "Email" => "example@test.com",
}
license.starts_at = Date.new(2020, 1, 1) # 开始时间
license.expires_at = Date.new(2050, 1, 1) # 结束时间
license.notify_admins_at = Date.new(2049, 12, 1)
license.notify_users_at = Date.new(2049, 12, 1)
license.block_changes_at = Date.new(2050, 1, 1)
license.restrictions = {
  active_user_count: 10000,
}
 
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 = 10000
  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

生成 GitLabBV.gitlab-license license_key license_key.pub 这三个文件。

使用许可证

license_key.pub 文件替换 /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub

GitLabBV.gitlab-license 即是许可证,填入 ${address}/admin/license 地址并重启 gitlab-ctl restart

修改等级

--- /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
+++ /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
@@ -458,7 +458,7 @@
  end
 
  def plan
-    restricted_attr(:plan).presence || STARTER_PLAN
+    restricted_attr(:plan).presence || ULTIMATE_PLAN
  end
 
  def edition
 

使用 GitLab-License-Generator 生成许可证

Docker 运行

docker run --rm -it \
  -v "./license:/license-generator/build" \
  -e LICENSE_NAME="Tim Cook" \
  -e LICENSE_COMPANY="Apple Computer, Inc." \
  -e LICENSE_EMAIL="tcook@apple.com" \
  -e LICENSE_PLAN="ultimate" \
  -e LICENSE_USER_COUNT="2147483647" \
  -e LICENSE_EXPIRE_YEAR="2500" \
  ghcr.io/lakr233/gitlab-license-generator:main

或者自己编译镜像,需要选择前几个没有被 DMCA 的提交

git clone https://github.com/Lakr233/GitLab-License-Generator.git
docker build GitLab-License-Generator -t gitlab-license-generator:main
docker run --rm -it \
  -v "./license:/license-generator/build" \
  -e LICENSE_NAME="Tim Cook" \
  -e LICENSE_COMPANY="Apple Computer, Inc." \
  -e LICENSE_EMAIL="tcook@apple.com" \
  -e LICENSE_PLAN="ultimate" \
  -e LICENSE_USER_COUNT="2147483647" \
  -e LICENSE_EXPIRE_YEAR="2500" \
  gitlab-license-generator:main

人工运行破解

由于 GitLab-License-Generator 被 DMCA takedown 了,所以我们需要手动运行它:

复制 仓库

# 可以直接在 gitlab docker 中运行,或者使用你喜欢的环境
docker exec -it gitlabee bash
apt update
apt install ruby-full
gem install bundler
gem install gitlab-license
git clone https://github.com/Lakr233/GitLab-License-Generator.git
cd GitLab-License-Generator

修改生成脚本

然后编辑 src/scan.features.rb 粘贴以下内容:

#!/usr/bin/env ruby
# encoding: utf-8

require 'json'
require 'optparse'

OptionParser.new do |opts|
    opts.banner = "Usage: scan.features.rb [options]"

    opts.on("-s", "--src-dir PATH", "Specify gitlab source dir (required if --features-file is ommited)") do |v|
        GITLAB_FEATURES_FILE="#{File.expand_path(v)}/ee/app/models/gitlab_subscriptions/features.rb"
    end

    opts.on("-f", "--features-file PATH", "Specify gitlab features path (required if --src-dir is ommited)") do |v|
        GITLAB_FEATURES_FILE = File.expand_path(v)
    end

    opts.on("-o", "--output PATH", "Output to json file (required)") do |v|
        EXPORT_JSON_FILE = File.expand_path(v)
    end

    opts.on("-h", "--help", "Prints this help") do
        puts opts
        exit
    end
end
.parse!
if GITLAB_FEATURES_FILE.nil? || EXPORT_JSON_FILE.nil?
    puts "[!] missing required options"
    puts "[!] use -h for help"
    exit 1
end
puts "Reading features from #{GITLAB_FEATURES_FILE}"

def ignore_exception
    begin
      yield
    rescue Exception
    end
end

puts "[*] loading features.rb..."
ignore_exception do
    require_relative "#{GITLAB_FEATURES_FILE}"
end

ALL_FEATURES = []
GitlabSubscriptions::Features.constants.each do |const_name|
    puts "[*] gathering features from #{const_name}"
    if const_name.to_s.include? 'FEATURE'
        ALL_FEATURES.concat(GitlabSubscriptions::Features.const_get(const_name))
    else
        puts "[?] unrecognized constant #{const_name}"
    end
end

ALL_FEATURES.uniq!
ALL_FEATURES.sort_by! { |feature| feature }

puts "[*] total features: #{ALL_FEATURES.size}"

puts "[*] writing to #{EXPORT_JSON_FILE}"
File.write(EXPORT_JSON_FILE, JSON.pretty_generate(ALL_FEATURES))

puts "[*] done"

生成许可证(按需求修改LICENSE变量):

运行 make.sh 脚本

chmod +x src/scan.features.rb
LICENSE_NAME="Tim Cook"
LICENSE_COMPANY="Apple Computer, Inc."
LICENSE_EMAIL="tcook@apple.com"
LICENSE_PLAN="ultimate"
LICENSE_USER_COUNT="2147483647"
LICENSE_EXPIRE_YEAR="2500"
./make.sh

生成的许可证在 build 文件夹下。

要使用的文件有 public.keyresult.gitlab-license

替换 Gitlab public key

我们要使用生成的 public.key 替换 GitLab 的 .license_encryption_key.pub

  • 本地安装
sudo cp ./build/public.key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
  • docker compose 安装
volumes:
  - "./build/public.key:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub"

然后重启 container

docker-compose down
docker-compose up -d

result.gitlab-license 的内容粘贴至

<YourGitLabURL>/admin/license/new 点击 Add License 选择 Enter license key 粘贴你 result.gitlab-license 里的内容。

选择接受 TOS 点击 Add license。

这时候 GitLab 就成功激活了!

安装 Gitlab 许可证

14.x Gitlab之前添加许可证位置

菜单->管理员->订阅->许可证上传

新版Gitlab添加许可证的位置在

菜单->管理员->设置->通用->添加许可证处点击展开->点击上传(build/result.gitlab-license)

修改完成后使用 gitlab-ctl restart 重新加载配置。

菜单->管理员->订阅

在这里可以看到激活状态,上面操作没问题的话,这里可以看到激活成功!

关闭 gitlab Service Ping (可选)

  • Open the configuration file:

    sudo nano /etc/gitlab/gitlab.rb
  • Add the following line:

    gitlab_rails['usage_ping_enabled'] = false
  • Reconfigure and restart GitLab:

    sudo gitlab-ctl reconfigure
    sudo gitlab-ctl restart

参考

现在你已经破解好了Gitlab ee, 可以使用其中的高级功能。

更多的Gitlab ee详细教程,请参考下面的gitlab系列教程! 👇︎

系列教程

全部文章RSS订阅

Gitlab 使用系列

Gitlab RSS 分类订阅

Devops系列

Devops 分类 RSS 订阅

项目管理系列

AI 分类 RSS 订阅


Posted on
July 9, 2021
reprint policy. If reproduced, please indicate source
Support
Comments
Data Loading...
 Previous

Read More

Gitlab的安装及使用
Gitlab的安装及使用 Gitlab的安装及使用
Gitlab的安装及使用全过程详细记录,中间各种问题及其解决办法,如果你想做自己Devops,那么绝对推荐看这篇了
2021-07-09
Next 

Read More

海思MPP&UNF构架源代码级分析
海思MPP&UNF构架源代码级分析 海思MPP&UNF构架源代码级分析
海思MPP&UNF构架源代码级分析。通过分析海思文档和代码,把海思SDK的MPI和UNF构架大概实现思想和构架进行了简略的分析。着重分析了内存管理,底层功能如何实现。本文前面简略分析了DVR,MPI构架的大体实现机制。后面就具体分析3798
2021-07-01