def get_real_path_pam_password(self):
     path = '/etc/pam.d/common-password'
     if 'red hat' in get_system_name():
         path = '/etc/pam.d/system-auth'
         print_message(
             'ok',
             'Sistema Red Hat detectado. Consultando /etc/pam.d/system-auth'
         )
     return path
 def get_params(self):
     print_message('ok', 'Analizando protección de los equipos.')
     config = {
         0: [self._check_crypt_partitions, self._check_partitions_splitted],
         1: [],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de protección de los equipos.')
 def get_params(self):
     print_message(
         'ok', 'Analizando protección de la autenticidad y la integridad.')
     config = {
         0: [self._check_unsecure_packages],
         1: [],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok',
                   'Fin de protección de la autenticidad y la integridad.')
Example #4
0
 def get_params(self):
     print_message('ok', 'Analizando la protección frente a código dañino.')
     config = {
         0: [
             self._parse_content_antivirus,
         ],
         1: [],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de la protección frente a código dañino.')
 def get_params(self):
     print_message('ok', 'Analizando bloqueo de puesto de trabajo.')
     config = {
         0: [],
         1: [
             self._check_autologout_shell,
             self._check_timeout_ssh,
         ],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de bloqueo de puesto de trabajo.')
Example #6
0
 def get_params(self):
     print_message('ok', 'Analizando la gestión de cambios.')
     config = {
         0: [
             self._parse_content_firewalls,
         ],
         1: [
             self._parse_content_updates,
         ],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de la gestión de cambios.')
Example #7
0
 def get_params(self):
     print_message('ok', 'Analizando las configuraciones de seguridad.')
     config = {
         0: [
             self._check_grub_protected_by_users_and_password,
             self._avoid_load_usb_storage,
             self._check_selinux,
             self._check_sysctl_config,
         ],
         1: [],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de las configuraciones de seguridad.')
 def get_params(self):
     print_message(
         'ok', 'Analizando los procesos de gestión de derechos de acceso.')
     config = {
         0: [
             self._load_sudoers_config,
             self._check_user_can_sudo_without_password,
             self._check_always_ask_password
         ],
         1: [],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok',
                   'Fin de los procesos de gestión de derechos de acceso.')
 def get_params(self):
     print_message('ok', 'Analizando acceso local.')
     config = {
         0: [
             self._load_system_config_file,
             self._get_account_lock_threshold,
             self._get_lock_account_root,
             self._get_unlock_time,
             self._check_accounts_with_uid_to_0,
         ],
         1: [
             self._show_last_login_on_tty,
         ],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de acceso local.')
Example #10
0
 def get_params(self):
     print_message(
         'ok',
         'Analizando el registro de actividades de usuario y protección de los mismos.'
     )
     config = {
         0: [],
         1: [
             self._check_logs,
             self._check_log_properties,
             self._parse_content_logs,
             self._parse_content_permissions,
         ],
         2: [],
     }
     self.get_max_lvl(config)
     print_message(
         'ok',
         'Fin del registro de actividades de usuario y protección de los mismos.'
     )
 def get_params(self):
     config = {}
     self._load_system_config_file()
     print_message('ok', 'Analizando acceso remoto.')
     if not self.config_file:
         print_message(
             'warning',
             'Fichero SSH no encontrado. Es posible que SSH Server no esté instalado'
         )
         config = {'0': [], '1': [], '2': []}
     else:
         config = {
             0: [
                 self._get_root_login,
                 self._get_host,
                 self._check_access_specific_users,
                 self._get_protocol,
                 self._check_ignore_rhosts,
                 self._check_host_based_authentication,
                 self._check_permit_empty_password,
                 self._check_x11_forwarding,
                 self._check_max_auth_retries,
             ],
             1: [
                 self._get_public_key_authentication,
                 self._show_last_login,
             ],
             2: [],
         }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de acceso remoto.')
 def get_params(self):
     print_message('ok', 'Analizando los mecanismos de autenticación.')
     config = {
         0: [
             self._load_system_config_file,
             self._get_pass_min_days,
             self._get_pass_max_days,
             self._get_min_length_pass,
             self._get_avoid_use_same_pass,
             self._get_pass_warn_age,
             self._get_complexity_pass,
             self._get_encryption_pass,
             self._get_num_days_inactive_account,
             self._get_counts_without_password,
         ],
         1: [
             self._check_FIPS,
         ],
         2: [],
     }
     self.get_max_lvl(config)
     print_message('ok', 'Fin de los mecanismos de autenticación.')
def full_html(html, score_str, nombre_usuario, nombre_organizacion,
              security_lvl, security_lvl_reached):
    """Generate html with ens result

    Args:
        html (str): html from ens_analysis
        score_str (str): total score
        nombre_usuario: username
        nombre_organizacion: organization name's
        lvl_security: security level

    Returns:
        str: return html content
    """
    print_message('ok', 'Generando fichero HTML.')
    full_html = """
        <!DOCTYPE html>
        <html lang="es">
           <head>
              <meta charset="utf-8">
              <link rel="stylesheet" href="statics/css/bootstrap.min.css">
              <script src="statics/js/jquery.min.js"></script>
              <script src="statics/js/bootstrap.min.js"></script>
              <style>
                th {
                    font-weight: inherit;
                }
                .panel-heading {
                    background-color: #7BA7C7 !important;
                }
                table {
                    border-collapse: separate;
                    white-space: normal;
                    line-height: normal;
                    font-size: medium;
                    border-spacing: 2px;
                }
                .title_a {
                    padding-left: 16px;
                    font-weight: bold;
                    color: white !important;
                    font-family: TAHOMA;
                }
                .panel-body {
                    padding-left: 16px;
                    padding-right: 00px;
                    font-size: 11pt;
                    margin-bottom: -1px;
                    color: #000000;
                    padding-top: 4px;
                    font-family: Tahoma;
                    position: relative;
                    word-wrap: break-word;
                    box-sizing: border-box;
                }
                thead > tr{
                    height: 35px;
                    color: #4169E1;
                    text-align: left;
                    font-weight: bold;
                }
                tbody > tr > th{
                    font-size: 14px;
                    font-weight: 400;
                    height: 18px;
                    line-height: normal;
                    vertical-align: top;
                }
                .div_title_top{
                    BORDER-RIGHT: #bbbbbb 1px solid;
                    PADDING-RIGHT: 5em;
                    BORDER-TOP: #bbbbbb 1px solid;
                    DISPLAY: block;
                    PADDING-LEFT: 8px;
                    FONT-WEIGHT: bold;
                    FONT-SIZE: 12pt;
                    MARGIN-BOTTOM: -1px;
                    MARGIN-LEFT: 0px;
                    BORDER-LEFT: #bbbbbb 1px solid;
                    margin-right: 0px;
                    CURSOR: hand;
                    COLOR: #FFFFFF;
                    MARGIN-RIGHT: 0px;
                    PADDING-TOP: 4px;
                    BORDER-BOTTOM: #bbbbbb 1px solid;
                    FONT-FAMILY: Tahoma;
                    POSITION: relative;
                    HEIGHT: 2.25em;
                    background-color: #4169E1 !important;
                    border-radius: 4px;
                }
                .red{
                    color: #FF0000 !important;
                }
                .green{
                    color: #008000 !important;
                }
              </style>
           </head>
           <body style="width: 98%; margin-left: 1%">
           <br>
    """
    full_html += get_header(nombre_usuario, nombre_organizacion, security_lvl)
    instance = extra_config.SystemInfo()
    info_system = instance.get_html()
    full_html += info_system
    full_html += """
                <br>
                <div class="well" style="width: 100%; padding: 0">
                    <div class="div_title_top" style="background-color: #4169E1;">
                        <span>
                            Resultado del ENS
                        </span>
                    </div>
                    <div style="width: 100%; padding-left: 1%;">
                        <div class="panel-group" style='margin-bottom: 0px'>
                            <div class="panel panel-default" style="padding-top: 20px; padding-bottom:20px;">
                               <div class="panel-collapse">
                                  <div class="panel-body">
                                     <table style="width: 100%">
                                        <tbody>
                                           <tr>
                                                <th style='padding-right: 10px; vertical-align: top; width: 30%; font-weight: bold;'>Porcentaje del ENS con éxito:</th>
                                                <th style='padding-right: 10px; vertical-align: top;'>""" + score_str + """%</th>
                                           </tr>
                                           <tr></tr><tr></tr><tr></tr>
                                           <tr style="margin-top: 5px;">
                                                <th style='padding-right: 10px; vertical-align: top; width: 30%; font-weight: bold;'>Nivel del ENS alcanzado:</th>
                                                <th style='padding-right: 10px; vertical-align: top;'>""" + security_lvl_reached + """</th>
                                           </tr>
                                        </tbody>
                                     </table>
                                  </div>
                               </div>
                            </div>
                        </div>
                    </div>
    """
    full_html += html

    services_on_boot = ServicesOnBoot()
    open_ports = OpenPortsInformation()
    full_html += services_on_boot.get_html()
    full_html += open_ports.get_html()

    full_html += """
        </div></body></html>
    """
    print_message('ok', 'Fin de generación del documento HTML')
    return full_html