Arquivo da categoria ‘howto’

#!/bin/sh
#Para a checagem de Sintaxe use a opção −n. ex: #!/bin/sh -n
# Script de backup
# hachidbackupservers.sh − Faz backup de Servidores usando Rsync
### Inicialização das variáveis
#
#@autor: Richardson Lima
#@email2:securityfusion@gmail.com
#

#ROOT_UID=0      # Apenas os usuários com $UID 0 tem privilégios root.
#LINES=500       # Número padrão de linhas salvas.
#E_XCD=66        # Não é possível alterar o diretório?
#E_NOTROOT=67    # Non−root, saída erro.

### Habilite para depuração
# DEBUG=1 # depuração: 0 desliga, 1 liga
### função de depuração
#Debug(){ [ “$DEBUG” = 1 ] && echo “$*” ; }

#Servidores
MAILSERVER=’192.168.0.x’
MYSQLSERVER=’192.168.0.x’
SMBSERVER=’192.168.0.x’     # Servidor Samba
SVNSERVER1=’192.168.0.x’    # Servidor SVN1
SVNSERVER2=’192.168.0.x’    # Servidor SVN2
CVSSERVER=’192.168.0.x’     # Servidor CVS

### MAILSEVER
HOME_MAIL_TMP_DIR=’/algumDiretorio/bkp-mail/tmp-home-mail/’           # Diretório de armazenamento temporario
VAR_MAIL_TMP_DIR=’/algumDiretorio/bkp-mail/tmp-var-mail/’             # Diretório de armazenamento temporario
ETC_MAIL_TMP_DIR=’/algumDiretorio/bkp-mail/tmp-etc-mail/’             # Diretório de armazenamento temporario
BKP_MAIL_DIR=’/algumDiretorio/bkp-mail/’                              # Diretório de armazenamento dos compactados

### MYSQLSERVER
BACKUP_REMOTO_DIR1=’/algumDiretorio/bkp-mysql/’
BACKUP_REMOTO_DIR2=’/algumDiretorio/bkp-mysql/’
BACKUP_DIR1=’/algumDiretorio/bkp-mysql/’
BACKUP_DIR2=’/algumDiretorio/b-mysql/bkp-reserva-mysql/’
BACKUP_TMP_DIR1=’/algumDiretorio/bkp-mysql/tmp1′
BACKUP_TMP_DIR2=’/algumDiretorio/bkp-mysql/tmp2′

### CVS SEVER
CVSDIR=’/algumDiretorio/cvs/’
BKP_TMP_CVS=’/algumDiretorio/bkp-cvs/tmp-cvs/’
CVS_BKP_DIR=’/algumDiretorio/bkp-cvs’

### SVN SERVER 1
SVNDIR1=’/algumDiretorio/svn/’
BKP_TMP_SVN1=’/algumDiretorio/b-svn1/tmp-svn1/’
SVN1_BKP_DIR=’/algumDiretorio/b-svn1/’

### SVN SERVER 2
SVNDIR2=’/algumDiretorio/svn/’
BKP_TMP_SVN2=’/algumDiretorio/bkp-svn2/tmp-svn2/’
SVN2_BKP_DIR=’/algumDiretorio/bkp-svn2/’

### Data e Log
LOG=’/var/log/backup.log’
DATA=`date +%d-%m-%Y-%H.%M`

# Executar como root, claro!.
#if [ “$UID” −ne “$ROOT_UID” ]
#then
#   echo “Ops ! Somente o usuário root pode rodar este programa.”
#   exit $E_NOTROOT
#fi
# Teste se apresentar argumento de linha de comando (non−empty).
#then
#   lines=$1
#else
#   lines=$LINES # Padrão, se não especificado em linha de comando.
#fi

echo “—————————————”
echo “-  Iniciando backup do servidor MySQL -”
echo “—————————————”
echo

