[Tool] Is Online v2.0 (By 2Fac3R)

Iniciado por 2Fac3R, Febrero 07, 2013, 09:13:32 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Febrero 07, 2013, 09:13:32 PM Ultima modificación: Marzo 22, 2014, 01:55:14 PM por Expermicid
Buenas, acabo de mejorar el código que tenía de este pequeño script en php, sirve para verificar si un servidor está online. Tiene diseño kaker xD

Código: php

<!DOCTYPE html>
<title> Is online? v2.0 By 2Fac3R</title>
<style>
body,html{
background-color:black;
color:green;
}
#ok{
font-weight:bold;
}
#bad{
font-weight:bold;
color:red;
}
</style>
<center>
<pre>
.___         ________         .__  .__            _________
|   | ______ \_____  \   ____ |  | |__| ____   ___\_____   \
|   |/  ___/  /   |   \ /    \|  | |  |/    \_/ __ \ /   __/
|   |\___ \  /    |    \   |  \  |_|  |   |  \  ___/|   |   
|___/____  > \_______  /___|  /____/__|___|  /\___  >___|   
         \/          \/     \/             \/     \/<___>   
</pre>

<?php
/*
¿Is online? 2.0 By 2Fac3R
Verificar si un servidor esta online
*/
$page = htmlentities($_POST['page'], ENT_QUOTES ,'utf-8');
$send = $_POST['send'];

function verificar($url){
if(filter_var($url,FILTER_VALIDATE_URL) or filter_var($url,FILTER_VALIDATE_IP)){
echo fopen($url,'r') ? "$url <div id='ok'>Online</div>" : "$url <div id='bad'>Offline</div>";
}else{
echo '<script>alert("URL/IP no valida!");window.location=""</script>';
}
}

if(!empty($page)){
verificar($page);
}else{
if(isset($send)){
?>
<script>
alert("Debes ingresar una URL!");
window.location=""</script>
<noscript>
<?die("Debes ingresar una URL! <a href=''><b> Regresar! </b> </a>")?>
</noscript><?
}
?>
<form action="" method="POST">
URL: <input type="text" name="page" value="http://">
<input type="submit" name="send" value="Comprobar!">
</form> <br> <i>By 2Fac3R</i> <br> <br>

<?}?>
<br><b>Gr33tz to:</b> <br> <br>
   
   xt3mp, arcangel_nigth, ANTRAX, 11Sep, Kr34t0r, GAMARRA, SkippyCreammy, v1c0_h4ck <br>
   w4rning, Snifer, arthusu, Kodeinfect, [Q]3rV[0], WilyXem, m3x1c0h4ck, etc, etc, etc ... <br> <br>
   <a href="http://www.underc0de.org"><b>Underc0de.Org</b></a>
   </center>


Espero les sirva de algo :P
Zalu2
Sólo el conocimiento te hace libre.

Hola, está super buena tu herramienta y bastante útil pero tiene un defecto y es que valida urls no externas y genera un path disclosure.

Por ejemplo si vamos a:
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Dice:
CitarValidates value as URL (according to » No tienes permitido ver los links. Registrarse o Entrar a mi cuenta), optionally with required components. Beware a valid URL may not specify the HTTP protocol http:// so further validation may be required to determine the URL uses an expected protocol, e.g. ssh:// or mailto:. Note that the function will only find ASCII URLs to be valid; internationalized domain names (containing non-ASCII characters) will fail.

Por lo tanto quiere decir que tu script validará tambien las urls de tipo ssh:// y mailto:, que pasa si le damos urls falsas pero válidas?
Citarmailto:[email protected]

CitarWarning: fopen(mailto:[email protected]): failed to open stream: No such file or directory in test.php on line x
mailto:[email protected]
Offline

Eso podría desvelar la url del script y es un tema un tanto peligroso porque es un dato muy valioso al momento de realizar un ataque.

