1. 程式人生 > >6.3版本x-pack破解

6.3版本x-pack破解

第一步:

elasticsearch-6.3.0\modules\x-pack\x-pack-core目錄下找到x-pack-core-6.3.0.jar,複製一份出來留個備份

第二步:新建兩個java檔案分別命名為LicenseVerifier.java和XPackBuild.java

package org.elasticsearch.license;
 
import java.nio.*;
import org.elasticsearch.common.bytes.*;
import java.util.*;
import java.security.*;
import org.elasticsearch.common.xcontent.*;
import org.apache.lucene.util.*;
import org.elasticsearch.core.internal.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;
    }
}
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 "/usr/share/elasticsearch/modules/x-pack/x-pack-core/x-pack-core-6.3.0.jar:/usr/share/elasticsearch/lib/lucene-core-7.3.1.jar:/usr/share/elasticsearch/lib/elasticsearch-6.3.0.jar:/usr/share/elasticsearch/lib/elasticsearch-core-6.3.0.jar" LicenseVerifier.java

javac -cp "/usr/share/elasticsearch/modules/x-pack/x-pack-core/x-pack-core-6.3.0.jar:/usr/share/elasticsearch/lib/lucene-core-7.3.1.jar:/usr/share/elasticsearch/lib/elasticsearch-6.3.0.jar:/usr/share/elasticsearch/lib/elasticsearch-core-6.3.0.jar” XPackBuild.java

第四步:替換x-pack-core-6.3.0.jar的class檔案

mkdir org/elasticsearch/license/

mv LicenseVerifier.class org/elasticsearch/license/LicenseVerifier.class

jar uvf x-pack-core-6.3.0.jar org/elasticsearch/license/LicenseVerifier.class

mkdir org/elasticsearch/xpack/core/

mv LicenseVerifier.class org/elasticsearch/xpack/core/XPackBuild.class

jar uvf x-pack-core-6.3.0.jar org/elasticsearch/xpack/core/XPackBuild.class

第五步:

獲取 license 證書

https://license.elastic.co/registration 填些使用者名稱,郵箱(重要,獲取下載連結),Country選擇China,其他資訊隨意填寫

②開啟郵箱獲取的地址,將下載後的檔案改名為license.json

③修改檔案中的內容,將兩個屬性改為

將 "type":"basic" 替換為 "type":"platinum"    # 基礎版變更為鉑金版

將 "expiry_date_in_millis":1561420799999替換為 "expiry_date_in_millis":3107746200000    # 1年變為50年

④使用curl替換 license(license.json指的是剛剛下載修改屬性後的證書,要開啟elasticsearch服務)

curl -H "Content-Type: application/json" -XPUT 'http://192.168.7.245:9200/_xpack/license?acknowledge=true' -d @license.json

⑤若失敗,修改配置檔案

xpack.security.enabled: false

破解成功後改回來

xpack.security.enabled: true

xpack.security.transport.ssl.enabled: true

⑥上傳後檢視證書時間

curl -XGET http://192.168.7.245:9200/_license