BUUCTF Java逆向解密 1

Class文件是Java编译后的二进制字节码文件。
我这里使用的是jadx-gui,直接将class文件拖进去即可

package defpackage;

import java.util.ArrayList;
import java.util.Scanner;

/* renamed from: Reverse  reason: default package */
/* loaded from: Reverse.class */
public class Reverse {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println("Please input the flag :");
        String str = s.next();
        System.out.println("Your input is :");
        System.out.println(str);
        char[] stringArr = str.toCharArray();
        Encrypt(stringArr);
    }

    public static void Encrypt(char[] arr) {
        ArrayList<Integer> Resultlist = new ArrayList<>();
        for (char c : arr) {
            int result = (c + '@') ^ 32;
            Resultlist.add(Integer.valueOf(result));
        }
        int[] KEY = {180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65};
        ArrayList<Integer> KEYList = new ArrayList<>();
        for (int i : KEY) {
            KEYList.add(Integer.valueOf(i));
        }
        System.out.println("Result:");
        if (Resultlist.equals(KEYList)) {
            System.out.println("Congratulations!");
        } else {
            System.err.println("Error!");
        }
    }
}

代码的逻辑也非常简单

if (Resultlist.equals(KEYList)) {
            System.out.println("Congratulations!");
}

主要就是我们输入的值最后需要等于KEYList这个数组,而KEYList的值就是

int[] KEY = {180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65};

exp

java

public class Test {
    public static void main(String[] args) {
        int[] KEY = {180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65};
        char cArr[] = new char[KEY.length * 2];
        for (int i = 0; i < KEY.length; i++) 
            cArr[i] = (char)((KEY[i] ^ 32 ) - '@');
        System.out.println(new String(cArr));
    }
 }

python

KEY = [180, 136, 137, 147, 191, 137, 147, 191,148, 136, 133, 191, 134, 140, 129, 135, 191, 65]
cArr = [chr(((KEY[i] ^ 32) - ord('@'))) for i in range(len(KEY))]
print(''.join(cArr))

flag

flag{This_is_the_flag_!}

你可能感兴趣的:(#,reverse,java,网络安全,buuctf,reverse)