mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
34 lines
1.3 KiB
Markdown
34 lines
1.3 KiB
Markdown
# DNSCat pcap 分析
|
||
|
||
{{#include ../../../banners/hacktricks-training.md}}
|
||
|
||
DNSCatによって**流出したデータ**を含むpcapがある場合(暗号化を使用せずに)、流出したコンテンツを見つけることができます。
|
||
|
||
**最初の9バイト**は実際のデータではなく、**C\&C通信**に関連していることを知っておくだけで十分です。
|
||
```python
|
||
from scapy.all import rdpcap, DNSQR, DNSRR
|
||
import struct
|
||
|
||
f = ""
|
||
last = ""
|
||
for p in rdpcap('ch21.pcap'):
|
||
if p.haslayer(DNSQR) and not p.haslayer(DNSRR):
|
||
|
||
qry = p[DNSQR].qname.replace(".jz-n-bs.local.","").strip().split(".")
|
||
qry = ''.join(_.decode('hex') for _ in qry)[9:]
|
||
if last != qry:
|
||
print(qry)
|
||
f += qry
|
||
last = qry
|
||
|
||
#print(f)
|
||
```
|
||
詳細については、次のリンクを参照してください: [https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap](https://github.com/jrmdev/ctf-writeups/tree/master/bsidessf-2017/dnscap)\
|
||
[https://github.com/iagox86/dnscat2/blob/master/doc/protocol.md](https://github.com/iagox86/dnscat2/blob/master/doc/protocol.md)
|
||
|
||
Python3で動作するスクリプトがあります: [https://github.com/josemlwdf/DNScat-Decoder](https://github.com/josemlwdf/DNScat-Decoder)
|
||
```
|
||
python3 dnscat_decoder.py sample.pcap bad_domain
|
||
```
|
||
{{#include ../../../banners/hacktricks-training.md}}
|