Elasticsearch x-pack 5x,6x 受權永久破解

該教程適用於 5.x 6.x 版本html

破解

1、反編譯class文件
在elasticsearch安裝目錄plugins/x-pack/找到x-pack-6.0.0.jar文件。java

# 新建測試目錄
mkdir test

# 剪切到測試目錄
cp /usr/local/elasticsearch/plugins/x-pack/x-pack-6.0.0.jar test/

# 切換到測試目錄,解壓jar包
cd test/
jar -xvf x-pack-6.0.0.jar
rm x-pack-6.0.0.jar

2、修改代碼
找到文件org/elasticsearch/license/LicenseVerifier.class拷貝到mac/windows中,用Luyten(jd-gui不許)反編譯查看。luyten項目地址:https://github.com/deathmarine/Luytennode

LicenseVerifier 中有兩個靜態方法,這就是驗證受權文件是否有效的方法,咱們把它修改成所有返回true,並拷貝內容到新建的文件LicenseVerifier.java,內容以下:git

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;
    }
}

3、從新編譯LicenseVerifier.javagithub

javac -cp "/usr/local/elasticsearch/lib/elasticsearch-5.5.0.jar:/usr/local/elasticsearch/lib/lucene-core-6.6.0.jar:/usr/local/elasticsearch/plugins/x-pack/x-pack-5.5.0.jar" LicenseVerifier.java

4、替換原來的class文件apache

cp LicenseVerifier.class test/org/elasticsearch/license/

#從新打包jar包
cd test
jar -cvf ../x-pack-6.0.0.jar ./*

#覆蓋原來x-pack的jar包
mv ../x-pack-6.0.0.jar /usr/local/elasticsearch/plugins/x-pack/

5、編寫License文件
去官網申請免費license,會發郵件給你進行下載。
將獲得的文件進行以下修改:
{"license":{"uid":"ba9ae270-28ee-4051-810f-09469dfd4aa4","type":"platinum","issue_date_in_millis":1498694400000,"expiry_date_in_millis":2524579200999,"max_nodes":100,"issued_to":"yu tao (shanghai)","issuer":"Web Form","signature":"AAAAAwAAAA0d3SXUL/5bRSxB/OU4AAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQCBFriH7K2dVFXmsQLHDvpY0Ppda0FHGTDSjAmnCcplQWaNKHtX+DR6znV+vOiokhQ8s/Yz5PmI5GFhsqkLEWXl975x1/8GHaDgb7aMv7UzciFw2duWsrH8mKTGGr2wHUKMVW7pUx2Kcr5WkH0G3ax3gynsvnYTApqWiyWdkdPX/jR/T1UhfjEqpCKCQryj+aNLxy2GP+4wF/wH4NvmDF0aWALFCKDAWhuDMCNmm+oKrLrgcIXyQERk7JBf5rZG5Xm7ViiyQ8aFf8X4CN7hA8xxrPmT57jtTrX9d4Q3Kf4jEBVeUnk/qa1Doj0/Ezn2G0vVE2oRQOXmUp9nwo0JTAHj","start_date_in_millis":1498694400000}}json

其中主要的就是:windows

①"type":"platinum"
②"expiry_date_in_millis":2524579200999

原本我想把type改成enterprise的,結果它不認。platinum是白金版,權限也很高。
expiry_date_in_millis就是你要截止的日期,我配置的是到2050年。
保存文件爲:license.json。centos

6、更新License文件
這裏能夠查看官網:https://www.elastic.co/guide/en/x-pack/5.5/installing-license.htmlcurl

5.x 直接執行 curl 便可

curl -XPUT -u elastic:changeme "http://192.168.0.166:9200/_xpack/license?acknowledge=true" -d @license.json

6.x 更新以前先配置elasticsearch.yml,加入:
xpack.security.enabled: false
#執行
curl -XPUT -u elastic:changeme "http://192.168.0.166:9200/_xpack/license?acknowledge=true" -d @license.json

生效以後,再開啓security,並開啓SSL\TLS:

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

7、最後重啓 elasticsearch

8、查看License狀態
curl -XGET -u elastic:changeme "http://192.168.0.166:9200/_license"

9、重置密碼
更改內置elastic用戶和kibana使Kibana在部署到生產以前與Elasticsearch通訊的 用戶的密碼。有關更多信息,請參閱設置用戶身份驗證

curl -XPUT -u elastic http://192.168.0.166:9200/_xpack/security/user/elastic/_password -d '{ "password" : "your_new_passwd" }'
curl -XPUT -u elastic http://192.168.0.166:9200/_xpack/security/user/kibana/_password -d '{ "password" : "your_new_passwd" }'
curl -XPUT -u elastic http://192.168.0.166:9200/_xpack/security/user/logstash_system/_password -d '{ "password" : "your_new_passwd" }'

10、修改配置文件
kibana用戶密碼被重置,則須要經過設置 kibana.yml的配置文件:

elasticsearch.password: "your_new_passwd"
xpack.security.enabled: true

要在Logstash中啓用此功能,須要在logstash.yml配置文件中進行設置來使用新密碼更新Logstash配置:

xpack.monitoring.elasticsearch.url: "http://192.168.0.166:9200"
xpack.monitoring.elasticsearch.username: "logstash_system"
xpack.monitoring.elasticsearch.password: "your_new_passwd"

參考
centos6安裝elasticsearch6錯誤筆記
x-pack 5破解
忘記密碼
x-pack受權區別

相關文章
相關標籤/搜索