Skip to content

Commit 9282d40

Browse files
author
gsbp
committed
update
1 parent f5608a4 commit 9282d40

File tree

22 files changed

+1077
-23
lines changed

22 files changed

+1077
-23
lines changed

.DS_Store

0 Bytes
Binary file not shown.

content/.DS_Store

0 Bytes
Binary file not shown.
543 KB
Binary file not shown.

content/post/.DS_Store

0 Bytes
Binary file not shown.

content/post/k8slanparty-WP.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
+++
2+
date = '2025-05-15T16:57:31+08:00'
3+
title = 'K8slanparty WP'
4+
draft = false
5+
author='GSBP'
6+
categories=["云安全","WP"]
7+
+++
8+
9+
---
10+
## DNSing with the stars
11+
12+
---
13+
14+
> You have shell access to compromised a Kubernetes pod at the bottom of this page, and your next objective is to compromise other internal services further.
15+
>
16+
> As a warmup, utilize [DNS scanning](https://thegreycorner.com/2023/12/13/kubernetes-internal-service-discovery.html#kubernetes-dns-to-the-partial-rescue) to uncover hidden internal services and obtain the flag. We have "loaded your machine with [dnscan](https://gist.github.com/nirohfeld/c596898673ead369cb8992d97a1c764e) to ease this process for further challenges.
17+
>
18+
> All the flags in the challenge follow the same format: wiz_k8s_lan_party{*}
19+
20+
---
21+
22+
根据题目信息可以知道是利用dnscan寻找k8s主机
23+
24+
通过env可以发现k8s的一些信息,比如service主机地址
25+
26+
![image-20250514172712063](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514172712063.png)
27+
28+
所以我们以service ip来找其cidr块中的其他主机就行了
29+
30+
![image-20250514172902917](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514172902917.png)
31+
32+
找到dns为**getflag-service.k8s-lan-party.svc.cluster.local.**
33+
34+
接下来curl一下就好了
35+
36+
![image-20250514172938267](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514172938267.png)
37+
38+
## Hello?
39+
40+
---
41+
42+
>Sometimes, it seems we are the only ones around, but we should always be on guard against invisible [sidecars](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/) reporting sensitive secrets.
43+
44+
---
45+
46+
Sidecar,指的是一种特殊的随着容器开启而启动的__init__容器
47+
48+
Sidecar具有独立的生命周期。它们可以独立于应用容器启动、停止和重启。 这意味着你可以更新、扩展或维护Sidecar容器,而不影响主应用。
49+
50+
变更Sidecar的镜像不会导致 Pod 重启,但会触发容器重启。
51+
52+
53+
54+
这一题的Sidecar的作用是不停的往主容器发数据,这些数据就有flag(别问为什么,问就是ctf靠猜
55+
56+
ifconfig找到网卡名
57+
58+
![image-20250514180022376](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514180022376.png)
59+
60+
tcpdump抓流量
61+
62+
```
63+
tcpdump -ins-bbf712 -XX -vvv -nn
64+
```
65+
66+
![image-20250514180103370](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514180103370.png)
67+
68+
## Exposed File Share
69+
70+
---
71+
72+
The targeted big corp utilizes outdated, yet cloud-supported technology for data storage in production. But oh my, this technology was introduced in an era when access control was only network-based 🤦‍️.
73+
74+
---
75+
76+
这题的问题主要是出在一个nfs系统上,在浏览文件时,可以看见根目录下多了个efs文件夹,flag.txt都在里面,但是没权限读
77+
78+
![image-20250514183942750](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514183942750.png)
79+
80+
根据题目里说的过期的储存架构,可以合理的看一眼mount
81+
82+
![image-20250514184134250](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514184134250.png)
83+
84+
确实是一个efs服务,由于efs的信任机制,我们可以使用nfs-cat和nfs-ls的同时自设uid和gid,version实现越权读取
85+
86+
下面是GPT老师的解释
87+
88+
>这是个非常好的问题。NFS 和 EFS 允许客户端“自报家门”(即客户端指定 UID/GID)听起来确实危险,但它背后有明确的**历史原因****设计取舍**。下面从多个角度解释为什么会有这种设计:
89+
>
90+
>------
91+
>
92+
>## 🧱 1. **历史背景:NFS 是为信任环境设计的**
93+
>
94+
>NFS(Network File System)最初由 Sun Microsystems 在 1980 年代设计,那时的目标是:
95+
>
96+
>- 在一个局域网(LAN)中的可信主机之间共享文件。
97+
>- 所有主机被认为是受信的,用户账户和 UID 是统一的。
98+
>- 系统管理员控制整个网络,因此不需要“验证”每个 UID。
99+
>
100+
>因此,NFS 协议从一开始就有个**基本假设**
101+
>
102+
>> “客户端发送过来的 UID/GID 是可信的。”
103+
>
104+
>这对性能和设计来说是很简单的方案,但不适合不可信网络。
105+
>
106+
>------
107+
>
108+
>## ☁️ 2. **EFS 基于 NFSv4 协议,为兼容而保留此行为**
109+
>
110+
>AWS EFS 是构建在 **NFSv4** 协议之上的托管服务。为了兼容现有生态和操作系统挂载行为,EFS 保留了 NFS 的传统机制:
111+
>
112+
>- 客户端控制 UID/GID。
113+
>- 服务端只根据 UID 来判断访问权限。
114+
>
115+
>这使得你可以**无缝把现有 Linux/NFS 系统迁移到 EFS**,不用修改太多逻辑。
116+
117+
118+
119+
这题我们用不了他的域名[fs-0779524599b7d5e7e.efs.us-west-1.amazonaws.com]来访问,好像是没有dns服务,这里用ip就好了,也在上面的红框框里
120+
121+
(这里的/要双写)
122+
123+
![image-20250514184434276](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514184434276.png)
124+
125+
## The Beauty and The Ist
126+
127+
---
128+
129+
> Apparently, new service mesh technologies hold unique appeal for ultra-elite users (root users). Don't abuse this power; use it responsibly and with caution.
130+
131+
---
132+
133+
这题考了个istio的规则绕过
134+
135+
根据hint1给的document可以得到下面的iptables
136+
137+
![image-20250514211427991](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514211427991.png)
138+
139+
一开始我还在想怎么获取环境里istio的iptables,没想到的是作者给这个hint就是把iptables给我们(似乎是默认配置啥的
140+
141+
我们可以在iptables里看到
142+
143+
```
144+
-A ISTIO_OUTPUT ! -d 127.0.0.1/32 -o lo -m owner --uid-owner 1337 -j ISTIO_IN_REDIRECT
145+
-A ISTIO_OUTPUT -o lo -m owner ! --uid-owner 1337 -j RETURN
146+
-A ISTIO_OUTPUT -m owner --uid-owner 1337 -j RETURN
147+
-A ISTIO_OUTPUT ! -d 127.0.0.1/32 -o lo -m owner --gid-owner 1337 -j ISTIO_IN_REDIRECT
148+
-A ISTIO_OUTPUT -o lo -m owner ! --gid-owner 1337 -j RETURN
149+
```
150+
151+
反正就是uid是1337的话就通过
152+
153+
istio的服务可以dnscan找到
154+
155+
看一下/etc/passwd,就找到了1337的istio
156+
157+
![image-20250514211639206](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250514211639206.png)
158+
159+
## Who will guard the guardians?
160+
161+
---
162+
163+
> Where pods are being mutated by a foreign regime, one could abuse its bureaucracy and leak sensitive information from the [administrative](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#request) services.
164+
165+
---
166+
167+
dnscan发现kyverno服务
168+
169+
![image-20250515161846130](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250515161846130.png)
170+
171+
kyverno是k8s的一个策略管理应用,这题我们的策略如下
172+
173+
```
174+
apiVersion: kyverno.io/v1
175+
kind: Policy
176+
metadata:
177+
name: apply-flag-to-env
178+
namespace: sensitive-ns
179+
spec:
180+
rules:
181+
- name: inject-env-vars
182+
match:
183+
resources:
184+
kinds:
185+
- Pod
186+
mutate:
187+
patchStrategicMerge:
188+
spec:
189+
containers:
190+
- name: "*"
191+
env:
192+
- name: FLAG
193+
value: "{flag}"
194+
```
195+
196+
kyverno会把创建在namespace=sensitive-ns的containers都添加一个flag环境变量
197+
198+
这里调用了kyverno的mutate接口,这个接口是 AdmissionReview的接口,需要我们发送对应的内容
199+
200+
这里用到了kube-review来生成
201+
202+
写一个yaml,用于创建一个新Containers在sensitive-ns下
203+
204+
```
205+
apiVersion: v1
206+
kind: Pod
207+
metadata:
208+
name: sensitive-pod
209+
namespace: sensitive-ns
210+
spec:
211+
containers:
212+
- name: nginx
213+
image: nginx:latest
214+
```
215+
216+
然后生成json,再搭个web服务传给攻击机
217+
218+
![image-20250515165235511](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250515165235511.png)
219+
220+
![image-20250515165306638](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250515165306638.png)
221+
222+
patch内容被base64加密了,根据kyverno的政策,可以判断patch就有他添加的env内容,即flag
223+
224+
![image-20250515165408567](https://tuchuang-1322176132.cos.ap-chengdu.myqcloud.com//imgimage-20250515165408567.png)
225+
226+
227+
228+
## 结尾
229+
230+
头一次打k8s的靶场,感觉东西很多,要了解的东西也有很多,网上有相关资料但不是特别丰富,用ai找一些解释就很方便,不过这里还没有让我们用kubectl这些东西,只能说入门了解还可以
543 KB
Binary file not shown.

public/categories/index.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ <h1>Categories</h1>
149149

150150
<div class="card">
151151

152-
<a href="http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/">
152+
<a href="http://localhost:1313/categories/wp/">
153153
</a>
154154
<div class="card-content has-text-centered">
155155
<div>
156-
<a class="title is-5 is-size-6-mobile" href="http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/">Java安全</a>
156+
<a class="title is-5 is-size-6-mobile" href="http://localhost:1313/categories/wp/">WP</a>
157157

158158
<strong>
159-
<sup style="font-size:16px;">4</sup>
159+
<sup style="font-size:16px;">5</sup>
160160
</strong>
161161
</div>
162162
</div>
@@ -165,11 +165,11 @@ <h1>Categories</h1>
165165

166166
<div class="card">
167167

168-
<a href="http://localhost:1313/categories/wp/">
168+
<a href="http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/">
169169
</a>
170170
<div class="card-content has-text-centered">
171171
<div>
172-
<a class="title is-5 is-size-6-mobile" href="http://localhost:1313/categories/wp/">WP</a>
172+
<a class="title is-5 is-size-6-mobile" href="http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/">Java安全</a>
173173

174174
<strong>
175175
<sup style="font-size:16px;">4</sup>
@@ -195,6 +195,22 @@ <h1>Categories</h1>
195195

196196
</div>
197197

198+
<div class="card">
199+
200+
<a href="http://localhost:1313/categories/%E4%BA%91%E5%AE%89%E5%85%A8/">
201+
</a>
202+
<div class="card-content has-text-centered">
203+
<div>
204+
<a class="title is-5 is-size-6-mobile" href="http://localhost:1313/categories/%E4%BA%91%E5%AE%89%E5%85%A8/">云安全</a>
205+
206+
<strong>
207+
<sup style="font-size:16px;">1</sup>
208+
</strong>
209+
</div>
210+
</div>
211+
212+
</div>
213+
198214

199215
</section>
200216

public/categories/index.xml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@
66
<description>Recent content in Categories on GSBP&#39;s Blog</description>
77
<generator>Hugo</generator>
88
<language>en-us</language>
9-
<lastBuildDate>Mon, 24 Mar 2025 22:00:00 +0800</lastBuildDate>
9+
<lastBuildDate>Thu, 15 May 2025 16:57:31 +0800</lastBuildDate>
1010
<atom:link href="http://localhost:1313/categories/index.xml" rel="self" type="application/rss+xml" />
1111
<item>
12-
<title>Java安全</title>
13-
<link>http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/</link>
14-
<pubDate>Mon, 24 Mar 2025 22:00:00 +0800</pubDate>
15-
<guid>http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/</guid>
12+
<title>WP</title>
13+
<link>http://localhost:1313/categories/wp/</link>
14+
<pubDate>Thu, 15 May 2025 16:57:31 +0800</pubDate>
15+
<guid>http://localhost:1313/categories/wp/</guid>
1616
<description></description>
1717
</item>
1818
<item>
19-
<title>WP</title>
20-
<link>http://localhost:1313/categories/wp/</link>
19+
<title>云安全</title>
20+
<link>http://localhost:1313/categories/%E4%BA%91%E5%AE%89%E5%85%A8/</link>
21+
<pubDate>Thu, 15 May 2025 16:57:31 +0800</pubDate>
22+
<guid>http://localhost:1313/categories/%E4%BA%91%E5%AE%89%E5%85%A8/</guid>
23+
<description></description>
24+
</item>
25+
<item>
26+
<title>Java安全</title>
27+
<link>http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/</link>
2128
<pubDate>Mon, 24 Mar 2025 22:00:00 +0800</pubDate>
22-
<guid>http://localhost:1313/categories/wp/</guid>
29+
<guid>http://localhost:1313/categories/java%E5%AE%89%E5%85%A8/</guid>
2330
<description></description>
2431
</item>
2532
<item>

public/categories/wp/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ <h2 class="archive-title">Category: WP</h2>
145145

146146

147147

148+
<article class="archive-item">
149+
<a href="http://localhost:1313/post/k8slanparty-wp/" class="archive-item-link hover-underline-animation">K8slanparty WP</a>
150+
<span class="archive-item-date">
151+
May 15, 2025
152+
</span>
153+
154+
</article>
155+
156+
157+
148158
<article class="archive-item">
149159
<a href="http://localhost:1313/post/%E8%BD%AF%E4%BB%B6%E6%94%BB%E9%98%B2%E8%B5%9B%E7%8E%B0%E5%9C%BA%E8%B5%9B%E4%B8%8A%E5%AF%B9justdeserialize%E6%94%BB%E5%87%BB%E7%9A%84%E5%87%A0%E6%AC%A1%E5%B0%9D%E8%AF%95/" class="archive-item-link hover-underline-animation">软件攻防赛现场赛上对justDeserialize攻击的几次尝试</a>
150160
<span class="archive-item-date">

public/categories/wp/index.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66
<description>Recent content in WP on GSBP&#39;s Blog</description>
77
<generator>Hugo</generator>
88
<language>en-us</language>
9-
<lastBuildDate>Mon, 24 Mar 2025 22:00:00 +0800</lastBuildDate>
9+
<lastBuildDate>Thu, 15 May 2025 16:57:31 +0800</lastBuildDate>
1010
<atom:link href="http://localhost:1313/categories/wp/index.xml" rel="self" type="application/rss+xml" />
11+
<item>
12+
<title>K8slanparty WP</title>
13+
<link>http://localhost:1313/post/k8slanparty-wp/</link>
14+
<pubDate>Thu, 15 May 2025 16:57:31 +0800</pubDate>
15+
<guid>http://localhost:1313/post/k8slanparty-wp/</guid>
16+
<description>&lt;hr&gt;&#xA;&lt;h2 id=&#34;dnsing-with-the-stars&#34;&gt;DNSing with the stars&lt;/h2&gt;&#xA;&lt;hr&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You have shell access to compromised a Kubernetes pod at the bottom of this page, and your next objective is to compromise other internal services further.&lt;/p&gt;&#xA;&lt;p&gt;As a warmup, utilize &lt;a href=&#34;https://thegreycorner.com/2023/12/13/kubernetes-internal-service-discovery.html#kubernetes-dns-to-the-partial-rescue&#34;&gt;DNS scanning&lt;/a&gt; to uncover hidden internal services and obtain the flag. We have &amp;ldquo;loaded your machine with &lt;a href=&#34;https://gist.github.com/nirohfeld/c596898673ead369cb8992d97a1c764e&#34;&gt;dnscan&lt;/a&gt; to ease this process for further challenges.&lt;/p&gt;&#xA;&lt;p&gt;All the flags in the challenge follow the same format: wiz_k8s_lan_party{*}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;根据题目信息可以知道是利用dnscan寻找k8s主机&lt;/p&gt;&#xA;&lt;p&gt;通过env可以发现k8s的一些信息,比如service主机地址&lt;/p&gt;</description>
17+
</item>
1118
<item>
1219
<title>软件攻防赛现场赛上对justDeserialize攻击的几次尝试</title>
1320
<link>http://localhost:1313/post/%E8%BD%AF%E4%BB%B6%E6%94%BB%E9%98%B2%E8%B5%9B%E7%8E%B0%E5%9C%BA%E8%B5%9B%E4%B8%8A%E5%AF%B9justdeserialize%E6%94%BB%E5%87%BB%E7%9A%84%E5%87%A0%E6%AC%A1%E5%B0%9D%E8%AF%95/</link>

0 commit comments

Comments
 (0)