# 1
#ssh root@${MYSQLSERVER} ‘/usr/bin/mysqldump -u root -pCOLOCARSENHA –all-databases > /algumDiretorio/b-mysql/backupmysql.sql’
#ssh root@${MYSQLSERVER} ‘cd ${BACKUP_REMOTO_DIR1}’
#ssh root@${MYSQLSERVER} ‘tar -czvf bkpMysql-${DATA}.tar.gz backupmysql.sql’

rsync -Cravzp root@${MYSQLSERVER}:${BACKUP_REMOTO_DIR1}* ${BACKUP_TMP_DIR1} >> ${LOG} # transferindo o backup do Mysql para o servidor de backup
cd ${BACKUP_TMP_DIR1} && tar -czvf bkpMysql-${DATA}.tar.gz backupmysql.sql && cp *sql ${BACKUP_DIR1} && cp *.tar.gz ${BACKUP_DIR1}
echo ”  Procurando arquivos com mais de 7 dias para remoção  ”
find ${BACKUP_DIR1} -name “*.tar.gz” -ctime +7 -exec rm -vrf {} >> ${LOG} \;
echo “Limpando diretório temporario”
cd ${BACKUP_TMP_DIR1}* >> ${LOG} && rm -vrf *.sql *.tar.gz >> ${LOG}

# 2
#ssh root@${MYSQLSERVER} ‘/usr/bin/mysqldump -u root -pCOLOCARSENHA –all-databases > /algumDiretorio/b-mysql/backupmysql.sql’
#ssh root@${MYSQLSERVER} ‘cd ${BACKUP_REMOTO_DIR2}’
#ssh root@${MYSQLSERVER} ‘tar -czvf bkpMysql-${DATA}.tar.gz backupmysql.sql’

rsync -Cravzp root@${MYSQLSERVER}:${BACKUP_REMOTO_DIR2}* ${BACKUP_TMP_DIR2} >> ${LOG} # transferindo o backup do Mysql para o servidor de backup
cd ${BACKUP_TMP_DIR2} && tar -czvf bkpMysql-${DATA}.tar.gz backupmysql.sql  && cp *sql ${BACKUP_DIR2} cp *.tar.gz ${BACKUP_DIR2}
echo ”  Procurando arquivos com mais de 7 dias para remoção  ”
find ${BACKUP_DIR2} -name “*.tar.gz” -ctime +7 -exec rm -vrf {} >> ${LOG} \;
echo “Limpando diretório temporario”
cd ${BACKUP_TMP_DIR2}* >> ${LOG} && rm -vrf *.sql *.tar.gz >> ${LOG}

# mensagem de resultado
echo
echo “——————————————-”
echo “-          BACKUP DO SERVIDOR MySQL       -”
echo “-  Seu backup foi realizado com sucesso.  -”
echo “——————————————-”

echo “————————————–”
echo “-  Iniciando backup do servidor Mail -”
echo “————————————–”
echo

echo
mount /dev/md0 /algumDiretorio
montado=`mount | grep /algumDiretorio`
if [ -z “$montado” ]; then
exit 1
else
echo ”  Iniciando copia dos arquivos … ”
rsync -Cravzp root@${MAILSERVER}:/Diretorio/ ${HOME_MAIL_TMP_DIR} >> ${LOG}
rsync -Cravzp root@${MAILSERVER}:/Diretorio/ ${VAR_MAIL_TMP_DIR} >> ${LOG}
rsync -Cravzp root@${MAILSERVER}:/Diretorio/ ${PAGINA_MAIL_TMP_DIR} >> ${LOG}
rsync -Cravzp root@${MAILSERVER}:/Diretorio/ ${ETC_MAIL_TMP_DIR} >> ${LOG}
cd ${BKP_MAIL_DIR}
#if [ `pwd` != “$BKP_MAIL_DIR” ]  # or   if [ “$PWD” != “$BKP_MAIL_DIR” ]
# Não está em /algumDiretorio/b-mail/?
#then
# echo “Não é possível alterar $BKP_MAIL_DIR.”
# exit $E_XCD
#fi # Doublecheck no diretório, antes de brincar com arquivo de registro.