Tambien sería bueno que manejara sesiones por ip en una pequeña base de datos para prevenir el uso abusivo del sistema y lanzar ataques de ddos con esto. Por ejemplo digamos que tu script está siendo usado en 7 sitios webs distintos, entonces haces un robot que haga cientos de peticiones a esos 7 servidores y que apunten a un mismo host para darle de baja el servicio WEB.

Son detalles cosmeticos pero igual para uso personal está bien :)

Saludos.
- No tienes permitido ver los links. Registrarse o Entrar a mi cuenta - No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Muy buena info me das brot...

En teoría está hecho para uso propio...

La verdad es que no se me ocurre cómo arreglar el asunto del FPD, pensé en quitar los tipos de errores [error_reporting(0)] o quebrarme la cabeza con expresiones regulares para evitar direcciones de tipo ssh:// y mailto:...

¿Qué me recomiendas?

Zalu2
Sólo el conocimiento te hace libre.

Lista blanca:

Código: php
<?php
/*
¿Is online? 2.0 By 2Fac3R
Verificar si un servidor esta online
*/
?>
<!DOCTYPE html>
<html>
<head>
<title> Is online? v2.0 By 2Fac3R</title>
<style type="text/css">
body,html{ background-color: #000000; color: #00FF00; }
#ok{ font-weight: bold; }
#bad{ font-weight: bold; color: #FF0000; }
._contenido{ text-align: center; }
a{ color: #FFFFFF; }
</style>
</head>
<body>
<div class="_contenido">
<pre>
.___         ________         .__  .__            _________
|   | ______ \_____  \   ____ |  | |__| ____   ___\_____   \
|   |/  ___/  /   |   \ /    \|  | |  |/    \_/ __ \ /   __/
|   |\___ \  /    |    \   |  \  |_|  |   |  \  ___/|   | 
|___/____  > \_______  /___|  /____/__|___|  /\___  >___| 
         \/          \/     \/             \/     \/<___> 
</pre>
<?php
if(isset($_POST['page'])){
if(
(substr(strtolower((string)$_POST['page']), 0, 7) === 'http://') or
(substr(strtolower((string)$_POST['page']), 0, 8) === 'https://') or
(substr(strtolower((string)$_POST['page']), 0, 6) === 'ftp://') or
(substr(strtolower((string)$_POST['page']), 0, 6) === 'ssh://')
){
if(fopen((string)$_POST['page'], 'r'))
echo htmlspecialchars((string)$_POST['page'], ENT_QUOTES, 'ISO-8859-1').' <div id="ok">Online</div>';
else
echo htmlspecialchars((string)$_POST['page'], ENT_QUOTES, 'ISO-8859-1').' <div id="bad">Offline</div>';
}else
echo 'URL no v&aacute;lida.';
}
?>
<p>
<form action="?" method="post">
URL: <input type="text" name="page" placeholder="http://example.com/" />
<input type="submit" value="Comprobar!">
</form>
</p>
<p><i>By 2Fac3R</i></p>
<br />
<p><b>Gr33tz to:</b></p>
<p>
xt3mp, arcangel_nigth, ANTRAX, 11Sep, Kr34t0r, GAMARRA, SkippyCreammy, v1c0_h4ck, <br />
w4rning, Snifer, arthusu, Kodeinfect, [Q]3rV[0], WilyXem, m3x1c0h4ck, etc, etc, etc ...
</p>
<br />
<p>
<a href="http://www.underc0de.org"><b>Underc0de.Org</b></a>
</p>
</div>
</body>
</html>


Saludos.
- No tienes permitido ver los links. Registrarse o Entrar a mi cuenta - No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Muy bueno brot, el problema es que esa no es una buena forma de validar, ya que si agregara algo como "http://@" me tiraría un error y aparece de nuevo el FPD.

PD: Gracias por la corrección del diseño ;D jeje

Zalu2
Sólo el conocimiento te hace libre.

Nop, si pruebas:

Código: php
<?php
if(fopen('http://x:[email protected]/', 'r'))
echo 1;
else
echo -1;


Retnará "1"

Lo que si da problemas es al momento de buscar un host inexistente, ahi da un error como este:

Código: php
<?php
if(fopen('http://ss.ss', 'r'))
echo 1;
else
echo -1;


CitarWarning: fopen(): php_network_getaddresses: getaddrinfo failed: Host desconocido. in .../c.php on line 2

Warning: fopen(No tienes permitido ver los links. Registrarse o Entrar a mi cuenta): failed to open stream: php_network_getaddresses: getaddrinfo failed: Host desconocido. in .../c.php on line 2
-1

En ese caso fopen() debería llevar un @ o un error_reporting(0):

Código: php
<?php
if(@fopen('http://ss.ss', 'r'))
echo 1;
else
echo -1;


Retorna "-1"
- No tienes permitido ver los links. Registrarse o Entrar a mi cuenta - No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Entonces para evitarnos el FPD no hay de otra que no mostrar errores...

Código: php

<!DOCTYPE html>
<meta charset="UTF-8" />
<title> Is online? 2.1 By 2Fac3R</title>
<style type="text/css">
body,html{
background-color: #000000;
color: #00FF00;
}
#ok{
font-weight:bold;
}
#bad{
font-weight:bold;
color:#FF0000;
}
._contenido{
text-align:center;
}
a{
color: #FFFFFF;
}
</style>
<div class="_contenido">
<pre>
.___         ________         .__  .__            _________
|   | ______ \_____  \   ____ |  | |__| ____   ___\_____   \
|   |/  ___/  /   |   \ /    \|  | |  |/    \_/ __ \ /   __/
|   |\___ \  /    |    \   |  \  |_|  |   |  \  ___/|   |   
|___/____  > \_______  /___|  /____/__|___|  /\___  >___|   
         \/          \/     \/             \/     \/<___>   
