这篇文章介绍了当WordPress开启错误记录以后,根据error_log来发现SQL注入攻击的思路。% y3 k( T" w7 P" r& F
/ U; [: U9 y5 z" Q# W7 X2 N吸引Cocoa的是这个博客其实是TrustWave公司下属的一个叫Spiderlab团队的官方博客,貌似比较有意思。例如它提到了Honeypot Alert这个标签里的文章都是分析他们一个Web蜜罐的Apache access_log日志的。) R& a. @+ Y/ B1 W' t
0 \, g4 Q" P H2 J- Q
简单介绍一下这篇文章吧。 * v4 d" j) n% w" T( l! j* s4 X- k6 W) |
开启WP错误记录功能6 {4 e( ]* m3 R+ D' I: h3 P6 G
只需要修改wp-config.php的如下几行:# d1 z) V* w9 S* n" R
7 l( g; r! K- {& ^+ ^/ V& ] ?( T
@ini_set('log_errors','On'); @ini_set('display_errors','Off'); @ini_set('error_log','/home/example.com/logs/php_error.log');SQL 注入扫描2 T' r w% \# `, V
8 T+ t' k- \8 R" `1 v
[07-Dec-2012 02:40:49] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = -1\'' at line 1 for query SELECT text, author_id, date FROM WHERE id = -1\': E# W$ s3 {3 y6 `, A- t5 _
[07-Dec-2012 02:40:50] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 999999.9 UNION ALL SELECT 0x31303235343830303536--' at line 1 for query SELECT text, author_id, date FROM WHERE id = 999999.9 UNION ALL SELECT 0x31303235343830303536-- ' \2 _/ g) P; [4 s[07-Dec-2012 02:40:53] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 999999.9 UNION ALL SELECT 0x31303235343830303536,0x313032353438303035' at line 1 for query SELECT text, author_id, date FROM WHERE id = 999999.9 UNION ALL SELECT 0x31303235343830303536,0x31303235343830303536-- / L5 I- M6 Y( y% Z0 a( B& Q( h+ m上面的日志就是在暴力猜解表的列数,那个巨大的十六进制值会被解析成null。 2 r/ t9 S$ n4 R9 d
SQL盲注扫描" [5 C& a$ F0 u
攻击者使用了类似"waitfor delay"和"benchmark"这样的函数来盲注。 8 S U8 M; e8 o; X* u& `+ M. D/ r: H; d2 C' G
[07-Dec-2012 02:43:21] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = -1; if (1=1) waitfor delay \'00:00:05\'--' at line 1 for query SELECT text, author_id, date FROM WHERE id = -1; if (1=1) waitfor delay \'00:00:05\'-- # l3 F. D* C& }$ S$ t[07-Dec-2012 02:43:27] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = -1 and if(1=1,BENCHMARK(8623333,MD5(0x41)),0)' at line 1 for query SELECT text, author_id, date FROM WHERE id = -1 and if(1=1,BENCHMARK(8623333,MD5(0x41)),0) + h r+ }9 ~% P. rGoogle一下大规模扫描 0 L& Y0 E# ^0 t" L + O% b2 K4 ~: _+ s5 k" Y ! v: r) ~% I' r- j) v% ] [attach]163[/attach] . [ k, ?% N( P M$ Y9 Z3 G' }, x; h & _7 `% F5 \( C; {% Q4 G) M/ g6 k" r
2 t8 W% B* }- Q6 L 僵尸网络控制着可能使用被感染主机来识别潜在的目标。下面是该公司的蜜罐捕获到的一个RFI(远程文件包含)攻击代码里的片段:
sub google() { my @list; my $key = $_[0]; for (my $i=0; $i<=400; $i+=10){ my $search = ("http://www.google.com/search?q=".&key($key)."&num=100&filter=0&start=".$i); my $res = &search_engine_query($search); while ($res =~ m/<a href="\"?http:\/\/([^">\"]*)\//g) { if ($1 !~ /google/){ my $link = $1; my @grep = &links($link); push(@list,@grep); } } } return @list;$ d' v0 l) ~% @% R
4 J0 q1 u2 o4 @2 y1 R' S. E
Cocoa总结:文章比较简单,但是从日志来检测攻击貌似是目前流行的一个方向。" V' J8 B7 I: e) u/ m