文件:LicenseVerifier.java 路徑:elasticsearch/x-pack/plugin/core/src/main/java/org/elasticsearch/license/java
文件:XPackBuild.java 路徑:elasticsearch/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/corenode
軟件名稱:elasticsearch-7.3.0-linux-x86_64.tar.gzlinux
操做環境: 系統:windows 10系統 解壓縮軟件:7z 反編譯工具:Luytengit
操做步驟:github
這些操做在linux系統下操做的話就很簡單:tar -zxv -f elasticsearch-7.3.0-linux-x86_64.tar.gz 直接獲得文件夾elasticsearch-7.3.0web
破解x-pack-core-7.3.0.jar須要反編譯工具Luyten(https://github.com/deathmarine/Luyten/releases),咱們能夠前往下載地址下載Luyten工具。 咱們這裏下載Luyten.exe windows版本,下載下來後打開,並將x-pack-core-7.3.0.jar文件拖進去,便可展開jar包的源代碼了。apache
在Luyten工具中咱們須要把2個文件提取出來進行修改。org.elasticsearch.license.LicenseVerifier和org.elasticsearch.xpack.core.XPackBuild。json
導出LicenseVerifier.class文件爲LicenseVerifier.java源碼文件,導出XPackBuild.class文件爲XPackBuild.java源碼文件 導出步驟 windows
LicenseVerifier中有兩個靜態方法,這就是驗證受權文件是否有效的方法,把它修改成所有返回true.瀏覽器
修改後的文檔以下:
package org.elasticsearch.license; import java.nio.*; import org.elasticsearch.common.bytes.*; import java.security.*; import java.util.*; 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[] publicKeyData) { 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 { CURRENT = new XPackBuild("Unknown", "Unknown"); } }
或者這樣的:
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_0109: { shortHash = "Unknown"; date = "Unknown"; } CURRENT = new XPackBuild(shortHash, date); } }
.class
文件上述LicenseVerifier.java和XPackBuild.java兩個文件在本地電腦windows修改完成後,須要將其複製到elasticsearch服務器上並編譯成class文件,而後打包到x-pack-core-7.3.0.jar中。這裏將這2個文件放到了/opt目錄下。
# 生成LicenseVerifier.class文件 javac -cp "/opt/elasticsearch-7.3.0/lib/elasticsearch-7.3.0.jar:/opt/elasticsearch-7.3.0/lib/lucene-core-8.1.0.jar:/opt/elasticsearch-7.3.0/modules/x-pack-core/x-pack-core-7.3.0.jar:/opt/elasticsearch-7.3.0/modules/x-pack-core/netty-common-4.1.36.Final.jar:/opt/elasticsearch-7.3.0/lib/elasticsearch-core-7.3.0.jar" /opt/LicenseVerifier.java # 生成XPackBuild.class文件 javac -cp "/opt/elasticsearch-7.3.0/lib/elasticsearch-7.3.0.jar:/opt/elasticsearch-7.3.0/lib/lucene-core-8.1.0.jar:/opt/elasticsearch-7.3.0/modules/x-pack-core/x-pack-core-7.3.0.jar:/opt/elasticsearch-7.3.0/lib/elasticsearch-core-7.3.0.jar" /opt/XPackBuild.java # 查看編譯後的文件 LicenseVerifier.class XPackBuild.class
把/opt/elasticsearch-7.3.0/modules/x-pack-core/目錄下的x-pack-core-7.3.0.jar提取出來,放到/opt/tmp目錄中。
cp /opt/elasticsearch-7.3.0/modules/x-pack-core/x-pack-core-7.3.0.jar /opt/tmp cd /opt/tmp # 解壓x-pack-core-7.3.0.jar jar -xvf x-pack-core-7.3.0.jar # 替換.class文件 cp /opt/XPackBuild.class /opt/tmp/org/elasticsearch/xpack/core/ cp /opt/LicenseVerifier.class /opt/tmp/org/elasticsearch/license/
cd /opt/tmp rm -rf x-pack-core-7.3.0.jar # 刪除臨時拷貝過來的源文件 jar cvf x-pack-core-7.3.0.jar .
至此在/opt/tmp目錄下會新生成一個x-pack-core-7.3.0.jar文件,也就是破解後的文件。
cp /opt/tmp/x-pack-core-7.3.0.jar /opt/elasticsearch-7.3.0/modules/x-pack-core/
完成以上步驟後,還須要去elastic官網申請一個license, License申請地址,申請完成後,下載下來的License格式爲json格式。並將該License的type
、expiry_date_in_millis
、max_nodes
分別修改爲platinum
、2524579200999
、1000
。以下:
{"license": { "uid":"537c5c48-c1dd-43ea-ab69-68d209d80c32", "type":"platinum", "issue_date_in_millis":1558051200000, "expiry_date_in_millis":2524579200999, "max_nodes":1000, "issued_to":"hkd", "issuer":"Web Form", "signature":"AAAAAwAAAA3fIq7NLN3Blk2olVjbAAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQCjNd8mwy8B1sm9rGrgTmN2Gjm/lxqfnTEpTc+HOEmAgwQ7Q1Ye/FSGVNIU/enZ5cqSzWS2mY8oZ7FM/7UPKVQ4hkarWn2qye964MW+cux54h7dqxlSB19fG0ZJOJZxxwVxxi8iyJPUSQBa+QN8m7TFkK2kVmP+HnhU7mGUrqXt3zTk5d3pZw3QBQ/Rr3wmSYC5pxV6/o2UHFgu1OPDcX+kEb+UZtMrVNneR+cEwyx7o5Bg3rbKC014T+lMtt69Y080JDI5KfHa7e9Ul0c3rozIL975fP45dU175D4PKZy98cvHJgtsCJF3K8XUZKo2lOcbsWzhK2mZ5kFp0BMXF3Hs", "start_date_in_millis":1558051200000 } }
文件存爲license.json
將過時時間寫到2049年,type改成platinum 白金版,這樣咱們就會擁有所有的x-pack功能。
完成以上全部操做在啓動elasticsearch前,須要配置elasticsearch的SSL/TLS安全協議,若是不配置的話,須要禁止security才能配置License。
當License配置完成後咱們須要再開啓security,並開啓SSL\TLS。
# 加載License到elasticsearch以前操做 echo "xpack.security.enabled: false" >> /opt/elasticsearch-7.3.0/config/elasticsearch.yml # 加載License到elasticsearch以後操做 echo "xpack.security.transport.ssl.enabled: true" >> /opt/elasticsearch-7.3.0/config/elasticsearch.yml ./bin/elasticsearch -d # 啓動elasticsearch
curl -XPUT 'http://localhost:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json {"acknowledged":true,"license_status":"valid"} # license寫入成功 # 在es日誌中能夠查看到以下信息, license [65eafbab-c360-4f64-900d-449499b3d530] mode [basic] - valid Active license is now [BASIC]; Security is disabled license [537c5c48-c1dd-43ea-ab69-68d209d80c32] mode [platinum] - valid Active license is now [PLATINUM]; Security is enabled
可是再次查看證書信息的話會報錯,由於沒有開啓ssl/tls curl 'http://localhost:9200/_xpack/license'
`{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/_xpack/license]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/_xpack/license]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}`
# 開啓ssl/tls,打開認證 sed -i 's/xpack.security.enabled: false/xpack.security.enabled: true/g' /opt/elasticsearch-7.3.0/config/elasticsearch.yml # 若是須要從新設置密碼,手動設置密碼 ./bin/elasticsearch-setup-passwords interactive # 自動生成密碼: ./bin/elasticsearch-setup-passwords auto Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user. The passwords will be randomly generated and printed to the console. Please confirm that you would like to continue [y/N]y Changed password for user apm_system PASSWORD apm_system = 7zkIYUXQpq8xZdaapTuQ Changed password for user kibana PASSWORD kibana = aQi7k57swBAaDOtvzdm2 Changed password for user logstash_system PASSWORD logstash_system = CboSzpSIq60Zkk0SgpAo Changed password for user beats_system PASSWORD beats_system = ZErooCE4ybll3UcLTsAP Changed password for user remote_monitoring_user PASSWORD remote_monitoring_user = EDYQShIhk5P1vjvpeijI Changed password for user elastic PASSWORD elastic = 3tdAyUIFLMdg79EBnrsg
curl -XGET -u elastic:3tdAyUIFLMdg79EBnrsg http://localhost:9200/_license { "license" : { "status" : "active", "uid" : "537c5c48-c1dd-43ea-ab69-68d209d80c32", "type" : "platinum", "issue_date" : "2019-05-17T00:00:00.000Z", "issue_date_in_millis" : 1558051200000, "expiry_date" : "2049-12-31T16:00:00.999Z", "expiry_date_in_millis" : 2524579200999, "max_nodes" : 1000, "issued_to" : "hkd", "issuer" : "Web Form", "start_date_in_millis" : 1558051200000 } }
由結果能夠看出x-pack到期時間爲2049-12-31,破解完成。也能夠在kibana web頁面管理中查看破解詳情。
useradd kibana cd /opt tar -zxv -f kibana-7.3.0-linux-x86_64.tar.gz chown -R kibana:kibana kibana-7.3.0-linux-x86_64 su - kibana cd /opt/kibana-7.3.0-linux-x86_64 cat config/kibana.yml server.port: 5601 server.host: "192.168.0.253" elasticsearch.hosts: ["http://localhost:9200"] elasticsearch.username: "kibana" elasticsearch.password: "aQi7k57swBAaDOtvzdm2"
瀏覽器訪問:http://192.168.0.253:5601 左側導航查看
以前已經開啓ssl/tls並設置帳號等 停用es,關閉security驗證,替換jar包,開啓es,導入license,啓動es
說明:此方法暫時走不通。
以上說的步驟指的是還沒有開啓security,未設置帳號密碼的狀況。
破解文件和license下載地址:https://files.cnblogs.com/files/sanduzxcvbnm/7.3.0%E7%A0%B4%E8%A7%A3%E6%96%87%E4%BB%B6%E5%92%8Clicense.7z
先按照上述步驟生成破解文件,而後再替換操做