unctf2020——Crypto

一、鞍山大法官开庭之缺的营养这一块怎么补

根据给出的密文:ottttootoootooooottoootooottotootttootooottotttooootttototoottooootoooottotoottottooooooooottotootto
可以看出密文只有两种字母,可以想到使用的可能会是培根密码。
因此可以有o=A,t=B或者o=B,t=A两种可能。
两种可能解码为PEIGENHENYOUYINGYANG 和QundefinedXZundefinedSYundefinedSHRLHXSZH
输入flag最后得到flag为unctf{PEIGENHENYOUYINGYANG}

二、easy_rsa

附件如下:
在这里插入图片描述

由附件可解

>>> import gmpy2
>>> a=320398687477638913975700270017132483556404036982302018853617987417039612400517057680951629863477438570118640104253432645524830693378758322853028869260935243017328300431595830632269573784699659244044435107219440036761727692796855905230231825712343296737928172132556195116760954509270255049816362648350162111168
>>> b=9554090001619033187321857749048244231377711861081522054479773151962371959336936136696051589639469653074758469644089407114039221055688732553830385923962675507737607608026140516898146670548916033772462331195442816239006651495200436855982426532874304542570230333184081122225359441162386921519665128773491795370
>>> c=22886015855857570934458119207589468036427819233100165358753348672429768179802313173980683835839060302192974676103009829680448391991795003347995943925826913190907148491842575401236879172753322166199945839038316446615621136778270903537132526524507377773094660056144412196579940619996180527179824934152320202452981537526759225006396924528945160807152512753988038894126566572241510883486584129614281936540861801302684550521904620303946721322791533756703992307396221043157633995229923356308284045440648542300161500649145193884889980827640680145641832152753769606803521928095124230843021310132841509181297101645567863161780
>>> p=(a+b)/2
>>> q=(a-b)/2
>>> e=65537
>>> phi=(p-1)*(q-1)
>>> d = gmpy2.invert(e,phi)
>>> print(d)
13520637333215938186701232387959186078192441834430646200152017496580083015894693608744446669957196067379816242548412185148719678858906249430631086296059347471406865114774824686655919643954375513480029176520925196420025095437582404880108633026550155505640286905930669447727266167475328689082873003809052013145641561953548574050510799399063204788021266291024788348241346451907588463054320379080780429068578299089418923223030202618570767162875599171107099044497918583654800248238807175687675702792006125086389940138212608569298856353395124065366005586641202732989813698557545059249478652073299085605820622861917775089649
>>> n=p*q
>>> m=gmpy2.powmod(c,d,n)
>>> print(m)
124674441944595208018198785195880808417611536884093
>>> from Crypto.Util.number import long_to_bytes
>>> flag = long_to_bytes(m)
>>> print (flag)
UNCTF{welcome_to_rsa}

三、简单的RSA

利用脚本

import ContinuedFractions, Arithmetic, RSAvulnerableKeyGenerator
from Crypto.Util.number import long_to_bytes
def hack_RSA(e,n):
    '''
    Finds d knowing (e,n)
    applying the Wiener continued fraction attack
    '''
    frac = ContinuedFractions.rational_to_contfrac(e, n)  
    convergents = ContinuedFractions.convergents_from_contfrac(frac)
    for (k,d) in convergents:        
        #check if d is actually the key
        if k!=0 and (e*d-1)%k == 0:
            phi = (e*d-1)//k
            s = n - phi + 1
            # check if the equation x^2 - s*x + n = 0
            # has integer roots
            discr = s*s - 4*n
            if(discr>=0):
                t = Arithmetic.is_perfect_square(discr)
                if t!=-1 and (s+t)%2==0:
                    print("Hacked!")
                    return d
# TEST functions
if __name__ == "__main__":    n=147282573611984580384965727976839351356009465616053475428039851794553880833177877211323318130843267847303264730088424552657129314295117614222630326581943132950689147833674506592824134135054877394753008169629583742916853056999371985307138775298080986801742942833212727949277517691311315098722536282119888605701
    e=18437613570247445737704630776150775735509244525633303532921813122997549954741828855898842356900537746647414676272022397989161180996467240795661928117273837666615415153571959258847829528131519423486261757569454011940318849589730152031528323576997801788206457548531802663834418381061551227544937412734776581781
    d=hack_RSA(e,n)
    print(d)
 c=140896698267670480175739817539898638657099087197096836734243016824204113452987617610944986742919793506024892638851339015015706164412994514598564989374037762836439262224649359411190187875207060663509777017529293145434535056275850555331099130633232844054767057175076598741233988533181035871238444008366306956934
    m=pow(c,d,n)
    print(m)
    flag=long_to_bytes(m)
    print(flag)
>>> print (flag)
unctf{wi3n3r_Att@ck}

四、Wing

附件如下
在这里插入图片描述
这是wingdings2字体
对照表如下在这里插入图片描述

可得出flag为unctf{wingdings_is_incomprehensible}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值