echo ”  Compactando os arquivos  …     ”
tar -czvf bkpHome-mail-${DATA}.tar.gz ${HOME_MAIL_TMP_DIR} >> ${LOG}
tar -czvf bkpVar-mail-${DATA}.tar.gz ${VAR_MAIL_TMP_DIR} >> ${LOG}
tar -czvf bkpHome-Pagina-mail-${DATA}.tar.gz ${PAGINA_MAIL_TMP_DIR} >> ${LOG}
tar -czvf bkpEtc-mail-${DATA}.tar.gz ${ETC_MAIL_TMP_DIR} >> ${LOG}
echo ”  Procurando arquivos com mais de 7 dias para remoção  ”
find ${BKP_MAIL_DIR} -name “*.tar.gz” -ctime +7 -exec rm -vrf {} >> ${LOG} \;
echo “Limpando diretório temporario”
rm -vrf ${HOME_MAIL_TMP_DIR}* >> ${LOG}
rm -vrf ${VAR_MAIL_TMP_DIR}* >> ${LOG}
rm -vrf ${PAGINA_MAIL_TMP_DIR}* >> ${LOG}
rm -vrf ${ETC_MAIL_TMP_DIR}* >> ${LOG}
# mensagem de resultado
echo
echo “——————————————-”
echo “-          BACKUP SEVIDOR-MAIL            -”
echo “-  Seu backup foi realizado com sucesso.  -”
echo “——————————————-”
echo
fi

echo
echo “———————————–”
echo “Iniciando backup do servidor SVN 1 ”
echo “———————————–”

echo
mount /dev/md0 /algumDiretorio
montado=`mount | grep /algumDiretorio`
if [ -z “$montado” ]; then
exit 1
else
echo “Iniciando copia dos arquivos … ”

rsync -Cravzp root@${SVNSERVER1}:${SVNDIR1} ${BKP_TMP_SVN1}
echo “Compactando os arquivos … ”
cd ${SVN1_BKP_DIR}

tar -czvf bkpSvn1-${DATA}.tar.gz ${BKP_TMP_SVN1} >> ${LOG}
echo “Procurando arquivos com mais de 7 dias para remoção”
find ${SVN1_BKP_DIR} -name “*.tar.gz” -ctime +7 -exec rm -vrf {} >> ${LOG} \;
echo “Limpando diretório temporario”
rm -vrf ${BKP_TMP_SVN1}* >> ${LOG}
# mensagem de resultado
echo
echo “———————————–”
echo ”     BACKUP SVN1 CONCLUIDO!        ”
echo “———————————–”
echo
fi

echo
echo “———————————–”
echo “Iniciando backup do servidor SVN 2 ”
echo “———————————–”

echo
mount /dev/md0 /algumDiretorio
montado=`mount | grep /algumDiretorio`
if [ -z “$montado” ]; then
exit 1
else
echo “Iniciando copia dos arquivos … ”

rsync -Cravzp root@${SVNSERVER2}:${SVNDIR2} ${BKP_TMP_SVN2}
echo “Compactando os arquivos … ”
cd ${SVN2_BKP_DIR}

tar -czvf bkpSvn2-${DATA}.tar.gz ${BKP_TMP_SVN2} >> ${LOG}
echo “Procurando arquivos com mais de 7 dias para remoção”
find ${SVN2_BKP_DIR} -name “*.tar.gz” -ctime +7 -exec rm -vrf {} >> ${LOG} \;
echo “Limpando diretório temporario”
rm -vrf ${BKP_TMP_SVN2}* >> ${LOG}
# mensagem de resultado
echo
echo “———————————–”
echo ”     BACKUP SVN2 CONCLUIDO!        ”
echo “———————————–”
echo
fi
#Enviando email de confirmacao

ssh root@${MAILSERVER} ‘/root/emailDoBackup.pl’

#Abaixo o conteudo do Script
#use MIME::Entity;

#$texto = “O servidor de backup realizou o backup com sucesso,em anexo o script de backup !”;

#$top = build MIME::Entity  From => ‘Root <root>’,
#                           To   =>   ‘suporte@domain’,
#                           Subject => “[Backup-Empresa] Confirmação do Backup “,
#                           Data => $texto;

# definindo o anexo
#$top->attach(
#            Name        => “backupscript.sh”,
#            Path        => “backupscript.sh”,
#Type        => “application/x-gtar”,
#            Encoding    => “base64″
#);

# caminho para o programa do agente MTA do seu servidor
#open(MAIL,”| /usr/lib/sendmail -t”);
#$top->print(\*MAIL);
#close(MAIL);

exit 0
# O valor zero é retornado após a saída do script
#+ Indica sucesso para o shell.

Instalando o Debian Etch

Publicado: agosto 1, 2008 em Debian, dicas, howto

Este tutorial mostra como instalar um Debian Etch (Debian 4.0)

Requisitos 1

Para instalar um sistema deste tipo que você vai precisar do seguinte:

O sistema básico

Insira o seu CD Debian Etch Netinstall em seu sistema e inicie a partir dele. Pressione ENTER para iniciar:

A instalação é iniciada e, primeiro você tem de escolher o seu idioma: Ex: English

Em seguida, selecione a sua localização: Ex: Germany

Escolher um layout para o seu teclado: Ex: German

O instalador checa o seu hardware, e configura a rede com DHCP, se houver um servidor DHCP na rede:

Digite o nome do host. Neste exemplo, o meu sistema é chamado server1.example.com:

Digite seu nome de domínio. Neste exemplo, é example.com:

Agora você tem que particionar o seu disco rígido. Por simplicidade vou criar uma grande partição (com o ponto de montagem /) e uma pequena partição swap , utilização disco inteiro (como é óbvio, se você quiser, pode criar mais de apenas uma grande partição, e você também pode usar LVM):

Selecione o disco que deseja particionar:

Em seguida, selecione o esquema de particionamento. Como mencionado anteriormente, eu selecionei tudos os diretórios numa partição (recomendado para novatos) :

Quando estiver concluída, selecione Terminar o particionamento e escrever as alterações no disco:

Seleccione Sim quando lhe for solicitado ‘‘escrever as alterações no disco?”:

Posteriormente, suas novas partições são criadas e formatadas:

Em seguida, especificar a senha do usuário root :

Confirmar a senha para evitar enganos:

Crie uma conta de usuário normal, por exemplo, o usuário administrador com o nome do usuário administrador (não use o nome de usuário admin, pois é um nome reservado no Debian Etch):

Agora o sistema básico vai ser instalado:

Porque você está usando o Debian Etch Netinstall CD que contém apenas um conjunto mínimo de pacotes, você deve usar um mirror de rede:

Selecione o país no qual o mirror de rede que pretende utilizar está localizado (normalmente este é o país onde o seu sistema Debian Etch está localizado):

Em seguida, selecione o mirror que pretende utilizar (por exemplo, ftp2.de.debian.org):

A não ser que você use um proxy HTTP, após deixar o campo em branco e clique em Continue:

O Apt agora está atualizando seus pacotes de dados:

Você pode pular a configuração do popularity-contest, selecionando No:

Preciso de um servidor web, DNS server, servidor de e-mail, e um banco de dados MySQL, mas mesmo assim eu não escolhi nenhum deles, porque agora eu gostaria de ter total controle sobre o que fica instalado no meu sistema. Vamos instalar os pacotes necessários manualmente mais tarde. Por esse motivo, basta selecionar sistema padrão e clique em Continue:

Os pacotes necessários estão sendo instalados no sistema:

Quando for solicitado Instalar o GRUB gestor de inicialização no master boot record, selecione Sim:

Em seguida, o gestor de inicialização GRUB será instalado:

A instalação do sistema base já está oncluída. Retire o CD Netinstall Debian Etch a da unidade de CD e tecle em Continuar a reinicialização do sistema:

Padrão iniciando programa no boot

Publicado: novembro 22, 2007 em howto

update-rc.d script defaults


I’ve had few questions about obtaining the MAC and IP addresses on a Windows box. Personally, I find the ipconfig command as the easiest way to get this information. Here’s an example.

C:\Documents and Settings\hachid>ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : ixxx
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Mixed
IP Routing Enabled. . . . . . . . : Yes
WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 CT Network Connect
ion
Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : xxx.xxx.x.x
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : xxx.xxx.xx.x
DHCP Server . . . . . . . . . . . : xxx.xxx.x.x
DNS Servers . . . . . . . . . . . : xxx.xxx.xx.x
xxx.xxx.xx.x
Lease Obtained. . . . . . . . . . : Monday, October 22, 2007 6:46:11 PM
Lease Expires . . . . . . . . . . : Tuesday, October 23, 2007 6:46:11 PM


After reviewing my Google Webmaster tools, I’ve observed several search iterations for “remove first 100 or 1000 lines in a log file.” Here’s an example to demonstrate removing the first 10 lines, 100 lines or 1000 lines in an .htaccess file.

Remove first 10 lines
# nl -ba .htaccess | more
1
2 order allow,deny
3 allow from all
4
5
6 deny from 213.xxx.xxx.xx
7 deny from 124.xxx.xxx.xx
8 deny from 81.xxx.xxx.xx
9 deny from 88.xxx.xxx.xx
10 deny from 88.xxx.xxx.11
11 deny from 84.xxx.xxx.56
12 deny from 88.xxx.xxx.xx
13 deny from 82.xxx.xxx.xx
14 deny from 69.xxx.xxx.xx
15 deny from 24.xxx.xxx.xx

# tail +11 .htaccess | more
deny from 84.xxx.xxx.56
deny from 88.xxx.xxx.xx
deny from 82.xxx.xxx.xx
deny from 69.xxx.xxx.xx
deny from 24.xxx.xxx.xx

Above is for illustration purposes but this syntax is all you need.
# tail +11 .htaccess > remove_10Lines.txt

Remove first 100 lines
# nl -ba .htaccess | more

96 deny from 85.xxx.xxx.xx
97 deny from 85.xxx.xxx.xx
98 deny from 85.xxx.xxx.xx
99 deny from 83.xxx.xxx.xx
100 deny from 81.xxx.xxx.70
101 deny from 81.xxx.xxx.29
102 deny from 81.xxx.xxx.xx
103 deny from 77.xxx.xxx.xx

# tail +101 .htaccess | more
deny from 81.xxx.xxx.29
deny from 81.xxx.xxx.xx
deny from 77.xxx.xxx.xx

Above is for illustration purposes but this syntax is all you need.
# tail +101 .htaccess > remove_100Lines.txt

Remove first 1000 lines
# nl -ba .htaccess | grep 1000 | more
1000 deny from 88.xxx.xxx.114

# nl -ba .htaccess | more

996 deny from 88.xxx.xxx.xxx
997 deny from 88.xxx.xxx.xxx
998 deny from 88.xxx.xxx.xxx
999 deny from 88.xxx.xxx.xxx
1000 deny from 88.xxx.xxx.114
1001 deny from 88.xxx.xxx.59
1002 deny from 88.xxx.xxx.xxx
1003 deny from 88.xxx.xxx.xxx

# tail +1001 .htaccess | more
deny from 88.xxx.xxx.59
deny from 88.xxx.xxx.xxx
deny from 88.xxx.xxx.xxx

Above is for illustration purposes but this syntax is all you need.
# tail +1001 .htaccess > remove_1000Lines.txt

Either with chkrootkit or with rkhunter.

chkrootkit

Either install the package that comes with your distribution (on Debian you would run)

apt-get install chkrootkit

, or download the sources from www.chkrootkit.org and install manually:

wget –passive-ftp ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
tar xvfz chkrootkit.tar.gz
cd chkrootkit-<version>/
make sense

