靶机练习:sunset: midnight
信息收集
扫全端口和服务
80 端口直接访问访问不了: /wp-admin http://sunset-midnight
看到域名先进行域名绑定,编辑 /etc/hosts
ip sunset-midnight
绑定后可正常访问,访问robots.txt 文件
访问 /wp-admin,存在wordpress服务
使用wpscan 扫描 地址
[+] WordPress version 5.4.2 identified (Insecure, released on 2020-06-10).
| Found By: Rss Generator (Passive Detection)
| - http://sunset-midnight/feed/, <generator>https://wordpress.org/?v=5.4.2</generator>
| - http://sunset-midnight/comments/feed/, <generator>https://wordpress.org/?v=5.4.2</generator>
[+] WordPress theme in use: twentyseventeen
| Location: http://sunset-midnight/wp-content/themes/twentyseventeen/
| Last Updated: 2024-04-02T00:00:00.000Z
| Readme: http://sunset-midnight/wp-content/themes/twentyseventeen/readme.txt
| [!] The version is out of date, the latest version is 3.6
| Style URL: http://sunset-midnight/wp-content/themes/twentyseventeen/style.css?ver=20190507
| Style Name: Twenty Seventeen
| Style URI: https://wordpress.org/themes/twentyseventeen/
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo...
| Author: the WordPress team
| Author URI: https://wordpress.org/
加参数 -e u 扫描用户,存在用户 admin
wpscan --url http://sunset-midnight -e u
爆破密码没爆出来,又看到xml-rpc开了,看看有没有东西
尝试文件读取,无果
尝试3306 服务,爆破,有账号密码
成功登陆 mariadb
存在 wordpress_db数据库,有wp_users 表,表里有账号与密码密文,尝试使用hash-identifier判断,判断不出来是什么密码
拿shell
root有更改数据表的权限,可更改密码为123456
回到web端登陆wordpress
成功登陆后台后,有多种getshell方法
在 Appearance -> Edit Themes 模块中,选择TwentyTwenty 主题(其他主题好像更新不了代码)
更新404.php,直接换成我们的php-reverse-shell.php,设置好监听后访问
注意地址是:http://sunset-midnight/wp-content/themes/twentytwenty/404.php
拿到shell了,下一步准备提权
提权
翻wordpress配置文件,发现存在账号jose的数据库账号密码
linpeas.sh 跑一遍也发现系统存在jose这个账户
成功在系统中su jose,再跑一遍linpeas.sh 看看有没有其他信息
尝试 sudo -s 失败
sudo不能用,看看还有没有suid的程序
status有点特殊,运行一下
提权过程为:status运用了service程序,调用过程中没有使用绝对路径,可以自定义services加到环境变量中以获得提权效果
我们可以看到命令中确实只用了相对路径(提权完以后再看到的,我也是看walkthrough做的)
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
本文作者:cha0s32
本文链接:https://www.cnblogs.com/cha0s32/p/18234072
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步