ELK 6.X 版本下xpack破解

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 都是須要安裝受權,同時記得文件前面的 @ 符號
相關文章
相關標籤/搜索