『攻防世界』:新手区 | CRYPTO

在正式做题前先要大致了解一下CRYPTO

0x01: base64

 将文本内容如题解密:

Y3liZXJwZWFjZXtXZWxjb21lX3RvX25ld19Xb3JsZCF9

考虑到比赛可能不能访问外网,我们需用通过python写几种base加密解密

Base64编码是一种“防君子不防小人”的编码方式。广泛应用于MIME协议,作为电子邮件的传输编码,生成的编码可逆,后一两位可能有“=”,生成的编码都是ascii字符。
优点:速度快,ascii字符,肉眼不可理解
缺点:编码比较长,非常容易被破解,仅适用于加密非关键信息的场合
Python中进行Base64编码和解码
>>> import base64
>>> s = '我是字符串'
>>> a = base64.b64encode(s)
>>> print a
ztLKx9fWt/u0rg==
>>> print base64.b64decode(a)
我是字符串
View Code

0x02:Caesar

知道原理后查看:oknqdbqmoq{kag_tmhq_xqmdzqp_omqemd_qzodkbfuaz}

这个格式就是flag偏移某位后得到的,计算出c->o是偏移12位,通过工具进行反向的解密就可以得到flag

def encryption():
    str_raw = input("请输入明文:")
    k = int(input("请输入位移值:"))
    str_change = str_raw.lower()
    str_list = list(str_change)
    str_list_encry = str_list
    i = 0
    while i < len(str_list):
        if ord(str_list[i]) < 123-k:
            str_list_encry[i] = chr(ord(str_list[i]) + k)
        else:
             str_list_encry[i] = chr(ord(str_list[i]) + k - 26)
             i = i+1
    print ("加密结果为:"+"".join(str_list_encry))
def decryption():
    str_raw = input("请输入密文:")
    k = int(input("请输入位移值:"))
    str_change = str_raw.lower()
    str_list = list(str_change)
    str_list_decry = str_list
    i = 0
    while i < len(str_list):
        if ord(str_list[i]) >= 97+k: str_list_decry[i] = chr(ord(str_list[i]) - k)
        else: str_list_decry[i] = chr(ord(str_list[i]) + 26 - k)
        i = i+1
    print ("解密结果为:"+"".join(str_list_decry))
while True:
    print (u"1. 加密")
    print(u"2. 解密")
    choice = input("请选择:")
    if choice == "1": encryption()
    elif choice == "2": decryption()
    else: print (u"您的输入有误!")
.py

0x03:Morse

11 111 010 000 0 1010 111 100 0 00 000 000 111 00 10 1 0 010 0 000 1 00 10 110

上面一串摩斯密码,用工具解码就可以

0x04:不仅仅是Morse

首先得到一串摩斯密码,解码后得到一串:

MAYBEHAVEANOTHERDECODEHHHHAAAAABAABBBAABBAAAAAAAABAABABAAAAAAABBABAAABBAAABBAABAAAABABAABAAABBABAAABAAABAABABBAABBBABAAABABABBAAABBABAAABAABAABAAAABBABBAABBAABAABAAABAABAABAABABAABBABAAAABBABAABB
step2

里面待解密的字符串只由A、B组成,立马想到二进制。这是培根密码的特征,使用工具解码即可

0x05:混合编码

JiM3NjsmIzEyMjsmIzY5OyYjMTIwOyYjNzk7JiM4MzsmIzU2OyYjMTIwOyYjNzc7JiM2ODsmIzY5OyYjMTE4OyYjNzc7JiM4NDsmIzY1OyYjNTI7JiM3NjsmIzEyMjsmIzEwNzsmIzUzOyYjNzY7JiMxMjI7JiM2OTsmIzEyMDsmIzc3OyYjODM7JiM1NjsmIzEyMDsmIzc3OyYjNjg7JiMxMDc7JiMxMTg7JiM3NzsmIzg0OyYjNjU7JiMxMjA7JiM3NjsmIzEyMjsmIzY5OyYjMTIwOyYjNzg7JiMxMDU7JiM1NjsmIzEyMDsmIzc3OyYjODQ7JiM2OTsmIzExODsmIzc5OyYjODQ7JiM5OTsmIzExODsmIzc3OyYjODQ7JiM2OTsmIzUwOyYjNzY7JiMxMjI7JiM2OTsmIzEyMDsmIzc4OyYjMTA1OyYjNTY7JiM1MzsmIzc4OyYjMTIxOyYjNTY7JiM1MzsmIzc5OyYjODM7JiM1NjsmIzEyMDsmIzc3OyYjNjg7JiM5OTsmIzExODsmIzc5OyYjODQ7JiM5OTsmIzExODsmIzc3OyYjODQ7JiM2OTsmIzExOTsmIzc2OyYjMTIyOyYjNjk7JiMxMTk7JiM3NzsmIzY3OyYjNTY7JiMxMjA7JiM3NzsmIzY4OyYjNjU7JiMxMTg7JiM3NzsmIzg0OyYjNjU7JiMxMjA7JiM3NjsmIzEyMjsmIzY5OyYjMTE5OyYjNzc7JiMxMDU7JiM1NjsmIzEyMDsmIzc3OyYjNjg7JiM2OTsmIzExODsmIzc3OyYjODQ7JiM2OTsmIzExOTsmIzc2OyYjMTIyOyYjMTA3OyYjNTM7JiM3NjsmIzEyMjsmIzY5OyYjMTE5OyYjNzc7JiM4MzsmIzU2OyYjMTIwOyYjNzc7JiM4NDsmIzEwNzsmIzExODsmIzc3OyYjODQ7JiM2OTsmIzEyMDsmIzc2OyYjMTIyOyYjNjk7JiMxMjA7JiM3ODsmIzY3OyYjNTY7JiMxMjA7JiM3NzsmIzY4OyYjMTAzOyYjMTE4OyYjNzc7JiM4NDsmIzY1OyYjMTE5Ow==
附件

