403Webshell
Server IP : 159.223.102.202  /  Your IP : 216.73.216.193
Web Server : nginx/1.26.0
System : Linux Gen1-cloudpanel2ubuntu2404-1vcpu-1gb-nyc1-01 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User : albasshbotta ( 1021)
PHP Version : 8.2.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/self/cwd/licen/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/cwd/licen/licence3.php
<?php
require_once "ip_bloqueadas.php";
require_once "system_log.php";
require_once "../clases/conexion.php";

//logo para nosotros
$l = new simplelog;
$l->entry();
//$l->display_log();

$ipHash = new IpBlock("hash_usados.ls", "back/",".bak");
$ipTest = new IpBlock("ip_blocks.ls", "back/",".bak");

//$_GET["user"] = "0f840338d213e212b4285dc9dff9efee7404972554edc5a89bce95177cbcab199bfba5c";

/**
* Fecha unificada con nuestro pais
*/
date_default_timezone_set('America/Buenos_Aires');

/**
* Tamano de la llave del usuario
*/
define("length_hash_user", "32");

/**
* LLave aleatoria
*/
define("length_key_aleatory", "7");

/**
* $ipCliente = $_SERVER['REMOTE_ADDR'];
*/ 
$ipCliente = $ipTest->get_client_ip();
$hash_user = isset($_GET["user"]) ? $_GET["user"] : null;

try{
    

if( !$ipTest->validateIp() )  //validar que la ip no este en la lista de bloqueadas
{
    header('HTTP/1.0 403 Forbidden');
    
    if ($hash_user != null) {
        $ipHash->addIpBlock( $hash_user );
    }

    $motivo = "Se intento recuperar licencia desde una IP bloqueada (Hash bloqueado). IP CLIENTE : $ipCliente, con Hash: $hash_user,  Fecha: " . date("Y-m-d H:i:s") . " \n ";
    $subject = 'Intento de recuperacion de licencia desde IP Bloqueada.' ;
    registrarActividad($ipCliente, $motivo, "", "+6");
    enviarAvisoAlertaSeguridad($ipCliente, $subject, $motivo );
}
else
{
    if( $hash_user == null || !$ipHash->validateHash( $hash_user )) //validar que el hash no halla sido utilizado previamente
    {
        header('HTTP/1.0 403 Forbidden');
		
        $ipTest->addIpBlock( $ipCliente );
        $subject = 'Intento de recuperacion de licencia con Hash repetido (IP Bloqueada)' ;
        $motivo = "Se intento recuperar licencia con Hash repetido. IP CLIENTE : $ipCliente,  Hash Repetido: " . $hash_user  . " , fecha: " . date("Y-m-d H:i:s") . " \n ";
        
        registrarActividad($ipCliente, $motivo, "", "+6");
        enviarAvisoAlertaSeguridad($ipCliente, $subject, $motivo );
    }
    else
    {
        $llave = $hash_user;

	$lenght_hash_user  = (int)length_hash_user;
	
	$length_key_aleatory = (int)length_key_aleatory;
	
	/*user hash que debe venir en el get*/
	$user_hash = substr($llave, 0 , $lenght_hash_user); 
	
	/* tiempo que viene inscrustado para que no se repita la solicitud */
	$time_hash = substr($llave, $lenght_hash_user , $length_key_aleatory);

	/* parametro cpu que viene en el get */
	$hash_param_cpu = substr($llave, $lenght_hash_user + $length_key_aleatory);
        
        $user = getUsuario($user_hash);
        
        if (count($user)==0) { 
        
        //usuario inexistente     
        header('HTTP/1.0 403 Forbidden');
		
        $ipTest->addIpBlock( $ipCliente );
        $subject = 'Intento de recuperacion de licencia con Usuario Inexistente (IP Bloqueada)' ;
        $motivo = "Se intento recuperar licencia con Usuario Inexistente. IP CLIENTE : $ipCliente,  Hash: " . $hash_user  . " , fecha: " . date("Y-m-d H:i:s") . " \n ";
        
        registrarActividad($ipCliente, $motivo, "", "+6");
        enviarAvisoAlertaSeguridad($ipCliente, $subject, $motivo );
                        
        }else
        {
			actualizarUltimoAcceso($user[0]["idUser"]);
			
            if ($user[0]["fechaBaja"]!= null) //usuario dado de baja
            {
                $subject = 'Intento de recuperacion de licencia con Usuario dado de Baja' ;
                $motivo = "Se intento recuperar licencia con Usuario dado de Baja (Orden Reiniciar BD). IP CLIENTE : $ipCliente,  Hash: " . $hash_user  . " , fecha: " . date("Y-m-d H:i:s") . " \n ";
                registrarActividad($ipCliente, $motivo, $user[0]["idUser"], "+12");
                enviarAvisoAlertaSeguridad($ipCliente, $subject, $motivo );
                
                header("Content-type: text/xml");
				echo "<license>4881jzrai29wfrfp3xwr9sifp6ib09mcp11qv49imyado4vueumodq9vbzg43j0g</license>";
                die;
                
		
                
            }else 
            {      
                if ($user[0]["ipFija"]!= "") {
                    $ipServidor = $user[0]["ipFija"];
                }else{
                    $ipServidor = gethostbyname($user[0]["no-ip"]);
                }
				//echo $ipCliente;
				//echo $ipServidor;
                if ($ipCliente != $ipServidor) {
                    //IP Incorrecta
		    header('HTTP/1.0 403 Forbidden');
                    //$ipTest->addIpBlock( $ipCliente ); //no bloqueo la ip pues si no-ip se ha retrasado al actualizar la ip esperada ya estara bloqueada la actual.
                    //$ipHash->addIpBlock( $hash_user ); //bloqueo si el hash utilizado pues al menos debera esperar a la proxima ejecucion
                    $pidUser = $user[0]["idUser"];
                    $motivo = "Se intento recuperar licencia IdUser:$pidUser desde una IP incorrecta(no bloqueada IP ni hash). IP CLIENTE : $ipCliente (IP esperada: $ipServidor), con Hash: $hash_user,  Fecha: " . date("Y-m-d H:i:s") . " \n ";
                    $subject = 'Intento de recuperacion de licencia desde IP incorrecta.' ;
                    registrarActividad($ipCliente, $motivo, $user[0]["idUser"], "+6");
                    enviarAvisoAlertaSeguridad($ipCliente, $subject, $motivo );
                    
                }else
                {
                    if ($hash_param_cpu != md5($user[0]["cpuid"])) 
                    {
                        //PC incorrecta
                        header("Content-type: text/xml");
                        echo "<license>4881jzrai29wfrfp3xwr9sifp6ib09mcp11qv49imyado4vueumodq9vbzg43j0g</license>";   
                        
                        $cpu = $user[0]["cpuid"];
                        $motivo = "Se intento recuperar licencia desde una CPU incorrecta(Orden Reiniciar BD). IP CLIENTE : $ipCliente (CPU esperada: $cpu ), con Hash: $hash_user,  Fecha: " . date("Y-m-d H:i:s") . " \n ";
                        $subject = 'Intento de recuperacion de licencia desde IP incorrecta.' ;
                        registrarActividad($ipCliente, $motivo, $user[0]["idUser"], "+12");
                        enviarAvisoAlertaSeguridad($ipCliente, $subject, $motivo );
                    die;
                    }else
                    {//todo correcto devolver ultima licencia valida y guardar hash
                        $ipHash->addHashBlock( $hash_user );
                        $tidUser = $user[0]["idUser"];
						$idLicen = getIdLicense($user[0]["idUser"]);
                        $motivo = "Recuperacion Exitosa de Licencia ($idLicen) cliente ID:$tidUser (Guardado Hash). IP CLIENTE : $ipCliente, con Hash: $hash_user,  Fecha: " . date("Y-m-d H:i:s") . " \n ";
                        $subject = "Recuperacion Exitosa de Licencia (ID: $tidUser)" ;
                        registrarActividad($ipCliente, $motivo, $user[0]["idUser"], "0");
                        enviarAvisoAlertaSeguridad($ipCliente, $subject, $motivo );
                        header("Content-type: text/xml");
                        $licen = getKey($user[0]["idUser"]);
                        echo "<license>" . $licen ."</license>";
                        die; 	
                        
                    }

                }
            }
        }
    }
}
}catch(Exception $e)
{
    $motivo = "Error en script de licencias: ". $e->getMessage();
    $subject = 'Error en script de licencias.' ;
    enviarAvisoAlertaSeguridad("", $subject, $motivo );   
}

function getUsuario($Key){
    $con=new conexion;
    $link=$con->GetLink();


    $sql="SELECT * FROM usuarios WHERE userKey = '$Key';";

    $result=mysqli_query($link,$sql);

    if($result){
            $i=0;
            while($rs=mysqli_fetch_array($result)){

            $arKeys = array_keys($rs);
            foreach($arKeys as $key)
            {
                    $array_mails[$i][$key] = $rs[$key];
            }
                    $i++;
            }

    }
    mysqli_close($link);
    return $array_mails;
		
}

