creacion de un ips utilizando linux y hardware soekris

40
CONGRESO NACIONAL DE SOFTWARE LIBRE INSTITUTO POLITECNICO NACIONAL Creación de un IPS utilizando Linux y equipo Soekris Eng. Javier Reyna Padilla Agosto, 2006

Upload: ozikox

Post on 14-Jun-2015

3.372 views

Category:

Technology


4 download

DESCRIPTION

Presentacion en el CONSOL de hace algunos años, comenta como crear un IPS utilizando Gentoo y Snort_Inline, para meterlo en cajitas Soekris.

TRANSCRIPT

Page 1: Creacion de un IPS utilizando Linux y hardware Soekris

CONGRESO NACIONAL DE SOFTWARE LIBRE

INSTITUTO POLITECNICO NACIONAL

Creación de un IPS utilizando Linux y equipo Soekris Eng.

Javier Reyna PadillaAgosto, 2006

Page 2: Creacion de un IPS utilizando Linux y hardware Soekris

2

Agenda

● Objetivo.● GNAP (Gentoo Network ApPliance).● Equipos Soekris.● IDS e IPS.● Configurando un IPS para Soekris.

Page 3: Creacion de un IPS utilizando Linux y hardware Soekris

3

Objetivo

Construir una solución (?) utilizando S.L. y hardware tipo appliance, la cual sea fácil de

crear y mantener.

Page 4: Creacion de un IPS utilizando Linux y hardware Soekris

4

GNAP

● Serie de scripts para manipular catalyst.● GNAP – Gentoo Network APpliance.● Sistema tipo Unix minimalista.● Compatible con el hardware de Soekris.● Fácil de modificar .● Diseñado para crear SO para appliance.

Page 5: Creacion de un IPS utilizando Linux y hardware Soekris

5

Características de GNAP

● FS recortado y comprimido con squashfs.● Usa hardened-sources para el kernel.● No utiliza busybox.● SSH, FW, VPN, NTPD, RP-PPOE.● Iftop, tcpdump.● Extensiones: boa, rrdtool, dash.

Page 6: Creacion de un IPS utilizando Linux y hardware Soekris

6

Cómo funciona GNAP

● overlay.conf - determina el uso final.● $ gnap_overlay ­i myfirewall.iso ­o myoverlay/

Page 7: Creacion de un IPS utilizando Linux y hardware Soekris

7

gnap_overlay

● Genera el sistema final.● Overlay - arbol de archivos que se agregarán

al sistema final (indispensable).● GNAPcore - base de gnap (indispensable).● Conflet - paquete de configuraciones ya

hechas que seran agregadas al sistema final (opcional).

Page 8: Creacion de un IPS utilizando Linux y hardware Soekris

8

¡¡¡ GNAP Avanzado !!!

● gnap_dev & gnap extensions.● Recompilar kernel para agregar nuevos

modulos mediante genkernel.● Agregar o quitar programas del GNAPcore.

Page 9: Creacion de un IPS utilizando Linux y hardware Soekris

9

gnap_make

● gnap_make ­t extensions ­p portage­latest.tar.bz2 ­e specs/

Page 10: Creacion de un IPS utilizando Linux y hardware Soekris

10

gnap_remaster

● gnap_remaster  ­d  extensions/  ­e  snort  ­e bridge ­k kernel.tar.bz2 ­m modules.tar.bz2 ­o ElfOS_rev7_SB.tar

Page 11: Creacion de un IPS utilizando Linux y hardware Soekris

11

Hardware Soekris Eng.

● Sistema embebido diseñado para sistemas operativos tipo UNIX.

● Diseñado como dispositivo de comunicaciones.● Procesador 266MHz Geode.● 128MB en RAM.● Memoria CF como medio de almacenamiento.● Pequeñas dimensiones.

Page 12: Creacion de un IPS utilizando Linux y hardware Soekris

12

Soekris net4801

Page 13: Creacion de un IPS utilizando Linux y hardware Soekris

13

Soekris net4801

Page 14: Creacion de un IPS utilizando Linux y hardware Soekris

14

Soekris net4801

Page 15: Creacion de un IPS utilizando Linux y hardware Soekris

15

Funcionamiento de un IDS

Page 16: Creacion de un IPS utilizando Linux y hardware Soekris

16

Funcionamiento de un SPI

Page 17: Creacion de un IPS utilizando Linux y hardware Soekris

17

Sistema Previsor de Intrusos

● Genera una acción inmediata frente anomalías que indiquen un riesgo potencial.

● Es un elemento activo.● Funciona en modo puente y es transparente

para la red.● Parche Virtual!● Principal punto de fallo si se rompe el puente.

Fail over!!!

Page 18: Creacion de un IPS utilizando Linux y hardware Soekris

18

