码迷,mamicode.com
首页 > 其他好文 > 详细

2020 m0leConCTF Andry

时间:2020-05-26 23:29:49      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:lag   pack   image   不难   xor   hex   for   col   一个   

测试文件:

 

代码分析

有两处关键点

获取输入password

第一处

技术图片

Onclick在对我们的键盘事件进行响应处理,调用check_password函数。通过check_password函数,我们知道密码长度为32,且调用了mo2c1等函数,这些函数是libandry-lib.so文件中的。

技术图片

因此,我们可以逆推出输入为

48bb6e862e54f2a795ffc4e541caed4dbf985de4d3d7c5df73cf960638b4bf2

但是我们输入之后,依然会闪退。

 

获取dex文件

第二处

技术图片

这里对enc_payload文件与我们的输入经过XORecrypt函数和DynamicDecode函数,输出flag,这里两个函数都没有定义,需要我们guess。

实际上,XORecrypt函数是将输入与enc_payload文件进行异或,这里不难猜出,可以看到结果

技术图片

猜测应该是生成了一个dex文件,在调用dex文件中DynamicDecode函数,进行解密。写出脚本

# -*- coding:utf-8 -*-

import binascii

a = [72,187,110,134,46,84,242,167,149,255,196,229,65,202,237,77,11,249,133,222,77,61,124,93,247,60,249,96,99,139,75,242]
b = [0x2C,0xDE,0x16,0x8C,0x1E,0x67,0xC7,0xA7,0x36,0x6F,0x11,0xB3,0x0F,0x6E,0x5C,0x13,0x2C,0x1B,0x60,0xE4,0x3C,0x61,0xA4,0xC2,0xDB,0xC0,0xE0,0x02,0x80,0x7F,0x22,0x0D,0xE8,0xBF,0x6E,0x86,0x5E,0x54,0xF2,0xA7,0xED,0xA9,0xF0,0xF7,0x41,0xCA,0xED,0x4D,0x0B,0xF9,0x85,0xDE,0x55,0x39,0x7C,0x5D,0xE0,0x3C,0xF9,0x60,0x13,0x8B,0x4B,0xF2,0x4F,0xBB,0x6E,0x86,0xE2,0x54,0xF2,0xA7,0x9D,0xFF,0xC4,0xE5,0xA9,0xCA,0xED,0x4D,0x0B,0xF9,0x85,0xDE,0x4D,0x3D,0x7C,0x5D,0xFB,0x3C,0xF9,0x60,0x2B,0x8A,0x4B,0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0x25,0xAF,0x8E,0x3F,0x72,0x89,0xF1,0xDE,0x4A,0x58,0x12,0x3E,0x85,0x45,0x89,0x14,0x63,0x8F,0x20,0x97,0x2D,0xCB,0x6E,0x80,0x42,0x31,0x9C,0xC0,0xE1,0x97,0xC4,0xED,0x35,0xA5,0xBE,0x39,0x79,0x90,0xEB,0xB9,0x4D,0x36,0x08,0x32,0xA2,0x4C,0x89,0x05,0x11,0xC8,0x2A,0x81,0x2D,0xBB,0x6E,0x86,0x2D,0x55,0xF2,0x26,0x15,0xFB,0x0C,0xE6,0x40,0xC3,0x0D,0x4E,0x0A,0xF0,0x69,0xDA,0x4E,0x3C,0x84,0x58,0xFC,0x3C,0xF9,0x60,0x63,0x8B,0x4B,0xF2,0x49,0xBB,0x6E,0x86,0x2E,0x54,0xF2,0xA7,0x94,0xFF,0xC4,0xE5,0x56,0xCA,0xED,0x4D,0x7B,0xF9,0x85,0xDE,0x4F,0x3D,0x7C,0x5D,0xF0,0x3C,0xF9,0x60,0xAF,0x8B,0x4B,0xF2,0x4B,0xBB,0x6E,0x86,0x26,0x54,0xF2,0xA7,0x7D,0xFF,0xC4,0xE5,0x44,0xCA,0xED,0x4D,0x07,0xF9,0x85,0xDE,0x05,0x3C,0x7C,0x5D,0xF1,0x3C,0xF9,0x60,0x62,0x8B,0x4B,0xF2,0xE0,0xBA,0x6E,0x86,0x2F,0x74,0xF2,0xA7,0x91,0xFF,0xC4,0xE5,0x89,0xCB,0xED,0x4D,0x0A,0xE9,0x85,0xDE,0x49,0x3D,0x7C,0x5D,0xFB,0x3F,0xF9,0x60,0x61,0xAB,0x4B,0xF2,0x5F,0xBB,0x6E,0x86,0x04,0x57,0xF2,0xA7,0x95,0xDF,0xC4,0xE5,0x40,0xCA,0xED,0x4D,0x09,0xFD,0x85,0xDE,0x4D,0x2D,0x7C,0x5D,0xF6,0x3C,0xF9,0x60,0x7B,0x8F,0x4B,0xF2]

data = []

for i in range(len(b)):
    data.append(b[i]^a[i%len(a)])
print (data)

s = ‘‘
for x in data:
    tmp =  hex(x)[2:]
    if len(tmp) == 1:
        tmp = 0+tmp
    s += tmp
print (s)
s = binascii.a2b_hex(s)

with open(biu.dex,wb+) as f:
    f.write(s)

 

dex解密

package p000;

/* renamed from: Inner */
public class Inner {
    public static String decrypt(String str) {
        int i = 0;
        String upperCase = "NUKRPFUFALOXYLJUDYRDJMXHMWQW".toUpperCase();
        String str2 = "";
        for (int i2 = 0; i2 < upperCase.length(); i2++) {
            str2 = str2 + ((char) ((((upperCase.charAt(i2) - str.charAt(i)) + 26) % 26) + 65));
            i = (i + 1) % str.length();
        }
        return str2;
    }

    public static String encrypt(String str, String str2) {
        int i = 0;
        String upperCase = str.toUpperCase();
        String str3 = "";
        for (int i2 = 0; i2 < upperCase.length(); i2++) {
            str3 = str3 + ((char) ((((upperCase.charAt(i2) - ‘A‘) + (str2.charAt(i) - ‘A‘)) % 26) + 65));
            i = (i + 1) % str2.length();
        }
        return str3;
    }

    public void keep() {
    }
}

调用的decrypt函数,我们能够很轻松写出脚本解密

s = "EASYPEASY"
m = "NUKRPFUFALOXYLJUDYRDJMXHMWQW".upper()
flag = ‘‘
i = 0
for j in range(len(m)):
    flag += chr(((ord(m[j]) - ord(s[i]))+26)%26+65)
    i = (i+1)%len(s)
print (ptm{+flag+})

 

get flag!

ptm{JUSTABUNCHOFAWFULANDROIDMESS}

 

ptm{JUSTABUNCHOFAWFULANDROIDMESS}

2020 m0leConCTF Andry

标签:lag   pack   image   不难   xor   hex   for   col   一个   

原文地址:https://www.cnblogs.com/Mayfly-nymph/p/12969463.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!