巴拉巴拉,啥也看不懂,但是看到末尾有两个等号觉得像是base64的特征,试着解码得到:

&#76;&#122;&#69;&#120;&#79;&#83;&#56;&#120;&#77;&#68;&#69;&#118;&#77;&#84;&#65;&#52;&#76;&#122;&#107;&#53;&#76;&#122;&#69;&#120;&#77;&#83;&#56;&#120;&#77;&#68;&#107;&#118;&#77;&#84;&#65;&#120;&#76;&#122;&#69;&#120;&#78;&#105;&#56;&#120;&#77;&#84;&#69;&#118;&#79;&#84;&#99;&#118;&#77;&#84;&#69;&#50;&#76;&#122;&#69;&#120;&#78;&#105;&#56;&#53;&#78;&#121;&#56;&#53;&#79;&#83;&#56;&#120;&#77;&#68;&#99;&#118;&#79;&#84;&#99;&#118;&#77;&#84;&#69;&#119;&#76;&#122;&#69;&#119;&#77;&#67;&#56;&#120;&#77;&#68;&#65;&#118;&#77;&#84;&#65;&#120;&#76;&#122;&#69;&#119;&#77;&#105;&#56;&#120;&#77;&#68;&#69;&#118;&#77;&#84;&#69;&#119;&#76;&#122;&#107;&#53;&#76;&#122;&#69;&#119;&#77;&#83;&#56;&#120;&#77;&#84;&#107;&#118;&#77;&#84;&#69;&#120;&#76;&#122;&#69;&#120;&#78;&#67;&#56;&#120;&#77;&#68;&#103;&#118;&#77;&#84;&#65;&#119;
step2

看到文本中存在大量的 &# 应当想到Unicode编码,接着解码得到:

LzExOS8xMDEvMTA4Lzk5LzExMS8xMDkvMTAxLzExNi8xMTEvOTcvMTE2LzExNi85Ny85OS8xMDcvOTcvMTEwLzEwMC8xMDAvMTAxLzEwMi8xMDEvMTEwLzk5LzEwMS8xMTkvMTExLzExNC8xMDgvMTAw
step3

字符串是8的整数尝试再次使用base64解码得到flag

0x06:Railfence

正如题目的名字使用栅栏密码,开始我将文本试了几次不同的偏移都得不到flag

这题虽然是栅栏加密,但是不是普通的| | | |形状的栅栏,而是W型的栅栏加密

 

 

 具体原理自己学习。附上解码网址

0x07:easy_RSA

需要掌握RSA算法和它的解码方式及工具

或者是python工具python solve.py --verbose --private -N 2135733555619387051 -e 17 -p 473398607161 -q 4511491

0x08:幂数加密

非常简洁的一串数字:8842101220480224404014224202480122

观察一下特征,都是2的幂次方数,将幂数得出,应为任何正数的幂次方都得不到0,所以用空格代替即可,得到:33210 011 23 1122 2 021121 123 011

emmm,再根据幂数加密的原理得到字母对应的顺序数字(2^3 + 2^3 + 2^2 + 2^1 + 2^0 = 23 [W])最后对应转化即为flag

0x09:easychallenge

这题提供了一个脚本,我们需要用工具或者网页工具对它进行反编译操作,得到:

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'
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'
easychallenge

大概意思就是明文(我们输入的)进过3次加密的到密文:final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='

注:ord() 函数是 chr() 函数(对于 8 位的 ASCII 字符串)的配对函数,它以一个字符串(Unicode 字符)作为参数,返回对应的 ASCII 数值,或者 Unicode 数值。

我们需要的flag = decode1(decode2(decode3(final)));接下写出逆过程将final传入即可:

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'
exp

0x0a轮转机密码

 这个知识点我也稀里糊涂,自己去学吧

 1 #coding:utf-8
 2 import re
 3 
 4 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 <'
 5 m = 'NFQKSEVOQOFNP'
 6 #将sss转化为列表形式
 7 content = re.findall(r'<(.*?)<',sss,re.S)
 8 #re.S: DOTALL,此模式下,“.”的匹配不受限制,可匹配任何字符,包括换行符
 9 iv = [2,3,7,5,13,12,9,1,8,10,4,11,6]
10 print(content)
11 vvv = []
12 for i in range(13):
13     index = content[iv[i] -1].index(m[i])
14     vvv.append(index)
15 print(vvv)
16 
17 for i in range(0,26):
18     flag = ""
19     for j in  range(13):
20         flag += content[iv[j]-1][(vvv[j]+i)%26]
21     print(flag.lower())
exp

 

posted @ 2020-08-14 21:39  Little_Fdog  阅读(352)  评论(0编辑  收藏  举报
TOP 底部