DirectAdmin默认密码
cat /usr/local/directadmin/scripts/setup.txt
cat /usr/local/directadmin/scripts/setup.txt
安装教程
cd /usr/local/src wget http://techsware.in/downloads/harden.sh chmod 755 harden.sh ./harden.sh
1:什么是KalluscPHarden?
答:KalluscPHarden是一个shell脚本,基于cPanel服务器安全加固、检查。
2:会为cPanel做什么?
答:改变调整设置,密码修改强度,后台进程检查,编译器的访问安全,Shell Bomb Fork保护等设置....
3:有什么额外的应用程序将安装到服务器?
答:CSF,CMM,CMQ,CMC,Maldet,Rkhunter,Linux Socket 监控,Linux的环境安全等
4:服务器会有哪些地方被调整/加固?
答:Apache,cPanel,FTP,SSH,MySQL,CSF,PHP等
5: What additional hardening steps it does ?
Ans : TMP hardening, Logrotate hardening, Daily Rkhunter scanning, rDNS Check, Disable unwanted processes, SYN FLOOD Kernel Tweak, etc
6: How to recover the old configuration, before running this tool?
Ans : All configurations will be backup as conf_file.beforetweak before making changes to it. So you can compare the configurations in you want to check anything.
7: Any more tweaks it do ?
Ans : Check change log for recent changes to the script
8:这个脚本多少钱?
答:它是完全免费的。
9:想知道更多?
Ans : Please feel free to reach me at kallu[at]techsware.in
官方主页:http://techsware.in/kcpharden.html
请注意,安装适用于 CustomBuild 2.0
cd /usr/local/directadmin/custombuild ./build update ./build set modsecurity yes ./build set modsecurity_ruleset comodo ./build modsecurity
wordpress后台暴力破解规则
/usr/local/cwaf/tmp/rules/workdir1/rules
新建文件,内容如下,保存后设置所属用户重启apache
SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134
<Locationmatch "/wp-login.php">
# Setup brute force detection.
# React if block flag has been set.
SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"
# Setup tracking. On a successful login, a 302 redirect is performed, a 200 indicates login failed.
SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"
SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"
SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"
</locationmatch>
SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000234
<Locationmatch "/xmlrpc.php">
# Rate limit requests to xml-rpc
SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000235,msg:'ip address blocked for 5 minutes, more than 10 attempts in 3 minutes.'"
# Setup tracking. Whenever it gets a 200 or 405 status code, increase our brute force counter.
SecRule RESPONSE_STATUS "^(200|405)" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000237"
SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"
</Locationmatch>规则来自:https://github.com/sensson/puppet-directadmin/blob/master/templates/modsecurity/modsec-wordpress.conf.erb
SYNFLOOD is disabled by default. If you are not receiving any sort of attack, there is no need to enable it. If you are expecting an attack, enable it and set the rules a bit strict, like
SYNFLOOD_RATE = "5/s"
SYNFLOOD_BURST = "3"
i.e. if 5 connections are received from an IP/sec for 3 times, block it. Make sure don't keep it too strict if you are not receiving an attack else it will generate false positives and will block legit connections.
摘自:http://www.webhostingtalk.com/showthread.php?t=892958
Hello,
update script not part from directadmin.com
**** USE IT YOUR OWN RISKS *********
*****
*****GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 2006,2007 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Update script made by Wael Isa
H188, R4008, Arad 240, Kingdom of Bahrain
http://www.web4host.net
Version: 1.8.1
Release Date: 1 / 9 / 2006*****
*****
*****If you find update script useful, please consider to make a donation to support this freeware.
Please keep in mind that donations are welcome, but in no way required to use and distribute update.script.
You can support update.script by paypal – CLICK HEREupdate.script Version: 1.8.1
update script tested in this OS 32bit and 64bit.
- RedHat Linux
- RedHat Fedora
- RedHat Enterprise
- CentOS
- Debian
安装
mkdir /usr/local/updatescript
cd /usr/local/updatescript
wget http://tools.web4host.net/update.script
chmod 755 update.script
Run this to read how to use.
运行以下命令查看如何使用
./update.script
查看更多:http://www.web4host.net/update-script/
ELS stands for Easy Linux Security. ELS was created by Richard Gannon, Martynas Bendorius and Wael Isa. ELS takes many of the tasks performed by our Administrators and puts it into an easy to use program for anyone to use. It is released under the GNU/GPL so it is free to use.
This program is always being improved with new features and bugfixes, so be sure to keep it up to date. If you found a bug or would like an improvement, please let us know! If you really like this program, donations are welcome!
支持的操作系统 :
* Red Hat Linux
* Red Hat Enterprise Linux
* Fedora Core
* CentOS
* Debian
ELS 有哪些功能:
* Install RKHunter
* Install RKHunter Cronjob which emails a user-set email address nightly
* Install/update APF
* Install/update BFD
* Install CHKROOTKIT
* Install CHKROOTKIT Cronjob which emails a user-set email address nightly
* Disable Telnet
* Force SSH Protocol 2
* Secure /tmp
* Secure /var/tmp
* Secure /dev/shm
* 安装/升级 Zend Optimizer
* 安装/升级 eAccelerator
* MySQL 4.1 and 5.0 Configuration Optimization
* Upgrade MySQL to 5.0
* Tweak WHM Settings for security and stability
* Configure RNDC if not already done (cPanel only)
* Change SSH port (also configure APF as necessary)
* Add wheel user and disable direct root login over SSH
* 优化 MySQL tables
* 安装/升级 Libsafe
* 安装/升级 ImageMagick (from latest source)
* Uninstall LAuS
* Harden sysctl.conf
* Install Chirpy’s Free Exim Dictionary Attack ACL (cPanel only)
* 更多!
安装 ELS, 以ROOT身份运行以下命令:
wget -O installer.sh http://els.web4host.net/installer.sh
chmod +x installer.sh
sh installer.sh
官方网站:http://www.web4host.net/easy-linux-security/
有些管理员不希望每个IP被封锁都得到DA的通知
brute_force_notice_ip.sh 的触发只发生在DA发送XX IP尝试多少次登入失败通知的时候,现在DA已经添加了一个选项,以防止发送,但brute_force_notice_ip.sh 仍然工作。
该directadmin.conf选项将是:
hide_brute_force_notifications=0
这是默认(选项禁用,发送通知)
如果你想不发通知,但brute_force_notice_ip.sh仍然工作,设置directadmin.conf:
hide_brute_force_notifications=1
MySQL错误提示如下:
ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/server.pcpartsadvice.com.pid)
解决办法:
# rm /var/lib/mysql/mysql.sock
# service mysqld restart
netstat 工具来检测SYN攻击
# netstat -n -p -t
tcp0 0 10.11.11.11:23124.173.152.8:25882 SYN_RECV-
tcp0 0 10.11.11.11:23236.15.133.204:2577 SYN_RECV-
tcp0 0 10.11.11.11:23127.160.6.129:51748 SYN_RECV-
LINUX系统中看到的,很多连接处于SYN_RECV状态(在WINDOWS系统中是SYN_RECEIVED状态), 源IP地址都是随机的,表明这是一种带有IP欺骗的SYN攻击。
# netstat -n -p -t | grep SYN_RECV | grep :80 | wc -l
324
查看在LINUX环境下某个端囗的未连接队列的条目数,显示TCP端囗22的未连接数有324个,虽然还远达不到系统极限,但应该引起管理员的注意。
[root@pub wxjsr]# netstat -na | grep SYN_RECV
tcp 0 0 58.193.192.20:80 221.0.108.162:32383 SYN_RECV
tcp 0 0 58.193.192.20:80 125.85.118.231:2601 SYN_RECV
tcp 0 0 58.193.192.20:80 222.242.171.215:2696 SYN_RECV
tcp 0 0 58.193.192.20:80 116.52.10.51:2629 SYN_RECV
tcp 0 0 58.193.192.20:80 218.171.175.157:1117
[root@pub wxjsr]# netstat -na | grep SYN_RECV |wc
11 66 979
查看系统SYN相关的配置
Linux内核提供了若干SYN相关的配置,用命令: sysctl -a | grep syn
[root@metc apache2]# /sbin/sysctl -a | grep syn
net.ipv6.conf.default.max_desync_factor = 600
net.ipv6.conf.all.max_desync_factor = 600
net.ipv6.conf.eth0.max_desync_factor = 600
net.ipv6.conf.lo.max_desync_factor = 600
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv = 60
net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent = 120
net.ipv4.tcp_max_syn_backlog = 1280
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 5
fs.quota.syncs = 18
防范SYN攻击设置
#缩短SYN- Timeout时间:
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -i eth0 -m limit --limit 1/sec --limit-burst 5 -j ACCEPT
#每秒 最多3个 syn 封包 进入 表达为 :
iptables -N syn-flood
iptables -A INPUT -p tcp --syn -j syn-flood
iptables -A syn-flood -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j RETURN
iptables -A syn-flood -j REJECT
#设置syncookies:
sysctl -w net.ipv4.tcp_syncookies=1
/sbin/sysctl -w net.ipv4.tcp_max_syn_backlog=3000
/sbin/sysctl -w net.ipv4.tcp_synack_retries=1
/sbin/sysctl -w net.ipv4.tcp_syn_retries=1
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.all.forwarding=0
/sbin/sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
/sbin/sysctl -w net.ipv4.conf.default.accept_source_route=0 # 禁用icmp源路由选项
/sbin/sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1 # 忽略icmp ping广播包,应开启
/sbin/sysctl -w net.ipv4.icmp_echo_ignore_all=1 # 忽略所有icmp ping数据,覆盖上一项
转载:http://www.tuicool.com/articles/m6nE3q
cat>>/home/cc.sh<#!/bin/sh
status=`netstat -na|awk '$5 ~ /[0-9]+:[0-9]+/ {print $5}' |awk -F ":" -- '{print $1}' |sort -n|uniq -c |sort -n|tail -n 1`
NUM=`echo $status|awk '{print $1}'`
IP=`echo $status|awk '{print $2}'`
result=`echo "$NUM > 150" | bc`
if [ $result = 1 ]
then
echo IP\:$IP is over $NUM, BAN IT!
echo $(date +"%y-%m-%d") `uptime`
/sbin/iptables -I INPUT -s $IP -j DROP
fi
EOF
ln -sf /usr/bin/apt-get /usr/bin/yum
yum install -y bc
执行/home/cc.sh即可! 也可以将执行脚本加入到Cron执行!
转载:http://www.jb4.net/archives/74.html
HttpGuard是基于openresty,以lua脚本语言开发的防cc攻击软件。而openresty是集成了高性能web服务器Nginx,以及一系列的Nginx模块,这其中最重要的,也是我们主要用到的nginx lua模块。HttpGuard基于nginx lua开发,继承了nginx高并发,高性能的特点,可以以非常小的性能损耗来防范大规模的cc攻击。
下面介绍HttpGuard防cc的一些特性。
github项目地址:https://github.com/centos-bz/HttpGuard
联系作者:admin#centos.bz
赞助作者持续开发:查看支付宝条码
一、安装openresty或者nginx lua
假设我们把HttpGuard安装到/data/www/waf/,当然你可以选择安装在任意目录,nginx运行的用户为www。
cd /data/www
wget --no-check-certificate https://github.com/centos-bz/HttpGuard/archive/master.zip
unzip master.zip
mv HttpGuard-master waf
chown www waf/logs
三、生成验证码图片(可选)
为了支持验证码识别用户,我们需要先生成验证码图片。生成验证码图片需要系统安装有php,以及php-gd模块。
以命令行执行getImg.php文件
cd /data/www/waf/captcha/
/usr/local/php/bin/php getImg.php
大概要生成一万个图片,可能需要花几分钟的时间。
四、修改nginx.conf配置文件
向http区块输入如下代码:
lua_package_path "/data/www/waf/?.lua";
lua_shared_dict guard_dict 100m;
lua_shared_dict dict_captcha 70m;
init_by_lua_file '/data/www/waf/init.lua';
access_by_lua_file '/data/www/waf/runtime.lua';
lua_max_running_timers 1;
记得要修改相关的路径。
五、配置HttpGuard
HttpGuard全部的配置项都在config.lua文件中,请根据以下文章修改配置文件。
进入谷歌那样的大公司工作是多少程序员的人生梦想!最近,Google Education代言啊不推荐了一系列计算机相关课程,为想要学习编程的大学生们指明方向,非大学生也可以来学习哟~
谷歌推荐的课程更像是一个“技能树”,课程主要来自美国名校和各种开源教程,你也可以按照这个顺序学习中文的同类课程。
前面的 academic 系列课程比较接近计算机专业的学习顺序。如果你不打算成为专业的工程师,只想掌握一点编程知识,在工作中使用的话,可以直接拉到帖子中部开始观看。
以下内容搬运自Google Education
要成为一名成功的软件工程师,你必须具备扎实的计算机科学基础。本自学指南适用于想要学习编程的大学生们,分为专业方向和非专业方向两个系列。你可以借助这个指南进行自学,但请首先修够你的专业学分,以保证顺利毕业。
本课程表中的课程不能代替大学课程,但它们能够帮助你进一步学习计算机科学,或者对这个领域建立初步理解。
关于如何使用本学习指南的4点建议:
【为进军学术界作准备的课程】
计算机科学导论课程
你可以选择提供在线编程工具的计算机导论课程。
课程推荐:
Coursera - Computer Science 101
学习至少一种面向对象编程语言,如C++,Java或Python
入门课程:
Coursera - Learn to Program: The Fundamentals,
MIT Intro to Programming in Java(注:这是他们的公开课视频)
Google's Python Class(注:Google Developers出品!)
Coursera - Introduction to Python
Python Open Source E-Book(注:Python教材免费在线看!)
中级课程:
Udacity's Design of Computer Programs
Coursera - Learn to Program: Crafting Quality Code,
Coursera - Programming Languages
Brown University - Introduction to Programming Languages (注:这是布朗大学公开课的课件)
学习其他的编程语言
To learn list:Java Script, CSS, HTML, Ruby, PHP, C, Perl, Shell. Lisp, Scheme.
相关在线学习资源:
测试和提高自己的编程能力
例如:排查故障,创建测试,破解软件
相关课程:
Udacity - Software Testing Methods
学习逻辑推理和离散数学
相关课程:
MIT Mathematics for Computer Science(注:这是MIT公开课)
Coursera - Introduction to Logic(注:《逻辑学导论》有中文字幕哟!)
Coursera - Linear and Discrete Optimization
Coursera - Probabilistic Graphical Models
Coursera - Game Theory(注:斯坦福精品课程,还有续集《博弈论2》!)
深入理解算法和数据结构
学习基本的数据类型,如堆栈、队列和数据包;
了解排序演算法,如快速排序,二路归并排序和堆排序;
了解数据结构,如二叉搜索树,红黑树和哈希表。
相关课程:
MIT Introduction to Algorithms,
Coursera Introduction to Algorithms Part 1 & Part 2
(注:这是英文维基给出的所有算法的列表,看看你完成了多少?)
List of Data Structures(注:同上)
参考书籍: The Algorithm Design Manual
(注:这是美国亚马逊的购买链接,不清楚有没有中文版)
深入了解操作系统
相关课程: UC Berkeley Computer Science 162
(注:上面的链接是Youtube的播放列表,ppt等课件请看学校网站的资源)
人工智能相关课程
Stanford University:
(以上全是斯坦福的课程!人工智能哪家强!)
如何开发一个编译器
相关课程:Coursera - Compilers
密码学
Udacity - Applied Cryptography
并行编程
相关课程:Coursera - Heterogeneous Parallel Programming
【如果你侧重应用方向】
项目开发相关课程
这方面的内容包括创建和维护一个网站,建立自己的服务器,或开发一个机器人。
相关课程:
Apache List of Projects(注:这是apache.org提供的教程)
如果你想了解一个大型系统的一部分(如代码库),阅读和理解代码,或跟踪文档和排查故障,那么你可以到Github上围观和学习别人的代码,并尝试开发自己的项目。
如果你想通过学习提高与程序员合作的能力,那么你可以先尝试和程序员们共同完成一个项目。
如果你想补充算法知识,练习编程技巧,可以参加CodeJam、ACM举办的国际编程大赛等活动。
如果你通过教学加深自己对计算机的理解,获得软件工程等相关领域的实习经验,那么你可以申请担任相关课程的助教。注意要在实习期开始前提前申请哟!
在美国,学生通常在五月到九月参加实习,一般需要提前几个月进行申请。
相关资源-到谷歌的招聘页面看看吧: google.com/jobs
本文来自Google Education,未经许可,谢绝转载。
好好学习,谷歌欢迎你!(图片来自网络)