ctf每日练习-第三天

easychallenge(来自攻防世界crypto新手区)

下载附件是一个pyc文件,需要反编译
在线反编译链接: 链接
编译后发现是三重加密,直接反过来写一手解密脚本

import base64

def decode1(ans):
    s = ''
    for i in ans:
        x = ord(i) - 25
        x = x ^36
        s += chr(x)
    
    return s


def decode2(ans):
    s = ''
    for i in ans:
        x = i ^ 36
        x = x - 36
        s += chr(x)
    
    return s


def decode3(ans):
    return base64.b32decode(ans)

flag = ' '
print ('Please Input your flag')


final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
print (decode1(decode2(decode3(final))))
这里要注意使用base64.b32decode()后得到的是int型,所以decode2中不需要写ord(i)
直接用i就可以

easy_RSA(攻防世界crypto新手区)

rsa密码
脚本如下:(太晚了,原理明天补上)

def exgcd(a,n):
    if n==0:
        return 1,0
    else:
        x,y=exgcd(n,a%n)
        x,y=y,x-(a//n)*y
        return x,y

def getReverse(a,n):
    re,y=exgcd(a,n)
    while(re<0):
        re+=n
    return re

p=473398607161
q=4511491
e=17
d=getReverse(e,(p-1)*(q-1))
print('d='+str(d))

总结:明天重点学习一下rsa算法

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值