Checklist

  • Đọc docs
  • Thiết lập môi trường
  • Recon
  • Dùng API monitor để theo dõi các tham số truyền vào/giá trị trả về của các hàm mã hóa/giải mã.
    • Chạy dumpbin.exe để kiểm tra xem file binary có dùng Windows API để mã hóa hay không.
    • Dùng Frida để hook vào các API call.
  • Dùng debugger để intercept giá trị của các tham số bị mã hóa khi được in ra file log.
  • Phân tích file memory dump với binwalk, bulk_extractorvolatility.
  • JWT token khi verify link (chẳng hạn khi mở từ Teams): thử dùng các kỹ thuật trong JWT AttacksJWT Algorithm Confusion Attacks.

Architecture

C4 Architecture Diagram - MetaDefender Fusion - Confluence

Sử dụng kiến trúc microservices. Công nghệ: Java/Spring Boot, Golang, MongoDB, Angular, RabbitMQ, Redis. Các component được đóng gói vào các Docker container.

Xác thực & Phân quyền: Sử dụng JWT token.

Được tích hợp với MD Kiosk, MD Drive, MD Endpoint và SIEM.

File Storage

File Storage trong môi trường on-premises là SeaweedFS: File Storage For On-Premise Environment - GEARS - Confluence.

SeaweedFS là một hệ thống lưu trữ tập tin phân tán mã nguồn mở. SeaweedFS có một master server quản lý các volume server phân tác. Các volume server sẽ quản lý các tập tin và metadata của tập tin.

Cite

By default, the SeaweedFS doesn’t authenticate. To enable credential-based access we can choose status or dynamic configuration:

  • Dynamic Configuration: setup auth with s3.configure in weed shell
  • Static Configuration: create a config.json file similar to the example below, and specify it via weed s3 -config=config.json

Flows

Console

Luồng tương tác của Admin với Fusion thông qua console:

Phân tích:

  • CRUD của Devices/Groups: qua RabbitMQ → Funsion Console Event Handler → cập nhật vào Fusion Console DB.
  • Chuyển tiếp API:
    • Gán/Xóa Devices/Kiosk → PMP Inventory API.
    • Gán Group/Xóa MD Drive → MDD Inventory API.
  • Tất cả thao tác đều qua Redis Cache.

Kiosk & MD Endpoint

Luồng tương tác của Kiosk và MD Endpoint với Fusion:

Phân tích:

  • Tương tác:
    • Kiosk → PMP Inventory API.
    • MD Endpoint → Device API.
  • Xử lý qua RabbitMQ:
    • Báo cáo của Kiosk và toàn bộ thao tác của MD Endpoint → PMP Consumer → cập nhật vào PMP Threat DB.
    • CRUD của Kiosk → Fusion Console Event Handler → cập nhật vào Fusion Console DB.
  • Một số CRUD của Kiosk, Policy, Group → PMP Inventory API → PMP Device DB.
  • Kiểm tra RegCode: PMP Inventory API → Fusion Account API → xử lý trên IT Access DB.

MD Drive

Luồng tương tác của MD Drive với Fusion:

Phân tích:

  • Đầu vào là MDD Inventory API.
  • Xử lý RegCode thông qua Fusion Account API tương tự luồng trên.
  • Từ MDD Inventory API có 4 luồng:
    1. Metadata report đến MDD Processor Handler → cập nhật vào MDD Processor DB.
    2. Upload report đến S3.
    3. Đồng bộ với Fusion thông qua RabbitMQ và Fusion Console Event Handler.
    4. CRUD của Group và Policy của MDD → MDD Device DB.

Authentication & Authorization

Authentication and Authorization Architecture - GEARS - Confluence

Kiến trúc xác thực và phân quyền cũ, tích hợp trong kiến trúc monolithic:

Kiến trúc xác thực và phân quyền mới, tích hợp trong kiến trúc microservices:

Cite

