# THOR Scanner 101

**THOR Scanner** có nhiều tùy chọn khi quét, tùy trường hợp mà sử dụng cho phù hợp. Khi gặp các máy chủ có dung lượng disk lớn và chứa nhiều dữ liệu, nếu ta quét ở chế độ mặc định có thể sẽ tốn rất nhiều thời gian. Vì vậy cần lựa chọn các option của **THOR** sao cho phù hợp:

Theo mặc định trong cấu hình của **THOR** như sau: `.\config\thor.yml`

*   `max_runtime: 168` ⇒ Dừng quét THOR sau 7 ngày nếu nó vẫn chưa quét xong
    
*   `min: 40` ⇒ THOR đánh điểm số cho mỗi file hoặc mỗi artifact mà nó phát hiện. **40** điểm là số điểm tối thiểu sẽ đưa vào Report
    
*   `max_file_size: 12000000` ⇒ Kích thước tệp tối đa có thể quét: **~12MB**
    
*   `max_file_size_intense: 30000000` ⇒ Ở chế độ: `--fsonly, --intense` THOR có thể quét tệp lớn hơn `max_file_size`, cấu hình này chỉ định kích thước tối đa của tệp khi quét chế độ này.
    
*   `cpulimit: 95` ⇒ Không cho THOR quét vượt quá **95%** CPU
    
*   `minmem: 50` ⇒ Dung lượng bộ nhớ trống tối thiểu để THOR có thể chạy: **50MB**
    
*   `truncate: 2048` ⇒ Giới hạn số ký tự đầu ra của THOR, không vượt quá độ dài là: **2048**
    

Mặc định phiên bản **THOR-Lite** (free) chỉ có các Module sau: `Autoruns, ProcessCheck, Filesystem Checks`

# 1\. Malware Files Scanner

## 1.1. Quét thư mục và mã hóa Report

Sử dụng trong trường hợp quét `malware`, `webshell`, `các tệp tin khả nghi` trên hệ thống hoặc trong một thư mục cụ thể:

```powershell
$ .\thor-lite.exe --fsonly --path "path\to\dir\" --json --encrypt --pubkey ".\thor-lite-rsa.pem" --silent
```

Hoặc với `CMD.EXE`:

```plaintext
$ thor-lite.exe --fsonly --path "path\to\dir\" --json --encrypt --pubkey "thor-lite-rsa.pem" --silent
```

C**ác tham số:**

*   `--fsonly`: Chỉ quét tệp tin hệ thống. Tham số: `--path "path\to\dir\"` sẽ chỉ định thư mục được quét, nếu không có tham số này thì THOR sẽ quét toàn bộ các phân vùng, sẽ tốn nhiều thơn gian hơn.
    
*   `--path`: Chỉ định quét một thư mục hoặc một phân vùng
    
*   `--json`: Ghi Report dưới dạng `JSON`. Tên Report được Gen tự động. Sử dụng tham số: `--jsonfile "example.json"` để chỉ định tên tệp Report
    
*   `--encrypt`: Mã hóa Report bằng thuật toán RSA. Theo mặc định sử dụng Public key được hardcode. Nếu muốn chỉ định Public key thì dùng thêm tham số: `--pubkey ".\thor-lite-rsa.pem"`
    
*   `--silent`: Không in bất kỳ thông tin, logs gì cả trong quá trình THOR quét ra console.
    

Theo mặc định thì **THOR** xuất Report gồm các file: `*.csv` (chứa md5, filepath, score) của các tệp bị phát hiện là malware, `*.htm` (dạng htm/html, có thể mở bằng trình duyệt), `*.txt` (dạng plaintext, quan trọng khi muốn tổng hợp tất cả các report lại thành một file report dạng HTML sau này). Và khi thêm tham số `--json` hoặc `--jsonfile` sẽ có thêm tệp report dạng `*.json`.

## 1.2. Giải mã các Report

Giải mã các tệp report của **THOR** đã quét trước đó nếu dùng tùy chọn mã hóa tệp tin:

```powershell
$ .\thor-lite-util.exe decrypt --privkey "path\to\thor-rsa-private.pem" .\DESKTOP-VQP1V6E_files_md5s.csv .\DESKTOP-VQP1V6E_thor_2021-04-28_1548.htm .\DESKTOP-VQP1V6E_thor_2021-04-28_1548.txt .\DESKTOP-VQP1V6E_thor_2021-04-28_1548.json

Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file '.\DESKTOP-VQP1V6E_files_md5s.csv' ...
Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file '.\DESKTOP-VQP1V6E_thor_2021-04-28_1548.htm' ...
Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file '.\DESKTOP-VQP1V6E_thor_2021-04-28_1548.txt' ...
Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file '.\DESKTOP-VQP1V6E_thor_2021-04-28_1548.json' ...
Apr 28 08:51:18 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
```

Sử dụng `Powershell` để tự động hóa với số lượng lớn các report:

```powershell
$ cd "path\to\report\dir\"
$ $files = (Get-ChildItem).Name
$ $thor_cmd = "path\to\thor-lite-util.exe decrypt --privkey path\to\key.pri "
$ foreach($item in $files) { Invoke-Expression -Command "$thor_cmd $item" }
```

Hoặc với `CMD.EXE`:

