自制靶机--Believe

发布时间:2026/5/24 1:22:25

自制靶机--Believe Believe设计思路靶机名称: Believe作者Gropers靶机ID661难度: baby靶机下载地址: https://ova-believe.oss-cn-beijing.aliyuncs.com/Believe.ova靶机收集地址: https://maze-sec.com靶机IP: 192.168.1.150攻击机IP: 192.168.1.195(Kali Linux)QQ Group: 660930334信息收集与外网突破端口扫描┌──(root㉿Gropers)-[~] └─# nmap -A -sT -p- 192.168.1.150 Starting Nmap 7.99 ( https://nmap.org ) at 2026-05-23 04:31 -0400 Nmap scan report for 192.168.1.150 Host is up (0.0011s latency). Not shown: 65531 closed tcp ports (conn-refused) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 10.3 (protocol 2.0) 80/tcp open http Apache httpd 2.4.67 ((Unix)) |_http-title: Login |_http-server-header: Apache/2.4.67 (Unix) | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set 2222/tcp open ssh OpenSSH 10.3 (protocol 2.0) 54321/tcp open ssh OpenSSH 10.3 (protocol 2.0) MAC Address: 08:00:27:AC:0E:5E (Oracle VirtualBox virtual NIC) No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ). TCP/IP fingerprint: OS:SCAN(V7.99%E4%D5/23%OT22%CT1%CU38292%PVY%DS1%DCD%GY%M080027%T OS:M6A1165E6%Px86_64-pc-linux-gnu)SEQ(SP100%GCD1%ISR104%TIZ%CIZ%III OS:%TS22)SEQ(SP104%GCD1%ISR10C%TIZ%CIZ%III%TS21)SEQ(SP106%GCD1%IS OS:R107%TIZ%CIZ%TS21)SEQ(SP106%GCD1%ISR10B%TIZ%CIZ%III%TS21)SEQ( OS:SPF9%GCD1%ISR10F%TIZ%CIZ%III%TS21)OPS(O1M5B4ST11NW9%O2M5B4ST11N OS:W9%O3M5B4NNT11NW9%O4M5B4ST11NW9%O5M5B4ST11NW9%O6M5B4ST11)WIN(W1FE88 OS:%W2FE88%W3FE88%W4FE88%W5FE88%W6FE88)ECN(RY%DFY%T40%WFAF0%OM5B4 OS:NNSNW9%CCY%Q)T1(RY%DFY%T40%SO%AS%FAS%RD0%Q)T2(RN)T3(RN)T4(R OS:Y%DFY%T40%W0%SA%AZ%FR%O%RD0%Q)T5(RY%DFY%T40%W0%SZ%AS%F OS:AR%O%RD0%Q)T6(RY%DFY%T40%W0%SA%AZ%FR%O%RD0%Q)T7(RY%DFY%T OS:40%W0%SZ%AS%FAR%O%RD0%Q)U1(RY%DFN%T40%IPL164%UN0%RIPLG%RID OS:G%RIPCKG%RUCKG%RUDG)IE(RY%DFIN%T40%CDS) Network Distance: 1 hop TRACEROUTE HOP RTT ADDRESS 1 1.06 ms 192.168.1.150 OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 24.77 seconds靶机一共开启了四个端口80端口用于web页面进入之后是一个登录页面gobuster扫一下目录┌──(root㉿kali)-[~] └─# gobuster dir -u http://192.168.1.150 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt,html,bak Gobuster v3.8.2 by OJ Reeves (TheColonial) Christian Mehlmauer (firefart) [] Url: http://192.168.1.150 [] Method: GET [] Threads: 10 [] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3- medium.txt [] Negative Status codes: 404 [] User Agent: gobuster/3.8.2 [] Extensions: txt,html,bak,php [] Timeout: 10s Starting gobuster in directory enumeration mode index.php (Status: 200) [Size: 772] dashboard.php (Status: 302) [Size: 0] [-- index.php] yu.txt (Status: 200) [Size: 27] server-status (Status: 403) [Size: 318] Progress: 1102790 / 1102790 (100.00%) Finished 在这可以发现除了登录页面还有一个dashboard控制面板在这里出现了一个设计失误导致yu.txt直接被扫描器扫出来了结果导致选手没有通过登陆页面直接获取到了准备的提示信息22、2222、54321开放了三个ssh端口其中22端口下有一组banner凭证通常来说选手得到这组凭证之后一定回去网页的登录口进行尝试但是输入这组凭证却无法进入这其实就是这个靶机的制作初衷就像是ssh登录一样哪怕你输入错误也会给你输入三次的机会需要连续 3 次使用 admin:yubao9694482664 登录同一次会话就可以进入到dashboard控制面板首先一进来就可以得到存在一yu用户我直接将它放在了网页上当然也可以直接通过ls -al /home得到存在的这个用户网页下给出的提示文件yu.txt也同样给出了提示SSH登录通过-p来修改端口尝试凭据复用成功从54321端口登录上了yu用户查看用户文件夹目录得到user flag还可以发现准备的hint文件yuBelieve:~$ cat hint.txt The walls have ears, and the logs have a heartbeat. it keeps whispering the truth. Just...以及一个没有任何权限的be文件hint文件提醒选手去查看log就可以注意到/var/log/.hidden/.ghost_radio这是个命名管道将管道内的内容提取出来并去掉影响字符就可以得到是一个反复输出的believe再通过sudo -l可以知道yu可以无密码以root身份执行/root/be发现是一个密钥验证程序同时也提醒了密钥是七位(*******)输入之前获得的believe密钥就可以得到密钥正确这时候再查看yu用户的当前目录下就可以看到be文件从 ---------- 变为 -rwsr-xr-xSUID root4755运行./be这同样是一个口令验证程序但是可以将它拉到本地进行一个逆向反编译反汇编分析main 函数 (0x401b1a)1. 在栈上设置 20 字节的硬编码密钥目标 2. 调用 generate_key() 生成 7 字节 RC4 密钥 3. 打印 请输入系统密钥: 4. 使用 scanf(%255s) 读取用户输入 5. 计算输入长度 strlen 6. 调用 rc4_init(key, 7) 初始化 RC4 7. 调用 rc4_crypt(state, input, length) 解密输入 8. 检查长度是否为 20 (0x14) 9. 逐字节比较解密后的输入与硬编码的 20 字节目标 10. 匹配则调用 get_shell() 并打印 验证成功。 11. 不匹配则打印 权限不足。generate_key 函数 (0x401a24)movl $0xc3c6cfc8,-0xb(%rbp) # 栈上存储加密数据 movl $0xcfdccfc3,-0x8(%rbp) # 循环 7 次 (i 0..6)每字节 XOR 0xaa推导过程偏移原始字节XOR 0xaaASCII00xc80x62b10xcf0x65e20xc60x6cl30xc30x69i40xcf0x65e50xdc0x76v60xcf0x65eRC4 密钥 “believe”get_shell 函数 (0x401a77)# 解码 /bin/bash (bitwise NOT 每字节) movabs $0x8c9e9dd091969dd0,%rax # NOT → 0x62696e2f /bin movw $0xff97,-0x6(%rbp) # NOT → 0x0068 h\0 # → 解码结果: /bin/bash setuid(0) # 设置 UID 为 root setgid(0) # 设置 GID 为 root puts([] 正在请求 Believe 核心权限...) execve(/bin/bash, {/bin/bash, -p, NULL}, NULL)计算密码get_shellRC4 架构密钥:believe(7 字节)对 20 字节硬编码目标进行 RC4 加密因为程序会解密用户输入后比对targetbytes([0x24,0x53,0x27,0x50,0x78,0x4b,0x9d,0xab,0xab,0x7e,0xf0,0xa1,0x49,0xf2,0xea,0x7e,0xec,0x6c,0x82,0x77])rc4_keybbelieve# RC4 加密目标得到密码passwordrc4_crypt(rc4_init(rc4_key),target)# → bBelieve_in_yourself! (20 字节)最后得到了口令就是Believe_in_yourself!输入口令就会执行一个/bin/bash得到最终的root flagWeb分析回过头来看/var/www/html文件夹下的文件分析index和dashboardindex.php?php error_reporting(0); session_start(); $m ; if (isset($_SESSION[auth]) $_SESSION[auth] true) { header(Location: dashboard.php); exit; } if ($_SERVER[REQUEST_METHOD] POST) { $u $_POST[u] ?? ; $p $_POST[p] ?? ; if ($u admin $p yubao9694482664) { $_SESSION[c] ($_SESSION[c] ?? 0) 1; if ($_SESSION[c] 3) { $_SESSION[auth] true; header(Location: dashboard.php); exit; } } else { $_SESSION[c] 0; } $m ; } ? !DOCTYPE html html head meta charsetutf-8 titleLogin/title style body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: #f4f4f4; font-family: sans-serif; } form { background: #fff; padding: 30px; border: 1px solid #ddd; box-shadow: 0 0 10px rgba(0,0,0,0.1); } input { margin-bottom: 15px; padding: 8px; width: 200px; display: block; } input[typesubmit] { width: 100%; cursor: pointer; background: #333; color: #fff; border: none; } .e { color: red; font-size: 14px; text-align: center; } /style /head body form methodPOST input typetext nameu placeholderUsername input typepassword namep placeholderPassword input typesubmit valueLogin ?php if ($m ! ) { echo div classe . htmlspecialchars($m) . /div; } ? /form /body /html需要连续 3 次使用admin:yubao9694482664登录同一次会话才能获得authtrue并访问dashboard.php。dashboard.php?php error_reporting(0); session_start(); if (isset($_POST[logout])) { session_destroy(); header(Location: index.php); exit; } if (!isset($_SESSION[auth]) || $_SESSION[auth] ! true) { header(Location: index.php); exit; } $r ; if (isset($_POST[cmd])) { $c trim($_POST[cmd]); if (preg_match(/^ls(\s.*)?$/, $c) || preg_match(/^cat\s.*\.txt$/, $c)) { if (!preg_match(/[;|$\n]/, $c)) { $r shell_exec($c); } } } ? !DOCTYPE html html head meta charsetutf-8 titleDashboard/title style body { background: #1e1e1e; color: #00ff00; font-family: monospace; padding: 20px; } .top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid #333; padding-bottom: 10px; } input[typetext] { background: #000; color: #00ff00; border: 1px solid #00ff00; padding: 5px; width: 300px; } input[typesubmit] { background: #00ff00; color: #000; border: none; padding: 6px 15px; cursor: pointer; } .logout-btn { background: #ff0000; color: #fff; border: none; padding: 6px 15px; cursor: pointer; } pre { background: #000; padding: 15px; border: 1px solid #333; min-height: 50px; } /style /head body div classtop-bar spanSystem Console/span form methodPOST stylemargin: 0; input typesubmit namelogout valueLogout classlogout-btn /form /div form methodPOST span classpromptyuBelieve:~$/span input typetext namecmd autofocus autocompleteoff input typesubmit valueExec /form br pre?php echo htmlspecialchars($r, ENT_QUOTES, UTF-8); ?/pre /body /html认证后可以执行ls和cat *.txt命令但存在过滤禁止;|$等字符。倒是可以用多文件规避正则实现读任意文件if (preg_match(/^ls(\s.*)?$/, $c) || preg_match(/^cat\s.*\.txt$/, $c)) { if (!preg_match(/[;|$\n]/, $c)) { $r shell_exec($c);总结这个靶机哪怕经过了多轮测试还是存在一些问题现在ai的不断强大对于静态二进制文件还是冲击较大选手可以通过ai快速完成最后对于二进制文件的反编译快速得到口令只有动态调试的文件暂时还算良好但是相信不久以后ai也能解决类似的问题这个靶机制作的一个初衷就是之前听到的一个玩笑话当你输入正确密码后也不能进入页面才能正在防护爆破因为真正知道密码的人一定还会输入几遍emoji[嘻嘻]if (preg_match(‘/^ls(\s.*)?$/’,KaTeX parse error: Undefined control sequence: \s at position 24: …eg_match(/^cat\̲s̲.*\.txt/‘,KaTeX parse error: Expected }, got at position 36: …reg_match(/[;|̲\n]/’, $c)) {r s h e l l e x e c ( r shell_exec(rshelle​xec(c);## 总结 这个靶机哪怕经过了多轮测试还是存在一些问题 现在ai的不断强大对于静态二进制文件还是冲击较大选手可以通过ai快速完成最后对于二进制文件的反编译快速得到口令只有动态调试的文件暂时还算良好但是相信不久以后ai也能解决类似的问题 这个靶机制作的一个初衷就是之前听到的一个玩笑话 当你输入正确密码后也不能进入页面才能正在防护爆破因为真正知道密码的人一定还会输入几遍emoji[嘻嘻] 而对于后面的提权只是因为我最初接触这个行业的时候是作为一个CTF选手去解决reverse方向的题目所以做了一道反编译题目。

相关新闻