Categoría: Administración

  • HTTPS, SSH Y OPENVPN EN UN MISMO PUERTO

    multi2De vez en cuando uno encuentra una de esas herramientas que resuelve un problema de una forma tan brillante que realmente dan ganas de aplaudir.

    Este es el caso de sslh, una herramienta que permite cumplir el sueño de todo aquel que ha tenido que lidiar en un entorno cuya salida estaba gestionada por un proxy.
    Sslh permite multiplexar un único puerto y convertirlo en varios servicios a la vez. Lo que hace es recibir la conexión en el puerto indicado, analizar que tipo de conexión es (ssl, openvpn, ssh, xmpp) y en función de ese análisis, enviar la conexión al puerto indicado.
    Por simple el concepto es brillante. Muchos nos hemos encontrado en un entorno donde un proxy solo facilita el método ‘CONNECT’ hacia el puerto 443. Si queríamos hacer uso de varios servicios era necesario usar túneles SSH que a la postre eran bastante engorrosos.
    Además, el creador de la herramienta indica un método para lidiar con proxys ‘inteligentes’ que no solo restringen conexiones a puertos sino que también analizan que las conexiones sean efectivamente SSL.
    Para instalarlo en Linux (para windows se proveen ejecutables) hay que hacer lo siguiente:
    Descargamos el paquete:
    wget https://github.com/yrutschle/sslh/archive/v1.15.tar.gz
    Lo descomprimimos
    tar -xvzf v1.15.tar.gz
    Compilamos e instalamos
    make install
    Una vez hecho eso, tenemos que configurar sslh para indicarle como queremos que mueva las conexiones.
    lo más fácil es usar el puerto 443 de la interface de red exterior para sslh y poner los otros servicios en localhost. De esa forma solo exponemos un puerto abierto al exterior y el resto de servicios están ocultos a miradas ajenas.
    Un ejemplo de uso de sslh para escuchar en el puerto 443 de la interface de red y enviar el tráfico SSH al puerto localhost 22
    sslh -p 172.16.183.139:443 –ssh 127.0.0.1:22
    Si queremos mover tráfico openvpn, tan solo tenemos que añadir el flag –openvpn 127.0.0.1:1194
    De esa forma estaremos moviendo tráfico SSH al puerto 22 y tráfico OpenVPN al puerto 1194 pero todas las conexiones desde el exterior irán contra el puerto 443.
  • Instalación de paquetes multiples en linux

    Todos hemos tenido la necesidad en multiples ocasiones de instalar varios servicios después de hacer la instalación básica de una distribución por defecto.

    Existe la conocida «apt-get install» donde le indicaremos el nombre del paquete:

    apt-get install mysql-server

    En muchas ocasiones queremos instalar por ejemplo las aplicaciones necesarias para disponer de un servidor web en nuestro equipo, por ejemplo. Tendremos que instalar probablemente, apache, mysql, php y todos sus aplicaciones básica y relacionadas. Las distribuciones basadas en debian nos ofrecen el comando «tasksel» que se puede instalar con «apt-get install tasksel».

    Su interfaz es muy simple:

    Screenshot from 2013-08-15 10:20:48Cómo se vé ahora solo tendremos que seleccionar las opciones que queramos y al pulsar en ok, se nos instalará todas las herramientas necesarias para que todo funcione correctamente.

     

     

  • Patator, una herramienta de fuerza bruta multipropósito

    Patator es un script en Python para lanzar una gran diversidad de ataques de fuerza bruta, con un diseño modular que permite un uso flexible.

    Actualmente incluye los siguientes módulos:

    ftp_login : Fuerza bruta FTP
    ssh_login : Fuerza bruta SSH
    telnet_login : Fuerza bruta Telnet
    smtp_login : Fuerza bruta SMTP
    smtp_vrfy : enumera usuarios válidos mediante el comando SMTP VRFY
    smtp_rcpt : enumera usuarios válidos mediante el comando SMTP RCPT TO
    finger_lookup : enumera usuarios válidos mediante Finger
    http_fuzz : Fuerza bruta HTTP/HTTPS
    pop_passd : Fuerza bruta poppassd (not POP3)
    ldap_login : Fuerza bruta LDAP
    smb_login : Fuerza bruta SMB
    mssql_login : Fuerza bruta MSSQL
    oracle_login : Fuerza bruta Oracle
    mysql_login : Fuerza bruta MySQL
    pgsql_login : Fuerza bruta PostgreSQL
    vnc_login : Fuerza bruta VNC
    dns_forward : reenvía búsquedas de subdominios
    dns_reverse : búsqueda inversa de subredes
    snmp_login : Fuerza bruta SNMPv1/2 y SNMPv3
    unzip_pass : Fuerza bruta de las contraseñas de ficheros ZIP
    keystore_pass : Fuerza bruta de las contraseñas de ficheros keystore Java

    Más información y sintáxis en su repositorio oficial.
    Advertencia: no se trata de una herramienta amigable o para script kiddies. Normalmente se requieren muchos parámetros para su ejecución, lo cual le hace más efectiva.
  • Enable AutoMount USB Drivers on Ubuntu Server

    By default, disk drives do not automount in Ubuntu Server Edition. If you are looking for a lightweight solution that does not depend on HAL/DBUS, usbmount is a good choice.

    The USBmount Debian package automatically mounts USB mass storage devices (typically USB pens) when they are plugged in, and unmounts them when they are removed. The mountpoints (/media/usb[0-7] by default), filesystem types to consider, and mount options are configurable. When multiple devices are plugged in, the first available mountpoint is automatically selected. If the device provides a model name, a symlink /var/run/usbmount/MODELNAME pointing to the mountpoint is automatically created.

    The script that does the (un)mounting is called by the udev daemon. Therefore, USBmount requires a 2.6 (or newer) kernel.

    USBmount is intended as a lightweight solution which is independent of a desktop environment. Users which would like an icon to appear when an USB device is plugged in should use the pmount and hal packages instead.

    USBmount is licensed under an ‘all-permissive license’ (i.e. everything is allowed, as long as the copyright and license notices and the warranty disclaimer are preserved). See the debian/copyright file in the package for details. (USBmount website)

    Install usbmount in Ubuntu:

    usbmount is available in Ubuntu repository, use this command to install it:

    sudo apt-get install usbmount
  • OWNCLOUD 2: YOUR PERSONAL CLOUD SERVER

    ownCloud is a free software alternative to some proprietary web services and it currently includes file management (with built-in file sharing), music streaming, calendar, contacts and more – all running on your computer or server..

    Try ownCloud 2

    If you want to try ownCloud before installing it, simply go to http://demo.owncloud.org/ .

    Install ownCloud 2

    The latest ownCloud 2 isn’t available in the official Ubuntu repositories so you must install it manually.

    1. Install the ownCloud 2 dependencies:

    sudo apt-get install apache2 php5 php-pear php-xml-parser php5-sqlite php5-json sqlite php5-mysql mp3info curl libcurl3 libcurl3-dev php5-curl zip

    2. Download ownCloud 2 and copy it to /var/www/:

    cd wget http://owncloud.org/releases/owncloud-2.tar.bz2 tar -xvf owncloud-2.tar.bz2 sudo mv owncloud /var/www/owncloud

    3. Set up the permissions:

    sudo chown -R www-data:www-data /var/www/owncloud

    4. Restart Apache:

    sudo /etc/init.d/apache2 restart
    5. Open a browser and enter http://localhost/owncloud – if you get an error similar to this: «No database drivers (sqlite or mysql) installed.«, restart your computer and the error should be gone.

    Ok, now back to: http://localhost/owncloud – here you’ll be prompted to enter a new admin username and password and you’re done!
    These instructions* can also be found @ ownCloud’s website, along with Arch Linux, openSuse, Fedora, CentOS, Gentoo, Mac and Windows installation instructions.

    Increase the maximum allowed file size


    By default, you can’t upload files larger than 2 mb to ownCloud. To change this you need to edit /etc/php5/apache2/php.ini:

    gksu gedit /etc/php5/apache2/php.ini


    In this file, search for:

    upload_max_filesize post_max_size


    And change their value to whatever you want. Then save the file and restart Apache:

    sudo /etc/init.d/apache2 restart


  • Transmission-daemon on a headless Ubuntu server

    Use Transmission-daemon on a headless Ubuntu server for remote control the torrents. Here I installed Transmisiion-daemon in a headless server running Ubuntu.

    Transmission is a fast, simple and cross-platform free BitTorrent client,  feature spotlight are,

    • Uses fewer resources than other clients
    • Native Mac, GTK+ and Qt GUI clients
    • Daemon ideal for servers, embedded systems, and headless use
    • All these can be remote controlled by Web and Terminal clients
    • Bluetack (PeerGuardian) blocklists with automatic updates
    • Full encryption, DHT, PEX and Magnet Link support

    Check new release at www.transmissionbt.com.

    Installation(Ubuntu)
    $ sudo apt-get install transmission-cli transmission-common transmission-daemon

    Start and stop Daemon
    $ sudo /etc/init.d/transmission-daemon start (stop)

    Edit Configuration Settings

    First, stop the daemon before editing.

    $ sudo nano /etc/transmossion-daemon/settings.json

    Some options(ref to WIKI):

    • download-dir: String
    • incomplete-dir: String (directory to keep incomplete files in)
    • incomplete-dir-enabled: Boolean (default = false) When enabled, new torrents will download the files to incomplete-dir. When complete, the files will be moved to download-dir.
    • watch-dir: String
    • watch-dir-enabled: Boolean (default = false)
    • rpc-authentication-required: Boolean (default = false)
    • rpc-bind-address: String (default = “0.0.0.0″) Where to listen for RPC connections
    • rpc-enabled: Boolean (default = true)
    • rpc-password: String
    • rpc-port: Number (default = 9091)
    • rpc-username: String
    • rpc-whitelist: String (Comma-delimited list of IP addresses. Wildcards allowed using ‘*’. Example: “127.0.0.*,192.168.*.*”, Default: “127.0.0.1″ )
    • rpc-whitelist-enabled: Boolean (default = true)

    My sample setting file for example:
    {
    “blocklist-enabled”: 0,
    “download-dir”: “/home/user/downloads”,
    “incomplete-dir”: “/home/user/tpm”,
    “incomplete-dir-enabled”: 1,
    “download-limit”: 100,
    “download-limit-enabled”: 0,
    “encryption”: 1,
    “lazy-bitfield-enabled”: 1,
    “message-level”: 2,
    “open-file-limit”: 32,
    “peer-limit-global”: 240,
    “peer-limit-per-torrent”: 60,
    “peer-port”: 51413,
    “peer-port-random-enabled”: 0,
    “peer-port-random-high”: 65535,
    “peer-port-random-low”: 1024,
    “peer-socket-tos”: 0,
    “pex-enabled”: 1,
    “port-forwarding-enabled”: 1,
    “preallocation”: 1,
    “proxy”: “”,
    “proxy-auth-enabled”: 0,
    “proxy-auth-password”: “”,
    “proxy-auth-username”: “”,
    “proxy-enabled”: 0,
    “proxy-port”: 80,
    “proxy-type”: 0,
    “rpc-authentication-required”: 1,
    “rpc-enabled”: 1,
    “rpc-password”: “transmission”,
    “rpc-port”: 9091,
    “rpc-username”: “transmission”,
    “rpc-whitelist”: “*”,
    “rpc-whitelist-enabled”: 1,
    “upload-limit”: 100,
    “upload-limit-enabled”: 0,
    “upload-slots-per-torrent”: 14
    }

    transmission-remote-gui

    Transmission Remote GUI is a tool to remotely control Transmission-daemon via its RPC  protocol. You can download native applications for Windows, Linux and Mac OS X. In Linux, to make the file «transgui» executable by doing the following,

    $ sudo chmod +x transgui

    I encountered difficulties with file permissions when I had Transmission save downloads within the /var/lib/transmission-daemon/. Therefore, I changed Transmissions setting to download to a folder within my home directory. To ensure that both I and the debian-transmission user had read/write permissions, I added my account to the debian-transmission group (which is created when you install transmission), and I changed the group ownership of my torrent download directory to debian-transmission. Doing so grants the debian-transmission group read/write access to that folder, preserves read/write/execute access for my account, and prevents access to all others.

    $ sudo usermod -a -G debian-transmission mjdescy
    $ chgrp debian-transmission ~/dl/torrent
    $ chmod 770 ~/dl/torrent

  • Grub Customizer

    Grub Customizer: la manera más “sencilla” de configurar el Grub
    Las prestaciones principales de este paquete para ubuntu y derivados son:
    Habilitar/deshabilitar entradas, cambiar el valor por defecto, el orden o los colores del menu se hace más simple utilizando Grub Customizer.

    Para instalarlo ejecuta:

    sudo add-apt-repository ppa:danielrichter2007/grub-customizer
    sudo apt-get update
    sudo apt-get install grub-customizer
    
    

    Lo ejecutamos con:

    gksudo grub-customizer &

    o desde Herramientas del Sistema > Grub Customizer

     

  • Comandos útiles (V)

    Siguiendo esta serie de comandos útiles, expongo otro nuevo:

    Tunelizando un servidor remoto en una máquina local con un puerto destino especificado.

    $ socat TCP-LISTEN:3333,fork TCP:192.168.3.200:22,sourceport=12345

    Este comando conecta a la ip 192.168.3.200 puerto 22, usando el puerto destino 12345 y une el tunel al puerto local 3333. Después de esto podemos conectar a  localhost:3333.

    Con este comando es posible conectar a servidores usando un puerto específico en destino.

     

  • Comandos útiles (IV)

     

     

     

     

     

     

    Averiguar las consultas que se están haciendo a una base de datos mysql en linux:

    tshark -i any -T fields -R mysql.query -e mysql.query
  • Comandos útiles (III)

    Siguiendo la serie de comandos útiles aquí tenemos otro:

    Mostar el tamaño de todos los directorio de la carpeta home:

    $ du -sh ~/*