Nada de nada, sigue con lo mismo, mira no te rompas más la cabeza con eso, a lo mejor es una tufe de la maquina donde lo estoy probando.
Mira tengo a mano un script que me descargaron de Internet, que lo que hace es montar un servidor web con nc y por lo que he visto creo que hasta se pueden ver los directorios en dicho server, pero al ejecutarlo, me da unos errores de la opción -e del nc, que al parecer no esta implementada en el nc que tengo instalado en Linux, donde se puede conseguir una versión de netcat que venga con esta opción implementada o el source para compilarlo. el scrip esta interesante y raro, que es lo que mas me llama la atención.
en estos dias voy a subir a la wiki como crear un servidor web simple usando netcat
te lo dejo para que le tires un ojo a ver que me dices....
Código: Seleccionar todo
#!/bin/bash
###########################################################################
# #
# netcat :3 - Webserver #
# a simple, directory listing HTTP- Server #
# written in Bash and powered by netcat #
# #
# #
# Copyright (C) 2012 Jan Alvar Penning <post [at] 0x21 [d0t] biz> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# #
# Usage: #
# ./netcatwebserver.sh [PORT] #
# ./netcatwebserver.sh 8080 #
# #
###########################################################################
# End it "friendly" with Ctrl+C
trap exit 1 2 3 6
# If this is the "master process"..
if [ $1 ]; then
while [ true ]; do
# Multiple connections for more than just one request at once
# Cout amount of listening "netcat :3 - Webservers"
proc="$(ps ax | grep "nc -l -p $1 -q 1 -e $0" | grep -v "grep" | wc -l)"
if [ "$proc" -lt "1" ]; then
# Spawn a new listening process if one is in use
nc -l -p "$1" -q 1 -e "$0" 2>/dev/null &
fi
done
fi
# Read just the first line of the HTTP- Request
read request
# Get target (e.g.: /) and urldecode it
target=".$(echo "$request" | awk '{ print $2 }' | echo -e $(sed 's/%/\\x/g'))"
# Get HTTP- Request- Method (e.g.: GET)
request="$(echo "$request" | awk '{ print $1 }')"
# Which HTTP- Request- Method is requested..
# There is currently just GET, HEAD and OPTIONS possible..
case "$request" in
# HTTP GET - default..
GET)
# If requested content is a file or a directory..
if [ -f "$target" ] || [ -d "$target" ]; then
echo "HTTP/1.1 200 OK"
echo "Server: netcat :3 - Webserver"
echo "Date: $(date --rfc-2822)"
if [ -f "$target" ]; then
# It's a file..
# So let's return the length of the file and the MIME..
echo "Content-Length: $(ls -l "$target" | awk '{ print $5 }')"
echo "Content-Type: $(file --mime-type "$target" | awk '{ print $2 }')"
echo ""
cat "$target"
else
# Directory!
# Prepare the path to our folder..
if [ "$target" = "./" ]; then
target="."
else
target="$(echo "$target" | sed 's/.\///')"
fi
# Print a "Directory- List" which reminds me of Apache..
contlist="<!DOCTYPE HTML>
<html>
<head>
<title>Index of $target - powered by \"netcat :3 - Webserver\"</title>
</head>
<body>
<h1>Index of $target</h1>
<table><tr><th><a href=\"\">Name</a></th></tr><tr><th colspan=\"5\"><hr></th></tr>"
# Find every entry (file and directories)..
for x in "$(echo $target)"/*; do
if [ "$x" = "$target/*" ]; then
# If directory is empty, then say it loud!
contlist="$contlist <tr><td>Nothing</td><td><td colspan=\"5\"></td></tr>"
else
contlist="$contlist <tr><td>"
# Add a stylish "[DIR]" if current entry is a directory
if [ -d "$x" ]; then contlist="$contlist [DIR]"; fi
contlist="$contlist <a href=\"/$x\">$x</a></td><td><td colspan=\"5\"></td></tr>"
fi
done
contlist="$contlist <tr><th colspan=\"5\"><hr></th></tr>
</table>
<address>powered by \"netcat :3 - Webserver\"</address>
</body></html>"
echo "Content-Length: $(expr length "$contlist")"
echo "Content-Type: text/html;charset=UTF-8"
echo ""
echo "$contlist"
fi
else
# We found a file .. Nope! Chuck Testa!
echo "HTTP/1.1 404 File Not Found"
echo "Server: netcat :3 - Webserver"
echo "Date: $(date --rfc-2822)"
contlist="<!DOCTYPE HTML>
<html><head>
<title>404 Not Found - powered by \"netcat :3 - Webserver\"</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL $target was not found on this server.</p>
<hr>
<address>powered by \"netcat :3 - Webserver\"</address>
</body></html>"
echo "Content-Length: $(expr length "$contlist")"
echo "Content-Type: text/html;charset=UTF-8"
echo ""
echo "$contlist"
fi
;;
# HTTP HEAD
HEAD)
# If our requested content is a file..
if [ -f "$target" ]; then
# return HTTP- Headers and stop!
echo "HTTP/1.1 200 OK"
echo "Server: netcat :3 - Webserver"
echo "Date: $(date --rfc-2822)"
echo "Content-Length: $(ls -l "$target" | awk '{ print $5 }')"
echo "Content-Type: $(file --mime-type "$target" | awk '{ print $2 }')"
echo ""
else
# ..else just return 404.
echo "HTTP/1.1 404 File Not Found"
echo "Server: netcat :3 - Webserver"
echo "Date: $(date --rfc-2822)"
echo ""
fi
;;
# HTTP OPTIONS .. perhaps a bit useless..
OPTIONS)
echo "HTTP/1.1 200 OK"
echo "Server: netcat :3 - Webserver"
echo "Date: $(date --rfc-2822)"
echo "Allow: GET, HEAD, OPTIONS"
echo ""
;;
# Otherwise return HTTP 400!
*)
echo "HTTP/1.1 400 Bad Request"
echo "Server: netcat :3 - Webserver"
echo "Date: $(date --rfc-2822)"
echo ""
;;
esac
Nacimos esclavos del software privativo y moriremos libres de el.
Escucha a tu disco duro y ve que tiene que decirte:
sudo cat /dev/sda | aplay -fdat
PD: Sirve para otros dispositivos, como USB, CD, etc.