破解x-pack 6.x和更新許可證

X-pack-6.2.4破解

一、前言:

X-pack是elasticsearch的一個擴展包,將安全,警告,監視,圖形和報告功能捆綁在一個易於安裝的軟件包中,雖然x-pack被設計爲一個無縫的工做,可是你能夠輕鬆的啓用或者關閉一些功能。java

目前6.2及如下版本只能使用免費版,然而免費版的功能至關少。X-pack 的破解基本思路是先安裝正常版本,以後替換破解的jar包來實現,目前只能破解到白金版,但已經夠用了。node

二、首先正常安裝 x-pack

先下載最新版本的 x-pack,裏面包含了 es,kibana,logstash 新版本的x-pack
下載地址:https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-6.2.4.zip
以後到es目錄執行git

[root@elk ~]#  ./bin/elasticsearch-plugin install file:///opt/x-pack-6.2.4.zip

或者:github

[root@elk ~]#  .bin/elasticsearch-plugin install x-pack

須要贊成下協議 回車 輸入y 回車 會提示安裝成功apache

三、破解 x-pack

  • 解壓 x-pack-6.2.4.zip
  • 進入elasticsearch目錄,找到x-pack-core-6.2.4.jar
  • 6.2 與以前版本的包結構變化很大,用luyten反編譯,其餘工具打開報錯。5.x版本只需破解LicenseVerifier.class便可
  • luyten項目地址:https://github.com/deathmarine/Luyten
  • 路徑:/usr/share/elasticsearch/plugins/x-pack/x-pack-core/
  • 打開後找到兩個class文件,分別爲org.elasticsearch.license.LicenseVerifier.class ,org.elasticsearch.xpack.core.XPackBuild.class
  • 將反編譯後的java 代碼複製到本身的IDE中,按照一樣的包名建立pack
    咱們不須要編譯整個項目,只須要編譯這兩個文件,因此要把依賴添加到classpath中。
  • 依賴也與以前有所變化,以前只須要x-pack 包自己,如今須要引入 elasticsearch 6.2.4 中 lib 目錄下的jar包 以及 x-pack-core-6.2.4.jar 自己
  • 修改代碼
    LicenseVerifier 中有兩個靜態方法,這就是驗證受權文件是否有效的方法,咱們把它修改成所有返回true.json

    package org.elasticsearch.license;
    import java.nio.*;
    import java.util.*;
    import java.security.*;
    import org.elasticsearch.common.xcontent.*;
    import org.apache.lucene.util.*;
    import org.elasticsearch.common.io.*;
    import java.io.*;
    public class LicenseVerifier
    {
      public static boolean verifyLicense(final License license, final byte[] encryptedPublicKeyData) {
        return true;
      }
      public static boolean verifyLicense(final License license) {
        return true;
      }
    }

    XPackBuild 中 最後一個靜態代碼塊中 try的部分所有刪除,這部分會驗證jar包是否被修改安全

    package org.elasticsearch.xpack.core;
    import org.elasticsearch.common.io.*;
    import java.net.*;
    import org.elasticsearch.common.*;
    import java.nio.file.*;
    import java.io.*;
    import java.util.jar.*;
    public class XPackBuild
    {
      public static final XPackBuild CURRENT;
      private String shortHash;
      private String date;
      @SuppressForbidden(reason = "looks up path of xpack.jar directly")
      static Path getElasticsearchCodebase() {
        final URL url = XPackBuild.class.getProtectionDomain().getCodeSource().getLocation();
        try {
          return PathUtils.get(url.toURI());
        }
        catch (URISyntaxException bogus) {
          throw new RuntimeException(bogus);
        }
      }
      XPackBuild(final String shortHash, final String date) {
        this.shortHash = shortHash;
        this.date = date;
      }
      public String shortHash() {
        return this.shortHash;
      }
      public String date() {
        return this.date;
      }
      static {
        final Path path = getElasticsearchCodebase();
        String shortHash = null;
        String date = null;
        Label_0157: {
        shortHash = "Unknown";
        date = "Unknown";
      }
      CURRENT = new XPackBuild(shortHash, date);
      }
    }

    編譯java文件,把class文件替換到原來的x-pack-core-6.2.2.jar中app

    [root@elk ~]#  javac -cp "/usr/share/elasticsearch/lib/elasticsearch-6.2.4.jar:/usr/share/elasticsearch/lib/lucene-core-7.2.1.jar:/usr/share/elasticsearch/plugins/x-pack/x-pack-core/x-pack-core-6.2.4.jar:/usr/share/elasticsearch/lib/elasticsearch-core-6.2.4.jar" XPackBuild.java
    [root@elk ~]#  javac -cp "/usr/share/elasticsearch/lib/elasticsearch-6.2.4.jar:/usr/share/elasticsearch/lib/lucene-core-7.2.1.jar:/usr/share/elasticsearch/plugins/x-pack/x-pack-core/x-pack-core-6.2.4.jar" LicenseVerifier.java

    四、安裝破解的x-pack

  • 將破解好的x-pack-core-6.2.4.jar 替換到已經安裝好的 elasticsearch中
  • 路徑爲 /usr/share/elasticsearch/plugins/x-pack/x-pack-core
  • 須要替換集羣中全部的x-pack
  • 初次安裝須要重置默認的賬號密碼
    [root@elk ~]#  ./bin/x-pack/setup-passwords interactive

    這樣破解的x-pack就安裝好了curl

elasticsearch 6.2.4 中默認開啓了安全驗證,咱們暫時修改配置文件以方便導入本身的文件
在elasticsearch.yml 中 添加一下配置elasticsearch

xpack.security.enabled:false

五、重啓集羣

  • 導入咱們本身填寫的license文件
  • 沒有license請到如下地址申請試用license,而後修改license中的type、max_nodes、expiry_date_in_millis
    License申請地址
    {"license":
    {
    "uid":"32575be3-f4d3-4bd7-a93f-be00562e976e",
    "type":"platinum",
    "issue_date_in_millis":1528070400000,
    "expiry_date_in_millis":252457920099,
    "max_nodes":1000,
    "issued_to":"billy li (test)",
    "issuer":"Web Form",
    "signature":"AAAAAwAAAS",
    "start_date_in_millis":1528070400000}}

    咱們將過時時間寫到2050年,type改成platinum 白金版,這樣咱們就會擁有所有的x-pack功能
    執行命令 導入

    curl -XPUT -u elastic 'http://10.31.90.181:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json

    執行後會提示導入成功。

注:若是有多個節點ES集羣,把全部es節點關閉而後開啓一個節點,在這個節點導入license,集羣其餘節點會自動同步license。

相關文章
相關標籤/搜索