Показать сообщение отдельно
  #1 (permalink)  
Старый 27.02.2012, 09:03
Новичок на форуме
Отправить личное сообщение для Jason Bourne Посмотреть профиль Найти все сообщения от Jason Bourne
 
Регистрация: 03.08.2008
Сообщений: 7

Идентификация пользователя и бан по ID
Существует система супербана, реализованная на одном сервисе форума, где генерируется уникальный ID компъютера на основе версий некоторых компонентов.
var key = screen.width + ' '+screen.height + ' ' + screen.colorDepth;
	var tz = -new Date().getTimezoneOffset()/60;
	var random = Math.floor(Math.random()*(99999-10000)+10000);
	key += ' ' + tz;

	var ie_info = '';
	if (isIE) {
		document.write('<xml:namespace ns=http://www.microsoft.com/ie prefix=IE><STYLE>@media all{IE\\:clientCaps {behavior:url(#default#clientcaps);}}</STYLE><IE:CLIENTCAPS ID="oClientCaps" />');
		key += ' ';
		if (oClientCaps.connectionType) ie_info += oClientCaps.connectionType + ' ';
		if (oClientCaps.cpuClass) ie_info += oClientCaps.cpuClass + ' ';
		if (oClientCaps.platform) ie_info += oClientCaps.platform + ' ';
		if (oClientCaps.systemLanguage) key += oClientCaps.systemLanguage + ' ';
		if (oClientCaps.userLanguage) key += oClientCaps.userLanguage + ' ';
		var bbb = new Array();
		var ccc = new Array(0,0,0,0);
		var CompO = new Array("{7790769C-0471-11D2-AF11-00C04FA35D02}","{89820200-ECBD-11CF-8B85-00AA005B4340}","{283807B5-2C60-11D0-A31D-00AA00B92C03}","{4F216970-C90C-11D1-B5C7-0000F8051515}","{44BBA848-CC51-11CF-AAFA-00AA00B6015C}","{9381D8F2-0288-11D0-9501-00AA00B911A5}","{36F8EC70-C29A-11D1-B5C7-0000F8051515}","{5A8D6EE0-3E18-11D0-821E-444553540000}","{89820200-ECBD-11CF-8B85-00AA005B4383}","{08B0E5C0-4FCB-11CF-AAA5-00401C608555}","{45EA75A0-A269-11D1-B5BF-0000F8051515}","{DE5AED00-A4BF-11D1-9948-00C04F98BBC9}","{22D6F312-B0F6-11D0-94AB-0080C74C7E95}","{44BBA842-CC51-11CF-AAFA-00AA00B6015B}","{3AF36230-A269-11D1-B5BF-0000F8051515}","{44BBA840-CC51-11CF-AAFA-00AA00B6015C}","{CC2A9BA0-3BDD-11D0-821E-444553540000}","{08B0E5C0-4FCB-11CF-AAA5-00401C608500}","{60B49E34-C7CC-11D0-8953-00A0C90347FF}","{03F998B2-0E00-11D3-A498-00104B6EB52E}","{0FDE1F56-0D59-4FD7-9624-E3DF6B419D0E}","{10072CEC-8CC1-11D1-986E-00A0C955B42F}","{1B00725B-C455-4DE6-BFB6-AD540AD427CD}","{4278C270-A269-11D1-B5BF-0000F8051515}","{44BBA855-CC51-11CF-AAFA-00AA00B6015C}","{4F645220-306D-11D2-995D-00C04F98BBC9}","{5FD399C0-A70A-11D1-9948-00C04F98BBC9}","{630B1DA0-B465-11D1-9948-00C04F98BBC9}","{6FAB99D0-BAB8-11D1-994A-00C04F98BBC9}","{C9E9A340-D1F1-11D0-821E-444553540600}","{D27CDB6E-AE6D-11CF-96B8-444553540000}","{E92B03AB-B707-11D2-9CBD-0000F87A369E}");
		if (typeof oClientCaps.getComponentVersion != 'undefined') {
			for (var iii = 0; iii < CompO.length; iii++) {
				var Ver = oClientCaps.getComponentVersion(CompO[iii], "ComponentID");
				var aaa = Ver.split(',');
				for (var jjj = 0; jjj < aaa.length; jjj++) {
					aaa[jjj]++; aaa[jjj]--; ccc[jjj] += aaa[jjj];
					random = ccc[0] + '' + ccc[1] + '' + ccc[2] + '' + ccc[3];
				}
			}
			ie_info += random;
		}
		//if (!ie_info) ie_info = 'no';
		key += ' ' + ddd;
	}


Я немного доработал этот код с учетом этой статьи. Получилось:

