首页 > 其他分享 >春秋杯冬季赛-EzMisc WP

春秋杯冬季赛-EzMisc WP

时间:2025-01-19 19:36:10浏览次数:1  
标签:24 ftp 私钥 春秋 image EzMisc pem WP dp

后面两天本来没打算写出来啥题的,因为都太难了呜呜,但是这道题竟然做出来了(虽然花了接近3个小时),还是有点小激动

前排提醒

1、是看了提示之后才做出来的

题目提示:1、利⽤DP泄露来求出私钥,从⽽还原私钥流解密密⽂ 2、图片经过了Arnold变换

2、存在偶然性,复现难度挺大的,大佬轻点喷QAQ

解答过程

1、流量分析

直接追踪流走起

image

这时候显示设置为UTF-8

第五个流显示有三个文件,私钥、压缩包、密文

-rw-------    1 ftp      ftp           256 Oct 24 12:06 encrypted.enc
-rw-------    1 ftp      ftp         31168 Oct 24 12:06 flag.7z
-rw-------    1 ftp      ftp          1679 Oct 24 12:04 private_key.pem

在第六个流显示传输私钥

150 Opening BINARY mode data connection for private_key.pem (1679 bytes).
226 Transfer complete.

第七个流就是私钥

说明格式都是文件名-文件内容

因此导出第7个流(另存为)为private_key.pem,第10个流为encrypted.enc

注意这里第10个流和12个流是二进制文件,要用“显示为原始数据”存储

这样我们就得到了三个文件

2、修复私钥

