Skip to content


PHP源代码安全漏洞自动化挖掘工具RIPS

RIPS是一个用php编写的源代码分析工具,它使用了静态分析技术,能够自动化地挖掘PHP源代码潜在的安全漏洞。渗透测试人员可以直接容易的审阅分析结果,

而不用审阅整个程序代码。由于静态源代码分析的限制,漏洞是否真正存在,仍然需要代码审阅者确认。RIPS能够检测XSS, SQL注入, 文件泄露,Header Injection漏洞等。

官方网站:http://rips-scanner.sourceforge.net/
目前最新版为rips-0.53.zip



使用方法:
下载后解压到web目录,然后访问此目录,输入需检测的路径(/var/www/web1)后提交

Posted in 安全.

Tagged with , , .


MariaDB/MySQL 概率性任意密码(身份认证)登录漏洞 建议升级到5.5.24以上(CVE-2012-2122)

漏洞版本:
All MariaDB
MySQL 5.1.61, 5.2.11, 5.3.5, 5.5.22 之前的版本
漏洞描述:

当连接MariaDB/MySQL时,输入的密码会与期望的正确密码比较,由于不正确的处理,会导致即便是memcmp()返回一个非零值,也会使MySQL认为两个密码是相同的。

也就是说只要知道用户名,不断尝试就能够直接登入SQL数据库。按照公告说法大约256次就能够蒙对一次。而且漏洞利用工具已经出现。

不过,MySQL身份认证的时候是采用3元组,username,ip,password。如果client的IP在mysql.user表中找不到对应的,也无法登陆。

http://seclists.org/oss-sec/2012/q2/493

安全建议:

强烈建议升级官方补丁:
目前有mysql5.5.25下载
http://dev.mysql.com/downloads/mysql/

Percona-Server-5.5.24-rel26.0.tar.gz

MariaDB 5.1.62, 5.2.12, 5.3.6, 5.5.23
MySQL 5.1.63, 5.5.24, 5.6.6

临时解决办法:
在防火墙上关闭mysql端口

参考:
http://sebug.net/vuldb/ssvid-60198
http://www.chinaz.com/news/2012/0612/256965.shtml
http://seclists.org/oss-sec/2012/q2/493

============== 补充说明 ==================
这个 Bug 在官方编译的版本中没有发现。如果你是下载的源码,然后自己编译的就有可能遇到这个问题。
这个问题和 memcmp() 这个函数的返回值有关系。目前知道的情况来看,gcc 自带的 memcmp 是安全的,BSD libc 的 memcmp 是安全的。Linux glibc sse 优化过的 memcmp 会有这个问题。

针对该漏洞 Percona Server 发表了说明如下:

很多人听说了 MySQL 的登录漏洞后纷纷询问 Percona Server 是否受此问题影响,因此我们决定有必要发表一下说明:

该问题存在于 MySQL 5.5.23(5.1.62) 以及之前版本的源码中,因为基于同一个源码库,因此 Percona Server 也有同样的问题。
但是,Percona 提供的二进制安装文件不存在此问题,因为构建过程我们没有使用 sse-optimized glibc memcmp,所有版本的 Percona 都如此,包括 tar.gz, RPM and DEB 包,如果你使用的是从 Percona 下载页 获取的软件并进行安全,那么请不用担心,这个漏洞对你没有任何影响。
如果你使用是你自己或者第三方二进制版,我们没法保证是否安全,你可执行进行测试,测试脚本在这里
另外你也可以考虑升级到最新的版本。

http://www.oschina.net/news/29899/mysql-root-bug

Posted in Mysql, 安全通告.

Tagged with , .


centos5.8 LINUX 安装PPTP VPN

其它VPN还有IPSEC VPN,L2TP VPN几种,PPTP最简便,IPSEC VPN最通用,各个平台都支持,L2TP VPN最安全

一.下载与安装PPTP

1.pptpd
由于Linux本身并没有集成PPTP功能,所以需要安装相关组件以让我们的RedHat支持PPP,根据内核的版本,下载相应的安装包
我这里是centos5.8 64位
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.rhel5.x86_64.rpm
32位用这个
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.rhel5.i386.rpm
安装pptpd
rpm -ivh pptpd-1.3.4-2.rhel5.x86_64.rpm

2.ppp支持
PPTP需要PPP支持,虽然系统本身有PPP功能,但它并不支持MPPE,所以需要更新系统的PPP组件,
yum -y install ppp

3.MPPE支持
用以下命令检查PPP是否支持MPPE(Microsoft Point to Point Encryption,微软点对点加密):

#strings ‘/usr/sbin/pppd’|grep -i mppe|wc –lines

42 如果以上命令输出为“0”则表示不支持;输出为“30”或更大的数字就表示支持,我这里为42。

如果不支持需安装相应的包

#wget http://poptop.sourceforge.net/yum/stable/packages/dkms-2.0.17.5-1.noarch.rpm
#rpm –ivh dkms-2.0.17.5-1.noarch.rpm
#rpm –ivh kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm

用以下命令检查内核MPPE补丁是否安装成功,MPPE module可否载如:

#modprobe ppp-compress-18 && echo success

二.修改配置文件
1.添加dns及客户端IP地址

echo “ms-dns 8.8.8.8” >> /etc/ppp/options.pptpd
echo “ms-dns 8.8.4.4” >> /etc/ppp/options.pptpd
echo “localip 192.168.10.1” >> /etc/pptpd.conf
echo “remoteip 192.168.10.2-100” >> /etc/pptpd.conf

2.添加VPN用户
/etc/ppp/chap-secrets

echo “pptpuser pptpd pptppass *” >> /etc/ppp/chap-secrets

3.创建设备文件

