几个常用函数的用法
substring(v1,v2)取 v1-v2的字符
m.equals(n) 比较m,n相同返回ture
str.charAt(1)表示从str中取第一个字符
程序用了三个函数进行加密
secodeStr()是flag的前半段
thirdstr()是flag的后半段
private boolean getFlag(String arg8) {
String v0 = first.firstStr(arg8);
int v2 = 15;
if(v0.length() < v2) {
return 0;
}
int v1 = 5;
if(v0.substring(0, v1).equals("flag{")) {
if(!v0.substring(v0.length() - 1).equals("}")) {
}
else {
String v1_1 = v0.substring(v1, v2);
String v2_1 = v0.substring(v2, v0.length() - 1);
if(!v1_1.equals(second.secondStr())) {
return 0;
}
else if(!third.thirdStr(v2_1)) {
return 0;
}
else {
return 1;
}
}
}
firststr()函数是将字符串中的某些字符做一些替换
public static String firstStr(String arg2) {
return arg2.replace("B1", "dN").replace("_", "8").replace("!", "P").replace("rea", "hwl").replace('1', 'u').replace("m", "+");
}
secondStr()函数是将字符串进行AES解密输出,直接用Java复写就可以,注意base64解密函数的用法
public static String secondStr() {
String v0 = "";
String v1 = "9z2ukkD3Ztxhj+t/S1x1Eg==";
byte[] v2 = "1234567890123456".getBytes();
String v3 = "AES/ECB/NoPadding";
String v4 = "AES";
try {
byte[] v5_1 = Base64.decode(v1, 0);
SecretKeySpec v6 = new SecretKeySpec(v2, v4);
Cipher v7 = Cipher.getInstance(v3);
v7.init(2, ((Key)v6));
return new String(v7.doFinal(v5_1)).replace(" ", ((CharSequence)v0));
}
catch(Exception v5) {
v5.printStackTrace();
return v0;
}
}
第三个函数对每个字符进行了判断,只有8个字符,手撕即可,得到的结果如下
v12=80
v10=84
v9=108
v8=119
v6=104
v5=57
v4=104
public static boolean thirdStr(String arg14) {
int v1 = 8;
if(arg14.length() != v1) {
return 0;
}
int v0 = arg14.charAt(0);
int v4 = arg14.charAt(1);
int v5 = arg14.charAt(2);
int v6 = arg14.charAt(3);
int v7 = 4;
int v8 = arg14.charAt(v7);
int v9 = arg14.charAt(5);
int v10 = arg14.charAt(6);
int v12 = arg14.charAt(7);
if(v0 % 8 == 7) {
if(v0 % 9 != v1) {
}
else {
int v11 = 100;
if(v4 - 3 != v11) {
return 0;
}
else if((v5 ^ 93) != v11) {
return 0;
}
else if(v5 * 2 - 10 != v6) {
return 0;
}
else if(v8 + 1 != 120) {
return 0;
}
else if((v9 ^ v10) != 56) {
return 0;
}
else {
if(v9 - v10 == 24) {
if(v10 - v12 != v7) {
}
else if(v12 != 80) {
return 0;
}
else {
return 1;
}
}
return 0;
}
}
}
第二个函数解除的字符串为 0dNlE8us8
第三个函数解除的字符串为 Gh9hwlTP
然后再用第一个函数进行替换 得到的字符串为 0B1lE_1s_Gh9reaT!
replace("B1", "dN").replace("_", "8").replace("!", "P").replace("rea", "hwl").replace('1', 'u').replace("m", "+")