easyapk
第一步一般都是先查壳(不过这种刚刚入门的题目基本上都是没壳的啦??)
然后先运行一下看看是个啥...
这个框是输入不了的。
拖到jeb或者jadx里面瞅瞅,这个界面就一个很明显的MainActivity,也不用adb dump当前活动了
很明显,就是获取text View文本框的内容,进行base64加密然后跟“5rFf7E2K6rqN7Hpiyush7E6S5fJg6rsi5NBf6NGT5rs=”比较即可,那整体思路就是对这个字符串进行解密即可。
但是注意到
这个base64是被重写过的。
package com.testjava.jack.pingan1;
public class Base64New {
private static final char[] Base64ByteToStr = {‘v‘, ‘w‘, ‘x‘, ‘r‘, ‘s‘, ‘t‘, ‘u‘, ‘o‘, ‘p‘, ‘q‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘, ‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘, ‘F‘, ‘G‘, ‘H‘, ‘I‘, ‘J‘, ‘y‘, ‘z‘, ‘0‘, ‘1‘, ‘2‘, ‘P‘, ‘Q‘, ‘R‘, ‘S‘, ‘T‘, ‘K‘, ‘L‘, ‘M‘, ‘N‘, ‘O‘, ‘Z‘, ‘a‘, ‘b‘, ‘c‘, ‘d‘, ‘U‘, ‘V‘, ‘W‘, ‘X‘, ‘Y‘, ‘e‘, ‘f‘, ‘g‘, ‘h‘, ‘i‘, ‘j‘, ‘k‘, ‘l‘, ‘m‘, ‘n‘, ‘8‘, ‘9‘, ‘+‘, ‘/‘};
private static final int RANGE = 255;
private static byte[] StrToBase64Byte = new byte[128];
public String Base64Encode(byte[] bytes) {
StringBuilder res = new StringBuilder();
for (int i = 0; i <= bytes.length - 1; i += 3) {
byte[] enBytes = new byte[4];
byte tmp = 0;
for (int k = 0; k <= 2; k++) {
if (i + k <= bytes.length - 1) {
enBytes[k] = (byte) (((bytes[i + k] & 255) >>> ((k * 2) + 2)) | tmp);
tmp = (byte) ((((bytes[i + k] & 255) << (((2 - k) * 2) + 2)) & 255) >>> 2);
} else {
enBytes[k] = tmp;
tmp = 64;
}
}
enBytes[3] = tmp;
for (int k2 = 0; k2 <= 3; k2++) {
if (enBytes[k2] <= 63) {
res.append(Base64ByteToStr[enBytes[k2]]);
} else {
res.append(‘=‘);
}
}
}
return res.toString();
}
}
这题主要学到了Base64编码原理:
????1、将字符串转为字节数组,然后每3个字节一组,一个24个比特,不足3个字节直接补0
????2、在每一组3个字节24bit中,以6个bit构成一个字节(高两位补0),形成4个字节为一组
????3、根据编码后的字节查找对照表,拼接成字符串,自此,Base64编码完成!!!
以及Base64解码原理:
????1、将编码后的字符串查找对照表后的字节以4个字节为一组,出现=直接去掉即可
????2、将这4个字节每个字节的高两位去掉,有32bit变为24bit,将这24bit以8个bit构成三个字节
????3、将第二步得到的字节数组转为字符串即
exp.py:
def Base64Decode(str_list):
list_base = []
a = str_list[0] << 2
c = str_list[1] & 15
b = str_list[1] >> 4
a = a | b
list_base.append(a)
c = c << 4
a = str_list[2] & 3
b = str_list[2] >> 2
c = c | b
list_base.append(c)
a = a << 6
a = a | str_list[3]
list_base.append(a)
return list_base
CodingTable = ‘vwxrstuopq34567ABCDEFGHIJyz012PQRSTKLMNOZabcdUVWXYefghijklmn89+/‘
Ciphertext = ‘5rFf7E2K6rqN7Hpiyush7E6S5fJg6rsi5NBf6NGT5rs=‘
i = 0
flag = ‘flag{‘
while i <= (len(Ciphertext) - 1):
list1 = []
n = 0
for k in range(4):
if Ciphertext[i + k] == ‘=‘:
list1.append(0)
n = n + 1
else:
list1.append(CodingTable.index(Ciphertext[i + k]))
ba = Base64Decode(list1)
for j in range(3 - n):
ch = chr(ba[j])
flag = flag + str(ch)
i = i + 4
flag = flag + ‘}‘
print(flag)
运行截图: