pablino76 escreveu:okey
Gracias, fíjate luego si podes probarlo en un virtual no se y explicarme porque no consigo arrancar el netdiscover.sh que crea el netdiscover.cgi una ves que se le asigna los parámetros
El archivo se crea pero cuando el cgi le da la orden
./netdiscover.sh &
Parece que todo bien pero no arranca pensé de entrada que era un problema de permisos y algo cambie pero tampoco
Bueno listo si llegas a tener noticia avísame estoy acá buscando resolver eso para ver si lo continuo creando.
PD:el runfile ese binario no hace falta era solo para ver si el problema era el archivo sh pero no fue así que hay que modificar el CGI y cambiarle la línea esa ./runfile &
Por la del sh ese que genera el cgi
Saludos.
pablino76 escreveu:este hay que descomprimirlo en /var/http/htdocs/cgi-bin/
gamba47 escreveu:No tengo un 2.x como para probar.
Se viene un nuevo developer!!
gamba47
nachazo escreveu:fijate coriendo el script sin formulario con un link directo y editando un archivo de texto (bien a lo argento ) si anda asi es un tema del comando en cgi....
nachazo escreveu:PD: gamba.... ojala se nos una a la cuadrilla la perdida de juanillo fue muy dura...
El guapo Dan escreveu:Hola.
runfile de donde salió?.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
system ("/var/http/htdocs/cgi-bin/netdiscover.sh");
return 0;
}
El guapo Dan escreveu:Prueba ejecutando dentro de bfw "/var/http/htdocs/cgi-bin/runfile", te va a decir "runfile file nor found", simplemente por que bfw no reconoce a runfile como un ejecutable válido. Tambien asegurate que runfile tenga permisos 754.
#!/bin/sh
# Netdiscover-CGI by chango From BrazilFW
. /var/http/web-functions
cl_header2 "Netdiscover - BrazilFW"
if ! [ "$FORM_OKBTN" = "$Fsb" ]; then
cat << CLEOF
<script>
function validar(ip) {
partes=ip.split('.');
if (partes.length!=4) {
alert("ip no valida");
return false;
}
for (i=0;i<4;i++) {
num=partes[i];
if (num>255 || num<0 || num.length==0 || isNaN(num)){
alert("ip no valida");
return false;
}
}
}
</script>
<form method="POST" action="/cgi-bin/netdiscover.cgi">
<table border=0 width="100%" class=maintable>
<tr><th colspan=2>Netdiscover Inicio</th></tr>
<tr><td width=50% class=row1 align=right><b>Interface</b></td><td width="50%" class=row2><input type=text name=IF_LOCAL value="${IF_LOCAL}" size=5></td></tr>
<tr><td width=50% class=row1 align=right><b>IP</b></td><td width="50%" class=row2><input type=text name=IPADDRESS size=25 maxlength="15" value="${LOCAL_IPADDR}"></td></tr>
<tr><td width=50% class=row1 align=right><b>Mascara Subred</b></td><td width="50%" class=row2>
<INPUT type="radio" name=SUBRED value="24" checked>24
<INPUT type="radio" name=SUBRED value="16">16
<INPUT type="radio" name=SUBRED value="8">8</td></tr>
<BR>
</table>
<input type=submit value="$Fsb" name=OKBTN onClick="validar(document.all.IPADDRESS.value);"> <input type=reset value="$Fer">
</P>
</FORM>
CLEOF
cl_footer2
exit
fi
echo "#!/bin/sh" >./netdiscover.sh
echo "echo '<meta http-equiv=REFRESH CONTENT=3;URL=./listhost.html><pre><link href=list.css rel=stylesheet type=text/css><div id=footer><p><FONT color=#FFBE0F>Netdiscover</FONT>-CGI <Blink>Monitor</blink></p></div>'>/var/http/htdocs/cgi-bin/listhost.html" >>./netdiscover.sh
echo "/usr/local/sbin/netdiscover -L -i $FORM_IF_LOCAL -r $FORM_IPADDRESS/$FORM_SUBRED >>/var/http/htdocs/cgi-bin/listhost.html &" >>./netdiscover.sh
sleep 2
/bin/chmod 754 ./netdiscover.sh
sleep 2
sh ./netdiscover.sh &
cat << CLEOF
<script>
<!--
function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=no, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}
// -->
</script>
<table class=maintable border=3><center><tr><th>.::Netdiscover Menu::.</th></tr><tr><td><br><ol>
<li><a href="/cgi-bin/netdiscover.cgi">Volver</a></li>
<li><a href="./listhost.html" target="popup" onClick="wopen('./listhost.html', 'popup', 600, 450); return false;">Mostrar Resultados</a>
<li><a href="/cgi-bin/diags.cgi?COMMAND=rm /var/http/htdocs/cgi-bin/listhost.html">Borrar Cache</a></li>
<li><a href="/cgi-bin/diags.cgi?COMMAND=killall netdiscover">Terminar Proceso</a></li>
</ol></td></tr></center></table>
CLEOF
macbab escreveu:Saludos por tu regreso Pablino , me temia que no lo hicieras.
echo '<meta http-equiv=REFRESH CONTENT=3;URL=./listhost.html><pre><link href=list.css rel=stylesheet type=text/css><div id=footer><p><FONT color=#FFBE0F>Netdiscover</FONT>-CGI <Blink>Monitor</blink></p></div>'>/var/http/htdocs/cgi-bin/listhost.html
/usr/local/sbin/netdiscover -L -i eth0 -r 192.168.1.1/24 >>/var/http/htdocs/cgi-bin/listhost.html &
jhonfw escreveu:el netdiscover no devuelve texto
es activo como el kismet
entones cuando ejecuta el netdiscover desde el cgi el webmin espera que el programa termine y le devuelva el texto
brazilfw# ./netdiscover.sh
brazilfw# ps -uax |grep "netdiscover"
16553 root 832 S /usr/local/sbin/netdiscover -L -i eth0 -r 192.168.0.
16554 root 832 S /usr/local/sbin/netdiscover -L -i eth0 -r 192.168.0.
16555 root 832 S /usr/local/sbin/netdiscover -L -i eth0 -r 192.168.0.
16556 root 832 R /usr/local/sbin/netdiscover -L -i eth0 -r 192.168.0.
brazilfw#
kuthulu
DD-WRT User
Solo por ahora te puedo decir que al ejecutar como cgi el script cada vez se crea una nueva sesion sh para ejecutarlo, así que si guardas algún valor en una variable éste no estará disponible en la siguiente ejecución, si necesitas guardar un valor puedes usar nvram o bien un archivo en /tmp/.
Si lo haces en una sesión de telnet conservarás las variables entre ejecuciones y por eso me imagino que te funciona en la consola pero no en web.
pablino76 escreveu:Hola gente estoy tratando de usar el comando crontrab que esta en brazilfw para realizar una tarea programa pero esta no parece andar
estoy editando el archivo :
edit /var/spool/cron/crontabs/root
y agregandole
# Example : runfile netdiscover at 14:27pm every monday and todos los dias
27 14 * * * runfile
sin embargo al ser las 14 hs 27 minutos este no se ejecuta
Como se usa entonces?
#!/bin/sh
#Netdiscover-CGI by Chango From BrazilFW
. /var/http/web-functions
cl_header2 "Netdiscover - BrazilFW"
LINEA=`grep "runfile" -n /var/spool/cron/crontabs/root |cut -d":" -f1`
sleep 1
sed -i 1d /var/spool/cron/crontabs/root
killall netdiscover
rm /var/http/htdocs/cgi-bin/listhost.html
echo "<h1><blink>Cancelado</blink></h1>" >/var/http/htdocs/cgi-bin/listhost.html
if [ -n "$FORM_COMMAND" ] ; then
sh ./netdiscover.cgi
COMMAND=$FORM_COMMAND
if [ -n "$FORM_PARAMNAME" ] ; then
echo "<center><form method=POST action=/cgi-bin/netdiscover.cgi>"
echo "$FORM_PARAMNAME"
echo " : "
echo "<input type=text size=30 name=PARAM value=\"$FORM_PARAM\"> "
echo "<input type=submit value= $Feo >"
echo "<input type=hidden name=COMMAND value=\"$FORM_COMMAND\">"
echo "<input type=hidden name=PARAMNAME value=\"$FORM_PARAMNAME\"></form></center>"
COMMAND=`echo $COMMAND | sed s/MARK_param_MARK/$FORM_PARAM/`
fi
echo "<pre>"
if [ -n "$FORM_PARAM" -o -z "$FORM_PARAMNAME" ] ; then
$COMMAND
fi
echo "</pre></td></tr></table>"
else
if ! [ "$FORM_OKBTN" = "$Fsb" ]; then
cat << CLEOF
<script>
function validar(ip) {
partes=ip.split('.');
if (partes.length!=4) {
alert("ip no valida");
return false;
}
for (i=0;i<4;i++) {
num=partes[i];
if (num>255 || num<0 || num.length==0 || isNaN(num)){
alert("ip no valida");
return false;
}
}
}
</script>
<form method="POST" action="/cgi-bin/netdiscover.cgi">
<table border=0 width="60%" class=maintable>
<tr><th colspan=2>Netdiscover Inicio</th></tr>
<tr><td width=50% class=row1 align=right><b>Interface</b></td><td width="50%" class=row2><input type=text name=IF_LOCAL value="${IF_LOCAL}" size=5></td></tr>
<tr><td width=50% class=row1 align=right><b>IP</b></td><td width="50%" class=row2><input type=text name=IPADDRESS size=25 maxlength="15" value="${LOCAL_IPADDR}"></td></tr>
<tr><td width=50% class=row1 align=right><b>Mascara Subred</b></td><td width="50%" class=row2>
<INPUT type="radio" name=SUBRED value="24" checked>24
<INPUT type="radio" name=SUBRED value="16">16
<INPUT type="radio" name=SUBRED value="8">8</td></tr>
<BR>
</table>
<input type=submit value="$Fsb" name=OKBTN onClick="validar(document.all.IPADDRESS.value);"> <input type=reset value="$Fer">
</P>
</FORM>
CLEOF
cl_footer2
exit
fi
echo "#!/bin/sh" >./netdiscover.sh
echo "echo '<meta http-equiv=REFRESH CONTENT=3;URL=./listhost.html><pre><link href=list.css rel=stylesheet type=text/css><div id=footer><p><FONT color=#FFBE0F>Netdiscover</FONT>-CGI <Blink>Monitor</blink></p></div>'>/var/http/htdocs/cgi-bin/listhost.html" >>./netdiscover.sh
echo "/usr/local/sbin/netdiscover -L -i $FORM_IF_LOCAL -r $FORM_IPADDRESS/$FORM_SUBRED >>/var/http/htdocs/cgi-bin/listhost.html &" >>./netdiscover.sh
/bin/chmod +x ./netdiscover.sh
sleep 1
./netdiscover.sh &
sleep 1
MINUTOS=`uptime |cut -d":" -f2`
if [ $MINUTOS ]
then
case "$MINUTOS" in
01)
MINUTOS=1
;;
02)
MINUTOS=2
;;
03)
MINUTOS=3
;;
04)
MINUTOS=4
;;
05)
MINUTOS=5
;;
06)
MINUTOS=6
;;
07)
MINUTOS=7
;;
08)
MINUTOS=8
;;
09)
MINUTOS=9
;;
00)
MINUTOS=1
;;
esac
fi
let SUMA=$MINUTOS+1
HORA=`uptime |cut -d":" -f1`
echo "$SUMA $HORA * * * runfile">>/var/spool/cron/crontabs/root
sleep 1
/usr/bin/crontab /var/spool/cron/crontabs/root
cat << CLEOF
<script>
<!--
function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=no, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}
// -->
</script>
<table class=maintable border=0><center><tr><th>.::Netdiscover Menu::.</th></tr><tr><td><br><ol>
<li><a href="./listhost.html" target="popup" onClick="wopen('./listhost.html', 'popup', 600, 450); return false;">Mostrar Resultados</a>
<li><a href="/cgi-bin/netdiscover.cgi">Cancelar</a></li>
</ol></td></tr></center></table>
CLEOF
fi
cl_footer2
exit
# Borramos líneas que contengan la palabra runfile.
sed -e '/runfile/d' /var/spool/cron/crontabs/root > /var/spool/cron/crontabs/root.tmp
# Ahora vamos a borrar las lineas en blanco que van apareciendo y ademas recuperamos el
# contenido que queremos en el archivo correcto.
sed '/^$/d' /var/spool/cron/crontabs/root.tmp > /var/spool/cron/crontabs/root
# Borramos el archivo temporal que ya no nos sirve.
rm /var/spool/cron/crontabs/root.tmp
# No nos olvidemos de recargar el cron
/usr/sbin/cron.reload
#!/bin/sh
#Netdiscover-CGI by chango From BrazilFW
. /var/http/web-functions
cl_header2 "Netdiscover - BrazilFW"
sed -i '/runfile/d' /var/spool/cron/crontabs/root
killall netdiscover
rm /var/http/htdocs/cgi-bin/listhost.html
echo "<h1><blink>Cancelado</blink></h1>" >/var/http/htdocs/cgi-bin/listhost.html
if [ -n "$FORM_COMMAND" ] ; then
sh ./netdiscover.cgi
COMMAND=$FORM_COMMAND
if [ -n "$FORM_PARAMNAME" ] ; then
echo "<center><form method=POST action=/cgi-bin/netdiscover.cgi>"
echo "$FORM_PARAMNAME"
echo " : "
echo "<input type=text size=30 name=PARAM value=\"$FORM_PARAM\"> "
echo "<input type=submit value= $Feo >"
echo "<input type=hidden name=COMMAND value=\"$FORM_COMMAND\">"
echo "<input type=hidden name=PARAMNAME value=\"$FORM_PARAMNAME\"></form></center>"
COMMAND=`echo $COMMAND | sed s/MARK_param_MARK/$FORM_PARAM/`
fi
echo "<pre>"
if [ -n "$FORM_PARAM" -o -z "$FORM_PARAMNAME" ] ; then
$COMMAND
fi
echo "</pre></td></tr></table>"
else
if ! [ "$FORM_OKBTN" = "$Fsb" ]; then
cat << CLEOF
<script>
function validar(ip) {
partes=ip.split('.');
if (partes.length!=4) {
alert("ip no valida");
return false;
}
for (i=0;i<4;i++) {
num=partes[i];
if (num>255 || num<0 || num.length==0 || isNaN(num)){
alert("ip no valida");
return false;
}
}
}
</script>
<form method="POST" action="/cgi-bin/netdiscover.cgi">
<table border=0 width="60%" class=maintable>
<tr><th colspan=2>Netdiscover Inicio</th></tr>
<tr><td width=50% class=row1 align=right><b>Interface</b></td><td width="50%" class=row2><input type=text name=IF_LOCAL value="${IF_LOCAL}" size=5></td></tr>
<tr><td width=50% class=row1 align=right><b>IP</b></td><td width="50%" class=row2><input type=text name=IPADDRESS size=25 maxlength="15" value="${LOCAL_IPADDR}"></td></tr>
<tr><td width=50% class=row1 align=right><b>Mascara Subred</b></td><td width="50%" class=row2>
<INPUT type="radio" name=SUBRED value="24" checked>24
<INPUT type="radio" name=SUBRED value="16">16
<INPUT type="radio" name=SUBRED value="8">8</td></tr>
<BR>
</table>
<input type=submit value="$Fsb" name=OKBTN onClick="validar(document.all.IPADDRESS.value);"> <input type=reset value="$Fer">
</P>
</FORM>
CLEOF
cl_footer2
exit
fi
echo "#!/bin/sh" >./netdiscover.sh
echo "echo '<meta http-equiv=REFRESH CONTENT=3;URL=./listhost.html><pre><link href=list.css rel=stylesheet type=text/css><div id=footer><p><FONT color=#FFBE0F>Netdiscover</FONT>-CGI <Blink>Monitor</blink></p></div>'>/var/http/htdocs/cgi-bin/listhost.html" >>./netdiscover.sh
echo "/usr/local/sbin/netdiscover -L -i $FORM_IF_LOCAL -r $FORM_IPADDRESS/$FORM_SUBRED >>/var/http/htdocs/cgi-bin/listhost.html &" >>./netdiscover.sh
/bin/chmod +x ./netdiscover.sh
sleep 1
./netdiscover.sh &
sleep 1
MINUTOS=`uptime |cut -d":" -f2`
if [ $MINUTOS ]
then
case "$MINUTOS" in
01)
MINUTOS=1
;;
02)
MINUTOS=2
;;
03)
MINUTOS=3
;;
04)
MINUTOS=4
;;
05)
MINUTOS=5
;;
06)
MINUTOS=6
;;
07)
MINUTOS=7
;;
08)
MINUTOS=8
;;
09)
MINUTOS=9
;;
00)
MINUTOS=1
;;
esac
fi
let SUMA=$MINUTOS+1
HORA=`uptime |cut -d":" -f1`
echo "$SUMA $HORA * * * runfile">>/var/spool/cron/crontabs/root
sleep 1
/usr/bin/crontab /var/spool/cron/crontabs/root
cat << CLEOF
<script>
<!--
function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=no, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}
// -->
</script>
<table class=maintable border=0><center><tr><th>.::Netdiscover Menu::.</th></tr><tr><td><br><ol>
<li><a href="./listhost.html" target="popup" onClick="wopen('./listhost.html', 'popup', 600, 450); return false;">Mostrar Resultados</a>
<li><a href="/cgi-bin/netdiscover.cgi">Cancelar</a></li>
</ol></td></tr></center></table>
CLEOF
fi
cl_footer2
exit
AdslWiFi escreveu:De todos modos no creo sea la forma mas correcta de correr netdiscover.
killall netdiscover > /dev/null 2>&1
pablino76 escreveu:la otra es que quiero ahora hacer dos tablas una al lado de la otra
y no me sale estoy viendo como
una llamada netdiscover inicio y la otra Ifconfig donde va salir dicho
resultado ifconfig u otra especificacion puede ser un help pero al lado derecho de la tabla Netdiscover menu
pablino76 escreveu:ahora estoy en plan de agregarle mas opciones al formulario Netdiscover inicio también
otra cosa que me tiene pensado es poder ir viendo el rango de barrido que se esta sucediendo
pero eso me parece que voy a tener que modificar algo del source de netdiscover por ahora
mas funciones al form inicio.
/*------------------------------------------------------------*
** Footer
**------------------------------------------------------------*/
#footer {
position: absolute !important;
width: 100% !important;
z-index: 200 !important;
position: relative;
padding: 11px 0;
margin-top: -15px;
background-color: #006699;
color: #999;
font-size: 16px;
border-top: 3px solid #ccc;
}
#footer p { margin: 0 10px; text-align: center; }
#footer a:hover { background-color: #222; }
#!/bin/sh
. /var/http/web-functions
echo Content-type: text/html
echo ""
/bin/cat << EOM
<HTML>
<HEAD><TITLE>Arping-CGI: Arping </TITLE>
</HEAD>
<P>
<BODY bgcolor="#cccccc" text="#000000">
<table width="100%" border="0" >
<tr bgcolor="#ffcc33">
<td><b><big>AREA PRUEBAS CAPA II</big></b></td></tr>
<tr><td><a href="/cgi-bin/arping.cgi?COMMAND=arping -c 4 MARK_param_MARK&PARAMNAME=IP Number or Host Name"><b><big>ARPING</b></big></a></td>
</tr>
<SMALL>
<PRE>
EOM
if [ -n "$FORM_COMMAND" ] ; then
COMMAND=$FORM_COMMAND
echo "<table class=maintable><tr><td nowrap>"
if [ -n "$FORM_PARAMNAME" ] ; then
echo "<center><form method=POST action=/cgi-bin/arping.cgi>"
echo "$FORM_PARAMNAME"
echo " : "
echo "<input type=text size=30 name=PARAM value=\"$FORM_PARAM\"> "
echo "<input type=submit value= $Feo >"
echo "<input type=hidden name=COMMAND value=\"$FORM_COMMAND\">"
echo "<input type=hidden name=PARAMNAME value=\"$FORM_PARAMNAME\"></form></center>"
echo "</td></tr><tr><td nowrap>"
COMMAND=`echo $COMMAND | sed s/MARK_param_MARK/$FORM_PARAM/`
fi
echo "<pre>"
if [ -n "$FORM_PARAM" -o -z "$FORM_PARAMNAME" ] ; then
$COMMAND
fi
cat << EOM
</PRE>
</SMALL>
<P>
</BODY>
</HTML>
EOM
fi
192.168.0.1/24
192.168.90.1/24
10.0.0.1/16
#!/bin/sh
. /var/http/web-functions
cl_header2 "Netdiscover - BrazilFW"
#----------------------------------------------------------
#comentar esta linea es solo para crear el archivo prueba formulario derecho
echo "Formulario tabla Menu" >infotxt
#----------------------------------------------------------
sed -i '/runfile/d' /var/spool/cron/crontabs/root > /dev/null 2>&1
killall netdiscover > /dev/null 2>&1
rm /var/http/htdocs/cgi-bin/listhost.html > /dev/null 2>&1
echo "<h1><blink>Cancelado</blink></h1>" >/var/http/htdocs/cgi-bin/listhost.html
if [ -n "$FORM_COMMAND" ] ; then
COMMAND=$FORM_COMMAND
if [ -n "$FORM_PARAMNAME" ] ; then
echo "<center><form method=POST action=/cgi-bin/netdiscover.cgi>"
echo "$FORM_PARAMNAME"
echo " : "
echo "<input type=text size=30 name=PARAM value=\"$FORM_PARAM\"> "
echo "<input type=submit value= $Feo >"
echo "<input type=hidden name=COMMAND value=\"$FORM_COMMAND\">"
echo "<input type=hidden name=PARAMNAME value=\"$FORM_PARAMNAME\"></form></center>"
COMMAND=`echo $COMMAND | sed s/MARK_param_MARK/$FORM_PARAM/`
fi
echo "<pre>"
if [ -n "$FORM_PARAM" -o -z "$FORM_PARAMNAME" ] ; then
$COMMAND
fi
echo "</pre></td></tr></table>"
else
if ! [ "$FORM_OKBTN" = "$Fsb" ]; then
cat << CLEOF
<script>
function validar(ip) {
partes=ip.split('.');
if (partes.length!=4) {
alert("ip no valida");
return false;
}
for (i=0;i<4;i++) {
num=partes[i];
if (num>255 || num<0 || num.length==0 || isNaN(num)){
alert("ip no valida");
return false;
}
}
}
</script>
<form method="POST" action="/cgi-bin/netdiscover.cgi">
<table border=0 width="100%" class=maintable>
<tr><th colspan=2>Netdiscover Basico</th></tr>
<tr><td width=50% class=row1 align=right><b>Interface</b></td><td width="50%" class=row2><input type=text name=IF_LOCAL value="${IF_LOCAL}" size=5></td></tr>
<tr><td width=50% class=row1 align=right><b>IP</b></td><td width="50%" class=row2><input type=text name=IPADDRESS size=25 maxlength="15" value="${LOCAL_IPADDR}"></td></tr>
<tr><td width=50% class=row1 align=right><b>Mascara Subred</b></td><td width="50%" class=row2>
<INPUT type="radio" name=SUBRED value="24" checked>24
<INPUT type="radio" name=SUBRED value="16">16
<INPUT type="radio" name=SUBRED value="8">8</td></tr>
</table>
<input type=submit value="$Fsb" name=OKBTN onClick="validar(document.all.IPADDRESS.value);"> <input type=reset value="$Fer">
<!--tabla de informacion-->
<td width="100%">
<table border=0 class=maintable>
<tr>
<tr><th colspan=2>Otras opciones</th></tr>
<td id=textoexterno>
<object type="text/plain"data="infotxt"></object>
</td>
</tr>
</table>
<!--fin de las tablas de informacion-->
</P>
</FORM>
CLEOF
cl_footer2
exit
fi
echo "#!/bin/sh" >./netdiscover.sh
echo "echo '<meta http-equiv=REFRESH CONTENT=3;URL=./listhost.html><pre><link href=list.css rel=stylesheet type=text/css><div id=footer><p><FONT color=#FFBE0F>Netdiscover</FONT>-CGI <Blink>Monitor</blink></p></div>'>/var/http/htdocs/cgi-bin/listhost.html" >>./netdiscover.sh
echo "/usr/local/sbin/netdiscover -L -i $FORM_IF_LOCAL -r $FORM_IPADDRESS/$FORM_SUBRED >>/var/http/htdocs/cgi-bin/listhost.html &" >>./netdiscover.sh
/bin/chmod +x ./netdiscover.sh
sleep 1
./netdiscover.sh &
sleep 1
MINUTOS=`uptime |cut -d":" -f2`
if [ $MINUTOS ]
then
case "$MINUTOS" in
01)
MINUTOS=1
;;
02)
MINUTOS=2
;;
03)
MINUTOS=3
;;
04)
MINUTOS=4
;;
05)
MINUTOS=5
;;
06)
MINUTOS=6
;;
07)
MINUTOS=7
;;
08)
MINUTOS=8
;;
09)
MINUTOS=9
;;
00)
MINUTOS=1
;;
esac
fi
let SUMA=$MINUTOS+1
HORA=`uptime |cut -d":" -f1`
echo "$SUMA $HORA * * * runfile">>/var/spool/cron/crontabs/root
sleep 1
/usr/bin/crontab /var/spool/cron/crontabs/root
cat << CLEOF
<script>
<!--
function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=yes, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}
// -->
</script>
<script>
<!--
function wopen2(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=yes, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}
// -->
</script>
<table class=maintable border=0><center><tr><th>.::Netdiscover Menu::.</th></tr><tr><td><br><ol>
<li><a href="./listhost.html" target="popup" onClick="wopen('./listhost.html', 'popup', 600, 450); return false;">Mostrar Resultados</a>
<li><a href="/cgi-bin/arping.cgi"target="popup" onClick="wopen2('/cgi-bin/arping.cgi', 'popup', 600, 450); return false;">Arping</a></li>
<li><a href="/cgi-bin/netdiscover.cgi">Cancelar</a></li>
</ol></td></tr></center></table>
CLEOF
fi
cl_footer2
exit
/***************************************************************************
* screen.c
*
* Tue Jul 12 03:23:41 2005
* Copyright 2005 Jaime Penalba Estebanez
* jpenalbae@gmail.com
*
* Contributors:
* Parsable output by Guillaume Pratte <guillaume@guillaumepratte.net>
****************************************************************************/
/*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* Thanks to Christophe Devine, aircrack creator, who gave me the
* inspiration to make this screen interface. You can see his site
* here http://www.cr0.net:8040/code/network/
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <pthread.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include "screen.h"
#include "misc.h"
#include "ifaces.h"
#include "data_al.h"
/* Shity globals */
struct termios stored_settings, working_settings;
extern pthread_t screen, keys, sniffer, injection;
int scroll;
int smode, oldmode;
char line[300], tline[300];
char blank[] = " ";
/* Inits lists with null pointers, sighandlers, etc */
void init_screen()
{
/* Interface properties */
scroll = 0;
smode = SMODE_HOST;
/* Set interative mode options if no parsable mode */
if(!parsable_output) {
/* Set signal handlers */
signal( SIGCONT, sighandler );
signal( SIGINT, sighandler );
signal( SIGKILL, sighandler );
signal( SIGTERM, sighandler );
signal( SIGHUP, sighandler );
signal( SIGABRT, sighandler );
/* Set console properties to read keys */
tcgetattr(0,&stored_settings);
working_settings = stored_settings;
working_settings.c_lflag &= ~(ICANON|ECHO);
working_settings.c_cc[VTIME] = 0;
working_settings.c_cc[VMIN] = 1;
tcsetattr(0,TCSANOW,&working_settings);
}
}
/* Handle signals and set terminal */
void sighandler(int signum)
{
if (parsable_output) {
exit(0);
} else {
if (signum == SIGCONT) {
tcsetattr(0,TCSANOW,&working_settings);
} else {
tcsetattr(0,TCSANOW,&stored_settings);
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
pthread_kill(keys, signum);
exit(0);
}
}
}
/* Check scrolling limit */
int scroll_limit()
{
const struct data_al *current_data_mode;
/* Use corresponding data layer depending on current screen mode */
current_data_mode = NULL;
switch (smode) {
case SMODE_REPLY:
current_data_mode = &_data_reply;
break;
case SMODE_REQUEST:
current_data_mode = &_data_request;
break;
case SMODE_HOST:
current_data_mode = &_data_unique;
break;
case SMODE_HELP:
current_data_mode = &_data_unique;
break;
}
return current_data_mode->hosts_count() - scroll;
}
/* Read input keys */
void read_key()
{
int ch, i;
ch = getchar();
/* Check for arrow keys */
if ( ch == 27 && (ch = getchar()) == 91) {
switch (getchar()) {
case 66:
ch = 106;
break;
case 65:
ch = 107;
break;
}
}
switch (ch) {
case 107: // Scroll up
if (scroll > 0)
scroll--;
break;
case 106: // Scroll down
if (scroll_limit() > 1)
scroll++;
break;
case ',': // Scroll page up
for (i = 0; i < win_sz.ws_row - 7; i++)
if (scroll > 0)
scroll--;
break;
case '.': // Scroll page down
for (i = 0; i < win_sz.ws_row - 7; i++)
if (scroll_limit() > 1)
scroll++;
break;
case 114: // Show requests view
smode = SMODE_REQUEST;
scroll = 0;
break;
case 97: // Show replies view
smode = SMODE_REPLY;
scroll = 0;
break;
case 117: // Show unique hosts view
smode = SMODE_HOST;
scroll = 0;
break;
case 113: // Quit
if (smode == SMODE_HELP)
smode = oldmode;
else
sighandler(0);
break;
case 104: // Show help screen
if (smode != SMODE_HELP) {
oldmode = smode;
smode = SMODE_HELP;
scroll = 0;
}
break;
}
/* Debug code
else
{
printf("\n\nYou pressed %i\n\n", ch);
sleep(2);
} */
print_screen();
}
/* Clear and fill the screen */
void print_screen()
{
/* Get Console Size */
if (ioctl(0, TIOCGWINSZ, &win_sz) < 0) {
win_sz.ws_row = 24;
win_sz.ws_col = 80;
}
/* Flush and print screen */
fprintf( stderr, "\33[1;1H" );
pthread_mutex_lock(data_access);
fill_screen();
pthread_mutex_unlock(data_access);
fprintf( stderr, "\33[J" );
fflush(stdout);
}
/* Print header line containing scanning and current screen mode */
void print_status_header()
{
int j;
char *current_smode = NULL;
switch (smode) {
case SMODE_REPLY:
current_smode = "ARP Reply";
break;
case SMODE_REQUEST:
current_smode = "ARP Request";
break;
case SMODE_HOST:
current_smode = "Unique Hosts";
break;
case SMODE_HELP:
current_smode = "Help";
break;
}
sprintf(line, " Currently scanning: %s | Screen View: %s",
current_network, current_smode);
printf("%s", line);
FILE *archivo;
if(!(archivo=fopen("scaning", "w"))) return -1;
fprintf(archivo, "%s");
fclose(archivo);
/* Fill with spaces */
for (j=strlen(line); j<win_sz.ws_col - 1; j++)
printf(" ");
printf("\n");
/* Print blank line with spaces */
for (j=0; j<win_sz.ws_col - 1; j++)
printf(" ");
printf("\n");
}
/* Fills the screen using white spaces to avoid refresh problems *
* not a very smart way, but it works :) */
void fill_screen()
{
const struct data_al *current_data_mode;
/* Use corresponding data layer depending on current screen mode */
current_data_mode = NULL;
switch (smode) {
case SMODE_REPLY:
current_data_mode = &_data_reply;
break;
case SMODE_REQUEST:
current_data_mode = &_data_request;
break;
case SMODE_HOST:
current_data_mode = &_data_unique;
break;
case SMODE_HELP:
current_data_mode = &_data_unique;
break;
}
/* Print headers */
print_status_header();
current_data_mode->print_header(win_sz.ws_col);
/* Print screen main data */
if (smode != SMODE_HELP) {
int x = 0;
current_data_mode->beginning_registry();
while (current_data_mode->current_registry() != NULL) {
if (x >= scroll)
current_data_mode->print_line();
current_data_mode->next_registry();
x++;
/* Check if end of screen was reached */
if (x >= ( (win_sz.ws_row + scroll) - 7))
break;
}
} else if(smode == SMODE_HELP) {
int i;
printf("\t ______________________________________________ \n"
"\t | | \n"
"\t | \33[1mUsage Keys\33[0m | \n"
"\t | h: show this help screen | \n"
"\t | j: scroll down (or down arrow) | \n"
"\t | k: scroll up (or up arrow) | \n"
"\t | .: scroll page up | \n"
"\t | ,: scroll page down | \n"
"\t | q: exit this screen or end | \n"
"\t | | \n"
"\t | \33[1mScreen views\33[0m | \n"
"\t | a: show arp replys list | \n"
"\t | r: show arp requests list | \n"
"\t | u: show unique hosts detected | \n"
"\t | | \n"
"\t ---------------------------------------------- \n");
for (i=25; i<win_sz.ws_row; i++)
printf("\n");
}
}
/***************************************************************************
* main.c
*
* Sun Jul 3 07:35:24 2005
* Copyright 2005 Jaime Penalba Estebanez
* jpenalbae@gmail.com
*
* Contributors:
* Parsable output by Guillaume Pratte <guillaume@guillaumepratte.net>
****************************************************************************/
/*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#define _GNU_SOURCE
#define VERSION "0.3-beta7"
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include "ifaces.h"
#include "screen.h"
#include "fhandle.h"
#include "misc.h"
#define RPATH "%s/.netdiscover/ranges"
#define FPATH "%s/.netdiscover/fastips"
extern void parseable_scan_end();
void *inject_arp(void *arg);
void *screen_refresh(void *arg);
void *parsable_screen_refresh(void *arg);
void scan_range(char *disp, char *sip);
void usage();
/* Last octect of ips scaned in fast mode */
/* Add new addr if needed here */
char **fast_ips;
char *dfast_ips[] = { "1", "2", "100", "200", "254", NULL};
/* Common local networks to scan */
/* Add new networks if needed here */
char **common_net;
char *dcommon_net[] = {
"192.168.0.0/16",
"172.16.0.0/16",
"172.26.0.0/16",
"172.27.0.0/16",
"172.17.0.0/16",
"172.18.0.0/16",
"172.19.0.0/16",
"172.20.0.0/16",
"172.21.0.0/16",
"172.22.0.0/16",
"172.23.0.0/16",
"172.24.0.0/16",
"172.25.0.0/16",
"172.28.0.0/16",
"172.29.0.0/16",
"172.30.0.0/16",
"172.31.0.0/16",
"10.0.0.0/8",
NULL
};
pthread_t injection, sniffer, screen, keys;
/* Command line flags */
int flag_fast_mode;
int flag_repeat_scan;
int flag_network_octect;
int flag_supress_sleep;
int flag_ignore_files;
int flag_auto_scan;
long flag_sleep_time;
/* Read control keys */
void *keys_thread(void *arg)
{
while ( 1 == 1 )
read_key();
}
/* main, fetch params and start */
int main(int argc, char **argv)
{
int c;
int flag_passive_mode = 0;
int flag_scan_range = 0;
int flag_scan_list = 0;
int no_parsable_header = 0;
char *plist = NULL;
char *mlist = NULL;
/* Config file handling vars */
char *home, *path;
struct t_data datos;
/* Some default values for the program options. */
datos.source_ip = NULL;
datos.interface = NULL;
datos.pcap_filter = NULL;
flag_sleep_time = 99;
flag_network_octect = 67;
flag_repeat_scan = 1;
flag_auto_scan = 0;
/* Globals defined in screen.h */
parsable_output = 0;
continue_listening = 0;
current_network = (char *) malloc ((sizeof(char)) * 19);
sprintf(current_network, "Starting.");
/* Fetch parameters */
while ((c = getopt(argc, argv, "i:s:r:l:m:n:c:F:pSfdPNLh")) != EOF)
{
switch (c)
{
case 'i': /* Set the interface */
datos.interface = (char *) malloc (sizeof(char) * (strlen(optarg) + 1));
sprintf(datos.interface, "%s", optarg);
break;
case 'p': /* Enable passive mode */
flag_passive_mode = 1;
break;
case 's': /* Set sleep time */
flag_sleep_time = atol(optarg);
break;
case 'S': /* Enable sleep supression */
flag_supress_sleep = 1;
break;
case 'c': /* Set no. of times to repeat the scan */
flag_repeat_scan = atoi(optarg);
break;
case 'n': /* Set las used octect */
flag_network_octect = atoi(optarg);
break;
case 'r': /* Set the range to scan */
datos.source_ip = (char *) malloc (sizeof(char) * strlen(optarg) + 1);
sprintf(datos.source_ip, "%s", optarg);
flag_scan_range = 1;
break;
case 'l': /* Scan ranges on the given file */
plist = (char *) malloc (sizeof(char) * (strlen(optarg) + 1));
sprintf(plist, "%s", optarg);
flag_scan_list = 1;
break;
case 'm': /* Scan MACs on the given file */
mlist = (char *) malloc (sizeof(char) * (strlen(optarg) + 1));
sprintf(mlist, "%s", optarg);
break;
case 'f': /* Enable fast mode */
flag_fast_mode = 1;
break;
case 'F': /* Edit pcap filter */
datos.pcap_filter = (char *) malloc (sizeof(char) * (strlen(optarg) + 1));
sprintf(datos.pcap_filter, "%s", optarg);
break;
case 'd': /* Ignore home config files */
flag_ignore_files = 1;
break;
case 'P': /* Produces parsable output (vs interactive screen) */
parsable_output = 1;
break;
case 'N': /* Do not print header under parsable mode */
no_parsable_header = 1;
break;
case 'L': /* Continue to listen in parsable output mode after active scan is completed */
parsable_output = 1;
continue_listening = 1;
break;
default:
printf("\n"); /* continues... */
case 'h': /* Show help */
usage(argv[0]);
exit(1);
break;
}
}
if (optind < argc) {
printf("Invalid extra argument: %s\n\n", argv[optind]);
usage(argv[0]);
exit(1);
}
/* Check for uid 0 */
if ( getuid() && geteuid() )
{
printf("You must be root to run this.\n");
exit(1);
}
/* If no iface was specified, autoselect one. exit, if no one available */
if (datos.interface == NULL)
{
datos.interface = pcap_lookupdev(errbuf);
if (datos.interface == NULL)
{
printf("Couldn't find default device: %s\n", errbuf);
exit(1);
}
}
/* Load user config files or set defaults */
home = getenv("HOME");
/* Read user configured ranges if arent disabled */
path = (char *) malloc (sizeof(char) * (strlen(home) + strlen(RPATH) + 1));
sprintf(path, RPATH, home);
if (((common_net = fread_list(path)) == NULL) || (flag_ignore_files == 1))
common_net = dcommon_net;
free(path);
/* Read user configured ips for fast mode if arent disabled */
path = (char *) malloc (sizeof(char) * (strlen(home) + strlen(FPATH) + 1));
sprintf(path, FPATH, home);
if(((fast_ips = fread_list(path)) == NULL) || (flag_ignore_files == 1))
fast_ips = dfast_ips;
free(path);
/* Read range list given by user if specified */
if (flag_scan_list == 1) {
if ((common_net = fread_list(plist)) == NULL) {
printf("File \"%s\" containing ranges, cannot be read.\n", plist);
exit(1);
}
}
/* Read Mac list of known hosts */
if (mlist != NULL) {
if (load_known_mac_table(mlist) < 0) {
printf("File \"%s\" containing MACs and host names, cannot be read.\n", mlist);
exit(1);
}
}
/* Init libnet, data layers and screen */
lnet_init(datos.interface);
_data_reply.init();
_data_request.init();
_data_unique.init();
init_screen();
/* Init mutex */
data_access = (pthread_mutex_t *)malloc(sizeof (pthread_mutex_t));
pthread_mutex_init(data_access, NULL);
/* If no mode was selected, enable auto scan */
if ((flag_scan_range != 1) && (flag_passive_mode != 1))
flag_auto_scan = 1;
/* Start the execution */
if (parsable_output) {
if (!no_parsable_header)
_data_unique.print_simple_header();
} else {
system("clear");
pthread_create(&screen, NULL, screen_refresh, (void *)NULL);
pthread_create(&keys, NULL, keys_thread, (void *)NULL);
}
pthread_create(&sniffer, NULL, start_sniffer, (void *)&datos);
if (flag_passive_mode == 1) {
current_network = "(passive)";
pthread_join(sniffer,NULL);
} else {
if (pthread_create(&injection, NULL, inject_arp, (void *)&datos))
perror("Could not create injection thread");
pthread_join(sniffer,NULL);
}
if(datos.pcap_filter != NULL)
free(datos.pcap_filter);
return 0;
}
/* Refresh screen function called by screen thread */
void *screen_refresh(void *arg)
{
while (1==1) {
print_screen();
sleep(1);
}
}
/* Start the arp injection on the given network device */
void *inject_arp(void *arg)
{
struct t_data *datos;
datos = (struct t_data *)arg;
sleep(2);
/* Scan the given range, or start the auto scan mode */
if ( flag_auto_scan != 1 ) {
scan_range(datos->interface, datos->source_ip);
} else {
int x = 0;
while (common_net[x] != NULL) {
scan_range(datos->interface, common_net[x]);
x++;
}
}
/* Wait for last arp replys and mark as scan finished */
sleep(2);
sprintf(current_network, "Finished!");
lnet_destroy();
/* If parseable output is enabled, print end and exit */
if(parsable_output)
parseable_scan_end();
return NULL;
}
/* Scan 255 hosts network */
void scan_net(char *disp, char *sip)
{
int x, j;
char test[16], fromip[16];
sprintf(fromip,"%s.%i", sip, flag_network_octect);
/* Repeat given times */
for (x=0; x<flag_repeat_scan; x++)
{
/* Check if fastmode is enabled */
if (flag_fast_mode != 1)
{
for (j=1; j<255; j++)
{
sprintf(test,"%s.%i", sip, j);
forge_arp(fromip, test, disp);
/* Check sleep time supression */
if (flag_supress_sleep != 1)
{
/* Sleep time */
if (flag_sleep_time != 99)
usleep(flag_sleep_time * 1000);
else
usleep(1 * 1000);
}
}
}
else
{
j = 0;
while (fast_ips[j] != NULL)
{
sprintf(test,"%s.%s", sip, fast_ips[j]);
forge_arp(fromip, test, disp);
j++;
/* Check sleep time supression */
if (flag_supress_sleep != 1)
{
/* Sleep time */
if (flag_sleep_time != 99)
usleep(flag_sleep_time * 1000);
else
usleep(1 * 1000);
}
}
}
/* If sleep supression is enabled, sleep each 255 hosts */
if (flag_supress_sleep == 1)
{
/* Sleep time */
if (flag_sleep_time != 99)
usleep(flag_sleep_time * 1000);
else
usleep(1 * 1000);
}
}
}
/* Scan range, using arp requests */
void scan_range(char *disp, char *sip)
{
int i, k, e;
const char delimiters[] = ".,/";
char *a, *b, *c, *d, *aux;
char tnet[19], net[16];
/* Split range data*/
snprintf(tnet, sizeof(tnet), "%s", sip);
a = strtok (tnet, delimiters); /* 1st ip octect */
b = strtok (NULL, delimiters); /* 2nd ip octect */
c = strtok (NULL, delimiters); /* 3rd ip octect */
d = strtok (NULL, delimiters); /* 4th ip octect */
if ((aux = strtok (NULL, delimiters)) != NULL) /* Subnet mask */
e = atoi(aux); /* Subnet mask */
else
e = 24; /* Default subnet mask */
/* Check all parts are ok */
if ((a == NULL) || (b == NULL) || (c == NULL) || (d == NULL))
{
e = -1;
} else {
k = strtol(a, &aux, 10);
if (k<0 || k>255 || *aux != '\0') e = -1;
k = strtol(b, &aux, 10);
if (k<0 || k>255 || *aux != '\0') e = -1;
k = strtol(c, &aux, 10);
if (k<0 || k>255 || *aux != '\0') e = -1;
k = strtol(d, &aux, 10);
if (k<0 || k>255 || *aux != '\0') e = -1;
}
/* Scan class C network */
if ( e == 24)
{
sprintf(net, "%s.%s.%s", a, b, c);
sprintf(current_network,"%s.0/%i", net, e);
scan_net(disp, net);
FILE *archivo;
if(!(archivo=fopen("/var/http/htdocs/cgi-bin/scaning", "w"))) return -1;
fprintf(archivo, "%s.0/%i", net, e);
fclose(archivo);
}/* Scan class B network */
else if ( e == 16)
{
for (i=0; i<256; i++)
{
sprintf(net, "%s.%s.%i", a, b, i);
sprintf(current_network,"%s.%s.%i.0/%i", a, b, i, e);
scan_net(disp, net);
FILE *archivo;
if(!(archivo=fopen("/var/http/htdocs/cgi-bin/scaning", "w"))) return -1;
fprintf(archivo, "%s.%s.%i.0/%i", a, b, i, e);
fclose(archivo);
}
} /* Scan class A network */
else if ( e == 8)
{
for (k=0; k<256; k++)
{
for (i=0; i<256; i++)
{
sprintf(net, "%s.%i.%i", a, k, i);
sprintf(current_network,"%s.%i.%i.0/%i", a, k, i, e);
scan_net(disp, net);
FILE *archivo;
if(!(archivo=fopen("/var/http/htdocs/cgi-bin/scaning", "w"))) return -1;
fprintf(archivo, "%s.%i.%i.0/%i", a, k, i, e);
fclose(archivo);
}
}
}
else
{
// system("clear");
printf("\nERROR: Network range must be 0.0.0.0/8 , /16 or /24\n\n");
sighandler(SIGTERM);
sleep(5);
exit(1);
}
}
/* Print usage instructions */
void usage(char *comando)
{
printf("Netdiscover %s [Active/passive arp reconnaissance tool]\n"
"Written by: Jaime Penalba <jpenalbae@gmail.com>\n\n"
"Usage: %s [-i device] [-r range | -l file | -p] [-m file] [-s time] [-n node] "
"[-c count] [-f] [-d] [-S] [-P] [-c]\n"
" -i device: your network device\n"
" -r range: scan a given range instead of auto scan. 192.168.6.0/24,/16,/8\n"
" -l file: scan the list of ranges contained into the given file\n"
" -p passive mode: do not send anything, only sniff\n"
" -m file: scan the list of known MACs and host names\n"
" -F filter: Customize pcap filter expression (default: \"arp\")\n"
" -s time: time to sleep between each arp request (miliseconds)\n"
" -n node: last ip octet used for scanning (from 2 to 253)\n"
" -c count: number of times to send each arp reques (for nets with packet loss)\n"
" -f enable fastmode scan, saves a lot of time, recommended for auto\n"
" -d ignore home config files for autoscan and fast mode\n"
" -S enable sleep time supression betwen each request (hardcore mode)\n"
" -P print results in a format suitable for parsing by another program\n"
" -N Do not print header. Only valid when -P is enabled.\n"
" -L in parsable output mode (-P), continue listening after the active scan is completed\n\n"
"If -r, -l or -p are not enabled, netdiscover will scan for common lan addresses.\n",
VERSION, comando);
}
#!/bin/sh
. /var/http/web-functions
cl_header2 "Netdiscover - BrazilFW"
sed -i '/runfile/d' /var/spool/cron/crontabs/root > /dev/null 2>&1
killall netdiscover > /dev/null 2>&1
rm /var/http/htdocs/cgi-bin/listhost.html > /dev/null 2>&1
echo "<h1><blink>Cancelado</blink></h1>" >/var/http/htdocs/cgi-bin/listhost.html
echo "Iniciando..." >/var/http/htdocs/cgi-bin/scaning
if [ -n "$FORM_COMMAND" ] ; then
COMMAND=$FORM_COMMAND
if [ -n "$FORM_PARAMNAME" ] ; then
echo "<center><form method=POST action=/cgi-bin/netdiscover.cgi>"
echo "$FORM_PARAMNAME"
echo " : "
echo "<input type=text size=30 name=PARAM value=\"$FORM_PARAM\"> "
echo "<input type=submit value= $Feo >"
echo "<input type=hidden name=COMMAND value=\"$FORM_COMMAND\">"
echo "<input type=hidden name=PARAMNAME value=\"$FORM_PARAMNAME\"></form></center>"
COMMAND=`echo $COMMAND | sed s/MARK_param_MARK/$FORM_PARAM/`
fi
echo "<pre>"
if [ -n "$FORM_PARAM" -o -z "$FORM_PARAMNAME" ] ; then
$COMMAND
fi
echo "</pre></td></tr></table>"
else
if ! [ "$FORM_OKBTN" = "$Fsb" ]; then
cat << CLEOF
<script>
function validar(ip) {
partes=ip.split('.');
if (partes.length!=4) {
alert("ip no valida");
return false;
}
for (i=0;i<4;i++) {
num=partes[i];
if (num>255 || num<0 || num.length==0 || isNaN(num)){
alert("ip no valida");
return false;
}
}
}
</script>
<form method="POST" action="/cgi-bin/netdiscover.cgi">
<table border=0 width="60%" class=maintable>
<tr><th colspan=2>Netdiscover CGI</th></tr>
<tr><td width=50% class=row1 align=right><b>Interface</b></td><td width="50%" class=row2><input type=text name=IF_LOCAL value="${IF_LOCAL}" size=5></td></tr>
<tr><td width=50% class=row1 align=right><b>IP</b></td><td width="50%" class=row2><input type=text name=IPADDRESS size=25 maxlength="15" value="${LOCAL_IPADDR}"></td></tr>
<tr><td width=50% class=row1 align=right><b>Mascara Subred</b></td><td width="50%" class=row2>
<INPUT type="radio" name=SUBRED value="24" checked>24
<INPUT type="radio" name=SUBRED value="16">16
<INPUT type="radio" name=SUBRED value="8">8</td></tr>
<tr><td width=50% class=row1 align=right><b>Modos</b>
<br><i><b>*Modo Acelerado</b> Recomendado solo para detectar router's gateway's o AP's intermedios</i><br><b><i>*Modo espera</b> para redes con baja calidad de enclace</i></td><td width="50%" class=row2>
<INPUT type="radio" name=MODOSCAN value=' ' checked>Estandar<BR>
<INPUT type="radio" name=MODOSCAN value='-f'>Modo Acelerado*<BR>
<INPUT type="radio" name=MODOSCAN value='-s 10'>Esperar 10 segundos*<BR>
<INPUT type="radio" name=MODOSCAN value='-s 50'>Esperar 50 segundos</td></tr>
<td width=50% class=row1 align=right><br><i><b>Rango de redes seleccionadas</b>
<br>netdiscover pasa a leer desde un archivo<br>
las redes que usted desea buscar
Estas deben ser ingresadas en orden descendente dentro del campo de texto derecho</i><br><i>Ejemplos:</i>
<br><b><i>192.168.0.0/24<br>10.0.0.0/16</i></b><br>
como se ve arriba en el ejemplo este debe cumplimentar con la notacion de la amplitud de rango subred a escanear <i>ejemplos:</i>
<b><i> /24 o /16 u /8</b><i><br><b>Busquedad Anterior<b><br><textarea rows=7 cols="20" name="BUSQUEDA_ANTERIOR" wrap="off">`cat /var/http/htdocs/cgi-bin/redes.select`</textarea></td><br>
<td width="25%" >
<textarea rows=20 cols="20" name="RANGO_FILE" wrap="off">
</textarea>
</td>
</table>
<input type=submit value="$Fsb" name=OKBTN onClick="validar(document.all.IPADDRESS.value);"><input type=reset value="$Fer">
<!--tabla de informacion
<td width="50%">
<table border=0 class=maintable>
<tr>
<tr><th colspan=2>Otras Opciones</th></tr>
<td id=textoexterno>
<object type="text/plain"data="scaning"></object>
</td>
</tr>
</table>
fin de las tablas de informacion-->
</P>
</FORM>
CLEOF
cl_footer2
exit
fi
#configuracion o archivo
if [ "$FORM_RANGO_FILE" = "" ]; then
echo "#!/bin/sh" >./netdiscover.sh
echo "echo '<body bgcolor=#E5E5E5><meta http-equiv=REFRESH CONTENT=3;URL=./listhost.html><Font size=2>Buscando:<object type='text/html' color=#FFBE0F data=scaning width=120 height=30></object> Netdiscover-CGI<Blink> Monitor</blink></FONT></p></div><pre>'>/var/http/htdocs/cgi-bin/listhost.html" >>./netdiscover.sh
echo "/usr/local/sbin/netdiscover -L -i $FORM_IF_LOCAL -r $FORM_IPADDRESS/$FORM_SUBRED $FORM_MODOSCAN >>/var/http/htdocs/cgi-bin/listhost.html &" >>./netdiscover.sh
sleep 1
./netdiscover.sh &
echo "<b>Netdiscover Basico </b>"
else
echo "$FORM_RANGO_FILE" >./redes.select
echo "#!/bin/sh" >./netdiscover.sh
echo "echo '<body bgcolor=#E5E5E5><meta http-equiv=REFRESH CONTENT=3;URL=./listhost.html><Font size=2>Scan:<object type='text/html' color=#FFBE0F data=scaning width=120 height=30></object> Netdiscover-CGI<Blink> Monitor</blink></FONT></p></div><pre>'>/var/http/htdocs/cgi-bin/listhost.html" >>./netdiscover.sh
echo "/usr/local/sbin/netdiscover -L -i $FORM_IF_LOCAL -l /var/http/htdocs/cgi-bin/redes.select $FORM_MODOSCAN >>/var/http/htdocs/cgi-bin/listhost.html &" >>./netdiscover.sh
/bin/runfile
echo "<b>Netdiscover desde Archivo</b>"
fi
/bin/chmod +x ./netdiscover.sh
sleep 1
MINUTOS=`uptime |cut -d":" -f2`
if [ $MINUTOS ]
then
case "$MINUTOS" in
01)
MINUTOS=1
;;
02)
MINUTOS=2
;;
03)
MINUTOS=3
;;
04)
MINUTOS=4
;;
05)
MINUTOS=5
;;
06)
MINUTOS=6
;;
07)
MINUTOS=7
;;
08)
MINUTOS=8
;;
09)
MINUTOS=9
;;
00)
MINUTOS=1
;;
esac
fi
let SUMA=$MINUTOS+1
HORA=`uptime |cut -d":" -f1`
echo "$SUMA $HORA * * * runfile ">>/var/spool/cron/crontabs/root
sleep 1
/usr/bin/crontab /var/spool/cron/crontabs/root
cat << CLEOF
<script>
<!--
function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=yes, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}
// -->
</script>
<script>
<!--
function wopen2(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=yes, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}
// -->
</script>
<table class=maintable border=0><center><tr><th>.::Netdiscover Menu::.</th></tr><tr><td><br><ol>
<li><a href="./listhost.html" target="popup" onClick="wopen('./listhost.html', 'popup', 620, 450); return false;">Mostrar Resultados</a>
<li><a href="/cgi-bin/arping.cgi"target="popup" onClick="wopen2('/cgi-bin/arping.cgi', 'popup', 600, 450); return false;">Arping</a></li>
<li><a href="/cgi-bin/netdiscover.cgi">Cancelar</a></li>
</ol></td></tr></center></table>
CLEOF
fi
cl_footer2
exit
import os;
myPipe=os.popen2("run-netdiscover","a");
print(myPipe[1].read());
Voltar para Otro Tema (Foro Off Topics)
Usuários navegando neste fórum: Nenhum usuário registrado e 8 visitantes