[WhaleCTF reverse problem] The first issue of Android encryption writeup

title information is as follows:

Installation to the simulator can be clearly seen using the XOR operation

JEB loading Find the key in check2 check1 this method There is no use. . .

Then let's see how check2 is operated

public void check2(String s) {
        String v5;
        Int v4 = 0;
        Int[] v7 = new int[16];
        Int v3 = 16;
        Int v1 = 5;
        V7[2] = 3;
        V7[7] = 4;
        V7[3] = 8;
        V7[1] = 10;
        V7[10] = 11;
        V7[0] = 15;
        V7[11] = 20;
        V7[6] = 20;
        V7[8] = 21;
        V7[15] = 24;
        V7[12] = 30;
        V7[13] = v3;
        V7[4] = 3;
        V7[14] = v3;
        V7[9] = 3;
        V7[5] = 89;
        If(s.length() != 16) {//Our input length must be equal to 16
            Throw new RuntimeException();
        }

        Try {
            V5 = this.getKey();//This will call the getKey() method to assign a value to v5.
        }
        Catch(Exception v0) {
            V5 = this.getKey();
            System.arraycopy(v5, 0, s, v1, v1);
        }

        While(v4 < s.length()) {//v4 is equivalent to the loop variable i charAt() is to obtain the corresponding position character.
            If((v7[v4] & 255) != ((s.charAt(v4) ^ v5.charAt(v4 % v5.length())) & 255)) {
                Throw new RuntimeException();
            }

            ++v4;
        }
    }

Then let's take a look at the value of v5

public String getKey() {
        Return "goodluck"; / / v5 value
    }

python code is as follows:

directly put the v7 array out of jeb to save trouble

#coding=utf-8
v4 = 0
v7 = [0] * 16
v3 = 16
v1 = 5
v7[2]=3
v7[7]=4
v7[3]=8
v7[1]=10
v7[10]=11
v7[0]=15
v7[11]=20
v7[6]=20
v7[8]=21
v7[15]=24
v7[12]=30
v7[13]=v3
v7[4]=3
v7[14]=v3
v7[9]=3
v7[5]=89
v5 = 'goodluck'
flag = ''
#b= []
#a[i] & 255 == (s[i] ^ v5[i % len(v5)]) & 255
for i in range(0,len(v7)):
	flag += chr(v7[i] ^ ord(v5[i % len(v5)]))
	#b.append(chr(v7[i] ^ ord(s[i % len(s)])))
print flag
#print b