</pre>

<?php
/*
¿Is online? 2.1 By 2Fac3R
Verificar si un servidor esta online
*/
$page = htmlentities($_POST['page'], ENT_QUOTES ,'UTF-8');
$send = $_POST['submit'];
define(ERROR,'<script>alert("URL no válida!");window.location=""</script>');

function validar($page){
if(
(substr(strtolower((string)$page), 0, 7) === 'http://') or
    (substr(strtolower((string)$page), 0, 8) === 'https://') or
    (substr(strtolower((string)$page), 0, 6) === 'ftp://')
){
    verificar($page);
    }else{
    echo ERROR;
    }
}

function verificar($url){

if(filter_var($url,FILTER_VALIDATE_URL)){
echo @fopen($url,'r') ? "$url <div id='ok'>Online</div>" : "$url <div id='bad'>Offline</div>";
}else{
echo ERROR;
}
}

if(!empty($page)){
validar($page);
}else{
if(isset($send)){
// Si en el campo de texto no se ingreso nada...
?>
<script>
alert("Debes ingresar una URL!");
window.location=""</script>
<noscript>
<?die("Debes ingresar una url! <a href=''><b> Regresar! </b> </a>")?>
</noscript><?
}
}
?>
<form action="" method="POST">
URL: <input type="text" name="page" placeholder="http://example.com">
<input type="submit" name="submit" value="Comprobar!">
</form> <br> <i>By 2Fac3R</i> <br> <br>

<br><b>Gr33tz to:</b> <br> <br>
   
   xt3mp, arcangel_nigth, ANTRAX, 11Sep, Kr34t0r, GAMARRA, SkippyCreammy, v1c0_h4ck <br>
   w4rning, Snifer, arthusu, Kodeinfect, [Q]3rV[0], WilyXem, m3x1c0h4ck, WHK, etc, etc, etc ... <br> <br>
   <a href="http://www.underc0de.org"><b>Underc0de.Org</b></a>
   </div>


Dime qué opinas....
Zalu2
Sólo el conocimiento te hace libre.

Que también tiene Path Disclosure xD

Código: php
$page = htmlentities($_POST['page'], ENT_QUOTES ,'UTF-8');


cuando le pasas $_POST['page'] que se supone que es un valor nulo porque no se ha enviado ninguna petición post te va a mostrar un error de php porque htmlspecialchars no devuelve un false, simplemente muestra un error re rutina de php.

A demás también debería mostrar un warning en algunos servidores con php configurado para mostrar warnings ya que $_POST['page'] no está definido tampoco, al tratar de acceder a un array inválido también da errores :p
- No tienes permitido ver los links. Registrarse o Entrar a mi cuenta - No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Será porque me duele la cabeza y que llevo ya un buen rato programando que no entendí ni papa xDDDDD.

Uso el valor por defecto en el php.ini: E_ALL & ~E_NOTICE

No le paso el valor hasta que se envia el formulario, por lo tanto no es nulo.

O no te entendí o ya no sé ni lo que digo xD...
Zalu2
Sólo el conocimiento te hace libre.

Acabo de darme cuenta que he estado acostumbrado a una forma "incorrecta" (o diferente) de programar, y la verdad es que he aprendido algo hoy jeje  ;D

Código: PHP

<!DOCTYPE html>
<meta charset="UTF-8" />
<title> Is online? 2.1 By 2Fac3R</title>
<style type="text/css">
body,html{
background-color: #000000;
color: #00FF00;
}
#ok{
font-weight:bold;
}
#bad{
font-weight:bold;
color:#FF0000;
}
._contenido{
text-align:center;
}
a{
color: #FFFFFF;
}
</style>
<div class="_contenido">
<pre>
.___         ________         .__  .__            _________
|   | ______ \_____  \   ____ |  | |__| ____   ___\_____   \
|   |/  ___/  /   |   \ /    \|  | |  |/    \_/ __ \ /   __/
|   |\___ \  /    |    \   |  \  |_|  |   |  \  ___/|   |   
|___/____  > \_______  /___|  /____/__|___|  /\___  >___|   
         \/          \/     \/             \/     \/<___>   
</pre>

<?php
/*
¿Is online? 2.1 By 2Fac3R
Verificar si un servidor esta online
*/

define('MAX',67); // Maximo numero de caracteres permitidos en un dominio
function validar($page){

if(

(strlen($page) <= MAX) and (
(substr(strtolower((string)$page), 0, 7) === 'http://') or
    (substr(strtolower((string)$page), 0, 8) === 'https://') or
    (substr(strtolower((string)$page), 0, 6) === 'ftp://')
)){
    verificar($page);
    }else{
    echo 'Url no válida!';
    }
}

function verificar($url){
if(filter_var($url,FILTER_VALIDATE_URL)){
echo @fopen($url,'r') ? "$url <div id='ok'>Online</div>" : "$url <div id='bad'>Offline</div>";
}else{
echo 'Ha ocurrido un error!';
}
}


if(!empty($_POST['page'])){
validar($_POST['page']);
}
?>
<form action="" method="POST">
URL: <input type="text" name="page" placeholder="http://example.com">
<input type="submit" value="Comprobar!">
</form>

<br> <i>By 2Fac3R</i> <br> <br>

<br><b>Gr33tz to:</b> <br> <br>
   
   xt3mp, arcangel_nigth, ANTRAX, 11Sep, Kr34t0r, GAMARRA, SkippyCreammy, v1c0_h4ck <br>
   w4rning, Snifer, arthusu, Kodeinfect, [Q]3rV[0], WilyXem, m3x1c0h4ck, WHK, etc, etc, etc ... <br> <br>
   <a href="http://www.underc0de.org"><b>Underc0de.Org</b></a>
   </div>



¿Qué opinas?

Zalu2
Sólo el conocimiento te hace libre.

Buen aporte de todos, aprendiendo a fullll programación con PHP!!  ;D

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta