Archive for Firewall

Correção do erro da biblioteca libevent

error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

The solution for this on Debian/Ubuntu (and probably most other linux distros) is this…

On a 32 bit system:

ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5

On a 64 bit system:

ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

Créditos : http://www.nigeldunn.com/2011/12/11/libevent-2-0-so-5-cannot-open-shared-object-file-no-such-file-or-directory/

Erro – /bin/bash^M: bad interpreter: no such file or directory

Quando tentei executar um script .sh o seguinte erro ocorreu:

/bin/bash^M: bad interpreter: no such file or directory

Causa

Provavelmente o arquivo .sh foi editado no windows utilizado algum editor como o notepad, o caractere ^M representa algum ctrl+v realizado no windows.

Solução

A solução é converter estes caracteres utilizando o programa dos2unix

Exemplo para o arquivo backup.sh:

dos2unix backup.sh

Créditos : http://ldiasrs.wordpress.com/2011/08/24/linuxbash-erro-binbashm-bad-interpreter-no-such-file-or-directory/

SendEmail & Patch AppGoogle

Link SendEmail : http://caspian.dotconf.net/menu/Software/SendEmail/

$ yum install perl perl-Net-SSLeay perl-IO-Socket-SSL make automake gcc g++

Se você estiver testando o SendEmail e estiver obtendo a mensagem “ERROR => Received: 535 5.7.0 Error: authentication failed: bad protocol / cancel” mesmo após ter revisado exaustivamente seus argumentos, você pode ter encontrado o bug descrito aqui.
Este bug afeta o SendEmail após este incorporar o recurso TLS. Consiste em uma falha na forma como SendEmail codifica as linhas que envia durante o processo de autenticação.
A boa notícia é que, caso você esteja usando a versão 1.55, você poderá usar o patch postado no link acima para corrigir este problema.
Para efetuar o patch você precisará do pacote patch:

$ yum install patch

Em seguida faça o download do patch disponibilizado no link acima. Sugiro que coloque o path no seu /tmp. Para aplicar o patch bastará executar a seguinte instrução:

$ patch -b -p1 </tmp/sendEmail.patch

A instrução poderá emitir um prompt perguntando pelo arquivo a ser “atualizado”. Informe /usr/bin/sendEmail, que – como vimos acima – é o local onde fica instalado o script do SendEmail.
Então estará concluído. Refaça seu teste. Se a falha se devia ao bug do TLS, seu teste deverá funcionar. De qualquer forma, se não estiver satisfeito com o patch, ele poderá ser desfeito, uma vez que a opção -b usada acima fez com que o patch criasse uma cópia do sendEmail, antes de aplicar a atualização. Esta cópia deverá estar na pasta /usr/bin com o nome de sendEmail.orig, (podendo variar, conforme a distro que estiver usando).

Créditos : http://sistemasecia.freehostia.com/component/jccmultilanguagecontent/article/51-sendemail.html?start=1

Script Perl para Apagar Fila Postfix

Traditionally you use the “sendmail -q” command to flush mail queue under Sendmail MTA. Under Postfix MTA, just enter the following command to flush the mail queue:
# postfix flush
OR
# postfix -f

To see mail queue, enter:
# mailq

To remove all mail from the queue, enter:
# postsuper -d ALL

To remove all mails in the deferred queue, enter:
# postsuper -d ALL deferred

postfix-delete.pl script

Following script deletes all mail from the mailq which matches the regular expression specified as the first argument (Credit: ??? – I found it on old good newsgroup)

  1. #!/usr/bin/perl
  2. $REGEXP = shift || die “no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!”;
  3. @data = qx</usr/sbin/postqueue -p>;
  4. for (@data) {
  5. if (/^(\w+)(\*|\!)?\s/) {
  6. $queue_id = $1;
  7. }
  8. if($queue_id) {
  9. if (/$REGEXP/i) {
  10. $Q{$queue_id} = 1;
  11. $queue_id = “”;
  12. }
  13. }
  14. }
  15. #open(POSTSUPER,”|cat”) || die “couldn’t open postsuper” ;
  16. open(POSTSUPER,”|postsuper -d -“) || die “couldn’t open postsuper” ;
  17. foreach (keys %Q) {
  18. print POSTSUPER “$_\n”;
  19. };
  20. close(POSTSUPER);

For example, delete all queued messages from or to the domain called fackspamdomain.com, enter:
./postfix-delete.pl fackspamdomain.com
Delete all queued messages that contain the word “xyz” in the e-mail address:
./postfix-delete.pl xyz

Updated for accuracy.

Créditos : http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html

Acentuação VIM

Vamos alterar de UTF-8 para ISO-8859-1, assim permitindo acentuação.

Adicionem no início do /etc/vimrc

set encoding=iso-8859-1
set fileencodings=iso-8859-1

Comentem todas as linhas antes dessa: set nocompatible

Créditos : http://www.htmlstaff.org/ver.php?id=22263

DDos via Nelson Brito

Achei interessante guardar …

