> For the complete documentation index, see [llms.txt](https://docs.unsafe-inline.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unsafe-inline.com/unsafe/netcat-relay.md).

# Netcat Relay

Post-exploitation aşamasında hedef sunucu üzerinde hizmet veren ssh, ftp, rdp, vnc gibi servislere yapılan inbound isteklerin network-based firewall veya host-based firewall'un bloklaması nedeniyle erişim sağlanamayabilir. Aynı zamanda firewall bazı portlar için inbound isteklere izin veriyorsa sunucu üzerinde netcat ile yönlendirme yaparak bu servislere erişim elde edilebilir.Senaryo şu şekilde olsun:

* Hedef sunucu üzerinde shell erişimimiz var.
* Network-based firewall, 22 (ssh-tcp) portuna inbound erişimi engellerken 80,443 (tcp) portlarına yapılan inbound istekleri kesmiyor.
* Ele geçirdiğimiz sunucu 443 portu üzerinde herhangi bir servis çalıştırmıyor.
* Hedef sunucuya, Windows bilgisayardan ssh bağlantısı yapılmak isteniyor.

Shell alınmış sunucu üzerinde netcat ile 443 portuna gelen istekleri 22 (ssh) portuna yönlendirerek firewall kuralına takılmadan ssh bağlantısı elde edilebilir. Senaryo, firewall konfigürasyonuna göre değişebilir ve netcat listener 443 yerine farklı bir port üzerinde de çalıştırılabilir tabii ki.

![](/files/-MQBaxDikjfENNAgmtUS)

Hedef sunucu (192.168.211.130 - Ubuntu) üzerinde netcat 443 portunu dinleyecek ve gelen isteği 22 (ssh) portuna forward pipe ( | ) ile iletecektir. Forward pipe ( | ) netcat listener'a gelen veriyi netcat client'a gönderir fakat netcat çift yönlü bir iletişim sağlamaktadır. Response almak için ise oluşturulan backpipe adlı dosya kullanılacak ve bu sayede netcat client'tan gelen veri netcat listener'a iletilecek çift yönlü iletişim kurulmuş olacaktır.

![](/files/-MQBb7QKTTXmp20ikcm-)

Hedef sunucunun ssh portuna bağlantı yapılmaya çalışıldığında beklenildiği gibi connection timed out hatası alınır.

![](/files/-MQBbHDVTH3sapqetAbu)

![](/files/-MQBbOeGgwCM2EOiKvyO)

İstek sunucunun (192.168.211.130 - Ubuntu) 443 portuna gönderildiğinde ise başarılı bir şekilde ssh bağlantısı sağlanmış olur.

![](/files/-MQBbY-kwELEgaNgFhGv)

![](/files/-MQBb_lXdZUqml1G9YMn)

<pre><code><strong># Author: Metin Yunus Kandemir
</strong></code></pre>

Reference:

{% embed url="<https://www.sans.org/blog/sans-cheat-sheet-netcat/>" %}


---

# 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://docs.unsafe-inline.com/unsafe/netcat-relay.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.