function get_id()
{
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

	var key = screen.width + ' '+screen.height + ' ' + screen.colorDepth;
	var tz = -new Date().getTimezoneOffset()/60;
	var random = Math.floor(Math.random()*(99999-10000)+10000);
	key += ' ' + tz;

	var ie_info = '';
	if (isIE) {
		document.write('<xml:namespace ns=http://www.microsoft.com/ie prefix=IE><STYLE>@media all{IE\\:clientCaps {behavior:url(#default#clientcaps);}}</STYLE><IE:CLIENTCAPS ID="oClientCaps" />');
		key += ' ';
		if (oClientCaps.connectionType) ie_info += oClientCaps.connectionType + ' ';
		if (oClientCaps.cpuClass) ie_info += oClientCaps.cpuClass + ' ';
		if (oClientCaps.platform) ie_info += oClientCaps.platform + ' ';
		if (oClientCaps.systemLanguage) key += oClientCaps.systemLanguage + ' ';
		if (oClientCaps.userLanguage) key += oClientCaps.userLanguage + ' ';
		var bbb = new Array();
		var ccc = new Array(0,0,0,0);
		var CompO = new Array("{7790769C-0471-11D2-AF11-00C04FA35D02}","{89820200-ECBD-11CF-8B85-00AA005B4340}","{283807B5-2C60-11D0-A31D-00AA00B92C03}","{4F216970-C90C-11D1-B5C7-0000F8051515}","{44BBA848-CC51-11CF-AAFA-00AA00B6015C}","{9381D8F2-0288-11D0-9501-00AA00B911A5}","{36F8EC70-C29A-11D1-B5C7-0000F8051515}","{5A8D6EE0-3E18-11D0-821E-444553540000}","{89820200-ECBD-11CF-8B85-00AA005B4383}","{08B0E5C0-4FCB-11CF-AAA5-00401C608555}","{45EA75A0-A269-11D1-B5BF-0000F8051515}","{DE5AED00-A4BF-11D1-9948-00C04F98BBC9}","{22D6F312-B0F6-11D0-94AB-0080C74C7E95}","{44BBA842-CC51-11CF-AAFA-00AA00B6015B}","{3AF36230-A269-11D1-B5BF-0000F8051515}","{44BBA840-CC51-11CF-AAFA-00AA00B6015C}","{CC2A9BA0-3BDD-11D0-821E-444553540000}","{08B0E5C0-4FCB-11CF-AAA5-00401C608500}","{60B49E34-C7CC-11D0-8953-00A0C90347FF}","{03F998B2-0E00-11D3-A498-00104B6EB52E}","{0FDE1F56-0D59-4FD7-9624-E3DF6B419D0E}","{10072CEC-8CC1-11D1-986E-00A0C955B42F}","{1B00725B-C455-4DE6-BFB6-AD540AD427CD}","{4278C270-A269-11D1-B5BF-0000F8051515}","{44BBA855-CC51-11CF-AAFA-00AA00B6015C}","{4F645220-306D-11D2-995D-00C04F98BBC9}","{5FD399C0-A70A-11D1-9948-00C04F98BBC9}","{630B1DA0-B465-11D1-9948-00C04F98BBC9}","{6FAB99D0-BAB8-11D1-994A-00C04F98BBC9}","{C9E9A340-D1F1-11D0-821E-444553540600}","{D27CDB6E-AE6D-11CF-96B8-444553540000}","{E92B03AB-B707-11D2-9CBD-0000F87A369E}");
		if (typeof oClientCaps.getComponentVersion != 'undefined') {
			for (var iii = 0; iii < CompO.length; iii++) {
				var Ver = oClientCaps.getComponentVersion(CompO[iii], "ComponentID");
				var aaa = Ver.split(',');
				for (var jjj = 0; jjj < aaa.length; jjj++) {
					aaa[jjj]++; aaa[jjj]--; ccc[jjj] += aaa[jjj];
					random = ccc[0] + '' + ccc[1] + '' + ccc[2] + '' + ccc[3];
				}
			}
			ie_info += random;
		}
		//if (!ie_info) ie_info = 'no';
		key += ' ' + ddd;
	}
	else
	{
		var ff_info = 'no';
		var bbb = new Array();
		var ccc = new Array(0,0,0,0);
		if(navigator.cpuClass) key += ' ' + navigator.cpuClass;
		if(navigator.platform) key += ' ' + navigator.platform;
		if(navigator.systemLanguage) key += ' ' + navigator.systemLanguage;
		if(navigator.userLanguage) key += ' ' + navigator.userLanguage;
		if(navigator.language) key += ' ' + navigator.language;
	  var prev
	  for(var i=0;i<navigator.plugins.length;i++) {
	    var plugin = navigator.plugins[i]
		var Ver = (plugin.version || '');
	    var plugin = plugin.name+" "+(plugin.version || '')
	    //if (prev == plugin ) continue
	    if(Ver == '') continue;
		var aaa = Ver.split('.');
		for (var jjj = 0; jjj < aaa.length; jjj++) {
			aaa[jjj]++; aaa[jjj]--; ccc[jjj] += aaa[jjj];
			random = ccc[0] + '' + ccc[1] + '' + ccc[2] + '' + ccc[3];
		}
	    //prev = plugin
	  }

	  ff_info += random;
	  key += ' ' + random;
	}
	return key;
}


Потом смотрел в базе данных и обнаружил, что ID таким способом можно получить не для всех браузеров. Хотя у многих получается. Часто в базу данных попадает только число random из строчки
var random = Math.floor(Math.random()*(99999-10000)+10000);


А как можно решить ту же задачу для браузеров Opera и Chrome? И правильно ли я делаю это для Firefox? Если нет, то как лучше?
UPD. Выяснил, что такой скрипт именно в Опере не работает.

Последний раз редактировалось Jason Bourne, 27.02.2012 в 09:24.
Ответить с цитированием