用openssl看私钥是否正确,结果是错的(不然怎么会卡到这里

image

现在就用到了提示1:利⽤DP泄露来求出私钥,从⽽还原私钥流解密密⽂

先对这个坏的私钥进行分析(这里只需要n和dp,就只拿出这两个)

E:\>openssl rsa -in PRIVATEKEY.pem -text
Private-Key: (2048 bit, 2 primes)
modulus:
    00:b3:ee:84:a7:c4:9a:b1:b8:6f:20:6e:b6:89:18:
    00:aa:9a:42:ec:4e:b1:b4:cd:de:74:f7:67:eb:9e:
    07:d0:82:09:72:bd:d3:b2:2b:3c:38:ee:49:70:49:
    52:1e:12:64:0a:44:f5:c6:d4:60:1e:6d:73:57:23:
    c8:a7:36:53:3d:96:37:bc:c8:0d:fb:14:ee:0f:09:
    fb:ae:83:eb:30:9f:68:62:15:04:f1:8b:77:94:11:
    a8:b4:ec:99:87:bf:df:4a:af:e1:77:d2:00:4e:a9:
    8e:de:04:e0:07:34:05:14:f2:8a:f8:d2:c7:86:27:
    58:60:49:1b:83:b3:23:d9:30:9a:48:e6:4e:66:d9:
    1a:ec:bb:0f:7e:39:eb:d9:ba:3f:87:73:2f:24:0c:
    7c:e9:11:03:3b:61:57:bc:90:21:63:d0:3f:56:20:
    5a:b6:ad:29:18:a0:ff:2e:2a:07:93:06:9f:8d:dd:
    ab:c5:00:37:4a:39:ee:af:c2:f1:39:67:8c:f6:73:
    59:91:94:78:0c:7f:e4:93:11:cb:2b:1b:25:45:e3:
    c6:90:e1:db:2e:0c:08:3b:d6:dd:a6:58:48:d6:4c:
    bb:81:0a:42:43:79:a8:8b:be:15:3d:df:3c:8e:79:
    e0:c8:07:ed:1a:a9:b6:87:43:30:da:35:59:83:0c:
    fa:45
publicExponent: 65537 (0x10001)
privateExponent:...
prime1:...
prime2:...
exponent1:
    00:97:24:1a:2c:d4:a3:a6:a6:24:57:ed:7a:08:bd:
    ae:42:85:aa:8a:a5:c8:2f:74:13:a0:d8:64:32:97:
    cb:44:ad:e7:e6:25:d2:9c:de:1a:6a:2d:9d:0c:2a:
    b6:7e:1a:81:64:70:ad:47:08:b7:92:f9:73:38:7c:
    fb:90:5e:47:3d:bb:2e:4b:70:da:2a:4e:74:62:f4:
    53:1b:c1:cb:a0:bc:fb:04:b6:0e:49:b5:eb:05:c3:
    4d:8e:91:48:ac:12:e9:a9:ce:34:d7:c7:af:73:e9:
    c6:be:76:94:2d:e1:f0:35:73:4f:6b:58:65:08:d1:
    57:80:9e:3e:9d:ed:df:fc:a7
exponent2:...
coefficient:...

修改一下格式(去掉冒号和空格,前面加0x)

n=0x00b3ee84a7c49ab1b86f206eb6891800aa9a42ec4eb1b4cdde74f767eb9e07d0820972bdd3b22b3c38ee497049521e12640a44f5c6d4601e6d735723c8a736533d9637bcc80dfb14ee0f09fbae83eb309f68621504f18b779411a8b4ec9987bfdf4aafe177d2004ea98ede04e007340514f28af8d2c786275860491b83b323d9309a48e64e66d91aecbb0f7e39ebd9ba3f87732f240c7ce911033b6157bc902163d03f56205ab6ad2918a0ff2e2a0793069f8dddabc500374a39eeafc2f139678cf673599194780c7fe49311cb2b1b2545e3c690e1db2e0c083bd6dda65848d64cbb810a424379a88bbe153ddf3c8e79e0c807ed1aa9b6874330da3559830cfa45

dp=0x0097241a2cd4a3a6a62457ed7a08bdae4285aa8aa5c82f7413a0d8643297cb44ade7e625d29cde1a6a2d9d0c2ab67e1a816470ad4708b792f973387cfb905e473dbb2e4b70da2a4e7462f4531bc1cba0bcfb04b60e49b5eb05c34d8e9148ac12e9a9ce34d7c7af73e9c6be76942de1f035734f6b586508d157809e3e9deddffca7

然后求解p、q,到网上搜了个代码,因为没有密文所以修改了一下

[RSA的dp泄露 BUUCTF] RSA2_dp=d%(p-1)-CSDN博客

import gmpy2 as gp
e = 65537
n=0x00b3ee84a7c49ab1b86f206eb6891800aa9a42ec4eb1b4cdde74f767eb9e07d0820972bdd3b22b3c38ee497049521e12640a44f5c6d4601e6d735723c8a736533d9637bcc80dfb14ee0f09fbae83eb309f68621504f18b779411a8b4ec9987bfdf4aafe177d2004ea98ede04e007340514f28af8d2c786275860491b83b323d9309a48e64e66d91aecbb0f7e39ebd9ba3f87732f240c7ce911033b6157bc902163d03f56205ab6ad2918a0ff2e2a0793069f8dddabc500374a39eeafc2f139678cf673599194780c7fe49311cb2b1b2545e3c690e1db2e0c083bd6dda65848d64cbb810a424379a88bbe153ddf3c8e79e0c807ed1aa9b6874330da3559830cfa45
dp=0x0097241a2cd4a3a6a62457ed7a08bdae4285aa8aa5c82f7413a0d8643297cb44ade7e625d29cde1a6a2d9d0c2ab67e1a816470ad4708b792f973387cfb905e473dbb2e4b70da2a4e7462f4531bc1cba0bcfb04b60e49b5eb05c34d8e9148ac12e9a9ce34d7c7af73e9c6be76942de1f035734f6b586508d157809e3e9deddffca7
for i in range(1, e):
    if (dp * e - 1) % i == 0:
        if n % (((dp * e - 1) // i) + 1) == 0:
            p = ((dp * e - 1) // i) + 1
            q = n // (((dp * e - 1) // i) + 1)
            phi = (q - 1) * (p - 1)
            d = gp.invert(e, phi)
print(p)
print(q)

然后就会输出p、q,再把p、q放到rsatool生成der证书,用openssl转成pem(大佬轻点喷,我只会这么用www

 > python rsatool.py -f DER -o key.der -p 167491603290232240165109588122788533113389414892381818156844128040193230978258977820405344205575296236371810427163650149605152056848232885222313353175604339541646561904247957829866027314556374355724182064112393004948463738291920723783245808179255742950559196088831263741806293908034669816429240284314008447447 -q 135614405996392828283288405736816325971158828195581321137267815028274015935746901788826424186827187305964377540945597767870885565726850264456049944775721936464833029271446916299066431842045054106684672619067404844022080815572204158632860297345943545872303196205961279815313762145298097712015966260328367919427
 > openssl rsa -inform DER -outform PEM -in key.der -out mykey.pem
writing RSA key

这时生成的mykey.pem就是正确的密钥,开始解密

这里又踩了一个坑,openssl解密死活不成功,结果用cyberchef一次就成功了,挺奇怪的(用open file as input)

image

这样就获得了压缩包密码

3、图片解密

提示 2、图片经过了Arnold变换(不给提示真的有人知道吗

在网上搜索这个变换,找到一个可用的代码,自己改了一下让他能把图片输出

-Arnold-/arnold.py at main · mouguawang/-Arnold-

import numpy as np
import cv2
import random


def dearnold_encode(image, a, b):
    arnold_image = np.zeros(shape=image.shape)  

    h, w = image.shape[0], image.shape[1]
    N = w  
    for x in range(h):
        for y in range(w):
            new_x = ((a * b + 1) * x - a * y) % N
            new_y = (-b * x + y) % N
            arnold_image[new_x, new_y, :] = image[x, y, :]

    arnold_image = np.uint8(arnold_image)

    return arnold_image


r = cv2.imread('flag.png')
cishu=0
for _ in range(10000):
    a=random.randint(1,1000)
    b=random.randint(1,1000)
    cishu+=1
    r = dearnold_encode(r, a, b)
    cv2.imwrite("D:\\hi\\" + "{}.png".format(cishu), r)

提示:opencv和numpy不兼容错误可以试试用python3.8(我的在虚拟机里面跑的)

这里纯随机,我开了八个Python强制多线程输出了几万张图片,花了一个小时去找,偶然间发现了最靓的仔
参数a=192,b=656

(其实这个也不是完美的,但是已经没办法了,只有这个是能看到内容的)
这里可以把图片缩小看得更清楚

image

通过我的反复查看和大胆的蒙,花了一个小时终于把flag弄出来了,挺不容易的QAQ

flag{3089ea1c-23a0-4889-a87f-daabe2f6e1b4}

标签:24,ftp,私钥,春秋,image,EzMisc,pem,WP,dp
From: https://www.cnblogs.com/ljnljn/p/18679811

相关文章

  • 2024春秋杯冬季赛day3writeup_cyi
    cyiWRITEUP个人信息个人名称:cyi个人排名:112解题情况解题过程miscInfinity(fail)操作内容:Png后藏zip,提出来随便解压几个发现是无限,解压缩有7z,zip,tar格式,gpt整个jio本得到最后的secret文件,内容是Inf1nityIsS0CoOL,结合BASE58-Ripple、SM4-ECB提示赛中:卡在解密了,我想着......
  • DASCTF --wp--web
    1、Rank-lSsti的报错查询cycler没用被禁用,很常规的到达popen阶段{{cycler.__init__.__globals__.__builtins__['__import__']('os').popen('ls').read()}}正常在浏览器中无法查看,使用pythonimportrequestswithrequests.Session()assession:  url_phone='http://1......
  • 如果通过 vxe-table 实现 Excel,可以和 Excel、WPS 复制粘贴
    如果通过vxe-table实现Excel,可以和Excel、WPS复制粘贴官网:https://vxetable.cn<template><div><vxe-gridref="gridRef"v-bind="gridOptions"@cell-area-selection-end="cellAreaSelectionEndEvent"......
  • 2024春秋杯冬季赛day2writeup_cyi
     解题过程miscWeevil'sWhisper操作内容:筛选http流,一开始就把马上传了搜索可知这是weevely的webshell这篇讲的很详细了https://xz.aliyun.com/t/11246?time__1311=Cq0xRD0Q0QD%3DdGNeeeqk75YitmczLbD#toc-5拿了这篇的解密脚本https://blog.csdn.net/m0_74091653/artic......
  • wps office 2019专业版破解版下载及安装使用教程
    前言wpsoffice2019专业增强版含无云版是一款非常方便的办公软件,我们在日常的工作中总会碰到需要使用WPS的时候,它能为我们提供更好的文档编写帮助我们更好的去阅读PDF等多种格式的文档,使用起来非常的快捷方便。使用某银行专业增强版制作,包含vba和Pdf,集成序列号,去除密匙校验,去除......
  • 2024春秋杯冬季赛day1writeup_cyi
    ......
  • ljnljn的春秋杯冬季赛wp(1.17)
    杂项1、Seeanythinginthesepics?压缩包里有个码,确认是aztec码这个是压缩包密码,解压出一张图片binwalk找到多个图片,foremost分离1:JPEGimagedata,JFIFstandard1.012:PNGimage,360x450,8-bitgrayscale,non-interlaced3:TIFFimagedata,big-endian,offset......
  • WPF动画-物体跟随轨迹进行运动
     主要用到:RenderTransformOrigin MatrixTransform  MatrixAnimationUsingPath DoesRotateWithTangent直接上代码<Grid.Resources><PathGeometryx:Key="PATH"Figures="M0,0C9.3627259,14.08419911.524114,20.69051435.333333,23.66666745.377......
  • wps数据分析000002
    目录一、快速定位技巧二、快速选中技巧全选选中部分区域选中部分区域(升级版)三、快速移动技巧四、快速录入技巧五、总结一、快速定位技巧ctrl+→(上下左右)快速定位光标对准单元格的上下部分双击名称单元格中输入二、快速选中技巧全选先把光标定位到数据区域,ctrl+A......
  • 龙信年终考核WP
    龙信年终考核WP难度偏低,题量小。但发挥不是很好,服务器一如既往地废掉,唐哥yyds!1.分析手机备份文件,该机主的QQ号为?(标准格式:123)12034945532.分析手机备份文件,该机主的微信号为?(标准格式:abcdefg)liudaren05073.请问该手机机主微信共有_____个现有好友?(标准格式:12)15要刨除自己......