BUUCTF [ACTF新生赛2020]rome

把文件拖入IDA

shift+F12查看可疑字符串  发现了you are correct

跟进查看 进入func函数

打开流程图 F5大法查看伪c代码

为了方便看代码 把数字转换为字符

开始慢慢搓代码

这里判断 flag[i] 是否属于大写小写字母 

这段代码比较两个字符串v1v12 的大小

这里我参考了其他师傅的做法

暴力枚举法

v15 =  "Qsw3sj_lz4_Ujw@l"
flag = ""
for i in range(0,16):
    for j in range(0,127):# ASCII
        x = j
        if j > 64 and j <= 90:
            j = (j  - 51) % 26 + 65
        if j > 96 and j <= 122:
            j = (j  - 79) % 26 + 97
        if chr(j) == v15[i]:
            flag += chr(x)
print(flag)

这里了解到了凯撒加密

凯撒加密(Caesarcipher)
凯撒加密是一种简单的消息编码方式:它根据字母表将消息中的每个字母移动常量位k(密钥)。
例如:如果k等于3,则在编码后的消息中,每个字母都会向前移动3位:a(明文)会被替换为d(密文);b会被替换成e;依此类推。字母表末尾将回卷到字母表开头。于是,w会被替换为z,x会被替换为a。

加密



int kaisa_encrypt(const char *str1,char *str2,const  int len)
{
    int i;
    int m = strlen(str1);
    if(m <= 0){
        return -1;
    }
    for(i=0;i<m;i++)
    {
        if(str1[i]>='a'&&str1[i]<='z')
            str2[i]='a'+(str1[i]-'a'+len)%26;
        else if(str1[i]>='A'&&str1[i]<='Z')
            str2[i]='A'+(str1[i]-'A'+len)%26;
        else
            str2[i]=str1[i];                                                                                 
    }
    return 0;

​

解密

​

int kaisa_decrypt(const char *str2,char *str3, const int len)
{
    int i;
    char small_letter[26]="abcdefghijklmnopqrstuvwxyz";
    char big_letter[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int m = strlen(str2);
    if(m <= 0){
        return -1;
    }//若字符串长度小于等于0则不继续进行 
    for(i=0;i<m;i++)
    {
        if((str2[i]>=small_letter[len]&&str2[i]<='z')||(str2[i]>=big_letter[len]&&str2[i]<='Z'))
            str3[i]=str2[i]-len;
        else if((str2[i]>='a'&&str2[i]<=small_letter[len-1])||(str2[i]>='A'&&str2[i]<=big_letter[len-1]))
            str3[i]=str2[i]+(26-len);
        else
            str3[i]=str2[i];
    }
    return 0;
}

​

最后flag

flag{Cae3ar_th4_Gre@t}

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值