ch4inrulz: 1.0.1靶机渗透

ch4inrulz: 1.0.1靶机渗透

扫描主机端口,还行啦四个开放的端口,8011和80端口都运行着web服务。

80端口下的robots.txt告诉我们什么都没有

在8011端口的apache服务下扫到一个api接口,貌似只有第三个是运行中的,即files_api.php

* web_api.php

* records_api.php

* files_api.php

* database_api.php  

转到第三个,告诉我们可以穿file,但不要用josn格式。

尝试穿了一个file参数过去直接被检测到了,但是这个时候出现了我的ip地址,可能存在ssti注入。

测试了一下发现加上foreward头没有改变,尝试用post的方式进行传递。

发现可行,接下来可能是找网站文件路径了,当然也可以利用php伪协议。

api.php:

<head>
  <title>franks website | simple website browser API</title>
</head>

<?php


$file = $_POST['file'];
include($file);
$get_file = $_GET['file'];

if(isset($get_file)){

echo "<b>********* HACKER DETECTED *********</b>";
echo "<p>YOUR IP IS : ".$_SERVER['REMOTE_ADDR'];
echo "</p><p>WRONG INPUT !!</p>";
break;
}


if(!isset($file)){

echo "<p>No parameter called file passed to me</p>";
echo "<p>* Note : this API don't use json , so send the file name in raw format</p>";

}

/** else{
echo strcmp($file,"/etc/passwd");
echo strlen($file);
echo strlen("/etc/passwd");
if($file == "/etc/passwd"){
        "HACKER DETECTED ..";
        }
}**/


?>

在11进行一下信息搜集发现无果,换一个字典扫描,在80端口的web服务下面发现了index.html.bak

在文件中发现路径:/development

访问发现需要用户名以及密码,在刚猜的文件当中有两个密文。

frank:$apr1$1oIGDEDK$/aVFPluYt56UvslZMBDoC0

爆破出密码为frank!!!

登录,告诉我们有一个上传的工具。

尝试输入以下uploader目录,直接跳转进来了是可以的。

害怕有什么过滤,所以把upload的源码读出来,猜的路径是/var/www/development/uploader/upload.php确实是这个。

<?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.";
    }
}
?>

这里的拦截方式非常的简陋,只是通过文件头来进行判断。

if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" )  

利用gif的头进行绕过。

上传成功,跟据这个文件可以看到路径为FRANKuploads/

利用之前端口的文件包含漏洞来执行反弹shell,反映了一下不能写一句话。

收到shell,提权还是利用系统版本的漏洞进行提权。

ubuntu 2.6.35-19-generic

存在提权的可能性

g++ -Wall -pedantic -O2 -std=c++11 -pthread -o test 12.cpp -lutil

没有g++,换一个gcc的。

这里我们利用的是40839.c这个提权文件,通过修改root账户的密码来进行提权,这里root用户为firefart

原文地址:https://www.cnblogs.com/ophxc/p/13386694.html