Paso 1. Preparar el ambiente

● Utilizar de preferencia Gentoo !!● Actualizar árbol de portes y

descargar portage_latest.● Obtener el software necesario:

gnap, gnap-dev, gnap-ext, hardened sources.

● Directorio de trabajo /usr/lib/gnap.

Page 19: Creacion de un IPS utilizando Linux y hardware Soekris

19

Paso 2. Kernel y módulos

●Incluir modulos ip_queue y bridge. ●Generar modules.tbz2 y kernel.tbz2 mediante genkernel.

Page 20: Creacion de un IPS utilizando Linux y hardware Soekris

20

Kernel y módulos - CLI

linux usr # emerge ­­oneshot ­­ask hardened­sources

linux usr # cd /usr/lib/gnap

linux gnap # tar xvfj gnap­specs.tar.bz2

linux gnap # cd specs/

linux specs # cat kernel.config | grep BRIDGE

CONFIG_BRIDGE=m

linux specs # cat kernel.config | grep QUEUE

CONFIG_IP_NF_QUEUE=m

Page 21: Creacion de un IPS utilizando Linux y hardware Soekris

21

Kernel y módulos – CLI Cont. 1

linux gnap #mkdir tempmod

linux gnap #genkernel ­­kerneldir=/usr/src/linux­2.6.13­hardened­r2/ \

­­kernel­config=/usr/lib/gnap/specs/kernel.config \

­­minkernpackage=/usr/lib/gnap/kernel.tar.bz2 \

–­modulespackage=/usr/lib/gnap/modules.tar.bz2 –no­install ­–module­prefix=/usr/lib/gnap/tempmod all

Page 22: Creacion de un IPS utilizando Linux y hardware Soekris

22

Paso 3. Generar extensiones

● Se van a agregar los paquetes snort y bridge-

utils.

● Se debe modificar el archivo extensions.conf

dentro de /usr/lib/gnap/specs.

● Es necesario obtener el snapshot de portage

más actualizado.

Page 23: Creacion de un IPS utilizando Linux y hardware Soekris

23

Generar extensiones - CLI

linux gnap # cat specs/extensions.conf# List of extensions to buildextensions: snort bridge­utils

snort/packlist: snortsnort/useflags: inlinesnort/cleanup: /usr/share /etc/

bridge­utils/packlist: bridge­utilsbridge­utils/cleanup: /usr/share

Page 24: Creacion de un IPS utilizando Linux y hardware Soekris

24

Generar extensiones – CLI Cont 1linux gnap # gnap_make ­t extensions ­p portage­latest.tar.bz2 ­e specs/

GNAP Core Building tool gnap_make version 1.8.2 * Checking parameters...                                                                                                               [ ok ]

* 'livecd­stage1' or 'extensions' was selected without 'stage3'.

* Should I use the seed stage as stage3 result ? [N]: Y * The following targets will be called: * [extensions] * Preparing portage snapshot...linux gnap # ls ­1 *.tbz2gnapext_bridge­utils­20051030.tbz2gnapext_snort­20051030.tbz2

Page 25: Creacion de un IPS utilizando Linux y hardware Soekris

25

Paso 4. Generar un nuevo Core

● El nuevo núcleo incluirá el nuevo kernel, los

módulos extras, las extensiones adicionales y

el sistema de archivos básico de GNAP.

● Nos poroveerá el sistema listo para ser

configurado.

Page 26: Creacion de un IPS utilizando Linux y hardware Soekris

26

Generar un nuevo Core - CLI

linux  gnap  #  gnap_remaster  ­d  extensions/  ­e  snort  ­e bridge  ­k  kernel.tar.bz2  ­m  modules.tar.bz2  ­o ElfOS_rev7_SB.tar

Page 27: Creacion de un IPS utilizando Linux y hardware Soekris

27

Paso 5. Configuraciones

●Las configuraciones en GNAP se llaman overlay.●Se trata de un árbol de directorios que serán copiados al sisteman final.

Se debe de configurar:●Modulos del kernel (ip_queue, bridge)●Tarjetas de red, bridge y firewall●Snort●Reglas de snort (Bleeding Snort)

Page 28: Creacion de un IPS utilizando Linux y hardware Soekris

28

/etc/conf.d/

● Existen 3 interfaces en el equipo Soekris: 2 para el bridge y 1 para la administración.

/etc/conf.d/net

linux conf.d # cat net

