ELK 6.X 版本下xpack破解
ELK 6.2.2 版本下xpack破解
1、下载xpack
先下载最新版本的 x-pack,里面包含了 es,kibana,logstash 新版本的x-pack 下载地址:https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-6.2.2.zip
2、安装xpack
之后到es目录执行 # ./bin/elasticsearch-plugin install file:///soft/x-pack-6.2.2.zip 或者: # bin/elasticsearch-plugin install x-pack 安装过程需要同意下协议 回车 输入y 回车 会提示安装成功
3、破解xpack
在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格式
4、修改class内容
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); } }
5、重新编译
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
6、重新压缩x-pack-core-6.2.2.jar
使用压缩软件winrar打开x-pack-core-6.2.2.jar,将重新编译得到的XPackBuild.class和LicenseVerifier.class文件 拖到原先位置。
7、替换破解后的文件
将文件上传到 目录/elasticsearch-6.2.2/plugins/x-pack/x-pack-core/下 替换原来的x-pack-core-6.2.2.jar文件
8、重置密码 (可选)
初次安装需要重置默认的帐号密码 # ./bin/x-pack/setup-passwords interactive 这样破解的x-pack就安装好了
9、修改授权文件
{ "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功能
10、导入授权文件
curl -u elastic:IjJ2Em8ZKybhvAPoI1iZ -XPUT 'http://192.168.23.35:9200/_xpack/license' -H "Content-Type: application/json" -d @/soft/license.json #注意:集群中的每台 Elasticsearch 都是需要安装授权,同时记得文件前面的 @ 符号