1

How to crack xpack license on elasticsearch

the script for crack xpack, it will generate a xpack crack jar and a license.json;

usage: replace the value of ES_HOME to your own directory where the elasticsearch were installed in.
notice: before you run this script, ensure you already install jdk environment correctly, the command javac are necessary to compile the LicenseVerifier.java.

[root@elasticsearch cracker_xpack]# cat crack_xpack.sh 
#!/bin/bash

ES_HOME='/usr/local/elasticsearch-6.0.0'

[ ! -d "${ES_HOME}" ] && echo "directory ${ES_HOME} does not exist!" > /dev/stderr && exit

lib_dir="${ES_HOME}/lib"

elasticsearch_jar_name=$(/bin/ls ${lib_dir} | grep -E '^elasticsearch-.*\.jar$')
[ $? -ne 0 ] && echo "could not found elasticsearch-x.x.x.jar in ${lib_dir}" && exit 1

lucene_core_jar_name=$(/bin/ls ${lib_dir} | grep -E '^lucene-core-.*\.jar$')
[ $? -ne 0 ] && echo "could not found lucene-core-x.x.x.jar in ${lib_dir}" && exit 1

xpack_jar_base_dir="${ES_HOME}/plugins/x-pack"
xpack_jar_name=$(/bin/ls ${xpack_jar_base_dir} | grep -E '^x-pack-.*\.jar$')
[ $? -ne 0 ] && echo "could not found x-pack-x.x.x.jar in ${xpack_jar_base_dir}" && exit 1

base_dir=$(mktemp -d --tmpdir $(basename $0).XXXXXXXX)
cd ${base_dir}

source_java_prefix='LicenseVerifier'
cat > ${source_java_prefix}.java << EOF_License
package org.elasticsearch.license;

public class LicenseVerifier
{
    public static boolean verifyLicense(final License license, final byte[] encryptedPublicKeyData) {
        return true;
    }
    
    public static boolean verifyLicense(final License license) {
        return true;
    }
}
EOF_License

javac -cp ${lib_dir}/${elasticsearch_jar_name}:${lib_dir}/${lucene_core_jar_name}:${xpack_jar_base_dir}/${xpack_jar_name} ${source_java_prefix}.java
mkdir xpack
cd xpack
jar -xf ${xpack_jar_base_dir}/${xpack_jar_name}
/bin/cp ../${source_java_prefix}.class org/elasticsearch/license/
jar -cf /tmp/${xpack_jar_name}.crack *
cat > /tmp/xpack_license.json << EOF_xpack_json
{"license":{"uid":"a122316a-1e06-4f91-9534-8d8418b97b1b","type":"platinum","issue_date_in_millis":1515628800000,"expiry_date_in_millis":2831215737000,"max_nodes":1000,"issued_to":"Roc Shen (Roc)","issuer":"Web Form","signature":"AAAAAwAAAA17GxIYIuMJmQjY1FP9AAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQCX+UD6bN8Y30VOr7KRBPPIpZ6487L6HHl4p0KtTlc9+zb50v22VhL+WuAbJbV0ZA7I5bUSBBqFIYgqbx1Wi/egaZ+TbY0wz8uaKvL6DICVZ/Ec1OBE6U/1aRQWASOhZ9aQZ2GynxwTNut8Q9YkbyvEhlevxpX/ZUMmDafG7P3CeslqTI07gx6zZj9zyDFB/S6I/WonpZZgjftDViSqhNTDgwOLZd8otpNxU1Ws162Eb2wafCxeRWMl6DaQJW1v4sLtnvIzzVh6rZsSaGdJsq/BqVOnoUrDHO9HPUS6zt8wCZch4c86dSMyEJ7TjNlP9FZ9JYiPaXw6yG2FbSFhBJpM","start_date_in_millis":1515628800000}}
EOF_xpack_json

cat << EOF
*********************************************************************************************
xpack crack file: /tmp/${xpack_jar_name}.crack     md5:$(md5sum /tmp/${xpack_jar_name}.crack | awk '{print $1}')
license file: /tmp/xpack_license.json        md5:$(md5sum /tmp/xpack_license.json | awk '{print $1}')
*********************************************************************************************
EOF

/bin/rm -rf ${base_dir}
execute that script
[root@elasticsearch cracker_xpack]# bash crack_xpack.sh
*********************************************************************************************
xpack crack file: /tmp/x-pack-6.0.0.jar.crack     md5:388b2887432262d94a0de10007b47a52
license file: /tmp/xpack_license.json        md5:91b8e861a28e7a99d3d55e3f0dbc3fcf
*********************************************************************************************
[root@elasticsearch cracker_xpack]#
before we upgrade license, the expire_date was one month later from the day wo install x-pack.
[elasticsearch@elasticsearch elasticsearch-6.0.0]$ curl -u elastic http://localhost:9200/_license?pretty
Enter host password for user 'elastic':
{
  "license" : {
    "status" : "active",
    "uid" : "f9b38dc5-4b6a-489c-9b1d-dbc2dfef28e2",
    "type" : "trial",
    "issue_date" : "2018-01-12T10:05:53.481Z",
    "issue_date_in_millis" : 1515751553481,
    "expiry_date" : "2018-02-11T10:05:53.481Z",
    "expiry_date_in_millis" : 1518343553481,
    "max_nodes" : 1000,
    "issued_to" : "elasticsearch",
    "issuer" : "elasticsearch",
    "start_date_in_millis" : -1
  }
}
[elasticsearch@elasticsearch elasticsearch-6.0.0]$ 
upgrade the license from xpack api, there's another few steps we'll to do it first.

1) replace the x-pack-x.x.x.jar.

[elasticsearch@elasticsearch elasticsearch-6.0.0]$ cp /tmp/x-pack-6.0.0.jar.crack plugins/x-pack/x-pack-6.0.0.jar 

2)restart the elasticsearch service.
3)upgrade the license.

[elasticsearch@elasticsearch elasticsearch-6.0.0]$ curl -XPUT -u elastic 'http://localhost:9200/_xpack/license?pretty' -H "Content-Type: application/json" -d @/tmp/xpack_license.json
Enter host password for user 'elastic':
{
  "acknowledged" : true,
  "license_status" : "valid"
}
[elasticsearch@elasticsearch elasticsearch-6.0.0]$ 

4)the license has been upgrade to a platinum role to play with elasticsearch. The most important is the license are avaliable untill 2059-09-19.

[elasticsearch@elasticsearch elasticsearch-6.0.0]$ curl -u elastic http://localhost:9200/_license?pretty
Enter host password for user 'elastic':
{
  "license" : {
    "status" : "active",
    "uid" : "a122316a-1e06-4f91-9534-8d8418b97b1b",
    "type" : "platinum",
    "issue_date" : "2018-01-11T00:00:00.000Z",
    "issue_date_in_millis" : 1515628800000,
    "expiry_date" : "2059-09-19T16:48:57.000Z",
    "expiry_date_in_millis" : 2831215737000,
    "max_nodes" : 1000,
    "issued_to" : "Roc Shen (Roc)",
    "issuer" : "Web Form",
    "start_date_in_millis" : 1515628800000
  }
}
[elasticsearch@elasticsearch elasticsearch-6.0.0]$ 


已注销
73 声望14 粉丝

运维工程师