Afterwards, you can move the chkrootkit directory somewhere else, e.g. /usr/local/chkrootkit:

cd ..
mv chkrootkit-<version>/ /usr/local/chkrootkit

Now you can run chkrootkit manually:

cd /usr/local/chkrootkit
./chkrootkit

(if you installed a chkrootkit package coming with your distribution, your chkrootkit might be somewhere else).

You can even run chkrootkit by a cron job and get the results emailed to you:

Run

crontab -e

to create a cron job like this:

0 3 * * * (cd /usr/local/chkrootkit-<version>; ./chkrootkit 2>&1 | mail -s "chkrootkit output my server" you@yourdomain.com)

That would run chkrootkit every night a 3.00h.

Results

webserver:/etc# /usr/sbin/chkrootkit
ROOTDIR is `/’
Checking `amd’… not found
Checking `basename’… not infected
Checking `biff’… not found
Checking `chfn’… not infected
Checking `chsh’… not infected
Checking `cron’… not infected
Checking `crontab’… not infected
Checking `date’… not infected
Checking `du’… not infected
Checking `dirname’… not infected
Checking `echo’… not infected
Checking `egrep’… not infected
Checking `env’… not infected
Checking `find’… not infected
Checking `fingerd’… not found
Checking `gpm’… not found
Checking `grep’… not infected
Checking `hdparm’… not infected
Checking `su’… not infected
Checking `ifconfig’… not infected
Checking `inetd’… not infected
Checking `inetdconf’… not infected
Checking `identd’… not found
Checking `init’… not infected
Checking `killall’… not infected
Checking `ldsopreload’… not infected
Checking `login’… not infected
Checking `ls’… not infected
Checking `lsof’… not infected
Checking `mail’… not infected
Checking `mingetty’… not found
Checking `netstat’… not infected
Checking `named’… not found
Checking `passwd’… not infected
Checking `pidof’… not infected
Checking `pop2’… not found
Checking `pop3’… not found
Checking `ps’… not infected
Checking `pstree’… not infected
Checking `rpcinfo’… not infected
Checking `rlogind’… not found
Checking `rshd’… not found
Checking `slogin’… not infected
Checking `sendmail’… not infected
Checking `sshd’… not infected
Checking `syslogd’… not infected
Checking `tar’… not infected
Checking `tcpd’… not infected
Checking `tcpdump’… not infected
Checking `top’… not infected
Checking `telnetd’… not found
Checking `timed’… not found
Checking `traceroute’… not infected
Checking `vdir’… not infected
Checking `w’… not infected
Checking `write’… not infected
Checking `aliens’… no suspect files
Searching for sniffer’s logs, it may take a while… nothing found
Searching for HiDrootkit’s default dir… nothing found
Searching for t0rn’s default files and dirs… nothing found
Searching for t0rn’s v8 defaults… nothing found
Searching for Lion Worm default files and dirs… nothing found
Searching for RSHA’s default files and dir… nothing found
Searching for RH-Sharpe’s default files… nothing found
Searching for Ambient’s rootkit (ark) default files and dirs… nothing found
Searching for suspicious files and dirs, it may take a while…
/lib/init/rw/.ramfs