A reverse proxy is integrated into the authorization service to efficiently route incoming requests based on predefined rules.

  • All requests to /gears are forwarded directly to the IT Access service
  • All requests that have the Authorization Bearer header are forwarded directly to the dedicated service based on their destination paths.
  • Otherwise, the requests’ validity and authorized permissions will be checked by the auth service.

Việc tích hợp với MD IT Access là để user có thể sử dụng tài khoản của MD IT Access để đăng nhập vào MD Fusion và ngược lại.

Sau khi xác thực thì sẽ chuyển tiếp request đến Role Management module (xem thêm Role Management and Enforcement).

Các role giữa IT Access và Fusion sẽ được ánh xạ và đồng bộ với nhau:

Tức là, bất kỳ thay đổi nào xảy ra trong một hệ thống cũng sẽ được cập nhật sang hệ thống còn lại.

Trong trường hợp service cần gửi request đến IT Access service thì sẽ đi qua một proxy để chuyển các authorization header thành một JWT mà IT Access có thể xác thực.

Cite

One potential drawback of the proposed mechanism is the risk of data inconsistency between the roles stored in the MD IT Access and the new MD Fusion authorization service.

Role Management and Enforcement

Quản lý role và ép thỏa sử dụng Casbin. Một cách đơn giản hóa, Casbin sử dụng enforcer để kiểm tra quyền truy cập dựa trên subject, object và action. Ví dụ cho ngôn ngữ Java:

  1. Khởi tạo enforcer sử dụng model và policy:

    Enforcer enforcer = new Enforcer("path/to/model.conf", "path/to/policy.csv");

    Model có thể có nhiều dạng chẳng hạn như ACL, RBAC, RESTful (KeyMatch), etc. Minh họa cho một file model.conf sử dụng cơ chế ACL:

    [request_definition]
    r = sub, obj, act
     
    [policy_definition]
    p = sub, obj, act
     
    [policy_effect]
    e = some(where (p.eft == allow))
     
    [matchers]
    m = r.sub == p.sub && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)

    File policy:

    p, alice, data1, read
    p, bob, data2, write
  2. Kiểm tra quyền truy cập:

    String sub = "alice"; // the user that wants to access a resource.
    String obj = "data1"; // the resource that is going to be accessed.
    String act = "read"; // the operation that the user performs on the resource.
     
    if (enforcer.enforce(sub, obj, act) == true) {
        // permit alice to read data1
    } else {
        // deny the request, show an error
    }
  3. Lấy danh sách role:

    Roles roles = enforcer.getRoles("alice");

Recon

Scan with RustScan:

Open 18.239.255.125:80
Open 18.239.255.125:443

Decompile Installer Files

Extract .rpm:

rpm2cpio opswatclient.rpm | cpio -idmv

Extract .deb:

ar vx opswatclient.deb

Use lessmsi to extract .msi.

Static Analysis

Dùng dumpbin.exe và API monitor, biết được rằng file GearsAgentService.exe dùng cả Windows API và thư viện OpenSSL (gồm libcrypto-1_1.dlllibssl-1_1.dll) để mã hóa.

Trong file memory dump của GearsAgentService.exe, tìm thấy một vài RSA private key:

...
9697533       0x93F8FD        PEM RSA private key
9699221       0x93FF95        PEM RSA private key
9700117       0x940315        PEM RSA private key
9701013       0x940695        PEM RSA private key
...

Hooking

Frida

Script hook vào các hàm của OpenSSL sử dụng Frida: jtravesi/Frida-OpenSSL-Hooks. Câu lệnh:

frida -p 23048 -l .\openssql_hook.js

Deluder

Có thể dùng tool Deluder (bản chất vẫn là dùng Frida):

deluder attach -c .\deluder-config.json -s openssl 8864

Với:

  • -c chỉ định file cấu hình.
  • -s chỉ định script Frida sẽ sử dụng.

