landv / landv.github.io

landv-blogs
https://landv.cn
2 stars 0 forks source link

[tcsl]天财商龙密码破解&pos站点登录和退出时间 #77

Open landv opened 1 year ago

landv commented 1 year ago

pos站点登录和退出时间

SELECT * FROM "biz_ps" WHERE open_time >= '2020-05-19' AND operator_id ='5259200000000000129'

fu主文件

使用打印出来的MD5值,进行解密https://www.cmd5.com/

import org.apache.commons.lang3.StringUtils;

public class fu {

    public static void main(String[] args) {
        System.out.println("1234567890");
        System.out.println(encrypt("1234567890"));
        // SmtwXtnZCOr6NA9kmAfXQSlz78c/sjAcPCQKYkc2qHv7b3hIuTykfQ==
        System.out.println(fuck("SmtwXtnZCOr6NA9kmAfXQSlz78c/sjAcPCQKYkc2qHv7b3hIuTykfQ=="));
        // password 数据库原始密码
        String aa = DESUtil.decrypt(fuck("bQmdPd1p5TqodxYpwNdTXMqztI87/xCdwFTT58TccSv7b3hIuTykfQ=="),"tcslTcsltcsl");
        System.out.printf("MD5:"+aa);

    }
    public static byte[] fuck(String password){
        if (StringUtils.isBlank(password)) {
            return null;
        }
        return Base64Utils.decode(password);
    }

    public static String encrypt(String password) {
        if (StringUtils.isBlank(password)) {
            return null;
        }
        String md5 = MD5Util.getMD5(password);
        byte[] bs = DESUtil.encrypt(md5, "tcslTcsltcsl");
        String base64 = Base64Utils.encode(bs);

        return base64;
    }
}

Base64Utils

//package cn.com.tcsl.framework.common.util;

import java.nio.charset.Charset;
import org.apache.commons.codec.binary.Base64;

public class Base64Utils
{
    public static byte[] decode(String base64) { return Base64.decodeBase64(base64.getBytes(Charset.forName("UTF-8"))); }

    public static String encode(byte[] bytes) { return new String(Base64.encodeBase64(bytes), Charset.forName("UTF-8")); }
}

DESUtil

//package cn.com.tcsl.framework.common.util;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

public class DESUtil
{
    public static byte[] encrypt(String source, String keyStr) {
        try {
            byte[] sourceBytes = source.getBytes("UTF-8");

            Key key = getKey(keyStr);

            Cipher cipher = Cipher.getInstance("DES");

            cipher.init(1, key);

            return cipher.doFinal(sourceBytes);
        }
        catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (NoSuchPaddingException e) {
            throw new RuntimeException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        } catch (InvalidKeyException e) {
            throw new RuntimeException(e);
        } catch (IllegalBlockSizeException e) {
            throw new RuntimeException(e);
        } catch (BadPaddingException e) {
            throw new RuntimeException(e);
        }
    }

    public static byte[] encrypt(String source) { return encrypt(source, null); }

    public static String decrypt(byte[] source, String keyStr) {
        try {
            Key key = getKey(keyStr);

            Cipher cipher = Cipher.getInstance("DES");

            cipher.init(2, key);

            byte[] dissect = cipher.doFinal(source);
            return new String(dissect);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (NoSuchPaddingException e) {
            throw new RuntimeException(e);
        } catch (InvalidKeyException e) {
            throw new RuntimeException(e);
        } catch (IllegalBlockSizeException e) {
            throw new RuntimeException(e);
        } catch (BadPaddingException e) {
            throw new RuntimeException(e);
        }
    }
    public static String decrypt(byte[] source) { return decrypt(source, null); }

    private static Key getKey(String keyStr) {
        if (keyStr == null) {
            return getKey();
        }

        try {
            byte[] bs = Base64Utils.decode(keyStr);

            KeySpec dks = new DESKeySpec(bs);

            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");

            return keyFactory.generateSecret(dks);
        } catch (InvalidKeyException e) {
            throw new RuntimeException(e);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (InvalidKeySpecException e) {
            throw new RuntimeException(e);
        }
    }

    private static Key getKey() { return getKey("s7Oh75I+1ew="); }

    public static void main(String[] args) throws Exception {
        System.out.println(encrypt("yang哈哈tao"));
        System.out.println(decrypt(encrypt("aabbc啊啊cdd")));
        System.out.println(Base64Utils.encode(encrypt("hjc")));
        System.out.println(decrypt(Base64Utils.decode(Base64Utils.encode(encrypt("hjc")))));
        System.out.println("MD5加密后的编码:" + MD5Util.getMD5("hjc"));
        System.out.println("MD5作为参数加密:" + Base64Utils.encode(encrypt(MD5Util.getMD5("hjc"))));
        System.out.println("MD5作为参数解密:" + decrypt(Base64Utils.decode(Base64Utils.encode(encrypt(MD5Util.getMD5("hjc"))))));
    }

}

MD5Util

//package cn.com.tcsl.framework.common.util;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;

public class MD5Util
{
    public static String getMD5(String data) {
        if (StringUtils.isBlank(data)) {
            return null;
        }
        return DigestUtils.md5Hex(data);
    }

    public static void main(String[] args) throws Exception { System.out.println(getMD5("yangtao")); }
}

输出效果

1234567890
SmtwXtnZCOr6NA9kmAfXQSlz78c/sjAcPCQKYkc2qHv7b3hIuTykfQ==
[B@3d494fbf
MD5:c6f057b86584942e415435ffb1fa93d4
Process finished with exit code 0

image