安恒杯二月月赛 抗【疫】练习赛 -re- easy-py
新手一枚,如有错误(不足)请指正,谢谢!!
<mark>个人博客:点击进入</mark>
题目下载:

链接: https://pan.baidu.com/s/1VAdpObsh0tgw4HLMS-Cfjw 提取码: 2020

pyc文件。将其进行在线反编译
得到python代码

import base64
import string

def caser(flag):
    enc1 = ''
    for i in flag:
        enc1 += chr(ord(i) - 5)
    
    return enc1


def rail(flag):
    p1 = ''
    p2 = ''
    p3 = ''
    enc2 = ''
    for i in range(len(flag)):
        j = i % 3
        if j == 0:
            p1 += flag[i]
            continue
        if j == 1:
            p2 += flag[i]
            continue
        p3 += flag[i]
    
    enc2 = p1 + p2 + p3
    return enc2


def rep(flag):
    table1 = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'
    table2 = 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'
    table = string.maketrans(table1, table2)
    return flag.translate(table, '=')

while True:
    flag = raw_input('please input flag to check:')
    if rep(base64.b64encode(rail(caser(flag)))) == 'ywjCytmRxI9CycWZngD2ncTDkZqYlJrGmhHCxISUnfWSlgfDlJi':
        print 'Success!you got it!'
        break
        continue
    print 'try a gain'

根据代码写脚本

import base64
string = "ywjCytmRxI9CycWZngD2ncTDkZqYlJrGmhHCxISUnfWSlgfDlJi"
flag=""
for i in string:
    if ord(i)>=65:
        flag += chr(ord(i)^32)
    else :
        flag += i
flag+='='
flag0=str(base64.b64decode(flag),'utf-8')
flag1=[0]*38
for i in range(len(flag0)):
    if((i%13)*3+i//13<len(flag0)):
        flag1[(i%13)*3+i//13]=flag0[i]
        flag1[(i%13)*3+i//13] = chr(ord(flag1[(i%13)*3+i//13])+5)
print("".join(flag1))

得到flag为flag{ca90f038b900ac91471a3fe9b1e38579}