aAura's desktopaurasec.top
我的文章GitHub
Aura Blog
aurasec.top
AuraHTB PhantomBundle
全部文章

HTB PhantomBundle

Sherlock Scenario

A targeted phishing campaign has been identified affecting S1rBank customers across the Middle East, with initial compromise achieved through social media vectors. The deployed malware establishes C2 communication, enabling threat actors to execute remote commands including fraudulent notifications, overlay attacks for credential harvesting, and sensitive data exfiltration. The combination of social engineering, persistent C2 access, and multi-vector financial fraud indicates a sophisticated threat actor explicitly targeting S1rBank's customer base.

Q1

What is the phone number that was used for phishing the victim?

拿到的是一个手机的镜像,先去看一下有哪些通信应用 /data 里面发现只有一个 WhatsAPP,去看一下数据库 WhatsAPP 的对话数据都存在 msgstore.db 中,提取出来看一下 里面的聊天记录只有一个 test,得去 media 解密 msgstore.db.crypt14 聊天记录备份数据库,根据网上现有的文章,数据库的加密密钥在 \data\data\com.WhatsApp\files\key 中。

#!/usr/bin/env python3

"""Decrypt a WhatsApp msgstore.db.crypt14 file with its 158-byte key file.

Dependency:
    python -m pip install pycryptodome
  
Example:
    python decrypt_crypt14.py key msgstore.db.crypt14 msgstore.db

"""

from __future__ import annotations
import argparse
import hashlib
import sqlite3
import sys
import zlib
from pathlib import Path
from Crypto.Cipher import AES

SQLITE_MAGIC = b"SQLite format 3\x00"
JAVA_KEY_FILE_SIZE = 158
AES_KEY_SIZE = 32
IV_OFFSET = 67
IV_SIZE = 16
TRAILER_PART_SIZE = 16

class DecryptionError(RuntimeError):
    """Raised when the input cannot be authenticated or decoded."""

def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(
        description="Decrypt a WhatsApp crypt14 backup into a SQLite database."
    )
    parser.add_argument("key", type=Path, help="158-byte WhatsApp key file")
    parser.add_argument("encrypted", type=Path, help="msgstore.db.crypt14")
    parser.add_argument("output", type=Path, help="output SQLite database")
    parser.add_argument(
        "--force", action="store_true", help="overwrite the output if it exists"
    )
    return parser.parse_args()

def extract_aes_key(key_file: bytes) -> bytes:
    if len(key_file) != JAVA_KEY_FILE_SIZE:
        raise DecryptionError(
            f"expected a {JAVA_KEY_FILE_SIZE}-byte crypt14 key file, "
            f"got {len(key_file)} bytes"
        )
    # The file is a Java-serialized byte array. Its final 32 bytes are the
    # AES-256 cipher key (equivalent to bytes 99:131 after deserialization).
    return key_file[-AES_KEY_SIZE:]

def decrypt_crypt14(key_path: Path, encrypted_path: Path) -> bytes:
    key_file = key_path.read_bytes()
    encrypted = encrypted_path.read_bytes()
    aes_key = extract_aes_key(key_file)

    if len(encrypted) < 2 + IV_OFFSET + IV_SIZE + 2 * TRAILER_PART_SIZE:
        raise DecryptionError("encrypted file is too short to be a crypt14 backup")

    # crypt14 starts with a one-byte protobuf length and a one-byte backup
    # type, followed by that protobuf header. The ciphertext starts after it.
    protobuf_size = encrypted[0]
    data_offset = 2 + protobuf_size
    iv = encrypted[IV_OFFSET : IV_OFFSET + IV_SIZE]

    if data_offset >= len(encrypted) - TRAILER_PART_SIZE:
        raise DecryptionError(f"invalid ciphertext offset: {data_offset}")

    # A normal single-file backup ends in:
    #   [16-byte GCM tag][16-byte MD5 checksum]
    # The checksum covers every byte preceding the checksum itself.
    expected_md5 = encrypted[-TRAILER_PART_SIZE:]
    actual_md5 = hashlib.md5(encrypted[:-TRAILER_PART_SIZE]).digest()
  
    if actual_md5 == expected_md5:
        ciphertext = encrypted[data_offset : -2 * TRAILER_PART_SIZE]
        auth_tag = encrypted[-2 * TRAILER_PART_SIZE : -TRAILER_PART_SIZE]
        backup_layout = "single-file"
    else:
        # Multi-file crypt14 members omit the MD5 checksum; their last 16
        # bytes are the GCM authentication tag.
        ciphertext = encrypted[data_offset:-TRAILER_PART_SIZE]
        auth_tag = encrypted[-TRAILER_PART_SIZE:]
        backup_layout = "multi-file member"
    try:
        compressed = AES.new(aes_key, AES.MODE_GCM, nonce=iv).decrypt_and_verify(
            ciphertext, auth_tag
        )
    except ValueError as exc:
        raise DecryptionError(
            "GCM authentication failed; the key does not match or the backup is damaged"
        ) from exc
    try:
        database = zlib.decompress(compressed)
    except zlib.error as exc:
        raise DecryptionError(f"decrypted payload is not valid zlib data: {exc}") from exc
    if not database.startswith(SQLITE_MAGIC):
        raise DecryptionError("decrypted payload does not have a SQLite header")
    print(f"crypt14 layout: {backup_layout}")
    print(f"protobuf size: {protobuf_size} bytes")
    print(f"ciphertext offset: {data_offset}")
    return database
  

def verify_sqlite(path: Path) -> str:
    connection = sqlite3.connect(f"file:{path}?mode=ro", uri=True)
    try:
        return str(connection.execute("PRAGMA quick_check").fetchone()[0])
    finally:
        connection.close()

