Elasticsearch6.2.3 X-Pack安装破解

1. Elasticsearch 安装 X-Pack

cd $ES_HOME
bin/elasticsearch-plugin install x-pack

安装过程全部输入y

bin/x-pack/setup-passwords interactive  # 设置密码

重启 elasticsearch

Installing X-Pack in Elasticserach

2. Kibana 安装 X-Pack

cd $KINABA_HOME
bin/kibana-plugin install x-pack

修改 conf/kibana.yml, 添加kibana用户帐号密码

elasticsearch.username: "kibana"
elasticsearch.password: "kibanapassword"

重启kibanba

Installing X-Pack in Kibana

3. 破解

  • 解压x-pack-core-6.2.3.jar

    cp ES_HOME/plugins/x-pack/x-pack-corex-pack-core-6.2.3.jar /tmp/x-pack
    cd /tmp/x-pack
    jar -xvf x-pack-core-6.2.3.jar
    

    找到org.elasticsearch.license.LicenseVerifier.class org.elasticsearch.xpack.core.XPackBuild.class, 用luyten反编译保存为java文件

  • 修改LicenseVerifier

    LicenseVerifier 中有两个静态方法,这就是验证授权文件是否有效的方法,我们把它修改为全部返回true.

    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

    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);
        }
    }
    
  • 重新编译压缩

    javac -cp "$ES_HOME/lib/elasticsearch-6.2.3.jar:/opt/elasticsearch/lib/lucene-core-7.2.1.jar:$ES_HOME/plugins/x-pack/x-pack-core/x-pack-core-6.2.3.jar" LicenseVerifier.java
    
    javac -cp "$ES_HOME/lib/elasticsearch-6.2.3.jar:$ES_HOME/lib/lucene-core-7.2.1.jar:$ES_HOME/plugins/x-pack/x-pack-core/x-pack-core-6.2.3.jar:$ES_HOME/plugins/x-pack/x-pack-core/netty-common-4.1.16.Final.jar:$ES_HOME/lib/elasticsearch-core-6.2.3.jar" XPackBuild.java
    

    编译的org.elasticsearch.license.LicenseVerifier.class org.elasticsearch.xpack.core.XPackBuild.class替换原来的class,重新压缩打包

    jar -cvf x-pack-core-6.2.3.jar ./*
    
  • 替换原来的x-pack-core-6.2.3.jar并重启elasticserach、kinaba

  • 导入授权文件

    {
            "license": {
                    "uid": "1f742aa9-068b-48b6-8b36-c36ff3a39ed7",
                    "type": "platinum", # 修改授权为白金版本
                    "issue_date_in_millis": 1526860800000,
                    "expiry_date_in_millis": 2524579200999, #修改到期时间
                    "max_nodes": 100, # 修改最大节点数
                    "issued_to": "aa",
                    "issuer": "Web Form",
                    "signature": "AAAAAwAAAA2+OXa0Aq7HFDzGSxl1AAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQCi1V5EMmUXsTUKTeVHJugLj0daqCDI/eAALGG2FWAnE7p9F9ZcCNp2cybBmJ8okoxEIvsUVHUEv50eodAzsxR7qYra1j3pbjMY9BSl13DTVByhow+ZbsXojEpxtXPv18Fd88iP7NcQDs/ERI3xQePDl4O3vB1qkpTxZiY+BC/YlCHF4VTz/sGq6PWvT0G7T4oUb91KIB42oFYNvS4SRkv4gvHOQWRkwdthA2dwpf2QNeH/5vMw9VWFV8x7hw+8HTcqkf2De3TFq94VvhWw9ZpXPaO79fuQoj7vR79BHbBLYnlHxMNAEGnzgJwK13DGDnHdoz0mGsCHgUuswn7+nTEX",
                    "start_date_in_millis": 1526860800000
            }
    }
    
    

    curl -u elastic:elastic -XPUT 'http://es-ip:port/_xpack/license' -H "Content-Type: application/json" -d @/tmp/license.json
    

    注: 如果授权文件license.json不可用,可以去官网注册下载一份basic版本授权文件,修改版本和到期时间后,重新导入

你可能感兴趣的:(Elasticsearch6.2.3 X-Pack安装破解)