mknod /dev/ppp c 108 0

4.打开ip转发

echo 1 > /proc/sys/net/ipv4/ip_forward
sed -i ‘/net.ipv4.ip_forward / {s/0/1/g} ‘ /etc/sysctl.conf

5.打开iptables端口

/sbin/iptables -A INPUT -p gre -j ACCEPT
/sbin/iptables -A INPUT -p tcp -m state –state NEW -m tcp –dport 47 -j ACCEPT

/sbin/iptables -A INPUT -p tcp -m tcp –dport 1723 -j ACCEPT
#OpenVZ venet0:0
#/sbin/iptables -t nat -A POSTROUTING -s ${PPTPIPAREA} -j SNAT –to-source `ifconfig | grep ‘inet addr:’| grep -v ‘127\.0\.0\.’ | grep -v ’10\.’ | grep -v ‘172\.’ | grep -v ‘192\.’ | cut -d: -f2 | awk ‘NR==1 { print $1}’`
# For Xen and KVM
/sbin/iptables -t nat -A POSTROUTING -s 192.168.10/24 -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -p tcp -–syn -s 192.168.10/24 -j TCPMSS –-set-mss 1356

保存

/etc/init.d/iptables save

6.开启pptpd

chkconfig pptpd on

/etc/init.d/pptpd stop
/etc/init.d/pptpd start

7.查看日志

tail -f /var/log/messags

三.客户端连接vpn

1. 打开 Windows控制面板 –> 网络和Internet连接,点击下图所示的“创建一个到您的工作位置的网络连接”
2. 选择“虚拟专用网络连接”,点击下一步
3. 填入一个连接名称,可以随意填写,当然最好是一个容易区分的名称,比如“vpn”
4. 填入VPN服务器的域名或者IP地址,请向你的VPN服务商索取(包括用户名和密码)
5. 创建VPN连接最后一步,可以选择“在我的桌面上添加一个到此连接的快捷方式”,点击“完成”
6. 在桌面上可以看到一个VPN连接的快捷方式,双击打开登录界面。
7. 填入VPN服务的用户名和密码,在vpn 连接窗口,单击“属性”;
8、 选择“安全”属性页,选择“高级(自定义设置)”,单击“设置”;
9. 在“数据加密”中选择“可选加密(没有加密也可以连接)”,在“允许这些协议”选中”Microsoft CHAP (MS-CHAP)(M) ”、 ”Microsoft CHAP版本2(MS-CHAP V2)(I) ”;
10. 选择“网络”属性页面,在“VPN 类型”选择“PPTP VPN”确认Inernet 协议(TCP/IP)、、“微软网络文件和打印共享”、“微软网络客户”被选中。 确认“NWLink IPX/SPX/NetBIOS Compatible Transport Prococol”协议没有被选中;
11. 连接成功后,在任务栏上会看到一个VPN连接的图标,现在可以到http://www.ip138.com,看一下你的ip地址是否发生了变化

数据加密和协议未正确选择可能出现下面错误

Jun 6 14:21:29 c1gstduio pppd[18302]: No CHAP secret found for authenticating pptpd
Jun 6 14:21:29 c1gstduio pppd[18302]: Peer pptpd failed CHAP authentication


Jun 6 14:22:06 c1gstduio pppd[18319]: Unsupported protocol ‘Novell IPX Control Protocol’ (0x802b) received
Jun 6 14:22:06 c1gstduio pppd[18319]: MPPE 128-bit stateless compression enabled
Jun 6 14:22:08 c1gstduio pppd[18319]: Cannot determine ethernet address for proxy ARP

可以参考下面地址
http://www.utt.com.cn/reference.php?id=282

参考
http://network.51cto.com/art/201009/225275.htm

Posted in VPN.

Tagged with , .


Lempelf一键包更新至1.1.0

Lempelf一键安装包是什么?
——————————————————————————–
Lempelf一键安装包是用Shell编写的在Linux平台快速安装常用服务的Shell程序。

ChangeLog
升级mysql,提升安全性,增加安全工具
——————————————————————————–
——————————————————————————–
2012-6-1 发布Lempelf 1.1.0
Bugfix:nginx在64位系统安装时需增加libpcre的软链接
Bugfix:nginx关闭默认主机头的日志
Bugfix:主dns改成上海电信202.96.209.133
Bugfix:centos6内核优化用nf_conntrack_max替代ip_conntrack_max
Feature:增加下载软件包时失败或文件名不匹配验证
Feature:fail2ban安装后使用restart启动,可以防止再次安装时没有放入到iptables
Feature:nginx的fcgi配置中增加try_files $fastcgi_script_name =404; 可以增加cgi.fix_pathinfo为1时的安全性,但可能会影响php rewrite
Feature:不再使用vim代替vi
Feature:取消sshd 反解dns,加速连接时间
Feature:删除mysql的test数据库
Feature:my.conf中指定运行用户为mysql
Feature:my.conf中设定local-infile=0;禁止load data local infile命令读系统文件,会影响数据导入功能
Feature:my.conf中max_heap_table_size = 1792M
Feature:my.conf中innodb_log_file_size = 256M
Feature:增加清除home中.mysql_history记录
Feature:mysql不编译PERFSCHEMA_SCHEMA库
Feature:升级至phpMyAdmin-3.5.1-all-languages
Feature:phpmyadmin中隐藏information_schema库
Feature:mysql升级Percona-Server-5.5.22-rel25.2
Feature:mailx安装脚本
Feature:logwatch安装脚本
Feature:chkrootkit安装脚本
Feature:rkhunter安装脚本

http://blog.c1gstudio.com/lempelfpage

Posted in Lempelf一键包.


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 安全.


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,c1g@c1gstudio.com/” /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 , .