Searching for LPD Worm files and dirs… nothing found
Searching for Ramen Worm files and dirs… nothing found
Searching for Maniac files and dirs… nothing found
Searching for RK17 files and dirs… nothing found
Searching for Ducoci rootkit… nothing found
Searching for Adore Worm… nothing found
Searching for ShitC Worm… nothing found
Searching for Omega Worm… nothing found
Searching for Sadmind/IIS Worm… nothing found
Searching for MonKit… nothing found
Searching for Showtee… nothing found
Searching for OpticKit… nothing found
Searching for T.R.K… nothing found
Searching for Mithra… nothing found
Searching for OBSD rk v1… nothing found
Searching for LOC rootkit… nothing found
Searching for Romanian rootkit… nothing found
Searching for Suckit rootkit… nothing found
Searching for Volc rootkit… nothing found
Searching for Gold2 rootkit… nothing found
Searching for TC2 Worm default files and dirs… nothing found
Searching for Anonoying rootkit default files and dirs… nothing found
Searching for ZK rootkit default files and dirs… nothing found
Searching for ShKit rootkit default files and dirs… nothing found
Searching for AjaKit rootkit default files and dirs… nothing found
Searching for zaRwT rootkit default files and dirs… nothing found
Searching for Madalin rootkit default files… nothing found
Searching for Fu rootkit default files… nothing found
Searching for ESRK rootkit default files… nothing found
Searching for rootedoor… nothing found
Searching for ENYELKM rootkit default files… nothing found
Searching for anomalies in shell history files… nothing found
Checking `asp’… not infected
Checking `bindshell’… not infected
Checking `lkm’… chkproc: nothing detected
Checking `rexedcs’… not found
Checking `sniffer’… lo: not promisc and no packet sniffer sockets
eth0: not promisc and no packet sniffer sockets
Checking `w55808’… not infected
Checking `wted’… chkwtmp: nothing deleted
Checking `scalper’… not infected
Checking `slapper’… not infected
Checking `z2’… chklastlog: nothing deleted

rkhunter

Download the latest rkhunter sources from www.rootkit.nl:

wget http://downloads.rootkit.nl/rkhunter-1.2.7.tar.gz
tar xvfz rkhunter-1.2.7.tar.gz
cd rkhunter/
./installer.sh

This will install rkhunter to the directory /usr/local/rkhunter. Now run

rkhunter –update

to download the latest chkrootkit/trojan/worm signatures (you should do this regularly).

Now you can scan your system for malware by running

rkhunter -c

 

You do it like this:

openssl genrsa -des3 -passout pass:yourpassword -out /path/to/your/key_file 1024

openssl req -new -passin pass:yourpassword -passout pass:yourpassword -key /path/to/your/key_file -out /path/to/your/csr_file -days 365

 

openssl req -x509 -passin pass:yourpassword -passout pass:yourpassword -key /path/to/your/key_file -in /path/to/your/csr_file -out /path/to/your/crt_file -days 365

openssl rsa -passin pass:yourpassword -in /path/to/your/key_file -out /path/to/your/key_file2

chmod 400 /path/to/your/key_file2

Resolving domain names with dig

Publicado: novembro 9, 2007 em howto

To resolve a domain name on the shell, you can use the command dig. Resolving the domain google.com:

hachidserver:~# dig google.com

; <<>> DiG 9.3.4 <<>> google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57678
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             300     IN      A       64.233.187.99
google.com.             300     IN      A       72.14.207.99
google.com.             300     IN      A       64.233.167.99

;; AUTHORITY SECTION:
google.com.             96442   IN      NS      ns1.google.com.
google.com.             96442   IN      NS      ns2.google.com.
google.com.             96442   IN      NS      ns3.google.com.
google.com.             96442   IN      NS      ns4.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.         94901   IN      A       216.239.32.10
ns2.google.com.         94901   IN      A       216.239.34.10
ns3.google.com.         94901   IN      A       216.239.36.10
ns4.google.com.         94901   IN      A       216.239.38.10

;; Query time: 193 msec
;; SERVER: 150.161.192.1#53(150.161.192.1)
;; WHEN: Fri Nov  9 14:31:33 2007
;; MSG SIZE  rcvd: 212

hachidserver:~#

A more detailed description you will find in the manpage of the dig command:

man dig

Run

route -nee

The output will look like this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface    MSS   Window irtt
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0     0     0      0
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0     0     0      0
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0     0     0      0

This means that the system with the IP address 192.168.0.100 is using 192.168.0.1 as gateway.

Show all processes for a specific user

Publicado: novembro 9, 2007 em howto

To view only the processes owned by a specific user, use the following command:

top -U [USERNAME]

and replace [USERNAME] with the name of the user.