题目:BUUCTF Java逆向解密
没壳,是java文件(大概)
ida打开看不懂,找了网页上的java反编译
Decompiler.com
没用过java啊…暂且用sublime打开
还好还挺好懂的
import java.util.ArrayList;
import java.util.Scanner;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(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]);}//KEYList和KEY的元素完全相同,就是一个是ArrayList<Integer>一个是int数组(?System.out.println("Result:");if (Resultlist.equals(KEYList)) {//Resultlist和KEYList相同System.out.println("Congratulations!");} else {System.err.println("Error!");}}
}
唯一有的说的就是那句
int result = arr[i] + 64 ^ 32;
注意加优先级比异或高,逆推得到
arr[i] = (result ^ 32) - 64
写代码!
int a[] = {180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65};for (int i = 0; i < sizeof(a) / sizeof(int); i++)cout << char((a[i] ^ 32) - 64);