def main() -> int:
    args = parse_args()
    if args.output.exists() and not args.force:
        print(
            f"error: output already exists: {args.output} (use --force to overwrite)",
            file=sys.stderr,
        )
        return 2
    try:
        database = decrypt_crypt14(args.key, args.encrypted)
        args.output.write_bytes(database)
        result = verify_sqlite(args.output)
        if result != "ok":
            raise DecryptionError(f"SQLite quick_check returned: {result}")
    except (OSError, DecryptionError, sqlite3.Error) as exc:
        print(f"error: {exc}", file=sys.stderr)
        return 1

    print(f"wrote: {args.output} ({len(database)} bytes)")
    print(f"SHA-256: {hashlib.sha256(database).hexdigest()}")
    print("SQLite quick_check: ok")
    return 0
  
  

if __name__ == "__main__":
    raise SystemExit(main())

在 message 表发现钓鱼短信,诱导下载一个 SubHub Pro,并伪装成 play-google.hrzn.run 需要定位一下是谁发的这个消息,chat_row_id 是 2 chat 表中,这个 chat_row_id 为 2 的对应的是 jid_row_id 为 5 发现这是一个匿名的用户,去 jid_map 表中将其还原 最终定位到是这个 jid 为 6 的用户,手机号就是 +201552869660

201552869660

Q2

When did the victim last visited the phishing site?

钓鱼页面就是上一问找到的那个 https://play-google.hrzn.run,用户有一个 Chrome 浏览器,可以去 Chrome 浏览器取证一下,看看历史记录 题目问的是最后一次访问时间,那就是这个 last_visit_time 的 WebKit 时间戳

2026-02-21 03:35:41

Q3

What is the last line of the message content used to lure the victim into downloading the malicious application?

第一问已经找到了,就是这条消息。

Spots are extremely limited – act fast before they're gone! – act fast before they're

Q4

The threat actor hosted the malicious application on a spoofed Google Play page. What is the account name of the last reviewer displayed on that page?

需要去找一下这个页面的缓存在哪,到这个 Offline Pages 里面看一下 去定位到这个 mhtml,如何把他提取出来。 最后一个评论的用户名是 Lara Croft

Lara Croft

Q5

What is the URL used by the downloader to download the second-stage malware?

这个问的是第二阶段的载荷,先去把刚才那个 apk 提取出来,然后分析一下。 主要是在这里,访问了分发恶意文件的 URL,然后下载文件自动安装。 尝试去把这个 URL 解密出来,逻辑很简单,就是先翻转字符串,然后 Base64 解码,最后再逐字节异或 126。

https://github.com/0xS1rx58/updater/releases/download/updater/icon.png

Q6

What is the package name of the application executed by the downloader?

下载不到这个了,手机里面也没找到,继续逆向 发现攻击者将下载的 icon.png 安装后,伪造成了 com.andorid.systemui 正常来说应该是叫 android,这个拼成了 andorid,不仔细看看不出来

com.andorid.systemui

Q7

The malware uses a service to run in the background, silently collecting and exfiltrating data. What is the name of the class/service used to achieve this?

去给他提取出来,继续逆向看看

C1AccessibilityService

Q8

The second-stage malware runs a foreground service to maintain persistence. What is the title of the notification displayed by this service?

System Update

Q9

What is the full endpoint URL used by the second-stage malware for Command and Control (C&C) communication?

http://107.189.13.21:8080/api

Q10

What command in the second-stage malware is responsible for capturing a screenshot of the victim's device, and which component does it use to achieve this?

去看一下 g 类 这里调用了 ScreenshotCaptureActivity 组件进行截图,回去对应到的命令是 71

71, ScreenshotCaptureActivity

Q11

The second-stage malware generates a dynamic encryption key for C2 communication. Provide the encryption key.

key 从流量包里面去找,在一开始建立连接的时候会分发一个 key

3BJCjd8ZFBCK/umyWUD9NuWOJE34Uq/p6Lb2kumv37k=

Q12

The threat actor delivered a fake bank transaction notification to lure the victim into entering their credentials. What was the fake urgent notification that caused the victim to panic, leading to credential harvesting?

需要具体看看攻击者执行了哪些操作,需要解密流量,拿到密钥后逆向一下加密算法 加密算法是 AES-CTR,密钥就是刚才那个,IV 是密文的最后 16 个字节

import base64
from Crypto.Cipher import AES
from Crypto.Util import Counter

key_b64 = "3BJCjd8ZFBCK/umyWUD9NuWOJE34Uq/p6Lb2kumv37k="
response_b64 = ""

key = base64.b64decode(key_b64.strip())
encrypted = base64.b64decode(response_b64.strip())
iv = encrypted[:16]
ciphertext = encrypted[16:]

counter = Counter.new(
    128,
    initial_value=int.from_bytes(iv, "big")
)

plaintext = AES.new(
    key,
    AES.MODE_CTR,
    counter=counter
).decrypt(ciphertext)
  
print(plaintext.decode("utf-8"))

Unauthorized transfer attempt: USD 2,000 from your account.

Q13

Identify the credentials that the threat actor was able to harvest.

Ali209714:Ali_3691Pass5

Q14

What is the slogan text of the deceptive banking login portal presented to the user by the malware to steal credentials?

结合之前的分析,命令 74 是启动假登录界面窃取登陆凭证,看一下 apk 里面具体的逻辑是什么 关键是 setContentView(R.layout.activity_login); 这里,直接去定位资源

Next Generation Banking

Q15

What is the MITRE ID of the subtechnique used to harvest credentials?

https://attack.mitre.org/techniques/T1417/002/ 结合上述场景,攻击者伪造一个登录界面,然后让用户输入凭证,再回传,符合 T1417.002 的描述。

T1417.002

全文完

中

搜索文章

输入关键词搜索文章。