current position:Home>Buuctf reverse Java reverse decryption (rowing)

Buuctf reverse Java reverse decryption (rowing)

2022-01-27 01:42:37 VVeaker

obtain class I'll drag the file in directly idea 了

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

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

public class Reverse {
    
    public 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(int i = 0; i < arr.length; ++i) {
    
            int result = arr[i] + 64 ^ 32;
            Resultlist.add(result);
        }

        int[] KEY = new int[]{
    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 j = 0; j < KEY.length; ++j) {
    
            KEYList.add(KEY[j]);
        }

        System.out.println("Result:");
        if (Resultlist.equals(KEYList)) {
    
            System.out.println("Congratulations!");
        } else {
    
            System.err.println("Error!");
        }

    }
}

Write reverse script

target = [180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65]
str = ''
for i in range(len(target)):
    inter = target[i] - 64 ^ 32
    str += chr(inter)
print(str)

The first time I didn't know their operation priority was written like this
inter = target[i] - (64 ^ 32)
The result is naturally wrong

copyright notice
author[VVeaker],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270142354327.html

Random recommended