ipaddr_eth0=( "192.168.1.215/24")iproute_eth0=( "default via 192.168.1.7"

Page 29: Creacion de un IPS utilizando Linux y hardware Soekris

29

/etc/conf.d/

etc/conf.d/snort_inline

# Config file for /etc/init.d/snort

# This tell snort which interface to listen onIFACE=eth1# Make sure this matches your IFACEPIDFILE=/var/run/snort_inline.pid

LOGDIR="/var/log/snort"

CONF=/etc/snort_inline/snort_inline.conf# This pulls in the options above

SNORT_OPTS="­QD ­u nobody ­i $IFACE ­l $LOGDIR ­c $CONF"

Page 30: Creacion de un IPS utilizando Linux y hardware Soekris

30

/etc/conf.d/

● La contraseña de root es “imposible”.

● Se utiliza crypt para cifrar una contraseña

utilizando DES.

etc/gnap/chpasswd

linux etc # cat gnap/chpasswdroot:qdp5EtUN0ttCM

Page 31: Creacion de un IPS utilizando Linux y hardware Soekris

31

/etc/init.d/etc/init.d/rc.firewall

#!/bin/bash

BRIDGE=/sbin/brctlIFCONFIG=/sbin/ifconfigIPTABLES=/sbin/iptablesECHO=/bin/echo

$IFCONFIG eth1 0.0.0.0 up ­arp$IFCONFIG eth2 0.0.0.0 up ­arp

$BRIDGE addbr idp0$BRIDGE addif idp0 eth1$BRIDGE addif idp0 eth2

Page 32: Creacion de un IPS utilizando Linux y hardware Soekris

32

/etc/init.d/

$IFCONFIG idp0 0.0.0.0 up ­arp

$IPTABLES ­F$IPTABLES ­A FORWARD ­j QUEUE

$IPTABLES ­A INPUT ­i eth0 ­p tcp ­­dport 22 ­j ACCEPT

Page 33: Creacion de un IPS utilizando Linux y hardware Soekris

33

/etc/

/etc/overlay.conf

#KEYMAP=fr (us)NBCARDS=1#IP_RELAY=yes (no)#EMPTY_ROOTPASS=yes (no)#USE_PPPOE=yes (no)RW_SYNC=/dev/hda2USE_SSH=yes

Page 34: Creacion de un IPS utilizando Linux y hardware Soekris

34

/etc/snort_inline

● snort_inline.conf – Prácticamente la

configuración es igual que para snort.

● snort_inline/rules – Contiene todas las

reglas que podrán habilitarse para inspección.drop tcp $HOME_NET any -> $EXTERNAL_NET 6881:6889

(msg:"P2P BitTorrent transfer"; flow:to_server,established; content:"|

13|BitTorrent protocol")

Page 35: Creacion de un IPS utilizando Linux y hardware Soekris

35

Paso 6. Instalar el sistema

●Antes de escribir el sistema en la tarjeta es necesario preparar el medio, en este caso se crearon 2 particiones:

Device Boot      Start         End      Blocks   Id  System/dev/hda1   *           1         764      195568   83  Linux/dev/hda2             765         978       54784   83  Linux

● E instalar el MBR

linux gnap # dd if=/usr/lib/gnap/mbr/mbr.bin of=/dev/sdb bs=512 count=1

Page 36: Creacion de un IPS utilizando Linux y hardware Soekris

36

Instalar el sistema

● Antes de escribir se debe cuidar desmontar la tarjeta.linux gnap # gnap_overlay ­n ­d /dev/sdb1 ­r hda1 ­g ElfOS_rev7_SB.tar ­o examples/idp/ ­m ­s 19200GNAP overlay tool gnap_overlay 1.8.2 * Checking parameters...                                       * Warning : you have selected disk install * Make sure you are root or have full access to /dev/sdb1 * /dev/sdb must have an MBR installed, run: * dd if=/usr/lib/gnap/mbr/mbr.bin of=/dev/sdb bs=512 count=1 if needed * /dev/sdb1 must contain an active partition: *  use fdisk /dev/sdb if needed * Current data on /dev/sdb1 will be destroyed ! * Are your sure you want to continue [N] Y

Page 37: Creacion de un IPS utilizando Linux y hardware Soekris

37

Poner el equipo en producción

Page 38: Creacion de un IPS utilizando Linux y hardware Soekris

38

Consideraciones

● GNAP genera un LiveCD todo esta en ramdisk.

●Cuidado con los logs !!!

●Soekris no incluye Fail Over en sus NIC.

●No hay actualizaciones automáticas.

●No es necesario reconstruir para reconfigurar.

●Permite lo no bloqueado específicamente.

Page 39: Creacion de un IPS utilizando Linux y hardware Soekris

39

Sitios de Interes● GNAP - www.gentoo.org/proj/en/base/embedded/gnap.xml

● SNORT INLINE - http://snort-inline.sourceforge.net/

● SOEKRIS ENG. - http://www.soekris.com/

● BLEEDING SNORT - http://www.bleedingsnort.com/

● ELFOS - http://sourceforge.net/projects/elfos

Page 40: Creacion de un IPS utilizando Linux y hardware Soekris

40