吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 186|回复: 2
收起左侧

[经验求助] 两个ctf题,一个流量分析,跟内网横向有关,一个rsa,xor相关

[复制链接]
linyuguan 发表于 2024-10-16 14:13
25吾爱币
两个ctf题,一个流量分析,跟内网横向有关,一个rsa,xor相关
求大佬指导
xor
https://pan.baidu.com/s/1LV5iXOG3QfW-k0IaDSWPOA 提取码caqf


analyse.zip
链接: https://pan.baidu.com/s/1xRSvCMSUY3I-Sj0_4dpomQ 提取码: x36k

最佳答案

查看完整内容

xor 1、先算出p和q ## p^^q N = 0x964DD7ACEC6A6AA87F47E22C6FCA8EE5AD6DF00C8998EA43205CCE2099F8FC7BA563EC43C3787070013640DED0F3DE9179982BCBEEA7A984A275CF2CC27811CA207FA75A86EDC1C0C4BD2DF9AF4E5AA7EA269CF56AB9B230737C4F73F75A5C70E5717EDD106D46F9B94574D2A5F03513BBD16A1B3C97D3398CB40C79CE3C41D5C34D79AA5AA8E97AB1393B9E5677B35944DAA572B9B91F0B0185D311579843AEAC1337D772FC7F7A8C70A6C6C663D80C0D16664997DB4 ...

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

sinQwQ 发表于 2024-10-16 14:13
xor
1、先算出p和q
## p^^q
N = 0x964DD7ACEC6A6AA87F47E22C6FCA8EE5AD6DF00C8998EA43205CCE2099F8FC7BA563EC43C3787070013640DED0F3DE9179982BCBEEA7A984A275CF2CC27811CA207FA75A86EDC1C0C4BD2DF9AF4E5AA7EA269CF56AB9B230737C4F73F75A5C70E5717EDD106D46F9B94574D2A5F03513BBD16A1B3C97D3398CB40C79CE3C41D5C34D79AA5AA8E97AB1393B9E5677B35944DAA572B9B91F0B0185D311579843AEAC1337D772FC7F7A8C70A6C6C663D80C0D16664997DB442EEB8100161D5A2CDB2BE2FC1029EEFDCB57632E88D747C9FEC8DC18C0CA3807AA825C41DFD5BFCCFD52ADB3DDD0B679526FB580870D6C8A65EB209D178FDED947D7E292A2C7BE4AD3
gift = 81616793159567136422389758585591940662857576283302867011800445277592420866836093507411736040996742950676922327919824777893118631113867500244368612517429678572193116622664051815861481500355863477109385340706136160893878015686817479333596425572252594901263332045777914789662665019123717287533930696370434650226


PR.<x> = PolynomialRing(Zmod(N))
ok = False
def pq_xor(tp,tq,idx):
    global ok
   
    if ok:
        return
    if tp*tq>N:
        return
    if (tp+(2<<idx))*(tq+(2<<idx))<N:
        return
        
    if idx<=400:
        try:
            f = tp + x
            rr = f.monic().small_roots(X=2^400, beta=0.4)
            if rr != []:
                print(rr)
                print(tp)
                print('p = ',f(rr[0]))
                ok = True
                return
        except:
            pass
        
        return
   
    idx -=1
    b = (gift >>idx)&1
    one = 1<<idx
    if b==0:
        pq_xor(tp,tq,idx)   
        pq_xor(tp+one,tq+one,idx)   
    else:   #1
        pq_xor(tp+one,tq,idx)
        pq_xor(tp,tq+one,idx)
   

#N.nbits()=2048 gift.nbits()=1023  p,q的1024位为1
tp = 1<<1023
tq = 1<<1023
pq_xor(tp,tq,1023)

2、解rsa
from gmpy2 import *
from Crypto.Util.number import *
from Crypto.Cipher import PKCS1_OAEP
from Crypto.PublicKey import RSA

f2 = open('flag.enc','rb').read()

c = bytes_to_long(f2)
print(f'c = {f2}')

N = 0x964DD7ACEC6A6AA87F47E22C6FCA8EE5AD6DF00C8998EA43205CCE2099F8FC7BA563EC43C3787070013640DED0F3DE9179982BCBEEA7A984A275CF2CC27811CA207FA75A86EDC1C0C4BD2DF9AF4E5AA7EA269CF56AB9B230737C4F73F75A5C70E5717EDD106D46F9B94574D2A5F03513BBD16A1B3C97D3398CB40C79CE3C41D5C34D79AA5AA8E97AB1393B9E5677B35944DAA572B9B91F0B0185D311579843AEAC1337D772FC7F7A8C70A6C6C663D80C0D16664997DB442EEB8100161D5A2CDB2BE2FC1029EEFDCB57632E88D747C9FEC8DC18C0CA3807AA825C41DFD5BFCCFD52ADB3DDD0B679526FB580870D6C8A65EB209D178FDED947D7E292A2C7BE4AD3
p = 157194667273395078091690715359649373226005247729684564897233925620451263163534476559233007477874770144949074471296577678270820453203784261690001421933906316488224081275610737920296334697466445787310072301759253431687655435272535953996103257268055911344285357880348486067423090573148921357811044304231614285373
q = N//p
print(isPrime(q))
assert N == p*q
e = 65537
d = inverse(e, (p-1)*(q-1))

key = RSA.construct((N,e,d,p,q))
cipher = PKCS1_OAEP.new(key)
m = cipher.decrypt(f2)
print(m)
# flag{b8f20dd8-a985-41f4-ada3-0926bfc3a283}
sinQwQ 发表于 2024-10-20 21:31
analyse.zip确实是信息收集和横向的过程,不清楚题目需要提交什么
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-12-16 01:09

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表