Lo de obtener un identificador único del equipo es algo que ha desvelado a muchos desde hace tiempo. Una técnica vía javascript llamada Canvas Fingerprint se describe aquí:
https://browserleaks.com/canvas#how-does-it-work Se basa en las sutiles diferencias o entropía que se dan en la salida de una imagen generada por el elemento canvas de html5. Aunque el resultado no es totalmente exclusivo, como mencionan aquí:
https://en.wikipedia.org/wiki/Canvas_fingerprinting, sumado a la ip y/o a otras técnicas existentes similares (AudioContext fingerprint, webGL fingerprint) puede brindar un identificador bastante confiable.
Dejo un ejemplo en javascript
:
Código:
<script>
"use strict";
function bin2hex (s) {
// From: http://phpjs.org/functions
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Onno Marsman
// + bugfixed by: Linuxworld
// + improved by: ntoniazzi (http://phpjs.org/functions/bin2hex:361#comment_177616)
// * example 1: bin2hex('Kev');
// * returns 1: '4b6576'
// * example 2: bin2hex(String.fromCharCode(0x00));
// * returns 2: '00'
var i, l, o = "", n;
s += "";
for (i = 0, l = s.length; i < l; i++) {
n = s.charCodeAt(i).toString(16)
o += n.length < 2 ? "0" + n : n;
}
return o;
}
var canvas=document.createElement('canvas');
var txt = "BrowserLeaks,com <canvas> 1.0";
var ctx = canvas.getContext('2d');
ctx.textBaseline = "top";
ctx.font = "14px 'Arial'";
ctx.textBaseline = "alphabetic";
ctx.fillStyle = "#f60";
ctx.fillRect(125,1,62,20);
ctx.fillStyle = "#069";
ctx.fillText(txt, 2, 15);
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
ctx.fillText(txt, 4, 17);
var b64 = canvas.toDataURL().replace("data:image/png;base64,","");
var bin = atob(b64);
var myDeviceId = bin2hex(bin.slice(-16,-12));
alert(myDeviceId);
</script>
De obtención de IP hay varios códigos por ahí en php. Este es de
https://stackoverflow.com/questions/...-from-visitor: Código PHP:
<?PHP
function getUserIP()
{
// Get real visitor IP behind CloudFlare network
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}
$user_ip = getUserIP();
echo $user_ip; // Output IP address [Ex: 177.87.193.134]
?>