… Assim como compartilhei a ferramenta, por acreditar que compartilhar o conhecimento é uma das melhores formas de se educar os profissionais e entusiastas de segurança, seguem algumas dicas, onde compartilho algumas idéias, de como se proteger destes tipos de ataque:

  1. Bloqueio no segmento de borda de qualquer protocolo que não seja utilizado pela empresa. Por exemplo:
    • Se o segmento de borda não utiliza tráfego IGMP, este tráfego deverá ser bloqueado.
    • Bloqueio de qualquer protocolo de uso “exclusivo” interno, como por exemplo: RIPDCCP,RSVPGREEIGRP e OSPF.
  2. Criação de ACLs em Routers/Firewalls, assim como criação de políticas de NIPS, para bloqueio de anomalias nos protocolos. Por exemplo:
    • Se o segmento de borda utiliza IPSec, mas o pacote IPSec venha com os cabeçalhos AHESP sem “payload“, este tráfego deverá ser bloqueado por ser um tráfego anômalo.
    • Tanto o T50 quanto algumas outras ferramentas utilização geração aleatória de valores para alguns campos de cabeçalho de protocolos, portanto isto deve ser considerado uma anomalia e seu tráfego, consequentemente, deve ser bloqueado.
  3. Para TCP SYN Flood (RFC4987), utilize SYN cookies e defesas contra anomalias do protocolo TCP.
  4. Para UDP Flood, bloqueie qualquer tráfego não necessário para este protocolo.
  5. Monitore anomalias estatísticas do volume de tráfego na rede. Por exemplo:
    • Ataques de TCP SYN Flood, assim como demais TCP Floods, possuem pacotes de aproximadamente 40 bytes, sendo que sua utilização não deve passar de ¼ do total do tráfego TCP (obviamente esta métrica deve ser minuciosamente avaliada para cada ambiente).
  6. Tenha um contato técnico interno na sua operadora de acesso à Internet, pois somente as operadoras poderão, de forma muito mais eficaz, criar ACLs para Ingress Filters (RFC2827/RFC3704), bloqueando pacotes com IP Spoofing. Por exemplo:
    • Tráfego com endereçamento IP do bloco de endereços pertencente ao Rio de Janeiro que venham por canais de comunicação de São Paulo sugerem que este tráfego utiliza IP Spoofing, portanto a operadora será capaz de criar ACLs impedindo a propagação deste tráfego.
  7. Crie ACLs para Egress Filters (RFC3013), impedindo que sua rede seja uma origem de ataques com IP Spoofing.
  8. Crie ACLs para Ingress Filters (RFC2827/RFC3704), bloqueando os endereços IP contidos e listados nos seguintes documentos:
Outras formas, um pouco mais esotéricas, podem ser adotadas. Por exemplo:
  1. Rate Limiting
  2. Connection Limiting
  3. Traffic Shaping
  4. Quality of Service
  5. Blackhole
  6. Sinkhole

Créditos : http://fnstenv.blogspot.com.br/

Bloqueio de Sub-Rede via Iptables usando IPRANGE

#!/bin/sh
# ifconfig wlan0 up
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -s 0.0.0.0/0 -m iprange –dst-range 192.168.0.1-192.168.0.253 -j DROP


Se Protegendo a Ataque Loic DDOS

LOIC (Low Orbit Ion Cannon) is an Open Source tool that has been used by anonymous group against governmental websites and mail servers, the main purpose of these attacks is to launch a distributed denial of service against a website and make them offline.

There are already other similar tools that may perform this attack to stop any website and make it unreachable for legitimate users. By looking at the technique used to perform this attack the tool send about 10 Long HTTP/HTTPS requests per second till it reach bandwidth or connection limits of hosts or networking equipment to make it offline . Now the question is how we can stop this attack? What are the preventive measures against the Layer7 DDoS?

First of all we start limiting the traffic using hashlimit on iptables this module can be used to allow just a certain number of packets per minute:

[php]iptables -A INPUT -p tcp –dport 80 -m hashlimit –hashlimit-upto 50/min

–hashlimit-burst X –hashlimit-mode srcip –hashlimit-name http -j ACCEPT

iptables -A INPUT -p tcp –dport 80 -j DROP[/php]

X is the number of connection so you can expect that the DDoS tool will send approximately 600 Long requests per minute so you need to make it less and as a result the firewall will Drop the connection ( do not also forget to change the port 80 according to the service that are provided from your facilities).

Now if you are using Apache you can add Module mod_reqtimeout this directive can set various timeouts for receiving the request headers and the request body from the client. If the client fails to send headers or body within the configured time, a 408 REQUEST TIME OUT error is sent.

A final important note is to stop the Hive which is used as the command-and-control server to send instructions regarding different target, so if you stop the Hive each person will be launching the attack separately and can stop the DDoS.

Créditos : http://www.sectechno.com/2011/01/25/preventing-layer-7-ddos-attack/

Repositório timb para CentOS

To install the repo first install the public key (yes all RPM’s will now be signed):-

Code:

rpm --import ftp://timburgess.net/RPM-GPG-KEY-TimB.txt

Then install the release RPM (by default the ‘timb’ and ‘timb-testing’ repo’s will be disabled)

Code:

wget ftp://timburgess.net/repo/clearos/5.2/os/timb-release-1-0.noarch.rpm
rpm -Kv timb-release-1-0.noarch.rpm
rpm -Uvh timb-release-1-0.noarch.rpm