BugkuCTF 逆向 easy-100(LCTF)

BugkuCTF 逆向 easy-100(LCTF)

(原创)
原题如下:
BugkuCTF 逆向 easy-100(LCTF)_第1张图片
下载附件:
在这里插入图片描述
原题中的关键代码:

private void getKey(){
    try {
        InputStream stream = this.getResources().getAssets().open("url.png");
        int v = stream.available();
        byte[] bs = new byte[v];
        stream.read(bs, 0, v);
        byte[] keybyte = new byte[16];
        System.arraycopy(bs, 144, keybyte, 0, 16);
        this.key = new String(keybyte, "utf-8");
    }
    catch (Exception e){
        e.printStackTrace();
    }
    //code
}
private String handle(String naive){
    try {
        naive.getBytes("utf-8");
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < naive.length(); i += 2) {
            str.append(naive.charAt(i + 1));
            str.append(naive.charAt(i));
        }
        return str.toString();
 
    }catch (UnsupportedEncodingException e){
        e.printStackTrace();
    }
    return null;
}        
protected void Encryption(byte[] key){
    try {
        if (key == null) {
            byte[] bytes = "".getBytes("utf-8");
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            byte[] bytes1 = messageDigest.digest(bytes);
 
            secretKeySpec = new SecretKeySpec(bytes1, "AES");
            cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        }
        else {
            secretKeySpec = new SecretKeySpec(key, "AES");
            cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        }
    }except{
        //...
    }
}

从png文件中获得key,使用handle函数进行奇偶位互换

byte[] bye = {21,-93,-68,-94,86,117,-19,-68,-92,33,50,118,16,13,1,-15,-13,3,4,103,-18,81,30,68,54,-93,44,-23,93,98,5,59};
new String(bye);

flag密文解密,得到flag。

你可能感兴趣的:(BugkuCTF 逆向 easy-100(LCTF))