
## この記事でわかること

- dnstwist（OSS）の基本
- インストールと基本コマンド
- 結果の絞り込み・自動化
- ドメイン番人ツールとの使い分け

## dnstwist とは

[dnstwist](https://github.com/elceef/dnstwist) は **MIT ライセンスの OSS**。Marcin Ulikowski 氏が開発し、Python で実装されている類似ドメイン列挙ツール。**typosquat 検出のデファクトスタンダード**として研究機関・セキュリティベンダーで広く使われています。

特徴:
- 11 パターンの類似ドメイン生成
- WHOIS / DNS / HTTP / SSL の自動取得
- IDN（Punycode）対応
- JSON / CSV / XLSX 出力
- 完全無料

## インストール

### macOS / Linux

```bash
pip install dnstwist
```

または Homebrew:
```bash
brew install dnstwist
```

### Docker（推奨）

```bash
docker pull elceef/dnstwist
docker run -it elceef/dnstwist example.com
```

依存関係（Python ライブラリ）の差で環境構築に手間取る場合は Docker が安全。

## 基本コマンド

![dnstwist 基本コマンド](/blog/dnstwist-tsukaikata/basic-commands.svg)

### 最小構成

```bash
dnstwist example.com
```

11 パターンの候補を生成し、登録済みドメインを一覧表示。所要 1〜3 分。

### よく使うオプション

```bash
# DNS レコード解決を含めて確認
dnstwist --registered example.com

# JSON 出力（後処理しやすい）
dnstwist --format json example.com > result.json

# MX レコードまでチェック
dnstwist --mxcheck --registered example.com

# Web スクリーンショット取得（要 Playwright）
dnstwist --phash --screenshots /tmp/shots example.com
```

### TLD バリエーションも含める

```bash
dnstwist --tld dictionaries/common_tlds.dict example.com
```

`dictionaries/` 内の TLD 辞書を使って 200+ TLD を試行。

## 結果の絞り込み

dnstwist の出力は数百〜数千行になりがちなので、絞り込みが必要:

```bash
# 登録済みかつ A レコードあり（実害可能性高）
dnstwist --registered --format json example.com \
  | jq '.[] | select(.dns_a)' > active.json

# MX 設定ありに絞る（フィッシング能力あり）
jq '.[] | select(.dns_mx)' active.json
```

## 自動化の組み込み例

### cron で月次棚卸し

```bash
#!/bin/bash
# /etc/cron.monthly/dnstwist-audit.sh
DOMAIN="example.co.jp"
OUT="/var/log/dnstwist/$(date +%Y%m).json"
docker run --rm elceef/dnstwist \
  --registered --format json $DOMAIN > $OUT
mail -s "Monthly typosquat audit" admin@example.co.jp < $OUT
```

### GitHub Actions ワークフロー

```yaml
name: Monthly typosquat audit
on:
  schedule:
    - cron: "0 0 1 * *"
jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - run: |
          docker run --rm elceef/dnstwist \
            --registered --format json example.co.jp > result.json
      - uses: actions/upload-artifact@v4
        with:
          name: typosquat-audit
          path: result.json
```

## dnstwist とドメイン番人ツールの使い分け

![dnstwist vs ドメイン番人](/blog/dnstwist-tsukaikata/comparison.svg)

| 用途 | dnstwist | ドメイン番人 |
|---|---|---|
| OSS / 自社環境で動かしたい | ✅ | ❌ |
| 出力を細かく加工したい | ✅ | △ |
| 即時に Web で確認したい | ❌ | ✅ |
| 日本語 UI で結果共有したい | ❌ | ✅ |
| リスク 3 段階の自動分類 | △（手動分類） | ✅ |
| 月次自動化 | ✅ | ❌ |

**おすすめ運用**:
- 普段は **ドメイン番人 [類似ドメイン棚卸し](/typosquat/check)** で半年に 1 回スポット
- 大規模ブランド管理 / 月次自動化したい場合は **dnstwist** を CI に組み込む

両方とも MIT ライセンス互換のロジックを使っているので **検出結果は概ね一致**します。

## まずは現状を把握しましょう

Web ブラウザだけで使える [類似ドメイン棚卸し 単発チェック](/typosquat/check) で 30 秒で類似ドメインを網羅できます。

棚卸しの結果精査と DMCA / UDRP テンプレ提供は [類似ドメイン棚卸し＋ブランド保護診断](/contact)（5 万円〜）でご相談ください。

関連記事:
- [Typosquatting とは](/blog/typosquatting-toha)
- [偽ドメインを検出する方法 5 選](/blog/nise-domain-kenshutsu)
- [ブランドドメイン棚卸しの実践 5 ステップ](/blog/brand-domain-junkin-bunseki)

総合点検は [無料のドメイン診断](/diagnose) を、SSL 単独は [SSL 単発チェック](/ssl/check) をご利用ください。