Với file config có thể được export bằng lệnh sau:

deluder config > config.json

PETEP

Có thể tích hợp Deluder với PETEP để trực quan hóa các gói tin. Cấu hình của PETEP:

Có thể cấu hình Frida với field petepPort9998 như sau để tích hợp với PETEP:

{
	"debug": false,
    "ignoreChildProcesses": true,
    "interceptors": [
        {
            "type": "petep",
            "config": {
                "petepHost": "127.0.0.1",
                "petepPort": 9998,
                "autoCloseConnections": false,
                "multipleConnections": true
            }
        }
    ],
    "scripts": [
		{
			"type": "openssl",
			"config": {
				"libs": [
					"libssl",
					"openssl",
					"ssleay",
					"libeay",
					"libcrypto"
				],
				"SSL_write": true,
				"SSL_write_ex": true,
				"SSL_read": true,
				"SSL_read_ex": true,
				"SSL_shutdown": true
			}
		}
    ]
}

Fritzl

Ngoài Deluder, còn có tool Fritzl. Về bản chất, tool này là tập các Frida script được dùng để hook vào OpenSSL.

Trước tiên, ta cần biên dịch file index.js có nội dung như sau:

/*
This file glues it all together.
*/
"use strict";
 
var Fritzl = require('./lib/fritzl');
var Utils = require('./lib/utils');
 
function hd(target, options) {
  console.log(Utils.hexdump(target, options));
}
 
function ts(address, max) {
  console.log(Utils.telescope(ptr(address), max));
}
 
Fritzl.disablePinning();
Fritzl.hookDecryption();
Fritzl.hookEncryption();
Fritzl.hookHMAC();
Fritzl.hookKeygen();
Fritzl.hookGoEncryption();
 
Fritzl.hd = hd;
Fritzl.ts = ts;
Fritzl.Utils = Utils;
 
module.exports = Fritzl;
 
global.Fritzl = Fritzl;
global.hd = Fritzl.hd;
global.ts = Fritzl.ts;

Câu lệnh biên dịch:

.\node_modules\.bin\frida-compile index.js -o fritzl.js

Chạy với Frida:

frida -p [pid] -l fritzl.js

Title Unavailable | Site Unreachable

Commands & Scripts

Lấy danh sách các tiến trình của Gears:

Get-Process | Where-Object { $_.Name -like "*Gears*" } | Select-Object Name, Id, SessionId

Sửa các registry chứa hardware ID (HWID) mỗi giây một lần:

# Registry keys to modify
$RegistryBasePath = "HKLM:\SOFTWARE\Wow6432Node\OPSWAT\Gears Client\Config"
 
# Values to set
$KeysToModify = @{
    HWID      = "c4585961e9dd5e79adec0c3ca79fabdb"
    LinkedID  = "c4585961e9dd5e79adec0c3ca79fabdb"
    uuid      = "c4585961e9dd5e79adec0c3ca79fabdb"
}
 
while ($true) {
    # Ensure the base path exists
    if (-not (Test-Path $RegistryBasePath)) {
        Write-Error "Registry base path '$RegistryBasePath' does not exist."
        exit 1
    }
 
    # Loop through each key-value pair and modify the registry
    foreach ($Key in $KeysToModify.Keys) {
        try {
            # Set the registry value
            Set-ItemProperty -Path $RegistryBasePath -Name $Key -Value $KeysToModify[$Key] -ErrorAction Stop
            Write-Output "$(Get-Date): Successfully modified '$Key' to '$($KeysToModify[$Key])'."
        } catch {
            Write-Error "$(Get-Date): Failed to modify '$Key'. $_"
        }
    }
 
    # Wait for 1 second
    Start-Sleep -Seconds 1
}

Để chạy script với Task Scheduler, sử dụng powershell.exe như sau:

powershell.exe "C:\path\to\script.ps1"

DiffChecker for Requests of Gears

Resources