```plaintext
$ thor-lite-util.exe decrypt --privkey "path\to\thor-rsa-private.pem" DESKTOP-VQP1V6E_files_md5s.csv DESKTOP-VQP1V6E_thor_2021-04-28_1604.htm DESKTOP-VQP1V6E_thor_2021-04-28_1604.json DESKTOP-VQP1V6E_thor_2021-04-28_1604.txt

Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file 'DESKTOP-VQP1V6E_files_md5s.csv' ...
Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file 'DESKTOP-VQP1V6E_thor_2021-04-28_1604.htm' ...
Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file 'DESKTOP-VQP1V6E_thor_2021-04-28_1604.json' ...
Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Decrypting file 'DESKTOP-VQP1V6E_thor_2021-04-28_1604.txt' ...
Apr 28 09:06:38 desktop-vqp1v6e THOR_LITE_UTIL: Info: Successfully encrypted
```

Hoặc trường hợp các report nằm ở các thư mục riêng lẻ

```powershell
$ $files = Get-ChildItem -Path "path\to\directory" -Attributes !Directory -Recurse | Select-Object -ExpandProperty FullName
$ $thor_cmd = "path\to\thor-lite-util.exe decrypt --privkey path\to\key.pri "
$ foreach($item in $files) { Invoke-Expression -Command "$thor_cmd $item" }
```

## 1.3. Gộp các Report

Kết quả scan của nhiều máy có thể gộp chung lại thành một report dạng HTML. Mỗi máy sẽ có các report dạng `*.txt`, cần thu thập các file này lại và đặt cùng một thư mục. Thực hiện lệnh sau:

```powershell
$ thor-lite-util.exe report --logdir path\to\report-txt\

Jan  5 09:57:36 desktop-h4sv2ln THOR_LITE_UTIL: Info: [!] filter file is empty or no filter file defined
Jan  5 09:57:36 desktop-h4sv2ln THOR_LITE_UTIL: Info: Counts: 0 Alerts, 10 Warnings, 88 Notices, 296 Infos, 0 Errors
Jan  5 09:57:37 desktop-h4sv2ln THOR_LITE_UTIL: Info: Counts: 0 Alerts, 13 Warnings, 47 Notices, 686 Infos, 0 Errors
Jan  5 09:57:37 desktop-h4sv2ln THOR_LITE_UTIL: Info: > 2 log files processed
Jan  5 09:57:37 desktop-h4sv2ln THOR_LITE_UTIL: Info: [+] Report generated as 'report.htm'
```

# 2\. Process Memory Scanner

Đôi khi nếu chỉ quét tệp tin thì sẽ không thể phát hiện được Malware, vì chúng có thể sử dụng rất nhiều kỹ thuật: `obfuscate`, `packing`,.. để bypass các hệ thống rà quét dựa trên signature. Trong vùng nhớ của một tiến trình độc hại đang hoạt động, rất có thể chứa các `strings`, `bytes` dữ liệu,.. Đây là các signature mà **THOR** có thể phát hiện (tất nhiên phải có Rules phát hiện). Lưu ý là THOR mặc định quét các tiến trình với kích thước trên Mem tối đa là `524288000 bytes = 524MB`.

## 2.1. **Chỉ định quét một Process:**

Phiên bản **THOR-Lite** sẽ mặc định enable các module như `Autoruns` và `FileSystem`, Cần disable các module này khi chỉ quét `Process`. Tham số `--process 2332,7888` chỉ ra ta đang quét các tiến trình có `PID = 2332 và 7888`. Lưu ý là nó chỉ quét một tiến trình đc chỉ định `PID`, nó không quét các tiến trình con và giả sử các tiến trình đều là cùng 1 tệp executable thì THOR sẽ chỉ Report 1 Process.

```powershell
$ thor-lite.exe --process 2332,7888 --noautoruns --nofilesystem
```

## 2.2. Quét kiểm tra các Process với C2 IOCs có sẵn:

Tùy chọn này: `--c2-in-memory` quét tất cả các tiến trình với các **IOCs** có sẵn trong: `.\signatures\iocs\`. Theo mặc định thì **THOR-Lite** bật module `ProcessCheck` và nó cũng đã có luôn tùy chọn này rồi.

```powershell
$ thor-lite.exe --c2-in-memory --noautoruns --nofilesystem
```

## 2.3. Quét Offline một tệp Process Dump:

Tùy chọn này **THOR-Lite** không hỗ trợ, phải có License của bản “**THOR xịn!**” 🤤 Để thu được các tệp dump này có thể dùng: Task Manager, Process Explorer, ProcDump,.v.v...

```powershell
$ thor-lite.exe --image_file "path\to\example.dmp"
```

# 3\. Output Options

Đầu ra của **THOR** có thể được tùy chỉnh để thuận tiện làm INPUT cho các hệ thống quản lý tập chung khác. Một số option hữu ích:

*   `--ascii`: Không in các ký tự non-ASCII vào Report
    
*   `--cmdkeyval`: Show kết quả dạng `JSON` ở CMD/Console
    
*   `--csvfile "PC-01.csv"`: Chỉ định tên Report dạng `CSV`. Mặc định `":hostname:_files_md5s.csv"`
    
*   `--htmlfile "PC-01.html"`: Chỉ định tên Report dạng `HTM`. Mặc định `":hostname:_thor_2021-04-28_1405.html"`
    
*   `l, --logfile "PC-01.txt"`: Chỉ định tên Report dạng `TXT`. Mặc định `":hostname:_thor_2021-04-28_1405.txt"`
    
*   `--encrypt`: Mã hóa RSA Report, sử dụng kết hợp với `--pubkey ".\thor-rsa-public.pem"`
    
*   `--json`: Mặc định không xuất Report dạng `JSON`, nếu dùng tham số này sẽ xuất JSON report theo tên mặc định, sử dụng `--jsonfile "PC-01.json"` để chỉ định tên file Report
    
*   `--nocsv, --nohtml, --nolog`: Không xuất Report theo các định dạng tương ứng