function getKey($idUsuario){
    $con=new conexion;
    $link=$con->GetLink();


    $sql="SELECT licenses.key FROM licenses WHERE idUser ='$idUsuario' AND fechaDesde = (SELECT MAX(fechaDesde) FROM licenses WHERE idUser ='$idUsuario' AND  DATE_FORMAT(fechaDesde,'%Y-%m-%d 00:00:00')<= NOW())";

    $result=mysqli_query($link,$sql);

    if($result){
            $i=0;
            while($rs=mysqli_fetch_array($result)){
                $key = $rs["key"];
            }
    }
    mysqli_close($link);
    return $key;
		
}

function getIdLicense($idUsuario){
    $con=new conexion;
    $link=$con->GetLink();


    $sql="SELECT licenses.idLicense FROM licenses WHERE idUser ='$idUsuario' AND fechaDesde = (SELECT MAX(fechaDesde) FROM licenses WHERE idUser ='$idUsuario' AND  DATE_FORMAT(fechaDesde,'%Y-%m-%d 00:00:00')<= NOW())";

    $result=mysqli_query($link,$sql);

    if($result){
            $i=0;
            while($rs=mysqli_fetch_array($result)){
                $id = $rs["idLicense"];
            }
    }
    mysqli_close($link);
    return $id;
		
}

function actualizarUltimoAcceso($idUsuario){
    $con=new conexion;
    $link=$con->GetLink();


    $sql="UPDATE usuarios SET ultimoAc = NOW() WHERE idUser = '$idUsuario'";

    $result=mysqli_query($link,$sql);

    mysqli_close($link);
		
}

/**
* Enviar alerta de seguridad
* @param string $ipCliente
* @param string $subject
* @param string $motivo
*/
function enviarAvisoAlertaSeguridad($ipCliente, $subject, $mensaje ){
        //mandar email avisando situacion

        require_once '../clases/class.phpmailer.php';

        $enviado = false;

        $owner_email = "licencias@bottaingenieria.com.ar";

        $messageBody = "<body>";
        $messageBody .= '<p>Reporte Incidente de Seguridad en Gestor de Licencias: </p>' . "\n";
        $messageBody .= "<p>$mensaje</p>";
        $messageBody .= "</body>";

        //if($_POST["stripHTML"] == 'true'){
        $messageBody = strip_tags($messageBody);
        //}

        try{
                //crear objeto mail
                $mail = new PHPMailer(); // defaults to using php "mail()"

                //fijar destinatario/s
                $mail->CharSet="utf-8";

                $mail->AddAddress("hernan@bottaingenieria.com.ar" , "Hernan");
				$mail->AddAddress("bottaingenieria@gmail.com" , "Hernan");

                //fijar a quien responder
                $mail->AddReplyTo("noresponder@bottaingenieria.com.ar", "NO RESPONDER");

                //fijar quien lo mando! esto esta especial para pescar despistados
                $mail->SetFrom("licencias@bottaingenieria.com.ar", "Gestor de Licencias");

                //fijar Copia Carbon Oculta - esto no me anduvo
//			$mail->AddBCC('hernan.botta@sametsis.com.ar', 'Contacto');
//			$mail->AddBCC('leandro.caballero@sametsis.com.ar', 'Contacto');

                //Asunto
                $mail->Subject = $subject;

                //cuerpo alternativo si el cliente de email no soporta html
                $mail->AltBody = "Para ver el mensaje, por favor utiliza un cliente con soporte HTML!"; 

                $mail->MsgHTML($messageBody);    

                if(!$mail->Send()){
                    $mensaje = "Error al enviar email: " . $mail->ErrorInfo . " Mensaje: " . $mensaje;
                    registrarActividad($ipCliente, $mensaje, "", "");
                }

        }catch(Exception $e){
                $enviado = false;
                $motivo = "error: ". $e->getMessage();
        }
}
        
        
function registrarActividad($ipCliente, $mensaje, $idUser, $contador)
{
    //conexion mysql
    $con = new conexion();
    $link = $con ->GetLink();

    $query = "INSERT INTO `actlicense` (`idUser`,`fecha`,`ip`,`respuesta`,`contador`)
                      VALUES ('$idUser', NOW( ),'$ipCliente', '$mensaje','$contador' )";

    $result = mysqli_query( $link,$query);
    
    
    $count="SELECT COUNT(*) AS cantidad FROM actlicense WHERE idUser = '$idUser';";
			$result = mysqli_query($link,$count);
			if($result){
				if($row=mysqli_fetch_assoc($result)){
					if($row['cantidad']>250){
						//rutina eliminar
						$delete="DELETE FROM actlicense WHERE idUser = '$idUser' ORDER BY fecha ASC LIMIT 50;";
						$result = mysqli_query($link,$delete);
					}
				}
			}
    
    mysqli_close($link);
}

die;

//


?>

Youez - 2016 - github.com/yon3zu
LinuXploit