├── LICENSE.md ├── README.md ├── SwissAdminTool ├── backup_server ├── bot_dhcp ├── dhcp_server ├── dns_server ├── ftp_server ├── install.sh ├── mysql_server ├── no_static_ip ├── send.py ├── server_config ├── ssh_server ├── static_ip ├── ufw_server └── vpn_server /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 ShadowVMX 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LinuxAdminTool 2 | 3 | ![system admin tools](https://user-images.githubusercontent.com/92258683/220797406-8062b6a5-3be0-4662-afa3-9bc07c81ad97.png) 4 | 5 | # ¿Qué es? 6 | 7 | LinuxAdminTool es una herramienta desarrollada en Bash para los Administradores de Servidores o Sistemas. Con esta herramienta 8 | podemos llevar a cabo la creación de un Servicio específico cómo puede ser DHCP,DNS,FTP,HTTP,SSH, etc ... sin necesidad de configurar ningún archivo pues la herramienta lo lleva a cabo de forma automatizada sin qué el Administrador deba de tocar mucha configuración. 9 | 10 | Este Script es de vital importancia para los Administradores de Sistemas y Servidores pues, llevará a cabo de forma automatizada la instalación de los distintos servicios y la configuración súper cómoda y eficiente de los mismos. 11 | 12 | # Creación de Directorio en OPT: 13 | 14 | - cd /opt 15 | - mkdir LinuxTool 16 | 17 | ![linux-arbol-directorios](https://user-images.githubusercontent.com/92258683/223760620-203ca48d-9801-4c0d-b1ef-c1eb70ef698c.jpg) 18 | 19 | 20 | # Instalación: 21 | 22 | 1. Has de clonar el repositorio en cualquier carpeta de trabajo, por ejemplo, /opt. 23 | 2. git clone https://github.com/ShadowVMX/LinuxAdminTool.git 24 | 3. cd LinuxAdminTool 25 | 4. chmod +x SwissAdminTool 26 | 5. ./SwissAdminTool <--> bash SwissAdminTool 27 | 28 | # Protocolos y Archivos qué configurará: 29 | 30 | - BackUps. 31 | - DHCP. 32 | - DNS. 33 | - FTP. 34 | - MySQL. 35 | - Configuración IP (Static || Dynamic). 36 | - Comprobación de configuración de Servidor. 37 | - SSH. 38 | - UFW (FireWall). 39 | - VPN. (BetaProcess). 40 | 41 | ![network-protocols-osi](https://user-images.githubusercontent.com/92258683/223760639-d4c8dc50-0db6-4242-9f44-e4003bb29dab.jpg) 42 | 43 | 44 | # Sistemas Probados: 45 | 46 | - Ubuntu. 47 | - Parrot. 48 | - Kali Linux. 49 | - Debian. 50 | - Linux Mint. 51 | - Elementary OS. 52 | - Zorin OS. 53 | - MX Linux. 54 | - Deepin. 55 | - Pop!_OS. 56 | 57 | 58 | ![debian-logo-1024x576](https://user-images.githubusercontent.com/92258683/223761042-6160bbda-6e19-4800-a0cb-a2e5d378c7e6.png) 59 | 60 | 61 | # Bot_Telegram. 62 | 63 | Se implantan 3 códigos en Python para qué, a través de un bot, podamos recibir mensajes de texto con la siguiente información: 64 | 65 | - DHCP. 66 | - FTP. 67 | - SSH. 68 | 69 | ¿Quién conecta? ¿IP qué conecta? ¿Nombre de dispositivo? ¿Recurso al qué accede? ¿Hora de conexión? 70 | 71 | ![Mejores-bots-de-Telegram-1](https://user-images.githubusercontent.com/92258683/223760665-3a9608a6-9d50-4ef8-9567-ce9dae73ee4f.png) 72 | 73 | 74 | # Implementaciones futuras: 75 | 76 | - SMTP. 77 | - SMB. 78 | - Nagios. 79 | - Docker. 80 | - Kubernetes. 81 | - AWS. 82 | 83 | ![icono-de-monitorizacion-elemento-simple-de-la-coleccion-de-seguridad-de-internet-creative-monitoring-icono-para-diseno-web-plantillas-infografias-y-mucho-mas-2c7ybdj](https://user-images.githubusercontent.com/92258683/223760679-4e900995-26ff-42f8-8e7f-d2744a108a0c.jpg) 84 | 85 | 86 | # Redes Sociales: 87 | 88 | LinkedIn --> https://www.linkedin.com/in/juanma-coello-romero-757280226/ 89 | 90 | Instagram --> @ShadowVMX 91 | 92 | GitHub --> https://github.com/ShadowVMX 93 | 94 | Gmail --> juanmacoello94@gmail.com 95 | 96 | 97 | # Buy me a Coffee: 98 | 99 | photo 100 | 101 | Después de tantos años de estudio y desarrollo, sería una gran ayuda y motivación para mi un buen café para seguir dándole caña hasta largas horas de la madrugada. 102 | 103 | ¡Saludos! 104 | 105 | https://www.buymeacoffee.com/ShadowVMX 106 | -------------------------------------------------------------------------------- /SwissAdminTool: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # 5 | # 6 | # 7 | # 8 | 9 | chmod +x install.sh &> /dev/null 10 | chmod +x backup_server &> /dev/null 11 | chmod +x dhcp_server &> /dev/null 12 | chmod +x dns_server &> /dev/null 13 | chmod +x ftp_server &> /dev/null 14 | chmod +x mysql_server &> /dev/null 15 | chmod +x no_static_ip &> /dev/null 16 | chmod +x server_config &> /dev/null 17 | chmod +x ssh_server &> /dev/null 18 | chmod +x static_ip &> /dev/null 19 | chmod +x ufw_server &> /dev/null 20 | chmod +x vpn_server &> /dev/null 21 | 22 | 23 | trap closeit SIGINT 24 | 25 | function closeit(){ 26 | echo "$(tput setaf 8)Ctrl_C detectado..." 27 | echo " " 28 | echo "$(tput setaf 4)Saliendo " 29 | echo " " 30 | echo -n "." && sleep 0.5 && echo -n "." && sleep 0.5 && echo -n "." && sleep 0.5 && echo -n "." && sleep 0.5 && echo -n "." && sleep 0.5 && echo -n "." && sleep 0.5 31 | echo " " 32 | echo "$(tput setaf 6)Éxito." 33 | tput sgr0 34 | exit 35 | } 36 | 37 | ls -l /usr/bin/figlet &> /dev/null 38 | 39 | if [[ $? == 2 ]] ; then 40 | echo " " 41 | echo "$(tput setaf 6)[$(tput setaf 1)*$(tput setaf 6)]$(tput setaf 2)Instalando figlet, no detectado ... " 42 | apt install figlet -y &> /dev/null 43 | echo " " 44 | fi 45 | 46 | 47 | echo "$(tput setaf 3)" && figlet SwissAdminTool 2> /dev/null 48 | echo " " 49 | echo "$(tput setaf 4) Versión $(tput setaf 8)1.0 para $(tput setaf 3)Administradores de Servidores y Sistemas." 50 | echo " " 51 | echo "$(tput setaf 5 ) _________________________________________________________________________" 52 | echo " " 53 | echo "$(tput setaf 4) Instagram $(tput setaf 1)--> $(tput setaf 8)@ShadowVMX " 54 | echo " " 55 | echo "$(tput setaf 4) LinkedIn $(tput setaf 1)--> $(tput setaf 8)https://www.linkedin.com/in/juanma-coello-romero-757280226/" 56 | echo " " 57 | echo "$(tput setaf 4) GitHub $(tput setaf 1)--> $(tput setaf 8)https://github.com/ShadowVMX" 58 | echo " " 59 | echo "$(tput setaf 5 ) _________________________________________________________________________" 60 | echo " " 61 | 62 | echo "$(tput setaf 2)[OPCIONES DE EJECUCIÓN Y/O INSTALACIÓN]:" 63 | 64 | echo " " 65 | echo -n "$(tput setaf 3)[1.] $(tput setaf 4) Instalar. [Rec]" && echo " $(tput setaf 3)[7.] $(tput setaf 4) IP Estática." 66 | echo " " 67 | echo -n "$(tput setaf 3)[2.] $(tput setaf 4) DNS." && echo " $(tput setaf 3)[8.] $(tput setaf 4) SSH." 68 | echo " " 69 | echo -n "$(tput setaf 3)[3.] $(tput setaf 4) BackUp." && echo " $(tput setaf 3)[9.] $(tput setaf 4) IP Dinámica." 70 | echo " " 71 | echo -n "$(tput setaf 3)[4.] $(tput setaf 4) FTP." && echo " $(tput setaf 3)[10.] $(tput setaf 4) UFW." 72 | echo " " 73 | echo -n "$(tput setaf 3)[5.] $(tput setaf 4) DHCP." && echo " $(tput setaf 3)[11.] $(tput setaf 4) VPN." 74 | echo " " 75 | echo -n "$(tput setaf 3)[6.] $(tput setaf 4) Server Config." && echo " $(tput setaf 3)[12.] $(tput setaf 4) MySQL." 76 | 77 | echo " " 78 | echo " " 79 | sleep 1.5 80 | 81 | read -p "$(tput setaf 8)¿Qué desea realizar? $(tput setaf 1)--> $(tput setaf 4)" answer 82 | 83 | case $answer in 84 | 85 | 1) 86 | ./install.sh 87 | ;; 88 | 2) 89 | ./dns_server 90 | ;; 91 | 3) 92 | ./backup_server 93 | ;; 94 | 4) 95 | ./ftp_server 96 | ;; 97 | 5) 98 | ./dhcp_server 99 | ;; 100 | 6) 101 | ./server_config 102 | ;; 103 | 7) 104 | ./static_ip 105 | ;; 106 | 8) 107 | ./ssh_server 108 | ;; 109 | 9) 110 | ./no_static_ip 111 | ;; 112 | 10) 113 | ./ufw_server 114 | ;; 115 | 11) 116 | ./vpn_server 117 | ;; 118 | 12) 119 | ./mysql__server 120 | ;; 121 | *) 122 | echo "$(tput setaf 1)[*] $(tput setaf 4)Opción no válida." 123 | ;; 124 | esac 125 | 126 | 127 | tput sgr0 128 | 129 | -------------------------------------------------------------------------------- /backup_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Crear carpeta en opt. 4 | 5 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) Creando carpeta backups en directorio opt... " 6 | echo " " 7 | 8 | mkdir /opt/backups 2> /dev/null 9 | 10 | 11 | # Definir la ubicación donde se guardará la copia de seguridad 12 | backup_dir="/opt/backups" 13 | 14 | # Definir la fecha actual para agregarla al nombre del archivo de copia de seguridad 15 | date=$(date +%Y-%m-%d-%H-%M-%S) 16 | 17 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) Las copias de seguridad se hacen de --> /etc /var/www y /home." 18 | echo " " 19 | 20 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) Si desea modificar las rutas, agrega diferentes líneas ..." 21 | echo " " 22 | 23 | sleep 2 24 | 25 | # Definir una lista de los archivos y directorios importantes que se incluirán en la copia de seguridad 26 | important_files=( 27 | "/etc" 28 | "/var/www" 29 | "/home" 30 | ) 31 | 32 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) Comenzando la copia de seguridad: " 33 | echo " " 34 | sleep 1 35 | 36 | read -p "¿Desea la compresión en segundo plano para evitar ruido en pantalla? (Y/N) --> " kkanswer 37 | echo " " 38 | 39 | if [[ $kkanswer == Y ]] ; then 40 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) Llevando a cabo la copia de seguridad ..." 41 | tar -czvf "$backup_dir/backup-$date.tar.gz" "${important_files[@]}" &> /dev/null 42 | echo " " 43 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) Completado." 44 | echo " " 45 | exit 46 | else 47 | # Crear un archivo comprimido con los archivos seleccionados 48 | tar -czvf "$backup_dir/backup-$date.tar.gz" "${important_files[@]}" 49 | 50 | # Confirmar que la copia de seguridad ha sido realizada correctamente 51 | if [ $? -eq 0 ] 52 | then 53 | echo "Copia de seguridad realizada correctamente, reporte guardado en /opt/backup." 54 | else 55 | echo "Error al realizar la copia de seguridad." 56 | fi 57 | fi 58 | tput sgr0 59 | -------------------------------------------------------------------------------- /bot_dhcp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #pip3 install --force-reinstall -v "python-telegram-bot==13.5" 4 | 5 | 6 | TOKEN="" 7 | CHAT_ID="" 8 | LOG_FILE="/var/log/syslog" 9 | 10 | 11 | 12 | 13 | # Inicia el bucle infinito para monitorear el archivo de registro de DHCP 14 | tail -n0 -f "$LOG_FILE" | while read LINE; do 15 | 16 | # Busca los mensajes relevantes usando grep 17 | if echo "$LINE" | grep -q "dhcpd:"; then 18 | 19 | # Envía el mensaje a través de la API de Telegram usando curl 20 | curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \ 21 | -d chat_id="$CHAT_ID" \ 22 | -d text="$LINE" 23 | 24 | fi 25 | done 26 | -------------------------------------------------------------------------------- /dhcp_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | #Script qué lleva a cabo la configuración del DHCP Server. 4 | # 5 | # 6 | 7 | # Verifica que el script se ejecute con permisos de superusuario 8 | 9 | if [[ $EUID -ne 0 ]]; then 10 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Este script debe ser ejecutado con permisos de superusuario" 11 | exit 1 12 | fi 13 | 14 | echo " " 15 | ip a 16 | echo " " 17 | sleep 1 18 | 19 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Qué Interfaz de red va a usar? (eth0) --> " intrfred 20 | echo " " 21 | sleep 1 22 | 23 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Qué id.red va a usar? (192.168.1.0) --> $(tput setaf 4)" idred 24 | echo " " 25 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Qué netmask va a usar? (255.255.255.0) --> $(tput setaf 4)" netmaskip 26 | echo " " 27 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Qué rango de ip desea usar? (192.168.1.10 192.168.1.50) --> $(tput setaf 4)" rangeip 28 | echo " " 29 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Qué Gateway va a usar? (192.168.1.1) --> $(tput setaf 4)" ipgate 30 | echo " " 31 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Qué servidores DNS va a usar? (8.8.8.8, 1.1.1.1) --> $(tput setaf 4)" dnsips 32 | echo " " 33 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Qué nombre de dominio va a usar? (contoso.local) --> $(tput setaf 4)" domainstring 34 | 35 | 36 | # Configura el servidor DHCP 37 | 38 | cat > /etc/dhcp/dhcpd.conf < /etc/default/isc-dhcp-server < /etc/resolv.conf 10 | 11 | # Configurar el dominio 12 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Configurando dominio..." 13 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)search $domain" >> /etc/resolv.conf 14 | 15 | # Agregar la dirección IP del servidor DNS al archivo hosts 16 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Agregando dirección IP del servidor DNS al archivo hosts..." 17 | echo "dns_ip www.$domain" >> /etc/hosts 18 | 19 | # Reiniciar el servicio de red 20 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Reiniciando el servicio de red..." 21 | systemctl restart network 22 | 23 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Configuración completa." 24 | 25 | tput sgr0 26 | -------------------------------------------------------------------------------- /ftp_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Hacer una copia de seguridad del archivo de configuración original de vsftpd.conf 4 | cp /etc/vsftpd.conf /etc/vsftpd.conf.bak 5 | 6 | # Crear un nuevo archivo de configuración de vsftpd.conf 7 | cat << EOF > /etc/vsftpd.conf 8 | # Configuración de vsftpd 9 | # Activar el soporte de IPv4 y IPv6 10 | listen=YES 11 | # Permitir que los usuarios escriban en sus propios directorios 12 | write_enable=YES 13 | # No permitir el acceso anónimo 14 | anonymous_enable=NO 15 | local_enable=YES 16 | # Permitir la escritura de archivos a los usuarios 17 | local_umask=022 18 | # No permitir que los usuarios vean los archivos ocultos 19 | hide_file=.* 20 | # Establecer el directorio raíz de FTP 21 | local_root=/srv/ftp 22 | # Permitir el acceso a los usuarios de la lista de usuario 23 | userlist_enable=YES 24 | userlist_file=/etc/vsftpd.user_list 25 | userlist_deny=NO 26 | EOF 27 | 28 | # Crear el directorio raíz de FTP 29 | mkdir /srv/ftp 2> /dev/null 30 | 31 | # Establecer los permisos de directorio correctos 32 | chmod 777 /srv/ftp 33 | 34 | # Reiniciar el servicio vsftpd 35 | systemctl restart vsftpd 36 | 37 | # Crear un nuevo usuario FTP 38 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Ingrese el nombre del usuario:" 39 | read username 40 | 41 | # Crear el usuario 42 | /usr/sbin/adduser $username 43 | 44 | # Establecer una contraseña para el usuario 45 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Ingrese una contraseña para el usuario:" 46 | read -s password 47 | echo "$username:$password" | chpasswd 2>/dev/null 48 | 49 | # Agregar el usuario a la lista de usuarios permitidos de vsftpd 50 | echo "$username" >> /etc/vsftpd.user_list 51 | 52 | # Mostrar un mensaje de éxito 53 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) El usuario FTP $username se ha creado correctamente." 54 | sleep 1 55 | 56 | tput sgr0 57 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | #Instalación de los servicios necesarios. 4 | # 5 | #DHCP,DNS,ADDS,VPN,MONITORIZACIÓN,LOGS,HTTP,SMTP,SSH,FTP, etc... 6 | # 7 | # 8 | # 9 | 10 | trap exity SIGINT 11 | 12 | 13 | function exity () { 14 | echo " " 15 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Ctrl_C Detected ... " 16 | echo " " 17 | sleep 1 18 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Saliendo. " 19 | echo " " 20 | sleep 1 21 | tput sgr0 22 | exit 23 | } 24 | 25 | timeout 0.7 ping -c 1 google.es &> /dev/null 26 | 27 | if [[ $? == 0 ]] ; then 28 | echo " " 29 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Hay conectividad!." 30 | echo " " 31 | else 32 | echo " " 33 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) No hay conectividad." 34 | echo " " 35 | exit 36 | fi 37 | 38 | 39 | apt install figlet -y &> /dev/null 40 | apt install net-tools -y &> /dev/null 41 | apt install zip -y &> /dev/null 42 | 43 | echo "$(tput setaf 6)" 44 | 45 | figlet Actualizacion de Sistema: 46 | 47 | echo " " 48 | echo " " 49 | read -p "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2)Va a llevar a cabo el proceso de instalación ... ¿Desea comentar alguna línea del script para cancelar alguna instalación específica?(Y/N) --> " answerXP 50 | echo " " 51 | echo " " 52 | 53 | if [[ $answerXP == "Y" ]] ; then 54 | nano install.sh 55 | else 56 | 57 | 58 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Updateando el Sistema ... " 59 | apt update -y &> /dev/null 60 | 61 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 62 | sleep 1 63 | 64 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Upgradeando el Sistema ..." 65 | apt upgrade -y &> /dev/null 66 | 67 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 68 | sleep 1 69 | 70 | echo "$(tput setaf 6)" 71 | 72 | figlet Instalando Servicios de Red: 73 | 74 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio DHCP ..." 75 | apt install isc-dhcp-server -y &> /dev/null 76 | 77 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 78 | sleep 1 79 | 80 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio DNS ... " 81 | apt install bind9 -y &> /dev/null 82 | 83 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 84 | sleep 1 85 | 86 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio SMTP ... " 87 | apt install postfix -y &> /dev/null 88 | 89 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 90 | sleep 1 91 | 92 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio FTP ... " 93 | apt install vsftpd -y &> /dev/null 94 | 95 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 96 | sleep 1 97 | 98 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio SSH ... " 99 | apt install openssh-server -y &> /dev/null 100 | 101 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 102 | sleep 1 103 | 104 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio SMB ... " 105 | apt install samba -y &> /dev/null 106 | 107 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 108 | 109 | echo "$(tput setaf 6)" 110 | 111 | figlet Instalando Servicios Web: 112 | 113 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servico HTTP Apache2 ... " 114 | apt install apache2 -y &> /dev/null 115 | 116 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 117 | sleep 1 118 | 119 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio HTTP nginx ... " 120 | apt install nginx -y &> /dev/null 121 | 122 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 123 | sleep 1 124 | 125 | echo "$(tput setaf 6)" 126 | 127 | figlet Instalando Servicios de Seguridad: 128 | 129 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio VPN ... " 130 | apt install openvpn -y &> /dev/null 131 | 132 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado." 133 | sleep 1 134 | 135 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio UFW ..." 136 | apt install ufw -y &> /dev/null 137 | 138 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado. " 139 | 140 | echo "$(tput setaf 6)" 141 | 142 | figlet Instalando Servicios DB: 143 | 144 | echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando servicio MySQL ... " 145 | apt-get install mariadb-server -y &> /dev/null 146 | 147 | echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado. " 148 | sleep 1 149 | 150 | echo "$(tput setaf 6)" 151 | 152 | #figlet Instalando Monitorización: 153 | 154 | #echo "$(tput setaf 9)[$(tput setaf 6)*$(tput setaf 9)]$(tput setaf 2) Instalando NetGIOS ... " 155 | #apt install nagios4 nagios-nrpe-plugin -y &> /dev/null 156 | 157 | #echo "$(tput setaf 9)[$(tput setaf 3)*$(tput setaf 9)]$(tput setaf 2) Completado. " 158 | #sleep 1 159 | 160 | 161 | tput sgr0 162 | 163 | chmod +x SwissAdminTool &> /dev/null 164 | chmod +x backup_server &> /dev/null 165 | chmod +x dhcp_server &> /dev/null 166 | chmod +x dns_server &> /dev/null 167 | chmod +x ftp_server &> /dev/null 168 | chmod +x mysql_server &> /dev/null 169 | chmod +x no_static_ip &> /dev/null 170 | chmod +x server_config &> /dev/null 171 | chmod +x ssh_server &> /dev/null 172 | chmod +x static_ip &> /dev/null 173 | chmod +x ufw_server &> /dev/null 174 | chmod +x vpn_server &> /dev/null 175 | fi 176 | 177 | -------------------------------------------------------------------------------- /mysql_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Iniciar el servicio de MariaDB 4 | systemctl start mariadb 5 | 6 | # Establecer la contraseña de root para MariaDB 7 | mysql_secure_installation 8 | 9 | # Crear una base de datos 10 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce el nombre de la base de datos:" 11 | read database_name 12 | 13 | mysql -e "CREATE DATABASE $database_name;" 14 | 15 | # Crear un usuario y asignar permisos para la base de datos 16 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce el nombre de usuario:" 17 | read username 18 | 19 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce la contraseña:" 20 | read password 21 | 22 | mysql -e "CREATE USER '$username'@'localhost' IDENTIFIED BY '$password';" 23 | mysql -e "GRANT ALL PRIVILEGES ON $database_name.* TO '$username'@'localhost';" 24 | 25 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)La configuración de MariaDB se ha completado satisfactoriamente." 26 | -------------------------------------------------------------------------------- /no_static_ip: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Obtener el nombre de la interfaz de red actual 4 | iface=$(ip -o -4 route show to default | awk '{print $5}') 5 | 6 | # Eliminar la configuración de IP estática de la interfaz 7 | sed -i '/^iface '$iface'/,/^$/d' /etc/network/interfaces 8 | sed -i '/^address/d' /etc/network/interfaces 9 | sed -i '/^netmask/d' /etc/network/interfaces 10 | sed -i '/^gateway/d' /etc/network/interfaces 11 | sed -i '/^dns-nameservers/d' /etc/network/interfaces 12 | 13 | # Configurar la interfaz para obtener una dirección IP dinámica a través de DHCP 14 | echo "auto $iface" >> /etc/network/interfaces 15 | echo "iface $iface inet dhcp" >> /etc/network/interfaces 16 | 17 | # Reiniciar la interfaz de red 18 | ifdown $iface && ifup $iface 19 | 20 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)La configuración de IP estática ha sido eliminada. Se ha solicitado una dirección IP dinámica a través de DHCP." 21 | 22 | tput sgr0 23 | -------------------------------------------------------------------------------- /send.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import re 3 | import requests 4 | 5 | # Token del bot de Telegram 6 | TOKEN = '' 7 | 8 | # ID del chat donde se enviará el mensaje 9 | CHAT_ID = '' 10 | 11 | # Expresión regular para buscar la información del cliente en el registro DHCP 12 | regex = r'DHCPACK on (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) to ([^\s]+) \(([\dA-Fa-f]{2}[:-]){5}([\dA-Fa-f]{2})\).*lease (\d+)' 13 | 14 | # Ejecutar el comando para leer el registro DHCP 15 | output = subprocess.check_output(['cat', '/var/log/syslog | grep "DHCPACK on"'], shell=True) 16 | 17 | # Buscar la información del cliente en el registro DHCP 18 | match = re.search(regex, output.decode()) 19 | 20 | # Si se encuentra la información del cliente 21 | if match: 22 | ip_address = match.group(1) 23 | hostname = match.group(2) 24 | mac_address = match.group(3).replace(':', '-') 25 | lease_time = match.group(4) 26 | 27 | # Construir el mensaje a enviar al bot de Telegram 28 | message = f'Cliente conectado al DHCP:\nIP: {ip_address}\nNombre de equipo: {hostname}\nDirección MAC: {mac_address}\nTiempo de concesión: {lease_time}' 29 | 30 | # Enviar el mensaje al bot de Telegram 31 | requests.get(f'https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={CHAT_ID}&text={message}') 32 | -------------------------------------------------------------------------------- /server_config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Obtener la configuración de red 4 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Obteniendo la configuración de red..." 5 | ip a > network_config.txt 6 | 7 | sleep 1 8 | 9 | # Obtener la configuración de sistema 10 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)bteniendo la configuración de sistema..." 11 | uname -a > system_config.txt 12 | cat /proc/cpuinfo >> system_config.txt 13 | cat /proc/meminfo >> system_config.txt 14 | lscpu >> system_config.txt 15 | lsblk >> system_config.txt 16 | df -h >> system_config.txt 17 | 18 | sleep 1 19 | 20 | # Comprimir los archivos en un archivo .zip 21 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Comprimiendo los archivos..." 22 | zip config_files.zip network_config.txt system_config.txt 23 | 24 | sleep 1 25 | 26 | # Eliminar los archivos de texto 27 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Eliminando los archivos de texto..." 28 | rm network_config.txt system_config.txt 29 | 30 | sleep 1 31 | 32 | echo "La configuración de red y de sistema ha sido guardada en el archivo config_files.zip, en la carpeta report." 33 | 34 | mkdir report 35 | 36 | mv config_files.zip report/ 37 | 38 | tput sgr0 39 | -------------------------------------------------------------------------------- /ssh_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copiar la configuración del archivo sshd_config original y hacer una copia de seguridad 4 | sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak 5 | 6 | # Modificar la configuración del archivo sshd_config 7 | sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/g' /etc/ssh/sshd_config 8 | sudo sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config 9 | 10 | # Reiniciar el servicio de SSH 11 | sudo systemctl restart sshd 12 | 13 | # Crear un nuevo usuario para SSH 14 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce el nombre del nuevo usuario para SSH:" 15 | read ssh_user 16 | 17 | sudo adduser $ssh_user 18 | sudo usermod -aG sudo $ssh_user 19 | 20 | # Información para el usuario 21 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Usuario $ssh_user creado satisfactoriamente." 22 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Puedes acceder por SSH con: ssh $ssh_user@" 23 | 24 | tput sgr0 25 | -------------------------------------------------------------------------------- /static_ip: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Pedir la IP y la máscara al usuario 4 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce la dirección IP: " IP 5 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce la máscara de red: " MASK 6 | 7 | # Configurar la IP estática en el archivo /etc/network/interfaces 8 | cat << EOF > /etc/network/interfaces 9 | auto eth0 10 | iface eth0 inet static 11 | address $IP 12 | netmask $MASK 13 | EOF 14 | 15 | # Reiniciar el servicio de red para aplicar los cambios 16 | systemctl restart networking.service 17 | 18 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)La dirección IP se ha configurado a $IP" 19 | 20 | tput sgr0 21 | -------------------------------------------------------------------------------- /ufw_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Habilitar UFW 4 | ufw enable 5 | 6 | # Establecer políticas por defecto 7 | ufw default deny incoming 8 | ufw default allow outgoing 9 | 10 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Quiere agregar o eliminar (A/E) --> $(tput setaf 4)" answert 11 | echo "" 12 | sleep 1 13 | 14 | if [[ $answert == "A" ]] ; then 15 | echo " " 16 | echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) Sección de AGREGACIÓN DE REGLAS: " 17 | echo " " 18 | read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6) ¿Cuántas políticas necesita implantar? --> $(tput setaf 4)" policiesk 19 | 20 | for ((i=1;i<=policiesk;i++)) 21 | do 22 | read -p "$(tput setaf 1)[$(tput setaf 6)*$(tput setaf 1)]$(tput setaf 2) Introduce el servicio específico (ssh) --> $(tput setaf 4)" service 23 | ufw allow $service 24 | echo " " 25 | done 26 | fi 27 | 28 | # Reiniciar UFW 29 | ufw disable 30 | ufw enable 31 | 32 | tput sgr0 33 | -------------------------------------------------------------------------------- /vpn_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Crear una carpeta para los archivos de configuración de la VPN 4 | sudo mkdir /etc/openvpn/easy-rsa 5 | sudo chown $USER /etc/openvpn/easy-rsa 6 | 7 | # Descargar easy-rsa y configurar la VPN 8 | cd /etc/openvpn/easy-rsa 9 | wget -O easy-rsa.tgz https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.7/EasyRSA-3.0.7.tgz 10 | tar xzf easy-rsa.tgz --strip-components=1 11 | ./easyrsa init-pki 12 | ./easyrsa build-ca 13 | ./easyrsa gen-dh 14 | ./easyrsa build-server-full server nopass 15 | openvpn --genkey --secret ta.key 16 | 17 | # Configurar el archivo de configuración de la VPN 18 | sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/ 19 | sudo gunzip /etc/openvpn/server.conf.gz 20 | sudo sed -i 's/;user nobody/user nobody/g' /etc/openvpn/server.conf 21 | sudo sed -i 's/;group nogroup/group nogroup/g' /etc/openvpn/server.conf 22 | sudo sed -i 's/dh dh2048.pem/dh dh.pem/g' /etc/openvpn/server.conf 23 | sudo sed -i 's/;tls-auth ta.key 0/tls-auth ta.key 0/g' /etc/openvpn/server.conf 24 | sudo sed -i 's/;cipher AES-256-CBC/cipher AES-256-CBC/g' /etc/openvpn/server.conf 25 | 26 | # Reiniciar el servicio OpenVPN 27 | sudo systemctl restart openvpn 28 | 29 | # Crear usuarios para la VPN 30 | echo "Introduce el nombre de usuario para la VPN:" 31 | read vpn_user 32 | ./easyrsa build-client-full $vpn_user nopass 33 | sudo cp pki/ca.crt pki/issued/$vpn_user.crt pki/private/$vpn_user.key /etc/openvpn/ 34 | 35 | # Generar el archivo de configuración para el usuario 36 | sudo bash -c "cat > /etc/openvpn/$vpn_user.ovpn" << EOF 37 | client 38 | dev tun 39 | proto udp 40 | remote 1194 41 | resolv-retry infinite 42 | nobind 43 | persist-key 44 | persist-tun 45 | remote-cert-tls server 46 | cipher AES-256-CBC 47 | comp-lzo 48 | verb 3 49 | ca ca.crt 50 | cert $vpn_user.crt 51 | key $vpn_user.key 52 | tls-auth ta.key 1 53 | EOF 54 | 55 | # Información para el usuario 56 | echo "Usuario $vpn_user creado satisfactoriamente." 57 | echo "Puedes descargar el archivo de configuración de la VPN en /etc/openvpn/$vpn_user.ovpn" 58 | 59 | tput sgr0 60 | --------------------------------------------------------------------------------