猫咪和键盘
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=1&diff=medium&id=452
纵向随机切割
with open("typed_printf.cpp","r") as f:
lines=f.readlines()
#print(lines)
for line in lines:
seg1=line[0:1]
seg2=line[1:7]
seg3=line[8:20]
seg4=line[20:22]
seg5=line[22:32]
seg6=line[32:39]
seg7=line[39:-1]
print((seg1+seg6+seg2+seg4+seg3+seg5+seg7).strip())
/*
* name: typed_printf.cpp
* compile: g++ -std=c++17 typed_printf.cpp
* title: type safe printf
* author: nicekingwei
* url: aHR0cHM6Ly96anUtbGFtYmRhLnRlY2gvY3BwZHQtcHJpbnRmLw==
* related knowledge:
* - value and type
* value->value: function
* type->value: parametric polymorphism
* type->type: generic
* value->type: dependent type
* - auto
* - if constexpr
*/
#include
#include
#include
using namespace std;
template
static auto println() {
if constexpr (format[0]=='%') {
if constexpr (format[1]=='d') {
return [](int x){cout<
constexpr auto get_arg(R (*f)(T)){
return T{};
}
template
constexpr bool cont_takes_no_arg(T cont){
using cont_t = decay_t;
using arg_type = decay_t;
return is_same::value;
}
template
auto print_var(T x){
cout<
auto print_var(T x){
cout<
auto print_const(X x){
cout<
auto print_const(){
cout<
constexpr auto cont_ret_type(R (*cont)(X)){
return R{};
}
template
constexpr auto cont_ret_type(R (*cont)()){
return R{};
}
template
constexpr auto cont_arg_type(R (*cont)(X)){
return X{};
}
template
constexpr auto cont_arg_type(R (*cont)()){
return unit_t{};
}
unit_t print_nothing(){return unit_t{};}
#define cont_ret_t decay_t
#define cont_arg_t decay_t
template
constexpr auto _typed_printf(){
if constexpr (format[i]=='%' && format[i+1] == 'd') {
constexpr auto cont = _typed_printf();
return print_var;
} else if constexpr (format[i]=='%' && format[i+1] == 's') {
constexpr auto cont = _typed_printf();
return print_var;
} else if constexpr (format[i]!='\0') {
constexpr auto cont = _typed_printf();
return print_const;
} else {
return print_nothing;
}
}
#define def_typed_printf(f,str) constexpr static const char str_fmt##f[] = str; auto f = _typed_printf();
#define ABC "FfQ47if9Zxw9jXE68VtGA"
#define BAC "JDk6Y6Xc88UrUtpK3iF8p"
#define CAB "7BMs4y2gzdG8Ao2gv6aiJ"
int main(){
def_typed_printf(f_l_x_g_1, "%s%s%s%s");
f_l_x_g_1("fl")("a")("g")("{");
def_typed_printf(a_a_a_a_a_a_a_a_a, "%s%s%s%s%s%s%d");
a_a_a_a_a_a_a_a_a(ABC)("")(BAC)("")(CAB)("")('}');
def_typed_printf(def_typed_printf_, "%s%d%s");
def_typed_printf_("typed_printf")('_')("}");
return 0;
}
c++17运行得flag
Quotes
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=6&id=973
My+mission+in+life+is+not+mer ely+to+survive+but
to+thrive+and+to+do+so+w ith+s ome+pass i on+some+compass ion+so
me+humor+and+some+style
英文句子有加号有空格,按空格分组,计算字母数量然后对照26英文字母表输出文字
import string
l1="My+mission+in+life+is+not+mer ely+to+survive+but to+thrive+and+to+do+so+w ith+s ome+pass i on+some+compass ion+so me+humor+and+some+style".split(' ')
l2 = [len(i) - i.count('+') for i in l1]
l3 = [len(i) for i in l1]
print(l2)
cs = [string.ascii_lowercase[i-1] if i > 0 else ' ' for i in l2]
print(cs)
print(''.join(cs)) # flag
你猜猜
题目地址 : https://adworld.xctf.org.cn/task/answer?type=crypto&number=5&grade=1&id=4930&page=1
另出为zip文件,打开发现需要输入密码
0和1的故事
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=1&diff=easy&id=79
flag为16进制字符串
s1='09 20 20 09 20 09 20 09 09 20 09 20 09 20 09 09 20 20 09 20 20 09 09 09 20 20 20 09 09 09 20 09 20 09 20 09 09 09 09 20 20 20 20 09 09 09 20 09 09 09 09 09 09 20 20 20 20 20 20'
res1 = ''
ls2 = s1.split(' ')
print(len(s1))
print(len(ls2))
for i in ls2:
if '09'==i:
res1 += '1'
elif '20'==i:
res1 += '0'
print(res1)
print(hex(int(res1,2)))
透明的文件
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=8&diff=easy&id=1018
第一眼就看着像是命令行的颜色字符
if __name__ == '__main__':
import os
os.system('cls')
s = open('./transparent.txt','r').read()
s = s.replace('[', '\033[').replace(' ', '█')
while 1:
print(s)
BASE
题目地址 : https://ce.pwnthebox.com/challenges?type=3&page=3&id=419
import base64
s1 = open('flag_encode.txt', 'r').read()
ls1 = [s1[i*2:i*2+2] for i in range( int(len(s1)/2))]
s2 = ''
for t in ls1:
s2 += chr(int(t,16))
s3 = base64.b64decode(s2)
s3 = base64.b64decode(s2)
s3 = base64.b64decode(s3)
ls3 = [s3[i*2:i*2+2] for i in range( int(len(s3)/2))]
s4 = ''
for t in ls3:
s4 += chr(int(t,16))
s4 = base64.b64decode(s4)
s5 = base64.b32decode(s4)
s5 = base64.b32decode(s5)
s5 = base64.b32decode(s5)
ls5 = [s5[i*2:i*2+2] for i in range( int(len(s5)/2))]
s6 = ''
for t in ls5:
s6 += chr(int(t,16))
s6 = base64.b32decode(s6)
s6 = base64.b32decode(s6)
s6 = base64.b32decode(s6)
s6 = base64.b32decode(s6)
s6 = base64.b32decode(s6)
ls6 = [s6[i*2:i*2+2] for i in range( int(len(s6)/2))]
s7 = ''
for t in ls6:
s7 += chr(int(t,16))
s7 = base64.b32decode(s7)
s7 = base64.b32decode(s7)
s7 = base64.b64decode(s7)
s7 = base64.b32decode(s7)
s7 = base64.b64decode(s7)
s7 = base64.b64decode(s7)
s7 = base64.b32decode(s7)
s7 = base64.b32decode(s7)
s8 = ''
ls7 = [s7[i*2:i*2+2] for i in range( int(len(s7)/2))]
for t in ls7:
s8 += chr(int(t,16))
s8 = base64.b32decode(s8)
s8 = base64.b64decode(s8)
s8 = base64.b64decode(s8)
s9 = ''
ls8 = [s8[i*2:i*2+2] for i in range( int(len(s8)/2))]
for t in ls8:
s9 += chr(int(t,16))
s9 = base64.b64decode(s9)
s9 = base64.b64decode(s9)
print(s9)
Ranma½
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=7&id=1833
用记事本查看文件发现是乱码,用vim查看就可以正常
Find the Flag
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=7&id=1885
查看到text有base64数据
解码直接得到flag
Polly
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=6&diff=easy&id=1237
1 import sympy
2
3 flag = ""
4 x = sympy.symbols('x')
5 y = eval(open('./Polly.txt','r').read())
6 #print (y)
7 for i in range(57):
8 #print(i)
9 flag +=chr(y.subs(x,i))
10 print(flag)
zhushi
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=3&diff=medium&id=170
压缩包的备注上有tab和空格的字符,复制下来转成摩斯密码解吗得到zip的密码
exp
a = """
"""
for j in a:
if ord(j) == 32:
print('.',end='')
elif ord(j) == 9:
print('-',end='')
else:
print(' ',end='')
#print(ord(j))
misc1
题目地址 : https://ce.pwnthebox.com/challenges?type=1&page=7&diff=easy&id=1344
打开文件发现是某种编码
Vigenère
题目地址 : https://ce.pwnthebox.com/challenges?type=3&page=1&id=421
维吉尼亚加密 : https://atomcated.github.io/Vigenere/