DASCTF-BabyAndroid

一个apk文件

下载下运行不出来

题目有提示

这是截取的信息

第一次写,我就按照大佬的wp思路来

首先我们确定

Host: yuanshen.com

这个信息

jeb打开,搜索

成功锁定到有价值的信息

protected String doInBackground(String[] params) {
            String contentText = params[0];
            try {
                ByteBuffer byteBuffer0 = ByteBuffer.wrap(NoteActivity.this.loadData("Sex.jpg"));
                Class class0 = (Build.VERSION.SDK_INT < 26 ? null : new InMemoryDexClassLoader(byteBuffer0, NoteActivity.this.getClassLoader())).loadClass("site.qifen.note.ui.Encrypto");
                Method method0 = class0.getMethod("encrypt", String.class);
                NoteActivity.this.contentText_back = contentText;
                String cipher = (String)method0.invoke(class0.getDeclaredConstructor().newInstance(), NoteActivity.this.sendInit(contentText));
                Log.d("JNITest", "Server Response: " + sendRequest.sendPost("http://yuanshen.com/", "data=" + cipher));
                return cipher;
            }
            catch(Exception e) {
                e.printStackTrace();
                return null;
            }
        }

首先用一个JPG文件?

查看一下loaddate

一个RC4

 Class class0 = (Build.VERSION.SDK_INT < 26 ? null : new InMemoryDexClassLoader(byteBuffer0, NoteActivity.this.getClassLoader())).loadClass("site.qifen.note.ui.Encrypto");

又加载了一个函数

我们去寻找一下

只发现了这个 encry0(注意原函数引用的o)

这是看出来了,是一个AES加密

可以看见这个keybytes16,被赋值了

它才是密钥,但是我们找不到这个值,也没找到相关的引用

同时DSACTF是初始的key

但是长度也够16的倍数

所以我们还是需要去找到encryo这个函数

先继续分析

这里用了invoke还有sendinint函数

我们找一下(换到JADX)

可以看见invoke就是一个check格式

在library的库中

这里我们可以看见就只要一个so文件

我们现在来理一下:

三个过程---jpg的函数-----encryo-------sendinit函数

一个一个来

jpg

很容易就找到他

用010把他的16进制倒出来

放厨子里面去

厨子自动识别出来了这是dex文件

我们导出这个文件

!

这里就是我们要的encrypto函数

package site.qifen.note.p000ui;

import android.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

/* renamed from: site.qifen.note.ui.Encrypto */
/* loaded from: C:\Users\15598\Desktop\download.dex */
public class Encrypto {
    private static final String KEY = "DSACTF";
    private static final String TAG = "Encrypto";

    private static byte[] customHash(String input) {
        byte[] keyBytes = new byte[16];
        int[] temp = new int[16];
        for (int i = 0; i < input.length(); i++) {
            int charVal = input.charAt(i);
            for (int j = 0; j < 16; j++) {
                temp[j] = ((temp[j] * 31) + charVal) % 251;
            }
        }
        for (int i2 = 0; i2 < 16; i2++) {
            keyBytes[i2] = (byte) (temp[i2] % 256);
        }
        return keyBytes;
    }

    public static String encrypt(String data) throws Exception {
        byte[] keyBytes = customHash(KEY);
        SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "AES");
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(1, secretKeySpec);
        byte[] encryptedBytes = cipher.doFinal(data.getBytes("UTF-8"));
        return Base64.encodeToString(encryptedBytes, 2);
    }
}

分析可知

对密钥进行了操作

我们直接复制粘贴

import java.security.Key;

public class Main {
    private static final String key = "DASCTF";

    private static byte[] customHash(String input) {
        byte[] keyBytes = new byte[16];
        int[] temp = new int[16];
        for (int i = 0; i < input.length(); i++) {
            int charVal = input.charAt(i);
            for (int j = 0; j < 16; j++) {
                temp[j] = ((temp[j] * 31) + charVal) % 251;
            }
        }
        for (int i2 = 0; i2 < 16; i2++) {
            keyBytes[i2] = (byte) (temp[i2] % 256);
        }
        return keyBytes;
    }

    public static void main(String[] args) {
        byte[] hashResult1 = customHash("DSACTF");
        // 打印第一个哈希结果
        System.out.print("Hash result 1: ");
        for (byte b : hashResult1) {
            System.out.printf("%02X", b);
        }
        System.out.println(); // 换行

    }
}

这里有个草鸡大坑

输入的key是DSACTF

这个比赛叫DASCTF

我服了

_________

Hash result 1: 0D0D0D0D0D0D0D0D0D0D0D0D0D0D0D0D

这里为什么要加0呢,因为我们AES解密需要的是16位

你不可能加个X吧

所以我们加0

同理

厨子

得到了很多的,浮点数?

458.853181,-18.325492,-18.251911,-2.097520,-21.198660,-22.304648,21.103162,-5.786284,-15.248906,15.329286,16.919499,-19.669045,30.928253,-37.588034,-16.593954,-5.505211,3.014744,6.553616,31.131491,16.472500,6.802400,-78.278577,15.280099,3.893073,56.493581,-34.576344,30.146729,4.445671,6.732204

我们再看最后一个函数

直接IDA打开so文件

 

没见过的函数

但是这个cos出现什么的

叫啥余弦变换,我听都没听过,我勒个骚刚

 

import cv2
import numpy as np

# 定义一个输入的频谱(DCT-II变换的结果)
spectrum = np.array([458.853181,-18.325492,-18.251911,-2.097520,-21.198660,-22.304648,21.103162,-5.786284,-15.248906,15.329286,16.919499,-19.669045,30.928253,-37.588034,-16.593954,-5.505211,3.014744,6.553616,31.131491,16.472500,6.802400,-78.278577,15.280099,3.893073,56.493581,-34.576344,30.146729,4.445671,6.732204], dtype=np.float32)

# 对频谱进行逆变换
signal = cv2.idct(spectrum).tolist()

for num in signal:
    print(chr(round(num[0])),end='')# round对浮点数四舍五入,第二个参数可指定保留小数位数,默认不保留小数

____________

这场比赛蛮不错的,我感觉,难度其实硬要说,不是很大,可惜我只写了一题,下次加油! 

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_Nickname

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值