Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

September 30, 2014

Как устранить уязвимость Shellshock на сервере или VDS под управлением Debian

Проверьте присутствует ли уязвимость:

env X="() { :;} ; echo busted" bash -c "echo stuff"

Если в выводе содержится "busted", дыра Shellshock присутствует.


Как это выглядит на уязвимой машине под управлением Debian OpenVZ VPS:

Вверху видно что текущая версия Bash это 4.2.


Теперь латаем дыру.


Обновляем список пакетов.

apt-get update

Проверьте свою версию баша. В моем случае это была 4.2+dfsg-0.1+deb7u3. Обновите баш. Здесь описано как выбрать определенную версию пакета для установки в случае если доступны несколько.

apt-get install bash=4.2+dfsg-0.1+deb7u3

Воткак выглядит пропатченный сервер:

Старая версия была 4.2+dfsg-0.1, после обновления стала 4.2+dfsg-0.1+deb7u3. Ну и последний тест, в результате которого значение busted не выводится.


Источник: http://habrahabr.ru/company/mailru/blog/238475/

How to quickly check and fix the Shellshock Bash vulnerability

First, see if this applies to you. Though since all of the bash versions for the last 25 years are vulnerable to this exploit, it most likely does.


To check if your machine has the Shellshock vulnerability, run the following:

env X='() { :;}; echo vulnerable' bash -c "echo this is a test"

If the output includes "busted", the machine is vulnerable to the Shellshock exploit.


Here's an example of how the output looks like on an infected Debian OpenVZ VPS:

At the top of the output you can see the current Bash version being 4.2.


Now, this is the time to update your bash version to the one that is more secure and has the exploit patched.


First, update the package list.

apt-get update

Refer to this in case you get the GPG errors.

Then see what's the latest Bash version you got. In my case it was 4.2+dfsg-0.1+deb7u3. Upgrade Bash to the latest version. Here's how you can specify which version of the package to install in case you have multiple available.

apt-get install bash=4.2+dfsg-0.1+deb7u3

This will install the recent version.


Here's how the patched VPS looks like now:

As you can see, initially the bash version was 4.2+dfsg-0.1, and after the upgrade it's 4.2+dfsg-0.1+deb7u3. Then there's another test which doesn't output the busted value anymore.


Source: http://habrahabr.ru/company/mailru/blog/238475/

UPD: More vulnerabilities to test against: http://en.wikipedia.org/wiki/Shellshock_(software_bug)#Reported_vulnerabilities. Bad news is that not all of those are fixed by the update, so now we wait.

November 1, 2011

root

Confucius say:
He who play in root, eventually kill tree.

June 20, 2011

Adding an IP-alias to CentOS server

In order to add an IP-alias to CentOS-powered server, go to /etc/sysconfig/network-scripts and create a new file eth0:X where X is the last existing interface's number incremented by 1.
Type this to see all enabled interfaces:
ifconfig

Result example:
eth0 Link encap:Ethernet HWaddr ...
eth0:1 Link encap:Ethernet HWaddr ...
lo Link encap:Local Loopback ...

This means X would be 2 in our case. So let's create a new file named eth0:2 with the following contents:
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0:2
BOOTPROTO=static
IPADDR=%IP_ALIAS%
NETMASK=255.255.255.0
NETWORK=%GATEWAY_IP%
ONBOOT=yes


Start:
ifup eth0:2

Установка Icecast2 под CentOS

Уже писал об установке Icecast2 под FreeBSD, но вот недавно потребовалось установить его на CentOS.

Я не нашел толкового руководства в интернете, действовал "вслепую". В итоге решил что ничего не получилось, и успокоился, поставив Icecast просто на другой сервер. Однако выяснилось, что он тогда всё-таки установился... Я разрыл .bash_history и привожу его часть где видны мои отчаянные попытки таки поставить Icecast. Знаю, возможно, это самое дерьмовое руководство, которое я публиковал :)

Внимание: не вбивайте в консоль все команды подряд (как перечислено ниже).

