攻防世界刷题日记(1)

easy_RSA

2.png

很简单用脚本算出来就可

# coding = utf-8

def computeD(fn, e):

    (x, y, r) = extendedGCD(fn, e)

    #y maybe < 0, so convert it

    if y < 0:

        return fn + y

    return y



def extendedGCD(a, b):

    #a*xi + b*yi = ri

    if b == 0:

        return (1, 0, a)

    #a*x1 + b*y1 = a

    x1 = 1

    y1 = 0

    #a*x2 + b*y2 = b

    x2 = 0

    y2 = 1

    while b != 0:

        q = a / b

        #ri = r(i-2) % r(i-1)

        r = a % b

        a = b

        b = r

        #xi = x(i-2) - q*x(i-1)

        x = x1 - q*x2

        x1 = x2

        x2 = x

        #yi = y(i-2) - q*y(i-1)

        y = y1 - q*y2

        y1 = y2

        y2 = y

    return(x1, y1, a)



p=473398607161

q=4511491
e = 17


n = p * q

fn = (p - 1) * (q - 1)



d = computeD(fn, e)

print d

easychallenge

一个pyc文件,先给他反编译
https://tool.lu/pyc/

import base64

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

    return s


def encode2(ans):
    s = ''
    for i in ans:
        x = ord(i) + 36
        x = x ^ 36
        s += chr(x)

    return s


def encode3(ans):
    return base64.b32encode(ans)

flag = ' '
print 'Please Input your flag:'
flag = raw_input()
final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
if encode3(encode2(encode1(flag))) == final:
    print 'correct'
else:
    print 'wrong'

嫖一个逆向脚本

#!/usr/bin/env python
# encoding: utf-8
# 先将字符串base32解码出来,然后将其变为字符串再进行ord等操作。
b = "\xa0\xbe\xa7Z\xb7\xb5Z\xa6\xa0Z\xb8\xae\xa3\xa9Z\xb7Z\xb0\xa9\xae\xa3\xa4\xad\xad\xad\xad\xad\xb2"
s = ''
for i in b:
    s += chr((ord(i) ^ 36) - 36)
l = ''
for i in s:
    l += chr((ord(i) - 25) ^ 36)
print ('flag is ',l)

Normal_RSA

题目给了一个密文,一个公钥文件
3.png

根据一个大佬的wp用工具解出来了

工具链接:https://github.com/3summer/CTF-RSA-tool

将文件解压到工具目录,输入命令

python2 solve.py --verbose -k ./pubkey.pem --decrypt ./flag.en

得到flag

轮转机加密

4.png

经过百度,我决定还是嫖一手脚本

#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import re

sss = '1: < ZWAXJGDLUBVIQHKYPNTCRMOSFE < 2: < KPBELNACZDTRXMJQOYHGVSFUWI < 3: < BDMAIZVRNSJUWFHTEQGYXPLOCK < 4: < RPLNDVHGFCUKTEBSXQYIZMJWAO < 5: < IHFRLABEUOTSGJVDKCPMNZQWXY < 6: < AMKGHIWPNYCJBFZDRUSLOQXVET < 7: < GWTHSPYBXIZULVKMRAFDCEONJQ < 8: < NOZUTWDCVRJLXKISEFAPMYGHBQ < 9: < XPLTDSRFHENYVUBMCQWAOIKZGJ < 10: < UDNAJFBOWTGVRSCZQKELMXYIHP < 11 < MNBVCXZQWERTPOIUYALSKDJFHG < 12 < LVNCMXZPQOWEIURYTASBKJDFHG < 13 < JZQAWSXCDERFVBGTYHNUMKILOP <'
m = 'NFQKSEVOQOFNP'
# 将sss转化为列表形式
content=re.findall(r'< (.*?) <',sss,re.S)
# re.S:DOTALL,此模式下,"."的匹配不受限制,可匹配任何字符,包括换行符
iv=[2,3,7,5,13,12,9,1,8,10,4,11,6]
print(content)
vvv=[]
for i in range(13):
    index=content[iv[i]-1].index(m[i])
    vvv.append(index)
print(vvv)

for i in range(0,26):
    flag=""
    for j in range(13):
        flag += content[iv[j]-1][(vvv[j]+i)%26]
    print(flag.lower())

easy_ECC

5.png

当然得百度一手啊

https://www.cnblogs.com/X-knight/p/9153209.html

然后用ECCTOOL解密了

下载地址:https://bbs.pediy.com/thread-66683.htm

填入相关参数即可计算出

6.png

7.png

rx = 13957031351290
ry = 5520194834100
rx + ry = 19477226185390

幂数加密

9.png

原理
8.png

也可以用脚本直接算出来

#! /usr/bin/env python

#coding=utf-8

a="8842101220480224404014224202480122"

a=a.split("0")

flag=''

for i in range(0,len(a)):

     str = a[i]

     list=[]

     sum=0

     for j in str:

        list.append(j)

        length = len(list)

     for k in range(0,length):

        sum+=int(list[k])

     flag+=chr(sum+64)

print flag
  • 版权声明: 本博客所有文章除特别声明外,均采用 Apache License 2.0 许可协议。转载请注明出处!
  • © 2020 丰年de博客

请我喝杯咖啡吧~

支付宝
微信