бесплатный скрипт защиты от школьного DDOS
Скачать: a.abcd.bz/public/dos.pl
В консоле по SSH надо запустить его примерно так
./dos.pl "example.com.access.log" -n 3 -t 10 -s "GET"
./dos.pl "example.com.access.log" -n 3 -t 10 -s "GET"
login as:
sudo yum -y update
sudo yum install mc
sudo groupadd virtwww
sudo useradd www -g virtwww -d /var/www
sudo useradd webserver -g virtwww
sudo passwd www
sudo passwd webserver
sudo chown www:virtwww /var/www
sudo chmod 0750 /var/www
sudo yum install mysql-server mysql
sudo /sbin/chkconfig --levels 235 mysqld on
sudo service mysqld start
mysql -u root
USE mysql
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('s10ZniYpar00L');
DELETE FROM user WHERE password = '';
DELETE FROM user WHERE user.user= '';
FLUSH PRIVILEGES;
DROP DATABASE test;
\q
sudo yum install vsftpd
sudo /sbin/chkconfig --levels 235 vsftpd on
sudo service vsftpd start
sudo mcedit /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
pasv_enable=YES
pasv_min_port=1024
pasv_max_port=1048
pasv_address=107.21.246.159
sudo service vsftpd restart
sudo chmod 0755 /var/www
sudo yum install httpd mod_ssl
sudo yum install php
sudo yum install pcre-devel
sudo yum -y install aspell aspell-en aspell-ru cvs php-gd php-intl php-mbstring php-mysql php-pdo php-soap php-xml php-xmlrpc php-pspell php-devel php-pear
sudo /sbin/chkconfig --levels 235 httpd on
sudo service httpd start
sudo mcedit /etc/httpd/conf/httpd.conf
ServerTokens Prod
TraceEnable Off
KeepAlive On
MaxKeepAliveRequests 256
KeepAliveTimeout 10
User webserver
Group virtwww
sudo service httpd restart
sudo chown www:virtwww /var/www/html /var/www/icons /var/www/error /var/www/cgi-bin
sudo mcedit /etc/php.ini
magic_quotes_gpc = On
short_open_tag = On
sudo service httpd restart
sudo mcview /var/log/httpd/error_log
sudo mcview /var/log/httpd/access_log
exit
python log2ban.py print (banned | allbanned)
python log2ban.py print (unbanned)
sudo apt-get install module-assistant xtables-addons-source
sudo module-assistant prepare
sudo module-assistant auto-install xtables-addons-source
depmod -a
ipset -L
sudo apt-get install mongodb python-pip
sudo pip install apachelog pexpect pymongo
git clone git://github.com/unicodefreak/log2ban.git
ECHO_LOG_COMMAND = "tail -f /var/log/nginx/access.log"
/var/log/nginx/*log {
daily
rotate 10
missingok
notifempty
compress
sharedscripts
postrotate
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
/etc/init.d/log2ban stop
/etc/init.d/log2ban start
endscript
}
sudo mkdir /opt/log2ban
sudo cp log2ban/log2ban.py /opt/log2ban/
sudo cp log2ban/ipset-control.sh /opt/log2ban/
sudo cp log2ban/init-scripts/log2ban-debian.sh /etc/init.d/log2ban
sudo chmod +x /etc/init.d/log2ban
sudo chmod +x /opt/log2ban/ipset-control.sh
sudo /etc/init.d/mongodb start
sudo /etc/init.d/log2ban start
*/5 * * * * /opt/log2ban/ipset_control.sh update
sudo ipset -L
-A INPUT -m set --match-set autoban src -j DROP
sudo /etc/init.d/networking restart
JAVA=/usr/bin/java //установленная java стандартно
JAR_HOME=/home/home/chat //записываем путь до папки с нашим ботом
JAR=jimb.jar //имя самого jar файла бота
chmod 777 bot.sh
/home/bot/bot.sh // ПУТЬ до bot.sh
!w:
!q:
$file=file("/proc/stat");
$tmp=explode(" ",$file[0]);
$cpu1=$this->session->userdata("cpu1");
$cpu2=$this->session->userdata("cpu2");
$cpu3=$this->session->userdata("cpu3");
$cpu4=$this->session->userdata("cpu4");
$cpu=(100/($tmp[5]-$cpu4))/(($tmp[2]-$cpu1)+($tmp[3]-$cpu2)+($tmp[4]-$cpu3))*100;
$this->session->set_userdata(array("cpu1"=>$tmp[2],"cpu2"=>$tmp[3],"cpu3"=>$tmp[4],"cpu4"=>$tmp[5]));
> cat /proc/stat
cpu 2255 34 2290 22625563 6290 127 456 0 0
cpu0 1132 34 1441 11311718 3675 127 438 0 0
cpu1 1123 0 849 11313845 2614 0 18 0 0
intr 114930548 113199788 3 0 5 263 0 4 [... еще куча цифр ...]
...
> cat /proc/meminfo
MemTotal: 2052604 kB
MemFree: 246012 kB
Buffers: 792332 kB
Cached: 584716 kB
...
$file=file("/proc/meminfo");
$memory["total"]=substr($file[0],strpos($file[0]," "),strrpos($file[0]," ")-strpos($file[0]," "));
$memory["free"]=substr($file[1],strpos($file[1]," "),strrpos($file[1]," ")-strpos($file[1]," "));
> cat /proc/swaps
Filename Type Size Used Priority
/dev/sda1 partition 7811064 2732 -1
...
$file=file("/proc/swaps");
$tmp=explode("\t",substr($file[1],strpos($file[1],"partition")));
$swap["total"]=$tmp[1];
$swap["free"]=$tmp[1]-$tmp[2];
$drives=array();
if($dir=opendir("/mnt")){
while(false !== ($file = readdir($dir))) {
$arr=array();
if(($file!=".")&&($file!="..")){
$arr["path"]="/mnt/".$file;
$arr["free"]=disk_free_space("/mnt/".$file);
$arr["total"]=disk_total_space("/mnt/".$file);
$drives[]=$arr;
}
}
}
$uptime=exec("uptime");
$uptime=explode(",",substr($uptime,strpos($uptime,"up")+3));
$time=explode(":",$uptime[1]);
$uptime=$uptime[0]." ".$time[0]." hours ".$time[1]." minutes";
$result["cpu"]=$cpu;
$result["memory"]=$memory;
$result["swap"]=$swap;
$result["uptime"]=$uptime;
json_encode($result);
{"uptime":"34 days 5 hours 45 minutes","cpu":1.7361111111111,"memory":{"total":"2052604","free":"191424"},"swap":{"total":"7811064","free":7808332}}
var json=$.parseJSON(data);
$("#systemInfo").html("CPU: "+json.cpu+"<br />Memory free "+json.memory.free+" / "+json.memory.total);
yum update
yum install mc
[root@cs hdd2]# mkdir source
[root@cs hdd2]# wget http://www.steampowered.com/download/hldsupdatetool.bin
[root@cs hdd2]# chmod +x hldsupdatetool.bin
[root@cs hlds]# ./hldsupdatetool.bin
-bash: ./hldsupdatetool.bin: /lib/ld-linux.so.2: bad ELF interpreter: Нет такого файла или каталога
[root@cs hlds]#
[root@cs hlds]# ./hldsupdatetool.bin
Enter 'yes' to accept this agreement, 'no' to decline: yes
Enter 'yes' to accept this agreement, 'no' to decline: yes
sh: uncompress: команда не найдена
tar: Это не похоже на tar-архив
tar: Завершение работы с состоянием неисправности с из-за возникших ошибок
[root@cs hlds]#
[root@cs hlds]#ln -s /usr/bin/gunzip /usr/bin/uncompress
[root@cs hlds]# ./hldsupdatetool.bin
Enter 'yes' to accept this agreement, 'no' to decline: yes
extracting steam.tar.Z...done
[root@cs hlds]# ls
hldsupdatetool.bin readme.txt steam
[root@cs hlds]# ./steam
Checking bootstrapper version ...
Getting version 45 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .
Steam Linux Client updated, please retry the command
[root@cs hlds]#
[root@cs hlds]# ./steam
Checking bootstrapper version ...
Getting version 45 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .
Steam Linux Client updated, please retry the command
CAsyncIOManager: 0 threads terminating. 0 reads, 0 writes, 0 deferrals.
CAsyncIOManager: 21 single object sleeps, 0 multi object sleeps
CAsyncIOManager: 0 single object alertable sleeps, 0 multi object alertable sleeps
[root@cs hlds]#
[root@cs hlds]# touch update.sh
[root@cs hlds]# chmod +x update.sh
[root@cs hlds]# echo ./steam -command update -game cstrike -dir . > update.sh
[root@cs hlds]# cat update.sh
./steam -command update -game cstrike -dir .
[root@cs hlds]#
[root@cs hlds]# ./update.sh
Checking bootstrapper version ...
Updating Installation
No installation record found at .
No installation record found at .
No installation record found at .
Checking/Installing 'Counter-Strike Base Content' version 35
0.16% downloading ./cstrike/cl_dlls/client.dll
0.16% downloading ./cstrike/classes/ak47.res
0.16% downloading ./cstrike/classes/arctic.res
0.16% downloading ./cstrike/classes/aug.res
0.16% downloading ./cstrike/classes/autoselect_ct.res
0.16% downloading ./cstrike/classes/autoselect_t.res
0.16% downloading ./cstrike/classes/awp.res
0.16% downloading ./cstrike/classes/cancelbutton.res
0.16% downloading ./cstrike/classes/default.res
0.16% downloading ./cstrike/classes/defuser.res
0.16% downloading ./cstrike/classes/deserteagle.res
0.16% downloading ./cstrike/classes/elites.res
0.16% downloading ./cstrike/classes/equipment.res
99.06% downloading ./valve/valve.rc
99.06% downloading ./valve/valvecomm.lst
100.00% downloading ./valve/xeno.wad
Connection Reset, errno 104 "Connection reset by peer"
CAsyncIOManager: 0 threads terminating. 0 reads, 0 writes, 0 deferrals.
CAsyncIOManager: 76 single object sleeps, 0 multi object sleeps
CAsyncIOManager: 0 single object alertable sleeps, 0 multi object alertable sleeps
[root@cs hlds]#
[root@cs hlds]# chmod +x start.sh
[root@cs hlds]# vi start.sh
#!/bin/bash
echo «Starting CS:1.6»
sleep 1
./hlds_run -binary ./hlds_i686 -game cstrike -secure -console -pingboost 1 +exec server.cfg -verify_all +port 27015 +maxplayers 22 +map de_dust2 +ip 0.0.0.0
[root@cs hlds]# ./start.sh
Starting CS:1.6
Auto-restarting the server on crash
Console initialized.
scandir failed:/hdd2/source/hlds/./valve/SAVE
scandir failed:/hdd2/source/hlds/./platform/SAVE
Protocol version 48
Exe version 1.1.2.6/Stdio (cstrike)
Exe build: 16:56:12 Mar 8 2010 (4883)
STEAM Auth Server
couldn't exec listip.cfg
couldn't exec banned.cfg
Server IP address 0.0.0.0:27015
scandir failed:/hdd2/source/hlds/./valve/SAVE
scandir failed:/hdd2/source/hlds/./platform/SAVE
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
scandir failed:/hdd2/source/hlds/./valve/SAVE
scandir failed:/hdd2/source/hlds/./platform/SAVE
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
couldn't exec listip.cfg
couldn't exec banned.cfg
scandir failed:/hdd2/source/hlds/./valve/SAVE
scandir failed:/hdd2/source/hlds/./platform/SAVE
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
Connection to Steam servers successful.
VAC secure mode is activated.
Птн Сен 2 07:22:45 NOVST 2011: Server Quit
[root@cs hlds]#
couldn't exec listip.cfg
[root@cs hlds]# touch cstrike/listip.cfg
couldn't exec banned.cfg
[root@cs hlds]# touch cstrike/banned.cfg
scandir failed:/hdd2/source/hlds/./valve/SAVE
[root@cs hlds]# mkdir valve/SAVE
scandir failed:/hdd2/source/hlds/./platform/SAVE
[root@cs hlds]# mkdir platform
[root@cs hlds]# mkdir platform/SAVE
[root@cs hlds]# ./start.sh
Starting CS:1.6
Enabling debug mode
./hlds_run: line 134: gdb: команда не найдена
Please install gdb first.
[root@cs hlds]# yum install gdb
[root@cs hlds]$ ./start.sh
Starting CS:1.6
Enabling debug mode
Auto-restarting the server on crash
Console initialized.
Protocol version 48
Exe version 1.1.2.6/Stdio (cstrike)
Exe build: 16:56:12 Mar 8 2010 (4883)
STEAM Auth Server
Server IP address 0.0.0.0:27015
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
Connection to Steam servers successful.
VAC secure mode is activated.
[root@cs hlds]# useradd gsrv
[root@cs hlds]# passwd gsrv
Смена пароля для пользователя gsrv.
Новый пароль :
Повторите ввод нового пароля :
passwd: все токены проверки подлинности успешно обновлены.
[root@cs hlds]#
[root@cs hlds]# chown -R gsrv:gsrv source/
[root@cs hdd2]# su gsrv
[gsrv@cs hdd2]$
[root@cs rc.d]# vi /etc/rc.d/rc.fw
#! /bin/sh
WAN_IF="eth0"
WAN_IP="ИП_АДРЕС_ВАШЕГО_СЕРВЕРА"
LO_IF="lo"
LO_IP="127.0.0.1"
LO_MASK="255.0.0.0"
LO_NET="$LO_IP/$LO_MASK"
SERV_PORT="27015:27025"
SHH_PORT="22"
IPT="/sbin/iptables"
$IPT -F
$IPT -t nat -F
$IPT -t mangle -F
$IPT -X
$IPT -P INPUT DROP
$IPT -P OUTPUT ACCEPT
$IPT -A INPUT -i $LO_IF -j ACCEPT
$IPT -A OUTPUT -o $LO_IF -j ACCEPT
$IPT -A INPUT -p ICMP --icmp-type 8 -j ACCEPT
$IPT -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
$IPT -A INPUT -p TCP --dport 22 -j ACCEPT
$IPT -A INPUT -p tcp --dport 27015 -j ACCEPT
$IPT -A INPUT -p udp --dport 27015 -j ACCEPT
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
# rpm -K rpmforge-release-*.rpm
# rpm -i rpmforge-release-*.rpm
# yum install phpmyadmin
# vi /etc/httpd/conf.d/phpmyadmin.conf
#
# Web application to manage MySQL
#
<Directory "/usr/share/phpmyadmin">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 192.168.0.0/24
</Directory>
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
# vi /usr/share/phpmyadmin/config.inc.php
$cfg['Servers'][$i]['auth_type'] = ‘cookies‘;
$cfg['Servers'][$i]['auth_type'] = ‘http‘;
# service httpd restart
http://<ip адрес сервера или доменное имя>/phpmyadmin/
# wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.4.5/phpMyAdmin-3.4.5-all-languages.zip/download?_test=goal
$cfg['blowfish_secret'] = 'super_puper_secret';
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
[root@localhost ~]#
[root@localhost ~]# cat /etc/host.conf
order hosts,bind
[root@localhost ~]#
[root@localhost ~]# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
[root@localhost ~]#
[root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward
0
[root@localhost ~]#
[root@localhost ~]# grep forward /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
[root@localhost ~]#
[root@localhost ~]# echo '1' > /proc/sys/net/ipv4/ip_forward
У вас есть новая почта в /var/spool/mail/root
[root@localhost ~]#
[root@localhost ~]# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
[root@localhost ~]#
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=alice2k.ru
[root@localhost ~]#
NETWORKING=yes — будет ли наш сервер работать в сети/etc/sysconfig/network-scripts/ — скрипты влияющие на работу сетевого интерфейса
NETWORKING_IPV6=no — тоже самое только для Ip6
HOSTNAME=centos52 — имя нашего сервера
[root@localhost ~]# ls -l /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r-- 1 root root 274 Мар 17 00:06 /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r-- 1 root root 254 Июл 4 2009 /etc/sysconfig/network-scripts/ifcfg-lo
[root@localhost ~]#
BOOTPROTO — (static,none,dhcp,bootp)Настройки для DHCP
DEVICE — (eth0) название интерфейса
HWADDR — (00:0C:29:43:5B:3D) — MAC-адрес нашей сетевой карты.
ONBOOT — (yes) — включать ли этот интерфейс автоматически при включение сервера.
IPADDR — (127.0.0.1) — ip-адрес интерфейса.
NETMASK — (255.0.0.0) — сетевая маска
NETWORK — (127.0.0.0) — сеть в которой находится наш ip-адрес
BROADCAST — (127.255.255.255) — адрес широковещательной рассылки
GATEWAY — (192.168.0.1) — шлюз через который мы попадаем в другие сети
DEVICE=eth0Настройки для статики:
BOOTPROTO=dhcp
ONBOOT=yes
DEVICE=eth0Прописываем маршруты
BOOTPROTO=static
BROADCAST=192.168.0.255
IPADDR=192.168.0.88
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.1
ONBOOT=yes
root@localhost ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.77.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
default 192.168.77.77 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.77.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default 192.168.77.77 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
[root@localhost ~]# cat /etc/sysconfig/network-scripts/route-eth1
192.168.148.0/24 via 192.168.147.1
[root@localhost ~]#
[root@localhost ~]# route add -net 192.168.148.0/24 gw 192.168.147.1
system-config-network-tui
system-config-network-gui
toor@babylol:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 90:e6:ba:44:a4:3d
inet addr:192.168.15.199 Bcast:192.168.15.255 Mask:255.255.255.0
inet6 addr: fe80::92e6:baff:fe44:a43d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6739839 errors:0 dropped:0 overruns:0 frame:0
TX packets:6370782 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3046437053 (3.0 GB) TX bytes:1870686129 (1.8 GB)
Interrupt:20 Память:f9fc0000-f9fe0000
toor@babylol:~$
[root@nskgw etc]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:1B:21:8E:31:44
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
[root@nskgw etc]#
[root@babylol etc]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.12.255
HWADDR=00:19:5B:72:57:C5
IPADDR=192.168.12.200
NETMASK=255.255.255.0
NETWORK=192.168.12.0
ONBOOT=yes
[root@a2k etc]#
[root@a2k ~]# /etc/init.d/network restart
Деактивируется интерфейс eth0: [ OK ]
Деактивируется интерфейс-петля: [ OK ]
Активируется интерфейс loopback: [ OK ]
Активируется интерфейс eth0: [ OK ]
[root@a2k ~]# ifconfig -a eth0 192.168.1.200 netmask 255.255.255.0
[root@a2k ~]# route add default gw 192.168.1.100
[client]
default-character-set = utf8
[mysql]
default-character-set =utf8
[mysqld]
default-character-set = utf8
skip-character-set-client-handshake
collation-server = utf8_unicode_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8