1
0
mirror of https://github.com/nganhkhoa/malware.git synced 2024-06-10 21:32:07 +07:00
mether049-malware/malware-tech_ref_and_memo.md

410 lines
22 KiB
Markdown
Raw Normal View History

2020-02-17 00:14:40 +07:00
# Anti-analysis/detection
2020-01-09 22:53:56 +07:00
- Anti-analysisに利用されるAPI,ファイル名プロセス名dllレジストリ等の一覧まとめ<br>
[Collection of Anti-Malware Analysis Tricks.(2016-10)](https://forum.tuts4you.com/topic/38931-collection-of-anti-malware-analysis-tricks/)
## Injection/Hollowing
- 正規プロセス等のアドレス空間にコードを注入することで検知や分析を妨害するTechnique
- 利用される正規プロセスsvchost.exe,explorer.exe,regsvr32.exe等
- Heaven's Gateと組み合わせて利用される場合あり
2020-01-17 22:52:36 +07:00
-
**ref:**<br>
- 各種Injection/Hollowingで利用されるAPIの一覧<br>
2020-01-09 22:53:56 +07:00
[HUNTING PROCESS INJECTION BY WINDOWSAPI CALLS (2019-11)](https://malwareanalysis.co/wp-content/uploads/2019/11/Hunting-Process-Injection-by-Windows-API-Calls.pdf)<br>
2020-01-17 22:52:36 +07:00
- 図で分かりやすく説明<br>
2020-01-09 22:53:56 +07:00
[Ten Process Injection Techniques: A Technical Survey Of Common And Trending Process Injection Techniques](https://www.endgame.com/blog/technical-blog/ten-process-injection-techniques-technical-survey-common-and-trending-process)
2020-01-17 22:52:36 +07:00
- プログラムベースの説明<br>
2020-01-09 22:53:56 +07:00
[Code & Process Injection,Red Teaming Experiments](https://ired.team/offensive-security/code-injection-process-injection)
### Dll Injection
- 正規プロセス探索->プロセスのハンドル取得->メモリ領域確保->悪性DLL注入->実行
- e.g. CreateToolhelp32Snapshot,Process32First,Process32Next->OpenProcess->VirtualAllocEx->WriteProcessMemory->CreateRemoteThread<br>
[07b8f25e7b536f5b6f686c12d04edc37e11347c8acd5c53f98a174723078c365](https://www.virustotal.com/gui/file/07b8f25e7b536f5b6f686c12d04edc37e11347c8acd5c53f98a174723078c365/detection)
### Thread Execution Hijacking
- 正規プロセス,スレッド探索->スレッドのハンドル取得->スレッド停止->メモリ領域確保->悪性コード注入->EIP書き換え->実行
- e.g. CreateToolhelp32Snapshot,Thread32First,Thread32Next->OpenThread->SuspendThread->VirtualAllocEx->WriteProcessMemory->SetThreadContext->ResumeThread
[787cbc8a6d1bc58ea169e51e1ad029a637f22560660cc129ab8a099a745bd50e](https://www.virustotal.com/gui/file/787cbc8a6d1bc58ea169e51e1ad029a637f22560660cc129ab8a099a745bd50e/detection)
### Dll Injection Using SetWindowsHookEx(Hook Injection)
- Hooking:
> Hooking is a technique used to intercept function calls.
- SetWindowsHookEx
> - The first argument is the type of event. The events reflect the range of hook types, and vary from pressing keys on the keyboard (WH_KEYBOARD) to inputs to the mouse (WH_MOUSE), CBT, etc.
> - The second argument is a pointer to the function the malware wants to invoke upon the event execution.
> - The third argument is a module that contains the function.
> - The last argument to this function is the thread with which the hook procedure is to be associated.
- dll読み込み->アドレス解決->正規プロセス,スレッドの探索->フック
- e.g. LoadLibrary->GetProcAddress->CreateToolhelp32Snapshot,Thred32First,Thread32Next->SetWindowsHookEx
[5d6ddb8458ee5ab99f3e7d9a21490ff4e5bc9808e18b9e20b6dc2c5b27927ba1](https://www.virustotal.com/gui/file/5d6ddb8458ee5ab99f3e7d9a21490ff4e5bc9808e18b9e20b6dc2c5b27927ba1/detection)
### Process Hollowing
- 正規プロセス作成(サスペンド状態)->空洞化->メモリ領域確保->悪性コード注入->エントリポイント設定->実行<br>
- e.g. CreateProcess->ZwUnmapViewOfSection(NtUnmapViewOfSection)->VirtualAllocEx->WriteProcessMemory->SetThreadContext->ResumeThread<br>
[eae72d803bf67df22526f50fc7ab84d838efb2865c27aef1a61592b1c520d144](https://www.virustotal.com/gui/file/eae72d803bf67df22526f50fc7ab84d838efb2865c27aef1a61592b1c520d144/detection)
### APC Injection
- プロセス,スレッド探索->アラート状態->ハンドル取得->キューに追加
- e.g. Createtoolhelp32Snapshot,Thread32First,Thread32Next->WaitForMultipleObjectEx->OpenThread->VirtualAllocEx->WriteProcessMemory->QueueUserAPC
- QueueUserAPC
> - First args: a handle to the target thread
> - Second args: a pointer to the function that the malware wants to run
> - Third args: the parameter that is passed to the function pointer.
[f74399cc0be275376dad23151e3d0c2e2a1c966e6db6a695a05ec1a30551c0ad](https://www.virustotal.com/gui/file/f74399cc0be275376dad23151e3d0c2e2a1c966e6db6a695a05ec1a30551c0ad/detection)
### ATOM BOMBING
to do...
### Shell Tray Window Injection
to do...
### Shim Injection
to do...
### IAT and Inline Hooking
to do...
### ALPC Injection
to do...
### REFLECTIVE PE Injection
to do...
### LOCKPOS
to do...
### KERNEL CALLBACK TABLE
to do...
### CLIPBRDWNDCLASS
to do...
### PROGATE
to do...
### EARLY BIRD
to do...
### CONSOLE WINDOW CLASS
to do...
### TOOLTIP Process Injection
to do...
2020-01-17 22:52:36 +07:00
### Persistence
2020-01-09 22:53:56 +07:00
- **Applnit_Dlls**<br>
to do...
- **AppCertDlls**<br>
to do...
- **IFEO**<br>
to do...
## Heaven's Gate
- 0x33セグメントセレクターを使用して32ビットWOW64プロセスで64ビットコードを実行するTechnique<br>
- x86用ユーザモードデバッガでの追跡が難しい<br>
- WinDBG等のカーネルモードデバッガでは追跡することができる<br>
- 名前の由来はVX Heavenに投稿されたから<br>
- 少なくともtrickbot,locky,emotet等では利用されていた<br>
2020-01-17 22:52:36 +07:00
**ref:**<br>
2020-01-09 22:53:56 +07:00
[Knockin on Heavens Gate Dynamic Processor Mode Switching(2012-09)](http://rce.co/knockin-on-heavens-gate-dynamic-processor-mode-switching/)<br>
[The 0x33 Segment Selector (Heavens Gate)](https://www.malwaretech.com/2014/02/the-0x33-segment-selector-heavens-gate.html)<br>
## API obfuscation
2020-02-18 21:59:40 +07:00
[A Museum of API Obfuscation on Win32](https://www.symantec.com/content/en/us/enterprise/media/security_response/whitepapers/a_museum_of_api_obfuscation_on_win32.pdf)<br>
### Using GetProcAddress and GetModulehandleA
2020-02-18 22:27:38 +07:00
- GetProcAddressを利用して呼び出したいAPIのアドレスを動的に解決することでAPIの呼び出し解析を回避する
2020-02-23 00:53:15 +07:00
- GetProcAddressの引数は第一引数に対象dllのハンドルを指定(e.g. GetModuleHandleA("kernel32.dll"))し第二引数にdllから呼び出したいAPI名を指定
2020-02-18 22:27:38 +07:00
```cpp
// Get a handle on kernel32.dll
HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
2020-02-18 21:59:40 +07:00
2020-02-18 22:27:38 +07:00
// Define the prototype of 'OpenProcess' (see https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-openprocess)
using OpenProcessPrototype = HANDLE(WINAPI*)(DWORD, BOOL, DWORD);
2020-02-18 21:59:40 +07:00
2020-02-18 22:27:38 +07:00
// Perform the dynamic resolving using GetProcAddress
OpenProcessPrototype OpenProcess = (OpenProcessPrototype)GetProcAddress(kernel32, "OpenProcess");
```
- GetProcAddressやGetModuleWのみインポートすること自体が怪しまれる可能性がある
- ref:
- [Hidden in PEB Sight: Hiding Windows API Imports With a Custom Loader,2020-02](https://blog.christophetd.fr/hiding-windows-api-imports-with-a-customer-loader/)
2020-02-18 22:33:13 +07:00
- [Salted algorithm - part 1,virusbulletin.,2014](https://www.virusbulletin.com/virusbulletin/2014/01/salted-algorithm-part-1)
2020-02-18 22:27:38 +07:00
### Using PEB
- GetProcAddressやGetModulehanleWのアドレスも動的に解決させることができる
- PEB(Process Environmental Block)の[PEB_LDR_DATA](https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-peb_ldr_data)構造体や[LDR_DATA_TABLE_ENTRY](https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-peb_ldr_data#remarks)構造体のリストを反復処理して目的のDLL名を探しアドレスを取得する
- 目的のDLLのメモリ内のエクスポートテーブルから呼び出す対象のAPIを探しアドレスを取得する
- ref:
- [Hidden in PEB Sight: Hiding Windows API Imports With a Custom Loader,2020-02](https://blog.christophetd.fr/hiding-windows-api-imports-with-a-customer-loader/)
2020-02-18 22:33:13 +07:00
- [Salted algorithm - part 1,virusbulletin.,2014](https://www.virusbulletin.com/virusbulletin/2014/01/salted-algorithm-part-1)
2020-01-09 22:53:56 +07:00
## PowerShell Script obfuscation
- 難読化ツール<br>
[Invoke-Obfuscation](https://github.com/danielbohannon/Invoke-Obfuscation)
2020-02-23 21:23:06 +07:00
- PS内の文字列(Mimikatz,DumpCreds,コメントetc.)の置換のみでVirusTotal上でMimikatzの検知率を0にしたという検証<br>
[How to Bypass Anti-Virus to Run Mimikatz](https://www.blackhillsinfosec.com/bypass-anti-virus-run-mimikatz/)
2020-01-09 22:53:56 +07:00
- Powershell Script内で用いられる難読化技術について
2020-01-11 14:43:32 +07:00
### Case-insensitive
2020-01-13 19:39:06 +07:00
- コマンドレット名や変数名に大文字,小文字を混ぜる
2020-01-09 22:53:56 +07:00
- PowerShellでは区別されない
2020-01-10 07:44:05 +07:00
```
INvOke-eXpReSsiOn
```
2020-01-11 14:43:32 +07:00
### Alias
2020-01-09 22:53:56 +07:00
- コマンドのエイリアスを用いる
- エイリアスの確認方法
2020-01-09 22:59:25 +07:00
```
2020-01-13 19:39:47 +07:00
get-alias # すべてのエイリアスの確認
2020-01-09 22:59:25 +07:00
get-alias iex #iexのエイリアス(Invoke-Expression)の確認
```
2020-01-09 22:53:56 +07:00
- よく利用されるエイリアス
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
iex -> Invoke-Expression
2020-01-09 22:59:25 +07:00
sal -> Set-Alias
```
2020-01-09 22:53:56 +07:00
- エイリアスの設定
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
set-alias <Name> <Value>
2020-01-09 22:59:25 +07:00
sal ping iex
```
2020-01-11 14:43:32 +07:00
### Dot expression and amp expression(Invoke-Expression)
2020-01-09 22:53:56 +07:00
- 文字列で表現されたコマンドレットを実行
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
.("get-alias")
&('gal')
2020-01-09 22:59:25 +07:00
iex("GeT-AliAs")
```
2020-01-09 22:53:56 +07:00
### Combining characters
- 文字や文字列の結合
2020-01-09 22:59:25 +07:00
```
'i'+'ex'
```
2020-01-09 22:53:56 +07:00
### Backticks
- コマンドレットや変数にバッククォートを挿入
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
`i`e`x("`gal `gal")
2020-01-09 22:59:25 +07:00
```
2020-01-09 22:53:56 +07:00
### Split method
- 文字列の分割
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
'bob@alice'-split('@') -> bob alice
2020-01-09 22:59:25 +07:00
'bob@alice' -split '@' -split "i" -> bob al ce
```
2020-01-09 22:53:56 +07:00
### Join method
- リストの結合
2020-01-09 22:59:25 +07:00
```
"bob","alice" -join "@" -> bob@alice
```
2020-01-09 22:53:56 +07:00
### Concatenation operations
- 文字列の並べ替えおよび連結
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
"{1} {0}" -f "Alice","Bob" -> Bob Alice
2020-01-09 22:59:25 +07:00
"{1} {0}" -f "Alice",("{1}{2}{0}" -f "b","B","o") -> Bob Alice
```
2020-01-09 22:53:56 +07:00
### No Space
- 空白の省略
2020-01-09 22:59:25 +07:00
```
"bob","alice"-join"@"
```
2020-01-09 22:53:56 +07:00
### Pipe operator
- パイプによる引数の引き渡し
2020-01-09 22:59:25 +07:00
```
'Write-host 1' | iex
```
2020-01-09 22:53:56 +07:00
### $ENV variable
- 環境変数の値を文字列の作成等に利用
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
.($seLLId[1]+$shEllId[13]+'x') -> .(iex)
2020-01-09 22:59:25 +07:00
&($EnV:cOmSpEc[4,15,25]-JOIN'') -> &(iex)
```
2020-01-09 22:53:56 +07:00
### Encode
- xor
- 文字16進数10進数等で指定可能
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
10-bxor"10" -> 0
2020-01-09 22:59:25 +07:00
"0xa"-bxor10 -> 0
```
2020-01-09 22:53:56 +07:00
- base64
2020-01-09 22:59:25 +07:00
```
[System.Convert]::FromBase64String("Ym9iYWxpY2UK") -> bobalice
```
2020-01-09 22:53:56 +07:00
- zlib
2020-01-09 22:59:25 +07:00
```
New-Object System.IO.Compression.DeflateStream([iO.mEmoRySTream] [sysTEM.ConVert]::frOMBASE64STrING("Ym9iYWxpY2UK"))
```
2020-01-09 22:53:56 +07:00
- unicode
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
[System.Text.Encoding]::Unicode.GetString($unicodeBytes)
2020-01-09 22:59:25 +07:00
```
2020-01-09 22:53:56 +07:00
### Ascii code
- 文字などをasciiコードの10進数16進数表記で示す
2020-01-09 22:59:25 +07:00
```
2020-01-10 07:44:05 +07:00
[string][char[]](0x69,0x65,0x58) -> i e X
2020-01-09 22:59:25 +07:00
```
2020-01-09 22:53:56 +07:00
### Replace method
- 文字や文字列を置換する
2020-01-09 22:59:25 +07:00
```
'i e x'-replace ' ','' -> ieX
```
2020-01-09 22:53:56 +07:00
### %(foreach-object)
- foreach-objectの省略系で%を利用
2020-01-09 22:59:25 +07:00
```
((0x69, 0x65, 0x58) | %{([char] [int] $_)})-jOIN'' -> ieX
```
2020-01-09 22:53:56 +07:00
### Comment out
- コメントアウト
2020-01-09 22:59:25 +07:00
```
<#bobalice#>
```
2020-01-17 22:52:36 +07:00
**ref:**<br>
2020-01-23 22:01:35 +07:00
[Powershell Static Analysis & Emotet results](https://hatching.io/blog/powershell-analysis)<br>
2020-01-09 22:53:56 +07:00
2020-01-17 22:52:36 +07:00
## Living Off The Land(LOL)
- システムに備わっている信頼性の高いツールを悪用する
- LOLで利用される各種Binary(LOLBin), Script(LOLScript), Library(LOLLib)のドキュメント<br>
[LOLBAS](https://lolbas-project.github.io/)<br>[GTFOBins(UNIX ver)](https://gtfobins.github.io/)
- LOLBinsとしてのの条件
> Be a Microsoft-signed file, either native to the OS or downloaded from Microsoft.
- LOLBinsで可能なこと
2020-01-18 14:59:47 +07:00
- UAC Bypass,AppLocker Bypass,Dumping process memory,Credential theft,Log evasion/modification,Persistence,File operations,etc.
2020-01-17 22:52:36 +07:00
- よく利用されるLOLBins
2020-01-18 14:59:47 +07:00
- [Certutil.exe](https://lolbas-project.github.io/lolbas/Binaries/Certutil/)
2020-01-18 15:01:26 +07:00
- エンコードされたバイナリをCertutil.exeでダウンロード->ダウンロードしたバイナリをCertutil.exeでデコード->デコードしたバイナリを,[Forfiles.exe](https://lolbas-project.github.io/lolbas/Binaries/Forfiles/)で実行
2020-01-18 14:59:47 +07:00
- [eventvwr.exe](https://lolbas-project.github.io/lolbas/Binaries/Eventvwr/)
- [Msbuild.exe](https://lolbas-project.github.io/lolbas/Binaries/Msbuild/)
- [Mshta.exe](https://lolbas-project.github.io/lolbas/Binaries/Mshta/)
- [Odbcconf.exe](https://lolbas-project.github.io/lolbas/Binaries/Odbcconf/)
- [Regasm.exe](https://lolbas-project.github.io/lolbas/Binaries/Regasm/) / [Regsvcs.exe](https://lolbas-project.github.io/lolbas/Binaries/Regsvcs/)
- [Regsvr32.exe](https://lolbas-project.github.io/lolbas/Binaries/Regsvr32/)
- [Wmic.exe](https://lolbas-project.github.io/lolbas/Binaries/Wmic/)
- Powershell.exe
- [Bitsadmin.exe](https://lolbas-project.github.io/lolbas/Binaries/Bitsadmin/)
- Wingding.tff
- Disk Cleanup
- werfault.exe
2020-01-17 22:52:36 +07:00
### UAC bypass
- Windows Publisherによってデジタル署名されている且つセキュリティ保護されたフォルダに存在するプログラム(Trusted binary)はUACプロンプトを表示せずにそのプログラムまたはそのプログラムを経由して実行されるプログラムを管理者権限で実行させることができる
- マルウェアはUACなしで自身を管理者権限で実行させたりセキュリティソフトのホワイトリストに自身を追加することができるようになる
- プログラムのデジタル署名の確認はWindows Sysinternalsのsigcheckと呼ばれるプログラムで確認することができる<br>
**ref:**
- UAC Bypassについて<br>
[Bypass User Account Control, MITRE ATT&CK](https://attack.mitre.org/techniques/T1088/)<br>
- UAC Bypassのメソッドの紹介及びそれらを利用するためのツール<br>
[UACMe](https://github.com/hfiref0x/UACME)
- fodhelper.exeによるUAC Bypass[Trickbotによって利用されるとの情報あり](https://www.bleepingcomputer.com/news/security/trickbot-now-uses-a-windows-10-uac-bypass-to-evade-detection/)(2020-01-16)<br>
[First entry: Welcome and fileless UAC bypass](https://winscripting.blog/2017/05/12/first-entry-welcome-and-uac-bypass/)
2020-01-09 22:53:56 +07:00
## DGA
- ドメイン生成アルゴリズム<br>
- 数学的なアルゴリズムを利用して一定間隔ごとに異なる通信先ドメインを生成することにより,ドメイン名での検知を困難にする<br>
- 43ファミリのDGAに対してseedタイプDGAタイプエントロピーTLD等様々な観点から比較<br>
[A Comprehensive Measurement Study of Domain Generating Malware,USENIX2016](https://www.usenix.org/conference/usenixsecurity16/technical-sessions/presentation/plohmann)
2020-01-19 10:55:39 +07:00
## Fast Flux
- ドメインに対応するIPアドレスを短い期間で切り替えることにより悪意のあるサイト(マルウェア配布c2フィッシング)を維持させる手法
- IPアドレスにはボットネットが用いられることがある
- 切り替えは平均5分
**ref:**<br>
[Fast Flux networks: What are they and how do they work?](https://www.welivesecurity.com/2017/01/12/fast-flux-networks-work/)
2020-01-20 18:07:22 +07:00
2020-02-16 23:46:48 +07:00
## Packing
- 実行形式を保持したまま,実行ファイルを圧縮
- パッキング後のプログラムには展開ルーチン,圧縮されたオリジナルコードが含まれる
- オリジナルコードを静的解析するためにはアンパッキングが必要
- 特徴
- 特徴的なセクション名
- 可読性のある文字列が少ない
- インポートされているAPIが少ない(オリジナルコードの展開ルーチンに利用するAPI?)
- 展開ルーチンの流れ(簡易)
- オリジナルコードをデコード
- ローダによりオリジナルコードのIATを再構築
- OEPに制御を移しオリジナルコードを実行
- プログラムをパッキングするまでの流れ(簡易)
- PEヘッダから下記のパッキングに必要な各種情報(AddressOfEntryPoint,ImageBase,SectionTable(VirtualAddress,VirtualSize,PointerToRawData,SizeOfRawData),etc.)を取得
- コードセクションのエンコード(PointerToRawからSizeOFRawData分の領域まで)
- 展開ルーチンの追加
- コードセクションの使われていない後方領域(0パディングされた領域)を利用(FileAlignment,VirtualSize,SizeOfRawDataから算出)
- PEヘッダの修正
- 展開ルーチン追加後のVirtualSize
- 展開ルーチンの先頭を示すAddressOfEntryPoint
- コードセクションへの書き込み属性の付与
- 既知のパッカー
- UPX
- ASProtect
- Stolen Bytesを利用
- tELock
- Import Redirectionを利用
## Anti-Unpacking
### Stolen Bytes(Stolen Codes)
- 展開ルーチンのコードの中にオリジナルコードの先頭部分(OEP付近)をあらかじめ含めて実行させることで展開ルーチンによって展開させるオリジナルコードをその先頭部分から後ろのみにし本来のOEPの特定を難化させる(展開されたオリジナルコードの領域監視によるOEP特定の難化)
### Import Redirection
- IATの再構築を妨害
- IATにAPIのアドレスではなくAPIを呼び出すための関数をsetする
- 関数内
- レジスタにAPIのアドレスをsetしてjmpしてAPIを呼び出し
- スタックにAPIのアドレスをsetしてretでAPIを呼び出し
2020-02-23 00:53:15 +07:00
## Mutex
- 本来はプロセス間の同期や排他制御を行うことが目的に作成されるが,マルウェアでは1つのホストで2重で感染させるのを回避する目的で利用されることが多い。
- ロック状態で該当プロセスが終了すると,自動解放される
- Mutexは感染ホスト固有の情報を用いて作成される場合があるため同一マルウェアでもシステムごとに異なるという可能性を考慮する必要がある
- e.g.
- OpenMutex():Mutexの状態確認
- CreateMutex():Mutexの作成
- OpenMutex()で状態を確認→ロック状態の場合自プロセス終了またはロックしているプロセス終了。アンロック状態の場合Mutexの作成。
- ref:
- [How Malware Generates Mutex Names to Evade Detection](https://isc.sans.edu/forums/diary/How+Malware+Generates+Mutex+Names+to+Evade+Detection/19429/#comments)
2020-02-22 23:29:55 +07:00
## Poisoning CRT Library
- C/C++ランタイム(CRT)ライブラリに悪性コードを注入,特定のランタイムライブラリ関数の改ざん
- libcmt.libやmsvcrt.libの上書き不正なライブラリファイルの指定
2020-02-22 21:59:54 +07:00
- 改ざんされた事例があるランタイム関数
- __crtExitProcess():プロセスの終了。管理アプリケーションか否かのチェック
2020-02-22 23:29:55 +07:00
- __scrt_common_main_seh():cランタイムライブラリ_mainCRTStartupのEntryPoint
2020-02-22 21:59:54 +07:00
- _security_init_cookie():セキュリティチェックを行う関数。バッファオバーフローを防ぐ
2020-02-22 23:29:55 +07:00
- _initterm():関数インポートテーブルのエントリー呼び出し
2020-02-23 00:53:15 +07:00
- e.g.
2020-02-22 23:29:55 +07:00
- DllEntryPoint() -> __DllmainCRTStartup() -> _CRT_INIT() -> _initterm() -> __imp_initterm() -> malicious_code()
- コンパイル時点のレベルで改ざんされ,サプライチェーン攻撃として利用されることがある
2020-02-23 00:53:15 +07:00
- e.g. ShadowPad,CCLeaner,Operation ShadowHammer,etc.
2020-02-22 23:29:55 +07:00
- ref:
- [Analyzing C/C++ Runtime Library Code Tampering in Software Supply Chain Attacks](https://blog.trendmicro.com/trendlabs-security-intelligence/analyzing-c-c-runtime-library-code-tampering-in-software-supply-chain-attacks/)
2020-02-23 00:53:15 +07:00
- [Mutex List,Hexacorn,2015](http://hexacorn.com/examples/2015-04-05_easter_bunny_with_a_bag_full_of_events.txt)
2020-02-22 21:59:54 +07:00
2020-02-17 00:08:13 +07:00
# Persistence
## Registry
- 利用されるWin32API
- RegSetValue
- 利用されるレジストリ
2020-02-17 00:16:16 +07:00
```
- HKCU\Software\Microsoft\Windows\CurrentVersion\Run
- HKLM\Software\Microsoft\Windows\CurrentVersion\Run
- HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
- HKCU\Software\Microsoft\Windows\CurrentVersion\RunServices
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices
- HKCU\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
- HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
- HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
- HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\SharedTaskScheduler
```
2020-02-17 00:08:13 +07:00
# Shell Backdoor
- Web Shell等
- 様々なShell Backdoor(PHP/ASP)<br>
[Shell Backdoor List - PHP / ASP Shell Backdoor List](https://www.kitploit.com/2020/01/shell-backdoor-list-php-asp-shell.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+PentestTools+%28PenTest+Tools%29)
2020-01-30 21:56:59 +07:00
# rootkit
## LKM rootkit
2020-01-30 22:10:45 +07:00
- 動的にカーネルに組み込めるモジュールであるLKM(Loadable Kernel Module)を利用してsys_call_tableの特定のカーネル関数のアドレスを任意の関数のアドレスへと書き換えることで本来とは異なるカーネル関数であるrootkitのカーネル関数等が呼び出せるようになる(システムコールフック)
- sys_call_tableへのアクセスは特権モードが必要であるためLKMを利用される
2020-01-30 21:56:59 +07:00
- rootkitの関数内で本来呼び出されるはずの正規のカーネル関数をあえて呼び出すことで正規の処理を行っているように見せかけることができる
- /proc/modulesからの隠ぺいも可能
- LKMについて
- init_module関数...カーネルにロードする際に最初に実行される関数LKM rootkitではsys_calltableを書き換える処理を記載
- clean_module関数...カーネルからアンロードする際に実行される関数LKM rootkitではsys_call_tableを元に戻す処理を記載
- LKMのロード
```
insmod [lkm_name].ko
```
- LKMのアンロード
```
rmmod [lkm_name].ko
```
**ref:**<br>
- LKMのrootkitへの応用について<br>
[侵入者の不利な情報を隠すLKM rootkitの仕組み,2003](https://www.atmarkit.co.jp/fsecurity/rensai/rootkit03/rootkit02.html)<br>
2020-01-30 22:11:33 +07:00
- LKM rootkit(work on Linux kernels 2.6.32-38 and 4.4.0-22 )<br>
2020-01-30 21:56:59 +07:00
[Linux Rootkit](https://github.com/nurupo/rootkit)
2020-01-30 22:11:33 +07:00
- LKM rootkitその2(developed using linux kernel version 4.4.13)<br>
2020-01-30 22:10:45 +07:00
[rootkit-kernel-module](https://github.com/croemheld/lkm-rootkit)
2020-01-30 22:11:33 +07:00
- LKM rootkitその3(runs on kernel 2.6.x/3.x/4.x)<br>
2020-01-30 22:10:45 +07:00
[Reptile](https://github.com/f0rb1dd3n/Reptile)
2020-01-30 22:11:33 +07:00
- LKM rootkitその4(Tested on Linux kernel [4.19.62] & [4.15.0])<br>
2020-01-30 22:10:45 +07:00
[Sutekh](https://github.com/PinkP4nther/Sutekh)