2020-07-12

第一周刷题总结

url编码
下载题目后我们会得到一串数字类型的编码%66%6c%61%67%7b%61%6e%64%20%31%3d%31%7d,根据提示我们找到url编码转换器然后转换成我们需要的flag{and 1=1}
在这里插入图片描述
一眼就解密
首先我们得到提示ZmxhZ3tUSEVfRkxBR19PRl9USElTX1NUUklOR30=其实看过之后我感觉有点懵,然后就百度了一下,发现了它属于base64编码,是一种编码方式。把3个8bit变成4个6bit。然后不足补0,符号是’=’. 然后还有一张表。
然后发现了解密代码
#include
#include
#include <stdio.h>
#include
#include
#include
#include
#include
using namespace std;
char str[1010];
char dict(int x,bool flag)
{ if(x == 0)
{ if(flag) return ‘=’;
else return ‘A’; }
else if(x < 26)
{ return ‘A’ + x; }
else if(x < 52)
{ return ‘a’ + x - 26; }
else if(x < 62)
{ return ‘0’ + x - 52; }
else if(x == 63)
return ‘+’; else return ‘/’;
}
char refdict(char x)
{
if(x >= ‘A’ && x <= ‘Z’)
{ return x - ‘A’; }
else if(x >= ‘a’ && x <= ‘z’)
{ return x - ‘a’ + 26; }
else if(x >= ‘0’ && x <= ‘9’)
{ return x - ‘0’ + 52; }
else if(x == ‘+’)
return 63; else if(x == ‘/’)
return 64; else if(x == ‘=’) return 0; }
int main()
{ while(gets(str))
{ string ans = “”;
int len = strlen(str);
for (int i = 0;i + 3 < len;i += 4)
{ int num = 0; for (int j = 0;j < 4;j ++)
{ num = (num << 6) + refdict(str[i * 4 + j]); } string tmp = “”; for (int j = 0;j < 3;j ++)
{ int val = num & 0x000000ff;
num >>= 8;
tmp = char(val) + tmp;
}
ans = ans + tmp;
}
cout << ans << endl;
} }
变异凯撒
首先我们得到提示
加密密文:afZ_r9VYfScOeO_UL^RWUc
格式:flag{ }
凯撒加密法,或称恺撒加密、恺撒变换、变换加密,是一种最简单且最广为人知的加密技术。它是一种替换加密的技术,明文中的所有字母都在字母表上向后(或向前)按照一个固定数目进行偏移后被替换成密文。
我的第一反应是查阅ascii表,可是发现密文中的“_”没有与之对应而
a:97 f:102 Z:106 _:95
c:99 t:116 f:102 {:123
f:102 l:108 a:97 g:103
a→f: 移动了5 f→l:移动了6, 后面依次移动了7、8。按这个规律得到了一些代码
#!/usr/bin/env python
#coding:utf-8

def b_kaisa(mstr):
j = 5
i = 0
lmstr = []
for i in range(len(mstr)):
m = ord(mstr[i]) # 将密文的第i个字母变为其ascii码值
m = m + j # ascii值+j
lmstr.append(m) # 将递进后的ascii值存入列表lmstr[]
i = i+1
j = j+1
return lmstr

if name == ‘main’:
m_str = ‘afZ_r9VYfScOeO_UL^RWUc’ # 密文
lstr = []
lstr = b_kaisa(m_str)
print lstr
然后运行
在这里插入图片描述
把这些结果放入ascii中转换得到
flag{Caesar_variation}

猜你喜欢

转载自blog.csdn.net/qq_46172668/article/details/107294597