Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

324
Vistas
Netcat only sends answer after I CTRL-C the connection

When I run this command cat index.html | nc -lnvp 2222 and then open the local address of the server in the browser with this header: GET / HTTP/1.1 Host: 192.168.146.131:2222 User-Agent: "my user agent here" Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: de,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate DNT: 1 Connection: keep-alive

and this as the index.html: hi whats up (thats it)

I get the http request in the terminal where netcat is running and my browser on my other machine is waiting. Only when I CTRL-C the connection on the terminal I get the response in the browser.

My uname -a prints out: Linux kali 4.0.0-kali1-amd64 #1 SMP Debian 4.0.4-1+kali2 (2015-06-03) x86_64 GNU/Linux

When I try to use cat index.html | nc -l 2222 it doesnt work at all. My Kali machine doesnt even get a http request. When I try the same on an Ubuntu machine it works like I want to it to work: It simply sends the index.html to the browser without waiting for me to CTRL-C netcat.

Anyone an idea why netcat behaves so weird?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

There are two different netcats, and you're using one of each:

  • Traditional netcat will avoid closing the connection by default, because the client might send more data.

  • OpenBSD netcat closes the connection by default when there's no more data to send.

Old versions of HTTP (like you're falling back on) expects the connection to be closed, so it works by default with the OpenBSD netcat.

You can have traditional netcat close the connection on eof as well, using -q 0:

stuff | nc.traditional -l -p 2222 -q 0
over 4 years ago · Santiago Trujillo Denunciar

0

man nc writes:

"netcat stays running until the network side closes" so your browser will wait forever for the data to finish. Use -q option to quit, see the man page again: "after EOF on stdin, wait the specified number of seconds and then quit".

cat index.html | nc -lnvp 2222 -q 0

nc -l 2222 does not make sense, you need to use -p to specify the port.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda