ELK 6.2.2 版本下xpack破解java
一、下载xpacknode
先下载最新版本的 x-pack,里面包含了 es,kibana,logstash 新版本的x-pack 下载地址:https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-6.2.2.zip
二、安装xpackapache
以后到es目录执行 # ./bin/elasticsearch-plugin install file:///soft/x-pack-6.2.2.zip 或者: # bin/elasticsearch-plugin install x-pack 安装过程须要赞成下协议 回车 输入y 回车 会提示安装成功
三、破解xpackjson
在windows环境下,解压 x-pack-6.2.2.zip文件,进入x-pack-6.2.2\elasticsearch\core\找到文件x-pack-core-6.2.2.jar 找到两个class文件,分别为 org.elasticsearch.license.LicenseVerifier.class org.elasticsearch.xpack.core.XPackBuild.class 反编译出文件,保存为.java格式
四、修改class内容windows
1)修改 LicenseVerifier.java文件 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; } ####### } 2)修改XPackBuild.java文件 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); } }
五、从新编译app
javac -cp "/usr/share/elasticsearch/lib/elasticsearch-6.2.2.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.2.jar:/usr/share/elasticsearch/lib/elasticsearch-core-6.2.2.jar" XPackBuild.java javac -cp "/usr/share/elasticsearch/lib/elasticsearch-6.2.2.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.2.jar" LicenseVerifier.java
六、从新压缩x-pack-core-6.2.2.jarcurl
使用压缩软件winrar打开x-pack-core-6.2.2.jar,将从新编译获得的XPackBuild.class和LicenseVerifier.class文件 拖到原先位置。
七、替换破解后的文件elasticsearch
将文件上传到 目录/elasticsearch-6.2.2/plugins/x-pack/x-pack-core/下 替换原来的x-pack-core-6.2.2.jar文件
八、重置密码 (可选)ui
初次安装须要重置默认的账号密码 # ./bin/x-pack/setup-passwords interactive 这样破解的x-pack就安装好了
九、修改受权文件this
{ "license": { "uid": "aa", "type": "platinum", #修改受权 "issue_date_in_millis": 1519689600000, "expiry_date_in_millis": 2524579200999, #修改到期时间 "max_nodes": 1000, #按须要修改 "issued_to": "aa", "issuer": "Web Form", "signature": "AAAAAwAAAA019", "start_date_in_millis": 1519689600000 } }
#咱们将过时时间写到2050年,type改成platinum 白金版,这样咱们就会拥有所有的x-pack功能
十、导入受权文件
curl -u elastic:IjJ2Em8ZKybhvAPoI1iZ -XPUT 'http://192.168.23.35:9200/_xpack/license' -H "Content-Type: application/json" -d @/soft/license.json #注意:集群中的每台 Elasticsearch 都是须要安装受权,同时记得文件前面的 @ 符号