uname -a
all
lsb_release -a
yum -y install icecast
yum -y install icecast2
yum search icecast
yum search icecast2
yum search icecast-server
uname -a
yum update
cd /etc/yum.repos.d
ls ./
yum info icecast
yum info icecast
yum update
yum search icecast2
yum search icecast-server
rpm -Uhv http://apt.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uhv http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
cd ~
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uhv rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm
yum info htop
yum info htop
yum info icecast
yum info icecast2
yum info icecast-server
yum install curl-devel libtheora-devel libvorbis-devel libxslt-devel speex-devel
rpm -ivh http://downloads.xiph.org/releases/icecast/icecast-2.3.1-0.src.rpm
rpm -ivh http://downloads.xiph.org/releases/icecast/icecast-2.3.1-0.src.rpm
rpmbuild -bb /usr/src/redhat/SPECS/icecast.spec
yum install rpm-build
rpmbuild -bb /usr/src/redhat/SPECS/icecast.spec
rpm -ivh http://downloads.xiph.org/releases/icecast/icecast-2.3.1-0.src.rpm
rpmbuild -bb /usr/src/redhat/SPECS/icecast.spec
rpm -ivh /usr/src/redhat/RPMS/i386/icecast-2.3.1-0.i386.rpm
service icecast start
exit
cd /home
wget http://downloads.xiph.org/releases/icecast/icecast-2.3.1-0.src.rpm
rpmbuild --rebuild icecast-2.3.1-0.src.rpm
exit
mc
jobs
exit


:)))

Так или иначе, на этом этапе, предполагается, что Icecast в системе установлен.

Теперь создадим ему пользователя (как описано здесь):
groupadd icecast && useradd icecast2 -g icecast


Создадим папки и файлы:
mkdir /var/log/icecast && touch /var/log/icecast/access.log && touch /var/log/icecast/error.log && touch /var/log/icecast/playlist.log && chown -R icecast2 /var/log/icecast/* && chgrp -R icecast /var/log/icecast/* && chmod 644 /var/log/icecast/*


Открываем конфиг (у меня это /etc/icecast.xml) и прописываем:
1. Запуск от имени пользователя icecast2 (иначе будет вылетать ERROR: You should not run icecast2 as root Use the changeowner directive in the config file):
<security>

<chroot>0</chroot>

<changeowner>

<user>icecast2</user>

<group>icecast</group>

</changeowner>

</security>


2. Пути к логам:
<logdir>/var/log/icecast</logdir>


Запускаеи Icecast2:
icecast -b -c /etc/icecast.xml

Можно также использовать полный путь к программе, в моём случае /usr/bin/icecast:
/usr/bin/icecast -b -c /etc/icecast.xml


Чтобы Icecast стартовал при запуске системы нужен соответствующий скрипт /etc/rc.d/init.d/icecast2. В моей системе его не оказалось, поэтому был найден следующий вариант:
#!/bin/sh
#
# icecast This shell script takes care of starting and stopping
# the icecast multimedia streaming systen.
#
# chkconfig: - 85 15
# description: icecast is a multimedia streaming daemon. It is used to \
# relay and offer multimedia streaming content.
# processname: icecast
# pidfile: /var/run/icecast/icecast.pid
# config: /etc/icecast.xml

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /usr/bin/icecast ] || exit 0

# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n $"Starting icecast streaming daemon: "
daemon "/usr/bin/icecast -b -c /etc/icecast.xml > /dev/null"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/icecast
;;
stop)
# Stop daemon.
echo -n $"Shutting down icecast streaming daemon: "
killproc icecast
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/icecast
;;
status)
status icecast
RETVAL=$?
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n $"Reloading icecast: "
killproc icecast -HUP
RETVAL=$?
echo
;;
condrestart)
[ -f /var/lock/subsys/icecast ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload}"
RETVAL=1
;;
esac

exit $RETVAL


Работает.

P.S. под конец все-таки нашел какое-то руководство, но уже не стал проверять. http://www.linuxhelp.net/forums/index.php?showtopic=8226&pid=27924&st=0&#entry27924

centos add user group

Adding a group in CentOS:
groupadd %groupname%

Creating a new user and adding him to a group:
useradd %username% -g %groupname%

Just adding a new user:
useradd %username%

Attaching an existing user to a group:
usermod -g %groupname% %username%

Check:
id %username%

Note! You may be getting errors like
bash: useradd: command not found
bash: groupadd: command not found

In this case, as advised here, use full path to commands or if you're using su, type it as follows:
su -